Files
dukang/apps/h5-partner/src/lib/upload-lock.ts
T
2026-07-09 23:52:00 +08:00

12 lines
339 B
TypeScript

/** 串行化上传,避免微信 JSSDK 并发选图/读图导致卡死 */
let uploadChain: Promise<unknown> = Promise.resolve();
export function enqueueUpload<T>(task: () => Promise<T>): Promise<T> {
const next = uploadChain.then(task, task);
uploadChain = next.then(
() => undefined,
() => undefined,
);
return next;
}