@molejs/global-helper
``` /** * 获取BSGlobal中值 */ getBSGlobal(key: string, defaultV?: any) { return BSGlobal[key] || defaultV; }, /** * 获取租户信息 */ getTenantInfo(key?: string) { return this.getBSGlobal(key || 'tenantInfo'); }, /** * 获取用户信息 */
Last updated a year ago by liugenpeng .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install @molejs/global-helper 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.0.1                                ...           latest (a year ago)

1 Versions

  • 0.0.1                                ...           a year ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (34)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |