feat: 完善服务端工程化、发布流程和自动化测试

This commit is contained in:
2026-07-16 08:36:12 +00:00
parent 0b71e8d024
commit 5d7aa560e5
29 changed files with 822 additions and 7987 deletions
+13 -1
View File
@@ -1,4 +1,4 @@
import { formatToken, getToken } from "@/utils/auth";
import { formatToken, getToken, removeToken } from "@/utils/auth";
export class AdminApiError extends Error {
status: number;
@@ -70,6 +70,12 @@ export async function adminRequest<T = any>(
}
if (!response.ok) {
if (response.status === 401) {
removeToken();
if (window.location.pathname !== "/login") {
window.location.href = "/login";
}
}
throw new AdminApiError(
`HTTP ${response.status}: ${text || response.statusText}`,
response.status,
@@ -122,6 +128,12 @@ export async function downloadAdminFile(
});
if (!response.ok) {
const text = await response.text();
if (response.status === 401) {
removeToken();
if (window.location.pathname !== "/login") {
window.location.href = "/login";
}
}
throw new AdminApiError(
`HTTP ${response.status}: ${text || response.statusText}`,
response.status,