@huntianning/components
Version:
Custom components for HTN
42 lines (40 loc) • 982 B
JavaScript
/**
* 获取当前登录的用户上下文数据
*/
export function getLoginUserData() {
const keys = ['companyName', 'companyId', 'roleType', 'name', 'token', 'phone'];
const result = keys.reduce((rs, k) => {
rs[k] = window.localStorage.getItem(k);
return rs;
}, {});
if (!result.token) {
return;
}
return result;
}
/**
* 设置当前登录的用户上下文数据
*/
export function setLoginUserData(data) {
const keys = ['companyName', 'companyId', 'roleType', 'name', 'token', 'phone'];
if (data) {
keys.forEach(k => {
window.localStorage.setItem(k, data[k]);
});
} else {
keys.forEach(k => {
window.localStorage.removeItem(k);
});
}
}
/**
* 获取模块是否启用水印
*/
export function getModuleEnableWatermark(moduleName) {
const storage = window.localStorage.getItem('waterMarkItem');
if (!storage) {
return false;
}
const modules = storage.split(',');
return modules.includes(moduleName);
}