This commit is contained in:
owenchen committed 2026-10-20 21:51:06 +08:00
1 parent 6417562c4f
commit f1e6e116c3
31 files changed
+2065 -309

No files matched your search

+8 -39
View File
@@ -7,6 +7,7 @@ import {
bearerAuth,
extractBusinessError,
} from "@/common/http.interceptor";
import { copyIntoAppUploadDir } from "@/utils/appUploadFile";
/**
* 上传队列 store:任务状态的唯一持有者,传输列表页只是它的视图。
@@ -80,47 +81,15 @@ function resolveChunkSize(): number {
return (intranet ? 3 : 1) * 1024 * 1024;
}
// #ifdef APP-PLUS
/**
* App 侧 UploadTask 的 multipart filename 取 filePath 的 basename,无法直接满后端
* uid-序号-总数.ext 协议(同 H5 踩过的 IndexOutOfRange),先把文件复制成
* _doc/uploads/uid-1-1.ext 再传;真机验证前不引入分片循环(读不了本地字节切片)。
* 项目 types 未含 plus 声明,本地宽松兜底(仅 App 运行时真实存在)。
*/
// eslint-disable-next-line ts/no-explicit-any
declare const plus: any;
// #endif
function prepareAppFilePath(item: UploadItem): Promise<string> {
// #ifdef APP-PLUS
const chunkName = `uni-${Date.now()}-1-1${extOf(item.name)}`;
return new Promise((resolve, reject) => {
plus.io.resolveLocalFileSystemURL(
"_doc/",
(root: any) => {
root.getDirectory(
"uploads",
{ create: true },
(dir: any) => {
plus.io.resolveLocalFileSystemURL(
item.filePath,
(entry: any) => {
entry.copyTo(
dir,
chunkName,
(moved: any) => resolve(moved.toLocalURL()),
reject,
);
},
reject,
);
},
reject,
);
},
reject,
);
});
// App 侧 UploadTask 的 multipart filename 取 filePath 的 basename,无法直接满后端
// uid-序号-总数.ext 协议(同 H5 踩过的 IndexOutOfRange),先复制成协议名再传;
// 真机验证前不引入分片循环(读不了本地字节切片)
return copyIntoAppUploadDir(
item.filePath,
`uni-${Date.now()}-1-1${extOf(item.name)}`,
);
// #endif
// #ifndef APP-PLUS
return Promise.resolve(item.filePath);