You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
921 B
JavaScript
47 lines
921 B
JavaScript
window.$message = () => {
|
|
ElMessage.closeAll();
|
|
return ElMessage;
|
|
};
|
|
window.$box = ElMessageBox;
|
|
let loading = null;
|
|
window.$loading = () => {
|
|
return {
|
|
open: () => {
|
|
loading = ElLoading.service({
|
|
lock: true,
|
|
text: "加载中...",
|
|
});
|
|
},
|
|
close: () => {
|
|
loading.close();
|
|
},
|
|
};
|
|
};
|
|
window.$open = (url, obj = {}, type = "href") => {
|
|
let urlString = url;
|
|
if (Object.keys(obj).length > 0) {
|
|
urlString +=
|
|
"?" +
|
|
Object.entries(obj)
|
|
.map(
|
|
([key, value]) =>
|
|
`${encodeURIComponent(key)}=${encodeURIComponent(value)}`
|
|
)
|
|
.join("&");
|
|
}
|
|
switch (type) {
|
|
case "href":
|
|
window.location.href = urlString;
|
|
break;
|
|
case "open":
|
|
window.open(urlString);
|
|
}
|
|
};
|
|
|
|
window.$response = (res, then) => {
|
|
if (res) {
|
|
if (!res.status) return window.$message().error(res.msg);
|
|
then();
|
|
}
|
|
};
|