Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Upload): fix image upload in wxwork #5581

Merged
merged 4 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,6 @@ export function getCurrentPage<T>() {
}

export const isPC = ['mac', 'windows'].includes(getSystemInfoSync().platform);

// 是否企业微信
export const isWxWork = getSystemInfoSync().environment === 'wxwork';
11 changes: 9 additions & 2 deletions packages/common/version.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions packages/uploader/utils.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -103,7 +103,7 @@ export function chooseFile({
return new Promise<File | File[]>((resolve, reject) => {
switch (accept) {
case 'image':
if (isPC) {
if (isPC || isWxWork) {
wx.chooseImage({
count: multiple ? Math.min(maxCount, 9) : 1,
sourceType: capture,
Expand Down