From 78c90346b0436b3f90f8c28a8eb6d06761644630 Mon Sep 17 00:00:00 2001 From: Taocap Date: Wed, 28 Dec 2022 10:47:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E9=A6=96=E6=AC=A1?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=97=B6=E7=99=BD=E5=B1=8F=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#10347)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.ts | 8 ++ public/scripts/loading.js | 202 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 210 insertions(+) create mode 100644 public/scripts/loading.js diff --git a/config/config.ts b/config/config.ts index bea47a1c..acf2afd6 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 00000000..c1ced54c --- /dev/null +++ b/public/scripts/loading.js @@ -0,0 +1,202 @@ +/** + * loading 占位 + * 解决首次加载时白屏的问题 + */ + (function () { + const _root = document.querySelector('#root'); + if (_root && _root.innerHTML === '') { + _root.innerHTML = ` + + +
+
+
+ + + + + + +
+
+
+ 正在加载资源 +
+
+ 初次加载资源可能需要较多时间 请耐心等待 +
+
+ `; + } +})();