mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-19 11:56:36 +08:00
fix: 启动动画卡顿
This commit is contained in:
parent
0f390defd5
commit
118cc7d6f8
@ -17,7 +17,7 @@ function domReady(...args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 插入 loading */
|
/** 插入 loading */
|
||||||
function insertLoading() {
|
function loadingBootstrap() {
|
||||||
const loadingStyle = document.createElement('style');
|
const loadingStyle = document.createElement('style');
|
||||||
const loadingBox = document.createElement('div');
|
const loadingBox = document.createElement('div');
|
||||||
|
|
||||||
@ -114,16 +114,16 @@ function insertLoading() {
|
|||||||
; (async function () {
|
; (async function () {
|
||||||
await domReady();
|
await domReady();
|
||||||
|
|
||||||
let _isCallClosePreloadLoading = false;
|
let _isCallRemoveLoading = false;
|
||||||
const { removeLoading, appendLoading } = insertLoading();
|
const { removeLoading, appendLoading } = loadingBootstrap();
|
||||||
|
|
||||||
window.ClosePreloadLoading = () => {
|
window.removeLoading = () => {
|
||||||
_isCallClosePreloadLoading = true;
|
_isCallRemoveLoading = true;
|
||||||
removeLoading();
|
removeLoading();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 5 秒超时自动关闭
|
// 5 秒超时自动关闭
|
||||||
setTimeout(() => !_isCallClosePreloadLoading && removeLoading(), 4999);
|
setTimeout(() => !_isCallRemoveLoading && removeLoading(), 4999);
|
||||||
|
|
||||||
appendLoading();
|
appendLoading();
|
||||||
})();
|
})();
|
||||||
|
@ -6,12 +6,17 @@ import { ipcRenderer } from 'electron'
|
|||||||
import Store from 'electron-store'
|
import Store from 'electron-store'
|
||||||
import './index.css'
|
import './index.css'
|
||||||
|
|
||||||
console.log('ipcRenderer:', ipcRenderer)
|
|
||||||
// Configuration name causes hot updates to be slow | 传递 name 后会导致热更新很慢
|
setTimeout(() => {
|
||||||
// console.log('electron-store', new Store({ name: 'electron-vue' }))
|
console.log('ipcRenderer:', ipcRenderer)
|
||||||
// https://github.com/caoxiemeihao/electron-vue-vite/issues/10
|
// Configuration name causes hot updates to be slow | 传递 name 后会导致热更新很慢
|
||||||
console.log('electron-store', new Store())
|
// 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)
|
createApp(App)
|
||||||
.mount('#app')
|
.mount('#app')
|
||||||
.$nextTick(window.ClosePreloadLoading)
|
.$nextTick(window.removeLoading)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user