clear fetch pool when click cancel

This commit is contained in:
Gabe Yuan
2023-08-11 16:48:09 +08:00
parent e5185150f8
commit 72785f2fca
5 changed files with 39 additions and 9 deletions

View File

@@ -4,6 +4,7 @@ import { taskPool } from "./pool";
import {
MSG_FETCH,
MSG_FETCH_LIMIT,
MSG_FETCH_CLEAR,
CACHE_NAME,
OPT_TRANS_MICROSOFT,
OPT_TRANS_OPENAI,
@@ -188,3 +189,17 @@ export const fetchUpdate = async (interval, limit) => {
fetchPool.update(interval, limit);
}
};
/**
* 清空任务池
*/
export const fetchClear = async () => {
if (isExt) {
const res = await sendMsg(MSG_FETCH_CLEAR);
if (res.error) {
throw new Error(res.error);
}
} else {
fetchPool.clear();
}
};