feat: tranbox hover trigger

This commit is contained in:
Gabe Yuan
2024-04-16 12:47:55 +08:00
parent 148a4e97a6
commit ca84bdb227
6 changed files with 110 additions and 40 deletions

View File

@@ -366,7 +366,7 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
fullWidth
name="transTiming"
value={transTiming}
label={i18n("translate_timing")}
label={i18n("trigger_mode")}
disabled={disabled}
onChange={handleChange}
>

View File

@@ -3,7 +3,13 @@ import Stack from "@mui/material/Stack";
import TextField from "@mui/material/TextField";
import MenuItem from "@mui/material/MenuItem";
import { useI18n } from "../../hooks/I18n";
import { OPT_TRANS_ALL, OPT_LANGS_FROM, OPT_LANGS_TO } from "../../config";
import {
OPT_TRANS_ALL,
OPT_LANGS_FROM,
OPT_LANGS_TO,
OPT_TRANBOX_TRIGGER_CLICK,
OPT_TRANBOX_TRIGGER_ALL,
} from "../../config";
import ShortcutInput from "./ShortcutInput";
import FormControlLabel from "@mui/material/FormControlLabel";
import Switch from "@mui/material/Switch";
@@ -52,6 +58,7 @@ export default function Tranbox() {
hideTranBtn = false,
hideClickAway = false,
simpleStyle = false,
triggerMode = OPT_TRANBOX_TRIGGER_CLICK,
} = tranboxSetting;
return (
@@ -186,6 +193,21 @@ export default function Tranbox() {
<MenuItem value={true}>{i18n("enable")}</MenuItem>
</TextField>
<TextField
select
size="small"
name="triggerMode"
value={triggerMode}
label={i18n("trigger_mode")}
onChange={handleChange}
>
{OPT_TRANBOX_TRIGGER_ALL.map((item) => (
<MenuItem key={item} value={item}>
{i18n(`trigger_${item}`)}
</MenuItem>
))}
</TextField>
{!isExt && (
<ShortcutInput
value={tranboxShortcut}