refactor: 统一错误处理并优化代码

- 移除重复的错误提示,统一在axios拦截器中处理
- 优化XSS拦截器,添加请求头白名单
- 修复注册码服务的日期处理问题
- 添加403权限错误处理
- 优化分组查询参数处理
This commit is contained in:
ikmkj
2026-03-03 23:41:20 +08:00
parent a4f95e7315
commit 25b52f87aa
20 changed files with 123 additions and 37 deletions

View File

@@ -59,8 +59,8 @@ const fetchRegistrationStatus = async () => {
try {
isRegistrationEnabled.value = await getRegistrationStatus();
} catch (error) {
// 错误已在 axios 拦截器中显示,这里不再重复显示
console.error("Failed to fetch registration status:", error);
ElMessage.error('获取注册状态失败');
}
};
@@ -69,7 +69,7 @@ const handleToggleRegistration = async (value) => {
await toggleRegistration(value);
ElMessage.success(`注册功能已${value ? '开启' : '关闭'}`);
} catch (error) {
ElMessage.error('操作失败');
// 错误已在 axios 拦截器中显示,这里不再重复显示
isRegistrationEnabled.value = !value; // Revert on failure
}
};
@@ -80,7 +80,8 @@ const handleGenerateCode = async () => {
generatedCode.value = code;
ElMessage.success('注册码生成成功');
} catch (error) {
ElMessage.error('生成注册码失败: ' + error.message);
// 错误已在 axios 拦截器中显示,这里不再重复显示
console.error('生成注册码失败:', error);
}
};