fix: 修复nginx缓存导致串用户问题

This commit is contained in:
CalciumIon
2024-07-19 13:39:05 +08:00
parent e2cf6b1e14
commit ce815a98d0
3 changed files with 44 additions and 1 deletions

View File

@@ -1,10 +1,13 @@
import { showError } from './utils';
import { getUserIdFromLocalStorage, showError } from './utils';
import axios from 'axios';
export const API = axios.create({
baseURL: import.meta.env.VITE_REACT_APP_SERVER_URL
? import.meta.env.VITE_REACT_APP_SERVER_URL
: '',
headers: {
'New-API-User': getUserIdFromLocalStorage()
}
});
API.interceptors.response.use(

View File

@@ -33,6 +33,13 @@ export function getLogo() {
return logo;
}
export function getUserIdFromLocalStorage() {
let user = localStorage.getItem('user');
if (!user) return -1;
user = JSON.parse(user);
return user.id;
}
export function getFooterHTML() {
return localStorage.getItem('footer_html');
}