fix;提交代码子账号
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useId, 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,
|
||||
@@ -87,13 +87,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 : '上传失败');
|
||||
@@ -111,7 +110,6 @@ export default function OssUploadField({
|
||||
} catch (e) {
|
||||
const text = e instanceof Error ? e.message : '微信授权失败';
|
||||
setError(text);
|
||||
toastError(text);
|
||||
setAuthorizing(false);
|
||||
}
|
||||
}
|
||||
@@ -121,15 +119,23 @@ export default function OssUploadField({
|
||||
}
|
||||
|
||||
async function pickWechatImage() {
|
||||
const files = await weixinSdk.chooseImages({
|
||||
count: 1,
|
||||
sourceType: ['album', 'camera'],
|
||||
});
|
||||
if (files?.[0]) {
|
||||
await uploadSelectedFile(files[0]);
|
||||
return;
|
||||
setUploading(true);
|
||||
setError('');
|
||||
try {
|
||||
await enqueueUpload(async () => {
|
||||
const files = await weixinSdk.chooseImages({
|
||||
count: 1,
|
||||
sourceType: ['album', 'camera'],
|
||||
});
|
||||
if (!files?.[0]) {
|
||||
throw new Error('未能获取图片,请重试');
|
||||
}
|
||||
const result = await uploadFileToOss(files[0], { bizType, mediaType });
|
||||
onChange?.(result.url);
|
||||
});
|
||||
} finally {
|
||||
setUploading(false);
|
||||
}
|
||||
throw new Error('未能获取图片,请重试');
|
||||
}
|
||||
|
||||
async function pickFile() {
|
||||
@@ -139,7 +145,6 @@ export default function OssUploadField({
|
||||
if (useWechatPicker && needsAuth) {
|
||||
const text = '请先完成微信授权后再上传照片';
|
||||
setError(text);
|
||||
toastError(text);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user