import Loading from './Loading' import { mount } from '../../utils/componentHelper' const seat = 1 const closeStack = [] Loading.use = function use(app) { Loading.show = function (config) { if (closeStack.length) { closeStack.push(seat) } else { const { destroy } = mount(Loading, { app, props: { ...config }, }) closeStack.push(destroy) } } Loading.hide = function () { if (closeStack.length) { const close = closeStack.pop() if (close !== seat) { close() } } } Loading.hideAll = function () { for (const close of closeStack) { if (close !== seat) { close() } } closeStack.length = 0 } } export default Loading