@molejs/global-helper
v0.0.1
Published
``` /** * 获取BSGlobal中值 */ getBSGlobal(key: string, defaultV?: any) { return BSGlobal[key] || defaultV; }, /** * 获取租户信息 */ getTenantInfo(key?: string) { return this.getBSGlobal(key || 'tenantInfo'); }, /** * 获取用户信息 */
Downloads
1
Keywords
Readme
标准BSGlobal 操作API
/**
* 获取BSGlobal中值
*/
getBSGlobal(key: string, defaultV?: any) {
return BSGlobal[key] || defaultV;
},
/**
* 获取租户信息
*/
getTenantInfo(key?: string) {
return this.getBSGlobal(key || 'tenantInfo');
},
/**
* 获取用户信息
*/
getUserInfo(key?: string): any {
return this.getBSGlobal(key || 'loginUserInfo');
},
/**
* 获取用户Id
*/
getUserId() {
const user = this.getUserInfo()
return user.Id || user.UserId || user.id;
},
/**
* 用户租户Id
*/
getTenantId() {
const tenant = this.getTenantInfo();
return tenant.Id || tenant.tenant_id || tenant.tenantId;
},
/**
* 获取环境标识
*/
getEnv() {
const env = this.getBSGlobal('env');
return {
get isProduction() {
return /production/ig.test(env);
},
get isDevelopment() {
return /development/ig.test(env) || /develop/ig.test(env);
},
get isTesting() {
return /test/ig.test(env)
}
};
},
// 获取协议
getProtocol() {
return window.location.protocol;
},