UNPKG

various-ui

Version:

This is a test version of the Vue 3 component library

60 lines (57 loc) 2.03 kB
import { createApp } from 'vue'; import '../../constants/index.mjs'; import UiLoading from '../../constants/components/loading/src/loading.vue.mjs'; const show = (config) => { const body = document.body; const size = innerWidth - document.documentElement.clientWidth; if (size) { document.documentElement.style.overflow = "hidden"; document.documentElement.style.paddingRight = size + "px"; } if (body.instance) { if (config == null ? void 0 : config.icon) body.instance.$.props.icon = config.icon; if (config == null ? void 0 : config.message) body.instance.$.props.message = config.message; } else { const app = createApp(UiLoading, Object.assign({ visible: false, mode: "fixed" }, config)); const instance = app.mount(document.createElement("div")); if (body.style.position == "") body.classList.add("ui-relative"); body.app = app; body.instance = instance; body.appendChild(instance.$el); } body.instance.$.props.visible = true; }; const $loading = { delay: false, timer: void 0, //* 虚假的Show函数, 用于控制Loading延迟显示 open: function(config) { this.timer && clearTimeout(this.timer); if (config == null ? void 0 : config.delay) { this.timer = setTimeout(() => { show(config); this.delay = true; }, config.delay); } else { show(config); } }, close: function() { this.timer && clearTimeout(this.timer); const body = document.body; if (this.delay) { this.delay = false; this.timer = setTimeout(() => { if (body.instance) body.instance.$.props.visible = false; document.documentElement.style.overflow = ""; document.documentElement.style.paddingRight = ""; }, 500); } else if (body.instance) { document.documentElement.style.overflow = ""; document.documentElement.style.paddingRight = ""; body.instance.$.props.visible = false; } } }; export { $loading, $loading as default }; //# sourceMappingURL=index.mjs.map