|
@@ -1,7 +1,9 @@
|
|
|
|
+import Cookies from 'js-cookie';
|
|
|
|
+
|
|
const TokenKey = 'GCLS_Token';
|
|
const TokenKey = 'GCLS_Token';
|
|
|
|
|
|
export function getSessionID() {
|
|
export function getSessionID() {
|
|
- const token = localStorage.getItem(TokenKey);
|
|
|
|
|
|
+ const token = Cookies.get(TokenKey) || sessionStorage.getItem(TokenKey) || localStorage.getItem(TokenKey);
|
|
const _token = token ? JSON.parse(token) : null;
|
|
const _token = token ? JSON.parse(token) : null;
|
|
return _token ? _token.session_id ?? '' : '';
|
|
return _token ? _token.session_id ?? '' : '';
|
|
}
|
|
}
|
|
@@ -11,7 +13,7 @@ export function getSessionID() {
|
|
* @returns {object | null}
|
|
* @returns {object | null}
|
|
*/
|
|
*/
|
|
export function getToken() {
|
|
export function getToken() {
|
|
- const token = localStorage.getItem(TokenKey);
|
|
|
|
|
|
+ const token = Cookies.get(TokenKey) || sessionStorage.getItem(TokenKey) || localStorage.getItem(TokenKey);
|
|
return token ? JSON.parse(token) : null;
|
|
return token ? JSON.parse(token) : null;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -21,7 +23,9 @@ export function getToken() {
|
|
*/
|
|
*/
|
|
export function setToken(token) {
|
|
export function setToken(token) {
|
|
const _token = typeof token === 'object' ? JSON.stringify(token) : '';
|
|
const _token = typeof token === 'object' ? JSON.stringify(token) : '';
|
|
|
|
+ sessionStorage.setItem(TokenKey, _token);
|
|
localStorage.setItem(TokenKey, _token);
|
|
localStorage.setItem(TokenKey, _token);
|
|
|
|
+ Cookies.set(TokenKey, _token);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -29,21 +33,27 @@ export function setToken(token) {
|
|
*/
|
|
*/
|
|
export function removeToken() {
|
|
export function removeToken() {
|
|
localStorage.removeItem(TokenKey);
|
|
localStorage.removeItem(TokenKey);
|
|
|
|
+ sessionStorage.removeItem(TokenKey);
|
|
|
|
+ Cookies.remove(TokenKey);
|
|
}
|
|
}
|
|
|
|
|
|
// 系统信息
|
|
// 系统信息
|
|
const ConfigKey = 'GCLS_Config';
|
|
const ConfigKey = 'GCLS_Config';
|
|
|
|
|
|
export function getConfig() {
|
|
export function getConfig() {
|
|
- const config = localStorage.getItem(ConfigKey);
|
|
|
|
|
|
+ const config = Cookies.get(ConfigKey) || sessionStorage.getItem(ConfigKey) || localStorage.getItem(ConfigKey);
|
|
return config ? JSON.parse(config) : null;
|
|
return config ? JSON.parse(config) : null;
|
|
}
|
|
}
|
|
|
|
|
|
export function setConfig(value) {
|
|
export function setConfig(value) {
|
|
let _val = typeof value === 'object' ? JSON.stringify(value) : '';
|
|
let _val = typeof value === 'object' ? JSON.stringify(value) : '';
|
|
localStorage.setItem(ConfigKey, _val);
|
|
localStorage.setItem(ConfigKey, _val);
|
|
|
|
+ sessionStorage.setItem(ConfigKey, _val);
|
|
|
|
+ Cookies.set(ConfigKey, _val);
|
|
}
|
|
}
|
|
|
|
|
|
export function removeConfig() {
|
|
export function removeConfig() {
|
|
localStorage.removeItem(ConfigKey);
|
|
localStorage.removeItem(ConfigKey);
|
|
|
|
+ sessionStorage.removeItem(ConfigKey);
|
|
|
|
+ Cookies.remove(ConfigKey);
|
|
}
|
|
}
|