12 lines
339 B
TypeScript
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;
|
|
}
|