delete alert style

This commit is contained in:
ailanyin
2023-05-17 09:56:28 +08:00
parent e9764b6eb3
commit 26d259e8f0
111 changed files with 7876 additions and 6223 deletions

View File

@ -1,26 +1,26 @@
import useUserStore from '@/store/modules/user'
import useUserStore from "@/store/modules/user";
function authPermission(permission) {
const all_permission = "*:*:*";
const permissions = useUserStore().permissions
const permissions = useUserStore().permissions;
if (permission && permission.length > 0) {
return permissions.some(v => {
return all_permission === v || v === permission
})
return permissions.some((v) => {
return all_permission === v || v === permission;
});
} else {
return false
return false;
}
}
function authRole(role) {
const super_admin = "admin";
const roles = useUserStore().roles
const roles = useUserStore().roles;
if (role && role.length > 0) {
return roles.some(v => {
return super_admin === v || v === role
})
return roles.some((v) => {
return super_admin === v || v === role;
});
} else {
return false
return false;
}
}
@ -31,15 +31,15 @@ export default {
},
// 验证用户是否含有指定权限,只需包含其中一个
hasPermiOr(permissions) {
return permissions.some(item => {
return authPermission(item)
})
return permissions.some((item) => {
return authPermission(item);
});
},
// 验证用户是否含有指定权限,必须全部拥有
hasPermiAnd(permissions) {
return permissions.every(item => {
return authPermission(item)
})
return permissions.every((item) => {
return authPermission(item);
});
},
// 验证用户是否具备某角色
hasRole(role) {
@ -47,14 +47,14 @@ export default {
},
// 验证用户是否含有指定角色,只需包含其中一个
hasRoleOr(roles) {
return roles.some(item => {
return authRole(item)
})
return roles.some((item) => {
return authRole(item);
});
},
// 验证用户是否含有指定角色,必须全部拥有
hasRoleAnd(roles) {
return roles.every(item => {
return authRole(item)
})
}
}
return roles.every((item) => {
return authRole(item);
});
},
};

View File

