fix(h5-partner): resolve merge conflicts for auth and sub-accounts

Merge partner session model (AuthGate, ensureSession, WeChat OAuth in Context) with sub-account routing, admin partner-account tree CRUD, upload lock, and partner staff flows.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-10 11:24:48 +08:00
20 changed files with 378 additions and 264 deletions
@@ -1,6 +1,6 @@
import { useEffect, useRef, useState } from 'react';
import { uploadFileToOss, type OssMediaType } from '../lib/upload';
import { toastError } from '../lib/toast';
import { enqueueUpload } from '../lib/upload-lock';
import {
authorizePartnerWechat,
fetchClientConfig,
@@ -92,13 +92,12 @@ export default function OssUploadField({
if (file.size > DEFAULT_MAX_MB * 1024 * 1024) {
const text = `文件不能超过 ${DEFAULT_MAX_MB}MB`;
setError(text);
toastError(text);
return;
}
setUploading(true);
setError('');
try {
const result = await uploadFileToOss(file, { bizType, mediaType });
const result = await enqueueUpload(() => uploadFileToOss(file, { bizType, mediaType }));
onChange?.(result.url);
} catch (e) {
setError(e instanceof Error ? e.message : '上传失败');
@@ -116,7 +115,6 @@ export default function OssUploadField({
} catch (e) {
const text = e instanceof Error ? e.message : '微信授权失败';
setError(text);
toastError(text);
setAuthorizing(false);
}
}
@@ -126,16 +124,23 @@ export default function OssUploadField({
}
async function pickWechatImage() {
await weixinSdk.init();
const files = await weixinSdk.chooseImages({
count: 1,
sourceType: ['album', 'camera'],
});
if (files?.[0]) {
await uploadSelectedFile(files[0]);
return;
setUploading(true);
setError('');
try {
await weixinSdk.init();
await enqueueUpload(async () => {
const files = await weixinSdk.chooseImages({
count: 1,
sourceType: ['album', 'camera'],
});
if (!files?.[0]) {
throw new Error('未能获取图片,请重试');
}
await uploadSelectedFile(files[0]);
});
} finally {
setUploading(false);
}
throw new Error('未能获取图片,请重试');
}
async function pickFile() {
@@ -145,7 +150,6 @@ export default function OssUploadField({
if (useWechatPicker && needsAuth) {
const text = '请先完成微信授权后再上传照片';
setError(text);
toastError(text);
return;
}