mirror of
https://github.com/certd/certd.git
synced 2026-04-24 20:57:26 +08:00
pref: 允许忽略自签证书校验
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
"debug:force": "vite --force --mode debug",
|
||||
"build": " vite build ",
|
||||
"dev-build": "echo 1",
|
||||
"test:unit": "vitest",
|
||||
"serve": "vite preview",
|
||||
"preview": "vite preview",
|
||||
"pretty-quick": "pretty-quick",
|
||||
@@ -114,7 +115,9 @@
|
||||
"vite-plugin-html": "^3.2.2",
|
||||
"vite-plugin-windicss": "^1.9.3",
|
||||
"vue-eslint-parser": "^9.4.2",
|
||||
"vue-tsc": "^1.8.8"
|
||||
"vue-tsc": "^1.8.8",
|
||||
"@vue/test-utils": "^2.4.6",
|
||||
"vitest": "^2.1.2"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
|
||||
@@ -53,7 +53,9 @@ function createService() {
|
||||
// @ts-ignore
|
||||
response.config.onError(new Error(errorMessage));
|
||||
}
|
||||
errorCreate(`${errorMessage}: ${response.config.url}`);
|
||||
//@ts-ignore
|
||||
const showErrorNotify = response?.config?.showErrorNotify;
|
||||
errorCreate(`${errorMessage}: ${response.config.url}`, showErrorNotify);
|
||||
return dataAxios;
|
||||
}
|
||||
}
|
||||
@@ -97,7 +99,7 @@ function createService() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
errorLog(error);
|
||||
errorLog(error, error?.response?.config?.showErrorNotify);
|
||||
if (status === 401) {
|
||||
const userStore = useUserStore();
|
||||
userStore.logout();
|
||||
|
||||
@@ -48,7 +48,7 @@ export function responseError(data = {}, msg = "请求失败", code = 500) {
|
||||
* @description 记录和显示错误
|
||||
* @param {Error} error 错误对象
|
||||
*/
|
||||
export function errorLog(error: any) {
|
||||
export function errorLog(error: any, notify = true) {
|
||||
// 打印到控制台
|
||||
console.error("errorLog", error);
|
||||
let message = error.message;
|
||||
@@ -58,17 +58,22 @@ export function errorLog(error: any) {
|
||||
if (message.indexOf("ssl3_get_record:wrong version number") >= 0) {
|
||||
message = "http协议错误,服务端要求http协议,请检查是否使用了https请求";
|
||||
}
|
||||
// 显示提示
|
||||
uiContext.get().notification.error({ message });
|
||||
if (notify) {
|
||||
// 显示提示
|
||||
uiContext.get().notification.error({ message });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 创建一个错误
|
||||
* @param {String} msg 错误信息
|
||||
*/
|
||||
export function errorCreate(msg: string) {
|
||||
export function errorCreate(msg: string, notify = true) {
|
||||
const err = new Error(msg);
|
||||
console.error("errorCreate", err);
|
||||
uiContext.get().notification.error({ message: err.message });
|
||||
if (notify) {
|
||||
uiContext.get().notification.error({ message: err.message });
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ const attrs = useAttrs();
|
||||
const optionsRef = ref([]);
|
||||
const message = ref("");
|
||||
const getOptions = async () => {
|
||||
message.value = "";
|
||||
const res = await doRequest(
|
||||
{
|
||||
type: props.type,
|
||||
@@ -53,10 +54,10 @@ const getOptions = async () => {
|
||||
{
|
||||
onError(err: any) {
|
||||
message.value = `获取选项出错:${err.message}`;
|
||||
}
|
||||
},
|
||||
showErrorNotify: false
|
||||
}
|
||||
);
|
||||
message.value = "";
|
||||
return res;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user