鉴权调整

This commit is contained in:
fan 2023-02-23 18:18:01 +08:00
parent be047fff67
commit f24c36dbed
3 changed files with 6 additions and 5 deletions

View File

@ -179,7 +179,6 @@ const user = {
commit('SET_TOKEN', '');
commit('SET_ID', '');
commit('SET_ROLES', []);
removeToken();
},
// 登出系统
@ -191,6 +190,7 @@ const user = {
dispatch('disconnect').then(()=>{
dispatch('FedLogOut').then(resp => {
logout(token).then(() => {
removeToken();
resolve();
}).catch(error => {
reject(error);
@ -215,6 +215,7 @@ const user = {
return new Promise((resolve, reject) => {
dispatch('FedLogOut').then(resp => {
logout(token).then(() => {
removeToken();
resolve();
}).catch(error => {
reject(error);
@ -234,7 +235,6 @@ const user = {
},
disconnect({commit}, params) {
commit('Disconnect', params);
removeToken();
},
setBaseUrl ({commit}, baseUrl) {
commit('setBaseUrl', baseUrl);

View File

@ -5,13 +5,13 @@ const TokenKey = 'Admin-Token';
// 设置教学实训仿真系统token, 设置城市轨道交通设计平台token
export function getToken() {
return SessionStorage.getItem(TokenKey);
return localStorage.getItem(TokenKey);
}
export function setToken(token) {
return SessionStorage.setItem(TokenKey, token);
return localStorage.setItem(TokenKey, token);
}
export function removeToken() {
return SessionStorage.removeItem(TokenKey);
return localStorage.removeItem(TokenKey);
}
// 操作sessionStorage

View File

@ -22,6 +22,7 @@ const service = axios.create({
// request拦截器108
service.interceptors.request.use(config => {
if (getToken()) {
config.headers['Authorization'] = `Bearer ${getToken()}`; // 让每个请求携带自定义token 请根据实际情况自行修改
config.headers['X-Token'] = getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改
}