新增 VITE_API_WS_URL 環境變數,更新主程式以引入嚴格模式包裝器,並在登錄頁面中整合觸客寶用戶信息獲取功能,調整請求模組以動態獲取 token2。

This commit is contained in:
超级老白兔
2025-08-18 11:30:56 +08:00
parent 7dd20b0a9b
commit 1b1bd7536d
11 changed files with 825 additions and 11 deletions

View File

@@ -6,7 +6,6 @@ import axios, {
} from "axios";
import { Toast } from "antd-mobile";
import { useUserStore } from "@/store/module/user";
const { token2 } = useUserStore.getState();
const DEFAULT_DEBOUNCE_GAP = 1000;
const debounceMap = new Map<string, number>();
@@ -27,9 +26,12 @@ const instance: AxiosInstance = axios.create({
});
instance.interceptors.request.use((config: any) => {
// 在每次请求时动态获取最新的 token2
const { token2 } = useUserStore.getState();
if (token2) {
config.headers = config.headers || {};
config.headers["Authorization"] = `Bearer ${token2}`;
config.headers["Authorization"] = `bearer ${token2}`;
}
return config;
});