78 lines
2.8 KiB
JavaScript
78 lines
2.8 KiB
JavaScript
import SessionStorage from 'sessionstorage';
|
||
import { LoginParams } from '@/utils/login';
|
||
|
||
const TokenKey = 'Admin-Token';
|
||
const TokenDesignKey = 'Design-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);
|
||
}
|
||
|
||
// 设置城市轨道交通设计平台token
|
||
export function getDesignToken() {
|
||
return SessionStorage.getItem(TokenDesignKey);
|
||
}
|
||
export function setDesignToken(token) {
|
||
return SessionStorage.setItem(TokenDesignKey, token);
|
||
}
|
||
export function removeDesignToken() {
|
||
return SessionStorage.removeItem(TokenDesignKey);
|
||
}
|
||
|
||
// 操作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);
|
||
}
|
||
|
||
// 根据路径判断获取token
|
||
export function handleToken() {
|
||
const path = window.location.href;
|
||
if (path.includes('/design') || path.includes('/scriptDisplay') || path.includes('/publish') || path.includes('/orderauthor') || path.includes('/system') || path.includes('/display/manage') || path.includes('/apply/')) {
|
||
return getDesignToken();
|
||
} else if (path.includes('/plan') || path.includes('/display/plan')) {
|
||
return getDesignToken() || getToken();
|
||
} else {
|
||
return getToken();
|
||
}
|
||
}
|
||
|
||
// 根据路径清除token
|
||
export function handleRemoveToken() {
|
||
const path = window.location.href;
|
||
if (path.includes('/design') || path.includes('/scriptDisplay') || path.includes('/plan') || path.includes('/publish') || path.includes('/orderauthor') || path.includes('/system') || path.includes('/display/plan') || path.includes('/display/manage') || path.includes('/apply/')) {
|
||
return removeDesignToken();
|
||
} else {
|
||
return removeToken();
|
||
}
|
||
}
|
||
|
||
// 根据route路径判断系统类型
|
||
export function gainClientId() {
|
||
const path = window.location.href;
|
||
let clientId = null;
|
||
if (path.includes('/dp/') || path.includes('/display/dp')) {
|
||
clientId = LoginParams.DaPing.clientId;
|
||
}
|
||
// else if (path.includes('/plan') || path.includes('/display/plan')) {
|
||
// clientId = LoginParams.LianJiHua.clientId;
|
||
// }
|
||
else if (path.includes('/design') || path.includes('/scriptDisplay') || path.includes('/plan') || path.includes('/publish') || path.includes('/orderauthor') || path.includes('/system') || path.includes('/display/plan') || path.includes('/display/manage') || path.includes('/apply/')) {
|
||
clientId = LoginParams.Design.clientId;
|
||
}
|
||
|
||
return clientId;
|
||
}
|