@ -1,69 +1,69 @@
const sessionCache = {
set (key, value) {
set(key, value) {
if (!sessionStorage) {
return
return;
}
if (key != null && value != null) {
sessionStorage.setItem(key, value)
sessionStorage.setItem(key, value);
}
},
get (key) {
get(key) {
if (!sessionStorage) {
return null
return null;
}
if (key == null) {
return null
return null;
}
return sessionStorage.getItem(key)
return sessionStorage.getItem(key);
},
setJSON (key, jsonValue) {
setJSON(key, jsonValue) {
if (jsonValue != null) {
this.set(key, JSON.stringify(jsonValue))
this.set(key, JSON.stringify(jsonValue));
}
},
getJSON (key) {
const value = this.get(key)
getJSON(key) {
const value = this.get(key);
if (value != null) {
return JSON.parse(value)
return JSON.parse(value);
}
},
remove (key) {
remove(key) {
sessionStorage.removeItem(key);
}
}
},
};
const localCache = {
set (key, value) {
set(key, value) {
if (!localStorage) {
return
return;
}
if (key != null && value != null) {
localStorage.setItem(key, value)
localStorage.setItem(key, value);
}
},
get (key) {
get(key) {
if (!localStorage) {
return null
return null;
}
if (key == null) {
return null
return null;
}
return localStorage.getItem(key)
return localStorage.getItem(key);
},
setJSON (key, jsonValue) {
setJSON(key, jsonValue) {
if (jsonValue != null) {
this.set(key, JSON.stringify(jsonValue))
this.set(key, JSON.stringify(jsonValue));
}
},
getJSON (key) {
const value = this.get(key)
getJSON(key) {
const value = this.get(key);
if (value != null) {
return JSON.parse(value)
return JSON.parse(value);
}
},
remove (key) {
remove(key) {
localStorage.removeItem(key);
}
}
},
};
export default {
/**
@ -73,5 +73,5 @@ export default {
/**
* 本地缓存
*/
local: localCache
}
local: localCache,
};

View File

@ -1,63 +1,71 @@
import axios from 'axios'
import { ElMessage } from 'element-plus'
import { saveAs } from 'file-saver'
import { getToken } from '@/utils/auth'
import errorCode from '@/utils/errorCode'
import { blobValidate } from '@/utils/ruoyi'
import axios from "axios";
import { ElMessage } from "element-plus";
import { saveAs } from "file-saver";
import { getToken } from "@/utils/auth";
import errorCode from "@/utils/errorCode";
import { blobValidate } from "@/utils/ruoyi";
const baseURL = import.meta.env.VITE_APP_BASE_API
const baseURL = import.meta.env.VITE_APP_BASE_API;
export default {
name(name, isDelete = true) {
var url = baseURL + "/common/download?fileName=" + encodeURIComponent(name) + "&delete=" + isDelete
var url =
baseURL +
"/common/download?fileName=" +
encodeURIComponent(name) +
"&delete=" +
isDelete;
axios({
method: 'get',
method: "get",
url: url,
responseType: 'blob',
headers: { 'Authorization': 'Bearer ' + getToken() }
responseType: "blob",
headers: { Authorization: "Bearer " + getToken() },
}).then((res) => {
const isBlob = blobValidate(res.data);
if (isBlob) {
const blob = new Blob([res.data])
this.saveAs(blob, decodeURIComponent(res.headers['download-filename']))
const blob = new Blob([res.data]);
this.saveAs(blob, decodeURIComponent(res.headers["download-filename"]));
} else {
this.printErrMsg(res.data);
}
})
});
},
resource(resource) {
var url = baseURL + "/common/download/resource?resource=" + encodeURIComponent(resource);
var url =
baseURL +
"/common/download/resource?resource=" +
encodeURIComponent(resource);
axios({
method: 'get',
method: "get",
url: url,
responseType: 'blob',
headers: { 'Authorization': 'Bearer ' + getToken() }
responseType: "blob",
headers: { Authorization: "Bearer " + getToken() },
}).then((res) => {
const isBlob = blobValidate(res.data);
if (isBlob) {
const blob = new Blob([res.data])
this.saveAs(blob, decodeURIComponent(res.headers['download-filename']))
const blob = new Blob([res.data]);
this.saveAs(blob, decodeURIComponent(res.headers["download-filename"]));
} else {
this.printErrMsg(res.data);
}
})
});
},
zip(url, name) {
var url = baseURL + url
var url = baseURL + url;
axios({
method: 'get',
method: "get",
url: url,
responseType: 'blob',
headers: { 'Authorization': 'Bearer ' + getToken() }
responseType: "blob",
headers: { Authorization: "Bearer " + getToken() },
}).then((res) => {
const isBlob = blobValidate(res.data);
if (isBlob) {
const blob = new Blob([res.data], { type: 'application/zip' })
this.saveAs(blob, name)
const blob = new Blob([res.data], { type: "application/zip" });
this.saveAs(blob, name);
} else {
this.printErrMsg(res.data);
}
})
});
},
saveAs(text, name, opts) {
saveAs(text, name, opts);
@ -65,8 +73,7 @@ export default {
async printErrMsg(data) {
const resText = await data.text();
const rspObj = JSON.parse(resText);
const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']
const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode["default"];
ElMessage.error(errMsg);
}
}
},
};

View File

