diff --git a/packages/common/utils.ts b/packages/common/utils.ts index 4b5f14c8..ef06a9c8 100644 --- a/packages/common/utils.ts +++ b/packages/common/utils.ts @@ -115,3 +115,6 @@ export function getCurrentPage() { } export const isPC = ['mac', 'windows'].includes(getSystemInfoSync().platform); + +// 是否企业微信 +export const isWxWork = getSystemInfoSync().environment === 'wxwork'; diff --git a/packages/common/version.ts b/packages/common/version.ts index e8ee1868..d2c46f98 100644 --- a/packages/common/version.ts +++ b/packages/common/version.ts @@ -1,10 +1,17 @@ -let systemInfo: WechatMiniprogram.SystemInfo; +interface WxWorkSystemInfo extends WechatMiniprogram.SystemInfo { + environment?: 'wxwork'; +} + +interface SystemInfo extends WxWorkSystemInfo, WechatMiniprogram.SystemInfo {} + +let systemInfo: SystemInfo; + export function getSystemInfoSync() { if (systemInfo == null) { systemInfo = wx.getSystemInfoSync(); } - return systemInfo; + return systemInfo as SystemInfo; } function compareVersion(v1, v2) { diff --git a/packages/uploader/utils.ts b/packages/uploader/utils.ts index eec56a5a..1a937f18 100644 --- a/packages/uploader/utils.ts +++ b/packages/uploader/utils.ts @@ -1,4 +1,4 @@ -import { pickExclude, isPC } from '../common/utils'; +import { pickExclude, isPC, isWxWork } from '../common/utils'; import { isImageUrl, isVideoUrl } from '../common/validator'; export interface File { @@ -103,7 +103,7 @@ export function chooseFile({ return new Promise((resolve, reject) => { switch (accept) { case 'image': - if (isPC) { + if (isPC || isWxWork) { wx.chooseImage({ count: multiple ? Math.min(maxCount, 9) : 1, sourceType: capture,