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.

42 lines
880 B
JavaScript

window.$message = () => {
ElMessage.closeAll()
return ElMessage
}
window.$box = ElMessageBox
let loading = null
window.$loading = () => {
return {
open: (text = '加载中...') => {
loading = ElLoading.service({
lock: true,
text: 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.code !== 200) return window.$message().error(res.message)
then()
}
}