mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-31 20:16:36 +08:00
20 lines
535 B
TypeScript
20 lines
535 B
TypeScript
import { useLoading } from './loading'
|
|
|
|
function domReady(condition: DocumentReadyState[] = ['complete', 'interactive']) {
|
|
return new Promise(resolve => {
|
|
if (condition.includes(document.readyState)) {
|
|
resolve(true)
|
|
} else {
|
|
document.addEventListener('readystatechange', () => {
|
|
if (condition.includes(document.readyState)) {
|
|
resolve(true)
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
const { appendLoading, removeLoading } = useLoading()
|
|
window.removeLoading = removeLoading
|
|
domReady().then(appendLoading)
|