fix: 用来标识是否为上传 这样在watch内部不需要请求api

This commit is contained in:
dap 2025-04-30 14:13:35 +08:00
parent 89dd4b8131
commit 9f978cc9b0

View File

@ -160,6 +160,8 @@ export function useUpload(
return undefined;
}
// 用来标识是否为上传 这样在watch内部不需要请求api
let isUpload = false;
function handleChange(info: UploadChangeParam) {
/**
*
@ -199,7 +201,8 @@ export function useUpload(
currentFile.fileName = transformFilename(cb);
currentFile.name = transformFilename(cb);
currentFile.thumbUrl = transformThumbUrl(cb);
// 标记为上传 watch根据值做处理
isUpload = true;
// ossID添加 单个文件会被当做string
if (props.maxCount === 1) {
bindValue.value = ossId;
@ -321,6 +324,14 @@ export function useUpload(
if (value.length === 0) {
return;
}
// 上传完毕 不需要调用获取信息接口
if (isUpload) {
// 清理 使下一次状态可用
isUpload = false;
return;
}
const resp = await ossInfo(value);
function transformFile(info: OssFile) {
const cb = { type: 'info', response: info } as const;