From 118cc7d6f8fa05789893abba6439206de0e50973 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, 23 Jun 2021 11:19:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=AF=E5=8A=A8=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=E5=8D=A1=E9=A1=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/preload/index.js | 12 ++++++------ src/render/main.ts | 17 +++++++++++------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/preload/index.js b/src/preload/index.js index 9bcc03a..1fc395a 100644 --- a/src/preload/index.js +++ b/src/preload/index.js @@ -17,7 +17,7 @@ function domReady(...args) { } /** 插入 loading */ -function insertLoading() { +function loadingBootstrap() { const loadingStyle = document.createElement('style'); const loadingBox = document.createElement('div'); @@ -114,16 +114,16 @@ function insertLoading() { ; (async function () { await domReady(); - let _isCallClosePreloadLoading = false; - const { removeLoading, appendLoading } = insertLoading(); + let _isCallRemoveLoading = false; + const { removeLoading, appendLoading } = loadingBootstrap(); - window.ClosePreloadLoading = () => { - _isCallClosePreloadLoading = true; + window.removeLoading = () => { + _isCallRemoveLoading = true; removeLoading(); }; // 5 秒超时自动关闭 - setTimeout(() => !_isCallClosePreloadLoading && removeLoading(), 4999); + setTimeout(() => !_isCallRemoveLoading && removeLoading(), 4999); appendLoading(); })(); diff --git a/src/render/main.ts b/src/render/main.ts index f3d031d..3348700 100644 --- a/src/render/main.ts +++ b/src/render/main.ts @@ -6,12 +6,17 @@ import { ipcRenderer } from 'electron' import Store from 'electron-store' import './index.css' -console.log('ipcRenderer:', ipcRenderer) -// Configuration name causes hot updates to be slow | 传递 name 后会导致热更新很慢 -// console.log('electron-store', new Store({ name: 'electron-vue' })) -// https://github.com/caoxiemeihao/electron-vue-vite/issues/10 -console.log('electron-store', new Store()) + +setTimeout(() => { + console.log('ipcRenderer:', ipcRenderer) + // Configuration name causes hot updates to be slow | 传递 name 后会导致热更新很慢 + // console.log('electron-store', new Store({ name: 'electron-vue' })) + // https://github.com/caoxiemeihao/electron-vue-vite/issues/10 + console.log('electron-store', new Store()) + + // new Store 会阻塞线程,导致 preload 动画卡顿 +}, 2999) createApp(App) .mount('#app') - .$nextTick(window.ClosePreloadLoading) + .$nextTick(window.removeLoading)