diff --git a/.dumi/theme/builtins/Previewer/CodeBlockButton.tsx b/.dumi/theme/builtins/Previewer/CodeBlockButton.tsx index 1c50a538cc..5c5828ad37 100644 --- a/.dumi/theme/builtins/Previewer/CodeBlockButton.tsx +++ b/.dumi/theme/builtins/Previewer/CodeBlockButton.tsx @@ -6,6 +6,12 @@ import { ping } from '../../utils'; let pingDeferrer: PromiseLike; +const codeBlockJs = + 'https://renderoffice.a' + + 'lipay' + + 'objects.com/p' + + '/yuyan/180020010001206410/parseFileData.js'; + function useShowCodeBlockButton() { const [showCodeBlockButton, setShowCodeBlockButton] = useState(false); @@ -13,6 +19,12 @@ function useShowCodeBlockButton() { pingDeferrer ??= new Promise((resolve) => { ping((status) => { if (status !== 'timeout' && status !== 'error') { + // Async insert `codeBlockJs` into body end + const script = document.createElement('script'); + script.src = codeBlockJs; + script.async = true; + document.body.appendChild(script); + return resolve(true); } diff --git a/.dumirc.ts b/.dumirc.ts index e0098081af..57672e5d8e 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -7,12 +7,6 @@ import rehypeAntd from './.dumi/rehypeAntd'; import remarkAntd from './.dumi/remarkAntd'; import { version } from './package.json'; -const codeBlockJs = - 'https://renderoffice.a' + - 'lipay' + - 'objects.com/p' + - '/yuyan/180020010001206410/parseFileData.js'; - export default defineConfig({ plugins: ['dumi-plugin-color-chunk'], @@ -189,7 +183,6 @@ export default defineConfig({ document.documentElement.className += isZhCN(pathname) ? 'zh-cn' : 'en-us'; })(); `, - codeBlockJs, ], scripts: [ {