@molejs/global-helper
TypeScript icon, indicating that this package has built-in type declarations

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

Readme

Keywords

none

Package Sidebar

Install

npm i @molejs/global-helper

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

6.46 kB

Total Files

7

Last publish

Collaborators

  • albert-zhang
  • luochongjie
  • jiayunqiu
  • liugenpeng
  • zhizhi_wang