feat(mini): v4.0.8 客服卡片主包落地、定位误报修复,合伙人微信内预览保存海报

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-01 15:23:52 +08:00
parent cdc4b82931
commit 283e6651aa
25 changed files with 291 additions and 93 deletions
+3
View File
@@ -25,6 +25,7 @@ export { scanQrCode } from './scan';
export { invokeWechatPay } from './pay';
export { chooseWechatImages, canUseWechatChooseImage, formatChooseImageFailMessage } from './chooseImage';
export type { ChooseWechatImageOptions } from './chooseImage';
export { previewWechatImage, isHttpImageUrl } from './previewImage';
export {
setWechatShareData,
canUseWechatShare,
@@ -53,6 +54,7 @@ import { getWechatLocation, getWechatLocationDetailed } from './location';
import { scanQrCode } from './scan';
import { invokeWechatPay } from './pay';
import { chooseWechatImages } from './chooseImage';
import { previewWechatImage } from './previewImage';
import { setWechatShareData, shareViaWechatSdk } from './share';
import {
wechatLogin,
@@ -76,6 +78,7 @@ export function createWeixinSdk(config: WeixinSdkConfig) {
scanQrCode: (options?: Parameters<typeof scanQrCode>[1]) => scanQrCode(config, options),
chooseImages: (options?: Parameters<typeof chooseWechatImages>[1]) =>
chooseWechatImages(config, options),
previewImage: (url: string) => previewWechatImage(config, url),
pay: (prepay: Parameters<typeof invokeWechatPay>[0]) =>
invokeWechatPay(prepay, {
apiBase: config.apiBase ?? '/api/v1',
+33
View File
@@ -0,0 +1,33 @@
import { ensureJssdkReady } from './jssdk';
import type { WeixinSdkConfig } from './types';
export function isHttpImageUrl(url?: string | null): url is string {
return !!url && /^https?:\/\//i.test(url.trim());
}
/** 微信内预览图片,便于长按保存到相册(须是可公网访问的 http(s) 地址) */
export async function previewWechatImage(config: WeixinSdkConfig, url: string): Promise<void> {
const href = url.trim();
if (!isHttpImageUrl(href)) {
throw new Error('图片地址无效');
}
await ensureJssdkReady({
apiBase: config.apiBase ?? '/api/v1',
clientApp: config.clientApp,
getAccessToken: config.getAccessToken,
});
if (!window.wx?.previewImage) {
throw new Error('微信预览图片不可用');
}
await new Promise<void>((resolve, reject) => {
window.wx!.previewImage!({
current: href,
urls: [href],
success: () => resolve(),
fail: (res) => reject(new Error(res?.errMsg || '预览失败')),
});
});
}
+7
View File
@@ -58,6 +58,12 @@ export type WxApi = {
success?: (res: { localData: string }) => void;
fail?: (res: { errMsg: string }) => void;
}) => void;
previewImage: (options: {
current: string;
urls: string[];
success?: () => void;
fail?: (res: { errMsg: string }) => void;
}) => void;
updateAppMessageShareData: (options: {
title: string;
desc: string;
@@ -121,6 +127,7 @@ export const DEFAULT_JS_API_LIST = [
'chooseWXPay',
'chooseImage',
'getLocalImgData',
'previewImage',
'updateAppMessageShareData',
'updateTimelineShareData',
'onMenuShareAppMessage',