feat(All):Initial

This commit is contained in:
2025-10-04 23:36:07 +08:00
commit 2b4e5d2668
1321 changed files with 415958 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import { ERROR_MSG_DURATION, NO_ERROR_MSG_CODE } from '@/config/service';
/** 错误消息栈,防止同一错误同时出现 */
const errorMsgStack = new Map<string | number, string>([]);
function addErrorMsg(error: Service.RequestError) {
errorMsgStack.set(error.code, error.msg);
}
function removeErrorMsg(error: Service.RequestError) {
errorMsgStack.delete(error.code);
}
function hasErrorMsg(error: Service.RequestError) {
return errorMsgStack.has(error.code);
}
/**
* 显示错误信息
* @param error
*/
export function showErrorMsg(error: Service.RequestError) {
if (!error.msg || NO_ERROR_MSG_CODE.includes(error.code) || hasErrorMsg(error)) return;
addErrorMsg(error);
window.console.warn(error.code, error.msg);
window.$message?.error(error.msg, { duration: ERROR_MSG_DURATION });
setTimeout(() => {
removeErrorMsg(error);
}, ERROR_MSG_DURATION);
}