Step F8:药品管理(IMP)

This commit is contained in:
Cheng Zhou
2025-12-17 12:46:58 +08:00
parent 88d2502812
commit 25fa11b9cc
49 changed files with 989 additions and 4 deletions
+11
View File
@@ -3,6 +3,7 @@ import { ElMessage } from "element-plus";
import router from "../router";
import { getToken, clearToken } from "../utils/auth";
import type { ApiError } from "../types/api";
import { useStudyStore } from "../store/study";
const instance: AxiosInstance = axios.create({
baseURL: "/",
@@ -23,6 +24,16 @@ instance.interceptors.response.use(
async (error: AxiosError<ApiError>) => {
const status = error.response?.status;
const data = error.response?.data;
// 如果当前项目不存在或已失效,清理项目并跳到项目列表
if (status === 404 && typeof data?.message === "string" && data.message.toLowerCase().includes("study")) {
try {
const studyStore = useStudyStore();
studyStore.clearCurrentStudy();
} catch {
/* ignore */
}
router.push("/studies");
}
if (status === 401) {
clearToken();
ElMessage.error(data?.message || "登录已过期,请重新登录");