preload/splash.ts -> preload/index.ts

This commit is contained in:
草鞋没号 2022-06-29 08:35:32 +08:00
parent 042f7af691
commit f129465d28
2 changed files with 7 additions and 3 deletions

View File

@ -1,4 +1,3 @@
function domReady(condition: DocumentReadyState[] = ['complete', 'interactive']) {
return new Promise(resolve => {
if (condition.includes(document.readyState)) {
@ -84,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)

View File

@ -23,7 +23,7 @@ export default defineConfig({
preload: {
input: {
// You can configure multiple preload here
splash: join(__dirname, 'electron/preload/splash.ts'),
index: join(__dirname, 'electron/preload/index.ts'),
},
vite: {
build: {