fix: hooks & injectjs

This commit is contained in:
Gabe
2025-10-30 00:19:13 +08:00
parent 5735fee36e
commit 172dce2867
14 changed files with 155 additions and 79 deletions

View File

@@ -38,7 +38,7 @@ import {
DEFAULT_BATCH_SIZE,
DEFAULT_BATCH_LENGTH,
DEFAULT_CONTEXT_SIZE,
OPT_ALL_TYPES,
OPT_ALL_TRANS_TYPES,
API_SPE_TYPES,
BUILTIN_STONES,
BUILTIN_PLACEHOLDERS,
@@ -54,7 +54,7 @@ function TestButton({ api }) {
const handleApiTest = async () => {
try {
setLoading(true);
const [text] = await apiTranslate({
const { trText } = await apiTranslate({
text: "hello world",
fromLang: "en",
toLang: "zh-CN",
@@ -62,7 +62,7 @@ function TestButton({ api }) {
useCache: false,
usePool: false,
});
if (!text) {
if (!trText) {
throw new Error("empty result");
}
alert.success(i18n("test_success"));
@@ -775,7 +775,7 @@ export default function Apis() {
const apiTypes = useMemo(
() =>
OPT_ALL_TYPES.map((type) => ({
OPT_ALL_TRANS_TYPES.map((type) => ({
type,
label: type,
})),

View File

@@ -108,7 +108,7 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
parentStyle = "",
grandStyle = "",
injectJs = "",
injectCss = "",
// injectCss = "",
apiSlug,
fromLang,
toLang,
@@ -695,7 +695,7 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
maxRows={10}
/> */}
<TextField
{/* <TextField
size="small"
label={i18n("inject_css")}
helperText={i18n("inject_css_helper")}
@@ -705,7 +705,7 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
onChange={handleChange}
maxRows={10}
multiline
/>
/> */}
<TextField
size="small"
label={i18n("inject_js")}

View File

@@ -38,7 +38,7 @@ export default function TranCont({
setTrText("");
setError("");
const [trText] = await apiTranslate({
const { trText } = await apiTranslate({
text,
fromLang,
toLang,