chore: move trace to async (#52300)

pull/52306/head
二货爱吃白萝卜 2 weeks ago committed by GitHub
parent 280d788645
commit 00eb0e3ebd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -6,6 +6,12 @@ import { ping } from '../../utils';
let pingDeferrer: PromiseLike<boolean>;
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<boolean>((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);
}

@ -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: [
{

Loading…
Cancel
Save