|
@@ -53,6 +53,13 @@ await fetch('./public/config.json')
|
|
|
|
|
|
|
|
|
const service = initializeAxios(config1);
|
|
|
+
|
|
|
+var localIp = function getLocalIP() {
|
|
|
+ // fetch('https://api.ipify.org?format=json')
|
|
|
+ // .then(response => response.json())
|
|
|
+ // .then(data => console.log('公网 IP 地址:', data.ip));
|
|
|
+}
|
|
|
+
|
|
|
// request interceptor 接口请求拦截
|
|
|
service.interceptors.request.use((config: AxiosRequestConfig) => {
|
|
|
/**
|
|
@@ -61,8 +68,15 @@ service.interceptors.request.use((config: AxiosRequestConfig) => {
|
|
|
*/
|
|
|
const userStore = useUserStore();
|
|
|
const token: string = userStore.token;
|
|
|
+
|
|
|
+ console.log(userStore.username);
|
|
|
+
|
|
|
+
|
|
|
// 自定义请求头
|
|
|
+ config.headers['userName'] = userStore.username
|
|
|
if (token) { config.headers['Authorization'] = token }
|
|
|
+ console.log(config);
|
|
|
+
|
|
|
return config
|
|
|
}, (error: AxiosError) => {
|
|
|
// 请求错误,这里可以用全局提示框进行提示
|