@ -1,18 +1,18 @@
import tab from './tab'
import auth from './auth'
import cache from './cache'
import modal from './modal'
import download from './download'
import tab from "./tab";
import auth from "./auth";
import cache from "./cache";
import modal from "./modal";
import download from "./download";
export default function installPlugins(app){
export default function installPlugins(app) {
// 页签操作
app.config.globalProperties.$tab = tab
app.config.globalProperties.$tab = tab;
// 认证对象
app.config.globalProperties.$auth = auth
app.config.globalProperties.$auth = auth;
// 缓存对象
app.config.globalProperties.$cache = cache
app.config.globalProperties.$cache = cache;
// 模态框对象
app.config.globalProperties.$modal = modal
app.config.globalProperties.$modal = modal;
// 下载文件
app.config.globalProperties.$download = download
app.config.globalProperties.$download = download;
}

View File

@ -1,43 +1,48 @@
import { ElMessage, ElMessageBox, ElNotification, ElLoading } from 'element-plus'
import {
ElMessage,
ElMessageBox,
ElNotification,
ElLoading,
} from "element-plus";
let loadingInstance;
export default {
// 消息提示
msg(content) {
ElMessage.info(content)
ElMessage.info(content);
},
// 错误消息
msgError(content) {
ElMessage.error(content)
ElMessage.error(content);
},
// 成功消息
msgSuccess(content) {
ElMessage.success(content)
ElMessage.success(content);
},
// 警告消息
msgWarning(content) {
ElMessage.warning(content)
ElMessage.warning(content);
},
// 弹出提示
alert(content) {
ElMessageBox.alert(content, "系统提示")
ElMessageBox.alert(content, "系统提示");
},
// 错误提示
alertError(content) {
ElMessageBox.alert(content, "系统提示", { type: 'error' })
ElMessageBox.alert(content, "系统提示", { type: "error" });
},
// 成功提示
alertSuccess(content) {
ElMessageBox.alert(content, "系统提示", { type: 'success' })
ElMessageBox.alert(content, "系统提示", { type: "success" });
},
// 警告提示
alertWarning(content) {
ElMessageBox.alert(content, "系统提示", { type: 'warning' })
ElMessageBox.alert(content, "系统提示", { type: "warning" });
},
// 通知提示
notify(content) {
ElNotification.info(content)
ElNotification.info(content);
},
// 错误通知
notifyError(content) {
@ -45,27 +50,27 @@ export default {
},
// 成功通知
notifySuccess(content) {
ElNotification.success(content)
ElNotification.success(content);
},
// 警告通知
notifyWarning(content) {
ElNotification.warning(content)
ElNotification.warning(content);
},
// 确认窗体
confirm(content) {
return ElMessageBox.confirm(content, "系统提示", {
confirmButtonText: '确定',
cancelButtonText: '取消',
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
});
},
// 提交内容
prompt(content) {
return ElMessageBox.prompt(content, "系统提示", {
confirmButtonText: '确定',
cancelButtonText: '取消',
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
});
},
// 打开遮罩层
loading(content) {
@ -73,10 +78,10 @@ export default {
lock: true,
text: content,
background: "rgba(0, 0, 0, 0.7)",
})
});
},
// 关闭遮罩层
closeLoading() {
loadingInstance.close();
}
}
},
};

View File

@ -1,5 +1,5 @@
import useTagsViewStore from '@/store/modules/tagsView'
import router from '@/router'
import useTagsViewStore from "@/store/modules/tagsView";
import router from "@/router";
export default {
// 刷新当前tab页签
@ -8,19 +8,21 @@ export default {
if (obj === undefined) {
matched.forEach((m) => {
if (m.components && m.components.default && m.components.default.name) {
if (!['Layout', 'ParentView'].includes(m.components.default.name)) {
if (!["Layout", "ParentView"].includes(m.components.default.name)) {
obj = { name: m.components.default.name, path: path, query: query };
}
}
});
}
return useTagsViewStore().delCachedView(obj).then(() => {
const { path, query } = obj
router.replace({
path: '/redirect' + path,
query: query
})
})
return useTagsViewStore()
.delCachedView(obj)
.then(() => {
const { path, query } = obj;
router.replace({
path: "/redirect" + path,
query: query,
});
});
},
// 关闭当前tab页签打开新页签
closeOpenPage(obj) {
@ -32,13 +34,15 @@ export default {
// 关闭指定tab页签
closePage(obj) {
if (obj === undefined) {
return useTagsViewStore().delView(router.currentRoute.value).then(({ visitedViews }) => {
const latestView = visitedViews.slice(-1)[0]
if (latestView) {
return router.push(latestView.fullPath)
}
return router.push('/');
});
return useTagsViewStore()
.delView(router.currentRoute.value)
.then(({ visitedViews }) => {
const latestView = visitedViews.slice(-1)[0];
if (latestView) {
return router.push(latestView.fullPath);
}
return router.push("/");
});
}
return useTagsViewStore().delView(obj);
},
@ -65,5 +69,5 @@ export default {
// 修改tab页签
updatePage(obj) {
return useTagsViewStore().updateVisitedView(obj);
}
}
},
};