From ff4b1f9278ffa5ff31a1aee278bf2404c3f190ba Mon Sep 17 00:00:00 2001 From: h_mo <596417202@qq.com> Date: Sat, 20 May 2023 17:47:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9C=A8=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E4=B8=AD=E8=8E=B7=E5=8F=96=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BD=BF=E7=94=A8=20process.env['UNI=5FPLATF?= =?UTF-8?q?ORM']=20=E6=97=A0=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/enums/platformEnum.ts | 89 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 2 deletions(-) diff --git a/src/enums/platformEnum.ts b/src/enums/platformEnum.ts index 3362faf..b54b54a 100644 --- a/src/enums/platformEnum.ts +++ b/src/enums/platformEnum.ts @@ -23,5 +23,90 @@ export enum PLATFORMS { QUICKAPP_WEBVIEW_HUAWEI = 'QUICKAPP-WEBVIEW-HUAWEI' /* 快应用华为 */, } -/* 当前平台 */ -export const CURRENT_PLATFORM = process.env['UNI_PLATFORM']; +/** + * 平台环境 + * @constructor + */ +function PLATFORM_ENV() { + let platform = PLATFORMS.DEFAULT; + + /* #ifdef VUE3 */ + platform = PLATFORMS.VUE3; + /* #endif */ + + /* #ifdef APP-PLUS */ + platform = PLATFORMS.APP_PLUS; + /* #endif */ + + /* #ifdef APP-PLUS-NVUE */ + platform = PLATFORMS.APP_PLUS_NVUE; + /* #endif */ + + /* #ifdef APP-NVUE */ + platform = PLATFORMS.APP_NVUE; + /* #endif */ + + /* #ifdef H5 */ + platform = PLATFORMS.H5; + /* #endif */ + + /* #ifdef MP */ + platform = PLATFORMS.MP; + /* #endif */ + + /* #ifdef MP-WEIXIN */ + platform = PLATFORMS.MP_WEIXIN; + /* #endif */ + + /* #ifdef MP-ALIPAY */ + platform = PLATFORMS.MP_ALIPAY; + /* #endif */ + + /* #ifdef MP_BAIDU */ + platform = PLATFORMS.MP_BAIDU; + /* #endif */ + + /* #ifdef MP-TOUTIAO */ + platform = PLATFORMS.MP_TOUTIAO; + /* #endif */ + + /* #ifdef MP-LARK */ + platform = PLATFORMS.MP_LARK; + /* #endif */ + + /* #ifdef MP-QQ */ + platform = PLATFORMS.MP_QQ; + /* #endif */ + + /* #ifdef MP-KUAISHOU */ + platform = PLATFORMS.MP_KUAISHOU; + /* #endif */ + + /* #ifdef MP-JD */ + platform = PLATFORMS.MP_JD; + /* #endif */ + + /* #ifdef MP-360 */ + platform = PLATFORMS.MP_360; + /* #endif */ + + /* #ifdef QUICKAPP-WEBVIEW */ + platform = PLATFORMS.QUICKAPP_WEBVIEW; + /* #endif */ + + /* #ifdef QUICKAPP-WEBVIEW-UNION */ + platform = PLATFORMS.QUICKAPP_WEBVIEW_UNION; + /* #endif */ + + /* #ifdef QUICKAPP-WEBVIEW-HUAWEI */ + platform = PLATFORMS.QUICKAPP_WEBVIEW_HUAWEI; + /* #endif */ + + return platform; +} + +/** + * 当前平台 + * 在微信小程序中 "process.env['UNI_PLATFORM']" 无效 + */ +export const CURRENT_PLATFORM = PLATFORM_ENV();