customize api

This commit is contained in:
Gabe Yuan
2023-09-06 14:57:02 +08:00
parent f772fa000c
commit c7c5866131
10 changed files with 232 additions and 231 deletions

View File

@@ -2,6 +2,7 @@ import { useEffect } from "react";
import { useState } from "react";
import { tryDetectLang } from "../libs";
import { apiTranslate } from "../apis";
import { DEFAULT_TRANS_APIS } from "../config";
/**
* 翻译hook
@@ -28,10 +29,10 @@ export function useTranslate(q, rule, setting) {
} else {
const [trText, isSame] = await apiTranslate({
translator,
q,
text: q,
fromLang,
toLang,
setting: setting[translator],
apiSetting: (setting.transApis || DEFAULT_TRANS_APIS)[translator],
});
setText(trText);
setSamelang(isSame);