UNPKG

@hocgin/taro-kit

Version:
52 lines (43 loc) 1.94 kB
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } import Taro from "@tarojs/taro"; import { LangKit } from "../_utils"; export var EnvPropsKit = /*#__PURE__*/function () { function EnvPropsKit() { _classCallCheck(this, EnvPropsKit); } _createClass(EnvPropsKit, null, [{ key: "getAppid", value: function getAppid() { var _EnvPropsKit$getAppIn; if (LangKit.isBrowser()) { return LangKit.getBrowserId(); } return (_EnvPropsKit$getAppIn = EnvPropsKit.getAppInfo()) === null || _EnvPropsKit$getAppIn === void 0 ? void 0 : _EnvPropsKit$getAppIn.appId; } }, { key: "getAppName", value: function getAppName() { try { return '授权应用'; } catch (e) { return undefined; } } }, { key: "getAppInfo", value: function getAppInfo() { if (Taro.getEnv() !== Taro.ENV_TYPE.WEAPP) { return undefined; } try { var _Taro$getAccountInfoS; return (_Taro$getAccountInfoS = Taro.getAccountInfoSync()) === null || _Taro$getAccountInfoS === void 0 ? void 0 : _Taro$getAccountInfoS.miniProgram; } catch (e) { return undefined; } } }]); return EnvPropsKit; }();