optimize fetchpool

This commit is contained in:
Gabe Yuan
2023-08-10 11:55:40 +08:00
parent 1c240d6edd
commit 69b5c4ff22
8 changed files with 104 additions and 71 deletions

View File

@@ -1,7 +1,7 @@
import { useEffect } from "react";
import { useState } from "react";
import { transPool } from "../libs/pool";
import { detectLang } from "../libs";
import { apiTranslate } from "../apis";
/**
* 翻译hook
@@ -25,7 +25,7 @@ export function useTranslate(q, rule) {
if (toLang.includes(deLang)) {
setSamelang(true);
} else {
const [trText, isSame] = await transPool.push({
const [trText, isSame] = await apiTranslate({
translator,
q,
fromLang,