1 |
- "use strict";exports.__esModule=!0,exports.getPlatformType=exports.getContainerType=exports.getAppType=exports.UA_IDENTIFIER=exports.InvokerRuntimeTypeEnum=exports.InvokerPlatformTypeEnum=exports.InvokerContainerTypeEnum=exports.InvokerAppTypeEnum=exports.APP_VERSION=exports.APP_NAME=void 0,exports.getUAIdentifier=getUAIdentifier;var _PlatformRegExpMap,InvokerContainerTypeEnum,InvokerPlatformTypeEnum,InvokerAppTypeEnum,InvokerRuntimeTypeEnum,_global=require("./global");exports.InvokerContainerTypeEnum=InvokerContainerTypeEnum,function(n){n.DingTalk="DingTalk",n.mPaaS="mPaaS",n.Alipay="Alipay",n.Unknown="unknown"}(InvokerContainerTypeEnum||(exports.InvokerContainerTypeEnum=InvokerContainerTypeEnum={})),exports.InvokerPlatformTypeEnum=InvokerPlatformTypeEnum,function(n){n.Android="Android",n.IOS="IOS",n.Mac="Mac",n.Linux="Linux",n.Windows="Windows",n.Unknown="Unknown"}(InvokerPlatformTypeEnum||(exports.InvokerPlatformTypeEnum=InvokerPlatformTypeEnum={})),exports.InvokerAppTypeEnum=InvokerAppTypeEnum,function(n){n.Mobile="mobile",n.Desktop="desktop",n.MiniApp="mini",n.Web="web",n.Unknown="unknown"}(InvokerAppTypeEnum||(exports.InvokerAppTypeEnum=InvokerAppTypeEnum={})),exports.InvokerRuntimeTypeEnum=InvokerRuntimeTypeEnum,function(n){n.Module="module",n.Plugin="plugin",n.App="app",n.Unknown="Unknown"}(InvokerRuntimeTypeEnum||(exports.InvokerRuntimeTypeEnum=InvokerRuntimeTypeEnum={}));var UA_IDENTIFIER=(null===_global.global||void 0===_global.global?void 0:_global.global.navigator)&&(navigator.swuserAgent||navigator.userAgent)||"";function getUAIdentifier(){return(null===_global.global||void 0===_global.global?void 0:_global.global.navigator)&&(navigator.swuserAgent||navigator.userAgent)||""}exports.UA_IDENTIFIER=UA_IDENTIFIER;var REG_TAURUS_CLIENT_INFO=/TaurusApp\((\S*)\/(\S*)\)/,uaResult=UA_IDENTIFIER.match(REG_TAURUS_CLIENT_INFO),PlatformRegExpMap=((_PlatformRegExpMap={})[InvokerPlatformTypeEnum.Android]=/Android/i,_PlatformRegExpMap[InvokerPlatformTypeEnum.IOS]=/iPhone|iPad|iPod|iOS/i,_PlatformRegExpMap[InvokerPlatformTypeEnum.Windows]=/Windows NT|Windows/i,_PlatformRegExpMap[InvokerPlatformTypeEnum.Mac]=/Macintosh|Mac/i,_PlatformRegExpMap[InvokerPlatformTypeEnum.Linux]=/Linux/i,_PlatformRegExpMap[InvokerPlatformTypeEnum.Unknown]=/[a-zA-Z]/,_PlatformRegExpMap),getContainerType=function(){return"unknown"!==APP_NAME&&APP_VERSION?/DingTalk/g.test(UA_IDENTIFIER)?InvokerContainerTypeEnum.DingTalk:InvokerContainerTypeEnum.mPaaS:/(mPaaSClient)|(AlipayClient)/g.test(UA_IDENTIFIER)?InvokerContainerTypeEnum.Alipay:InvokerContainerTypeEnum.Unknown};function isUndef(n){return"undefined"===n}function isMiniApp(){return!isUndef(typeof my)&&null!==my&&!isUndef(typeof my.alert)}exports.getContainerType=getContainerType;var APP_NAME=uaResult?uaResult[1]:"unknown";exports.APP_NAME=APP_NAME;var APP_VERSION=uaResult?uaResult[2]:"unknown";exports.APP_VERSION=APP_VERSION;var getPlatformType=function(){var n=InvokerPlatformTypeEnum.Unknown;return Object.keys(PlatformRegExpMap).some((function(e){return!!PlatformRegExpMap[e].test(UA_IDENTIFIER)&&(n=e,!0)})),n};exports.getPlatformType=getPlatformType;var getAppType=function(){var n,e,o,p=InvokerAppTypeEnum.Unknown,r=getPlatformType();return r!==InvokerPlatformTypeEnum.Android&&r!==InvokerPlatformTypeEnum.IOS||"unknown"===APP_NAME||isMiniApp()?(null===(n=window)||void 0===n||null===(e=n.navigator)||void 0===e||null===(o=e.userAgent)||void 0===o?void 0:o.indexOf("dingtalk-win"))>=0?p=InvokerAppTypeEnum.Desktop:isUndef(typeof my)||null===my||isUndef(typeof my.alert)?/[http|https]/.test(location.protocol)?p=InvokerAppTypeEnum.Web:(console.warn("[ENV] 检测到页面在非钉钉客户端中打开,JSAPI 调用不会生效!"),p=InvokerAppTypeEnum.Unknown):p=InvokerAppTypeEnum.MiniApp:p=InvokerAppTypeEnum.Mobile,p};exports.getAppType=getAppType;
|