feat: baidu dict can be disabled
This commit is contained in:
@@ -930,4 +930,8 @@ export const I18N = {
|
||||
zh: `翻译移除时运行,入参为: 翻译节点。`,
|
||||
en: `Run when translation is removed, the input parameters are: translation node.`,
|
||||
},
|
||||
english_dict: {
|
||||
zh: `英文词典`,
|
||||
en: `English Dictionary`,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -102,6 +102,8 @@ export const URL_NIUTRANS_REG =
|
||||
export const DEFAULT_USER_AGENT =
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36";
|
||||
|
||||
export const OPT_DICT_BAIDU = "Baidu";
|
||||
|
||||
export const OPT_TRANS_GOOGLE = "Google";
|
||||
export const OPT_TRANS_MICROSOFT = "Microsoft";
|
||||
export const OPT_TRANS_DEEPL = "DeepL";
|
||||
@@ -487,6 +489,7 @@ export const DEFAULT_TRANBOX_SETTING = {
|
||||
followSelection: false, // 翻译框是否跟随选中文本
|
||||
triggerMode: OPT_TRANBOX_TRIGGER_CLICK, // 触发翻译方式
|
||||
extStyles: "", // 附加样式
|
||||
enDict: OPT_DICT_BAIDU, // 英文词典
|
||||
};
|
||||
|
||||
// 订阅列表
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
OPT_LANGS_TO,
|
||||
OPT_TRANBOX_TRIGGER_CLICK,
|
||||
OPT_TRANBOX_TRIGGER_ALL,
|
||||
OPT_DICT_BAIDU,
|
||||
} from "../../config";
|
||||
import ShortcutInput from "./ShortcutInput";
|
||||
import FormControlLabel from "@mui/material/FormControlLabel";
|
||||
@@ -63,6 +64,7 @@ export default function Tranbox() {
|
||||
followSelection = false,
|
||||
triggerMode = OPT_TRANBOX_TRIGGER_CLICK,
|
||||
extStyles = "",
|
||||
enDict = OPT_DICT_BAIDU,
|
||||
} = tranboxSetting;
|
||||
|
||||
return (
|
||||
@@ -143,6 +145,18 @@ export default function Tranbox() {
|
||||
))}
|
||||
</TextField>
|
||||
|
||||
<TextField
|
||||
select
|
||||
size="small"
|
||||
name="enDict"
|
||||
value={enDict}
|
||||
label={i18n("english_dict")}
|
||||
onChange={handleChange}
|
||||
>
|
||||
<MenuItem value={"-"}>{i18n("disable")}</MenuItem>
|
||||
<MenuItem value={OPT_DICT_BAIDU}>{OPT_DICT_BAIDU}</MenuItem>
|
||||
</TextField>
|
||||
|
||||
<TextField
|
||||
size="small"
|
||||
label={i18n("tranbtn_offset_x")}
|
||||
|
||||
@@ -108,6 +108,7 @@ function TranForm({
|
||||
transApis,
|
||||
simpleStyle,
|
||||
langDetector,
|
||||
enDict,
|
||||
}) {
|
||||
const i18n = useI18n();
|
||||
|
||||
@@ -240,7 +241,10 @@ function TranForm({
|
||||
</>
|
||||
)}
|
||||
|
||||
{(!simpleStyle || !isValidWord(text) || !toLang.startsWith("zh")) && (
|
||||
{(!simpleStyle ||
|
||||
!isValidWord(text) ||
|
||||
!toLang.startsWith("zh") ||
|
||||
enDict === "-") && (
|
||||
<TranCont
|
||||
text={text}
|
||||
translator={translator}
|
||||
@@ -253,8 +257,12 @@ function TranForm({
|
||||
/>
|
||||
)}
|
||||
|
||||
<DictCont text={text} />
|
||||
<SugCont text={text} />
|
||||
{enDict !== "-" && (
|
||||
<>
|
||||
<DictCont text={text} />
|
||||
<SugCont text={text} />
|
||||
</>
|
||||
)}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
@@ -277,6 +285,7 @@ export default function TranBox({
|
||||
setFollowSelection,
|
||||
extStyles,
|
||||
langDetector,
|
||||
enDict,
|
||||
}) {
|
||||
const [mouseHover, setMouseHover] = useState(false);
|
||||
return (
|
||||
@@ -310,6 +319,7 @@ export default function TranBox({
|
||||
transApis={transApis}
|
||||
simpleStyle={simpleStyle}
|
||||
langDetector={langDetector}
|
||||
enDict={enDict}
|
||||
/>
|
||||
</DraggableResizable>
|
||||
</ThemeProvider>
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
OPT_TRANBOX_TRIGGER_CLICK,
|
||||
OPT_TRANBOX_TRIGGER_HOVER,
|
||||
OPT_TRANBOX_TRIGGER_SELECT,
|
||||
OPT_DICT_BAIDU,
|
||||
} from "../../config";
|
||||
import { isMobile } from "../../libs/mobile";
|
||||
import { kissLog } from "../../libs/log";
|
||||
@@ -34,6 +35,7 @@ export default function Slection({
|
||||
btnOffsetY,
|
||||
boxOffsetX = 0,
|
||||
boxOffsetY = 10,
|
||||
enDict = OPT_DICT_BAIDU,
|
||||
} = tranboxSetting;
|
||||
|
||||
const boxWidth =
|
||||
@@ -236,6 +238,7 @@ export default function Slection({
|
||||
setFollowSelection={setFollowSelection}
|
||||
extStyles={extStyles}
|
||||
langDetector={langDetector}
|
||||
enDict={enDict}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user