From 0ab15c65f1e77aac1e2188c2fc41b717c802f430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7?= <308487730@qq.com> Date: Wed, 29 Jun 2022 07:38:37 +0800 Subject: [PATCH] `preload/splash.ts` -> `preload/index.ts` --- electron/preload/{splash.ts => index.ts} | 7 ++++++- vite.config.ts | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) rename electron/preload/{splash.ts => index.ts} (95%) diff --git a/electron/preload/splash.ts b/electron/preload/index.ts similarity index 95% rename from electron/preload/splash.ts rename to electron/preload/index.ts index 90c0647..0ee2dcc 100644 --- a/electron/preload/splash.ts +++ b/electron/preload/index.ts @@ -83,5 +83,10 @@ function useLoading() { // ---------------------------------------------------------------------- const { appendLoading, removeLoading } = useLoading() -window.removeLoading = removeLoading domReady().then(appendLoading) + +window.onmessage = ev => { + ev.data.payload === 'removeLoading' && removeLoading() +} + +setTimeout(removeLoading, 4999) diff --git a/vite.config.ts b/vite.config.ts index f3dcc59..3c8855d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -30,7 +30,7 @@ export default defineConfig({ preload: { input: { // You can configure multiple preload scripts here - splash: join(__dirname, 'electron/preload/splash.ts'), + index: join(__dirname, 'electron/preload/index.ts'), }, vite: { build: { @@ -40,7 +40,7 @@ export default defineConfig({ } }, }, - // Enables use of Node.js API in the Renderer-process + // Enables use of Node.js API in the Electron-Renderer renderer: {}, }), ],