initHeader

This commit is contained in:
2024-08-22 11:27:06 +08:00
parent fe895bd37c
commit e0aaa7a30d
178 changed files with 5726 additions and 4999 deletions

View File

@@ -0,0 +1,27 @@
import { ElNotification } from "element-plus";
/**
* @description 全局代码错误捕捉
* */
const errorHandler = (error: any) => {
// 过滤 HTTP 请求错误
if (error.status || error.status == 0) return false;
let errorMap: { [key: string]: string } = {
InternalError: "Javascript引擎内部错误",
ReferenceError: "未找到对象",
TypeError: "使用了错误的类型或对象",
RangeError: "使用内置对象时,参数超范围",
SyntaxError: "语法错误",
EvalError: "错误的使用了Eval",
URIError: "URI错误"
};
let errorName = errorMap[error.name] || "未知错误";
ElNotification({
title: errorName,
message: error,
type: "error",
duration: 3000
});
};
export default errorHandler;