refactor(projects): 精简版+动态路由权限初步

This commit is contained in:
Soybean
2022-01-03 22:20:10 +08:00
parent 7a0648dba5
commit de2057f141
354 changed files with 2053 additions and 22117 deletions

View File

@ -1,16 +1,16 @@
import type { RequestServiceError } from '@/interface';
import { NO_ERROR_MSG_CODE, ERROR_MSG_DURATION } from '@/config';
import { consoleWarn } from '../common';
/** 错误消息栈,防止同一错误同时出现 */
const errorMsgStack = new Map<string | number, string>([]);
function addErrorMsg(error: RequestServiceError) {
function addErrorMsg(error: Service.RequestError) {
errorMsgStack.set(error.code, error.msg);
}
function removeErrorMsg(error: RequestServiceError) {
function removeErrorMsg(error: Service.RequestError) {
errorMsgStack.delete(error.code);
}
function hasErrorMsg(error: RequestServiceError) {
function hasErrorMsg(error: Service.RequestError) {
return errorMsgStack.has(error.code);
}
@ -18,11 +18,12 @@ function hasErrorMsg(error: RequestServiceError) {
* 显示错误信息
* @param error
*/
export function showErrorMsg(error: RequestServiceError) {
export function showErrorMsg(error: Service.RequestError) {
if (!error.msg) return;
if (!NO_ERROR_MSG_CODE.includes(error.code)) {
if (!hasErrorMsg(error)) {
addErrorMsg(error);
consoleWarn(error.code, error.msg);
window.$message?.error(error.msg, { duration: ERROR_MSG_DURATION });
setTimeout(() => {
removeErrorMsg(error);