import { nextTick } from 'vue'; import '/@/theme/loading.scss'; /** * 页面全局 Loading * @method start 创建 loading * @method done 移除 loading */ export const NextLoading = { // 创建 loading start: () => { if (window.nextLoading) { return; } const bodys: Element = document.body; const div = document.createElement('div'); div.setAttribute('class', 'loading-next'); const htmls = `
`; div.innerHTML = htmls; bodys.insertBefore(div, bodys.childNodes[0]); window.nextLoading = true; }, // 移除 loading(清除所有残留层,避免登录后页面无法点击) done: (time: number = 0) => { nextTick(() => { setTimeout(() => { window.nextLoading = false; document.querySelectorAll('.loading-next').forEach((el) => el.parentNode?.removeChild(el)); }, time); }); }, };