diff --git a/config/config.ts b/config/config.ts index bea47a1c84..acf2afd6a8 100644 --- a/config/config.ts +++ b/config/config.ts @@ -119,6 +119,14 @@ export default defineConfig({ * @doc https://umijs.org/docs/max/access */ access: {}, + /** + * @name
中额外的 script + * @description 配置 中额外的 script + */ + headScripts: [ + // 解决首次加载时白屏的问题 + { src: '/scripts/loading.js', async: true }, + ], //================ pro 插件配置 ================= presets: ['umi-presets-pro'], /** diff --git a/public/scripts/loading.js b/public/scripts/loading.js new file mode 100644 index 0000000000..c1ced54c1e --- /dev/null +++ b/public/scripts/loading.js @@ -0,0 +1,202 @@ +/** + * loading 占位 + * 解决首次加载时白屏的问题 + */ + (function () { + const _root = document.querySelector('#root'); + if (_root && _root.innerHTML === '') { + _root.innerHTML = ` + + +