fix(weixin-sdk): fix iOS scanQRCode false camera permission error

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-09 16:49:01 +08:00
parent d8c240c839
commit 3d3588babb
6 changed files with 141 additions and 32 deletions
+2 -3
View File
@@ -1,5 +1,5 @@
import { getRuntimePlatform } from './env';
import { ensureJssdkReady, normalizeJssdkPageUrl } from './jssdk';
import { ensureJssdkReady, normalizeJssdkPageUrl, getJssdkSignUrl } from './jssdk';
import type { WeixinSdkConfig } from './types';
export type ChooseWechatImageOptions = {
@@ -84,14 +84,13 @@ export async function chooseWechatImages(
const sourceType = options.sourceType ?? ['album', 'camera'];
if (platform === 'wechat-h5') {
const pageUrl = typeof window !== 'undefined' ? normalizeJssdkPageUrl(window.location.href) : '';
const pageUrl = typeof window !== 'undefined' ? getJssdkSignUrl() : '';
const sourceTypeKey = sourceType.join(',');
try {
await ensureJssdkReady({
apiBase: config.apiBase ?? '/api/v1',
clientApp: config.clientApp,
getAccessToken: config.getAccessToken,
url: pageUrl,
jsApiList: ['chooseImage', 'getLocalImgData'],
});
} catch (e) {