WMS_PDA/core/utils/auth.js

26 lines
688 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const TokenKey = 'token'
const WorkbenchTokenKey = 'workbenchToken'
export function getToken() {
return uni.getStorageSync(TokenKey);
}
export function setToken(token) {
console.log("设置token");
return uni.setStorageSync(TokenKey,token);
}
export function removeToken() {
return uni.setStorageSync(TokenKey,'');
}
/**
* 是否为工作台会话:全局 token 与工作台 token(workbenchToken)一致
* 工作台会话下不做用户态校验,不调用 user.info
*/
export function isWorkbenchSession() {
const token = getToken();
const workbenchToken = uni.getStorageSync(WorkbenchTokenKey);
return !!token && !!workbenchToken && token === workbenchToken;
}