various-ui
Version:
This is a test version of the Vue 3 component library
65 lines (60 loc) • 2.13 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
require('../../constants/index.js');
var loading = require('../../constants/components/loading/src/loading.vue.js');
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 = vue.createApp(loading.default, 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;
}
}
};
exports.$loading = $loading;
exports.default = $loading;
//# sourceMappingURL=index.js.map