46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
import SessionStorage from 'sessionstorage';
|
||
import store from '@/store/index';
|
||
|
||
const TokenKey = 'Admin-Token';
|
||
|
||
// 设置教学,实训,仿真系统token, 设置城市轨道交通设计平台token
|
||
export function getToken() {
|
||
return SessionStorage.getItem(TokenKey);
|
||
}
|
||
export function setToken(token) {
|
||
return SessionStorage.setItem(TokenKey, token);
|
||
}
|
||
export function removeToken() {
|
||
return SessionStorage.removeItem(TokenKey);
|
||
}
|
||
|
||
// 操作sessionStorage
|
||
export function getSessionStorage(key) {
|
||
return SessionStorage.getItem(key);
|
||
}
|
||
export function setSessionStorage(key, value) {
|
||
return SessionStorage.setItem(key, value);
|
||
}
|
||
export function removeSessionStorage(key) {
|
||
return SessionStorage.removeItem(key);
|
||
}
|
||
|
||
// 操作LocalStorage
|
||
export function getLocalStorage(key) {
|
||
const idKey = getUserIdKey(key);
|
||
return localStorage.getItem(idKey);
|
||
}
|
||
export function setLocalStorage(key, value) {
|
||
const idKey = getUserIdKey(key);
|
||
return localStorage.setItem(idKey, value);
|
||
}
|
||
export function removeLocalStorage(key) {
|
||
const idKey = getUserIdKey(key);
|
||
return localStorage.removeItem(idKey);
|
||
}
|
||
export function getUserIdKey(key) {
|
||
const id = store.state.user.id;
|
||
const idKey = `${id}_${key}`;
|
||
return idKey;
|
||
}
|