Miss any of our Open RFC calls?Watch the recordings here! »

@molejs/global-helper

0.0.1 • Public • Published

标准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;
  },

Keywords

none

Install

npm i @molejs/global-helper

DownloadsWeekly Downloads

3

Version

0.0.1

License

MIT

Unpacked Size

6.46 kB

Total Files

7

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar