num of newline characters
This commit is contained in:
@@ -60,6 +60,10 @@ export const I18N = {
|
|||||||
zh: `最大翻译长度 (100-10000)`,
|
zh: `最大翻译长度 (100-10000)`,
|
||||||
en: `Max Translate Length (100-10000)`,
|
en: `Max Translate Length (100-10000)`,
|
||||||
},
|
},
|
||||||
|
num_of_newline_characters: {
|
||||||
|
zh: `换行字符数 (1-1000)`,
|
||||||
|
en: `Number of Newline Characters (1-1000)`,
|
||||||
|
},
|
||||||
translate_service: {
|
translate_service: {
|
||||||
zh: `翻译服务`,
|
zh: `翻译服务`,
|
||||||
en: `Translate Service`,
|
en: `Translate Service`,
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ export const DEFAULT_SUBRULES_LIST = [
|
|||||||
|
|
||||||
export const TRANS_MIN_LENGTH = 5; // 最短翻译长度
|
export const TRANS_MIN_LENGTH = 5; // 最短翻译长度
|
||||||
export const TRANS_MAX_LENGTH = 5000; // 最长翻译长度
|
export const TRANS_MAX_LENGTH = 5000; // 最长翻译长度
|
||||||
|
export const TRANS_NEWLINE_LENGTH = 40; // 换行字符数
|
||||||
|
|
||||||
export const DEFAULT_SETTING = {
|
export const DEFAULT_SETTING = {
|
||||||
darkMode: false, // 深色模式
|
darkMode: false, // 深色模式
|
||||||
@@ -175,6 +176,7 @@ export const DEFAULT_SETTING = {
|
|||||||
fetchInterval: DEFAULT_FETCH_INTERVAL, // 任务间隔时间
|
fetchInterval: DEFAULT_FETCH_INTERVAL, // 任务间隔时间
|
||||||
minLength: TRANS_MIN_LENGTH,
|
minLength: TRANS_MIN_LENGTH,
|
||||||
maxLength: TRANS_MAX_LENGTH,
|
maxLength: TRANS_MAX_LENGTH,
|
||||||
|
newlineLength: TRANS_NEWLINE_LENGTH,
|
||||||
clearCache: false, // 是否在浏览器下次启动时清除缓存
|
clearCache: false, // 是否在浏览器下次启动时清除缓存
|
||||||
injectRules: true, // 是否注入订阅规则
|
injectRules: true, // 是否注入订阅规则
|
||||||
subrulesList: DEFAULT_SUBRULES_LIST, // 订阅列表
|
subrulesList: DEFAULT_SUBRULES_LIST, // 订阅列表
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
DEFAULT_COLOR,
|
DEFAULT_COLOR,
|
||||||
EVENT_KISS,
|
EVENT_KISS,
|
||||||
MSG_TRANS_CURRULE,
|
MSG_TRANS_CURRULE,
|
||||||
|
TRANS_NEWLINE_LENGTH,
|
||||||
} from "../../config";
|
} from "../../config";
|
||||||
import { useTranslate } from "../../hooks/Translate";
|
import { useTranslate } from "../../hooks/Translate";
|
||||||
|
|
||||||
@@ -19,6 +20,8 @@ export default function Content({ q, translator }) {
|
|||||||
const { text, sameLang, loading } = useTranslate(q, rule, translator.setting);
|
const { text, sameLang, loading } = useTranslate(q, rule, translator.setting);
|
||||||
const { textStyle, bgColor } = rule;
|
const { textStyle, bgColor } = rule;
|
||||||
|
|
||||||
|
const { newlineLength = TRANS_NEWLINE_LENGTH } = translator.setting;
|
||||||
|
|
||||||
const handleMouseEnter = () => {
|
const handleMouseEnter = () => {
|
||||||
setHover(true);
|
setHover(true);
|
||||||
};
|
};
|
||||||
@@ -87,7 +90,7 @@ export default function Content({ q, translator }) {
|
|||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{q.length > 40 ? <br /> : " "}
|
{q.length > newlineLength ? <br /> : " "}
|
||||||
<LoadingIcon />
|
<LoadingIcon />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -96,7 +99,7 @@ export default function Content({ q, translator }) {
|
|||||||
if (text && !sameLang) {
|
if (text && !sameLang) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{q.length > 40 ? <br /> : " "}
|
{q.length > newlineLength ? <br /> : " "}
|
||||||
<span
|
<span
|
||||||
style={style}
|
style={style}
|
||||||
onMouseEnter={handleMouseEnter}
|
onMouseEnter={handleMouseEnter}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import Link from "@mui/material/Link";
|
|||||||
import { useSetting } from "../../hooks/Setting";
|
import { useSetting } from "../../hooks/Setting";
|
||||||
import { limitNumber } from "../../libs/utils";
|
import { limitNumber } from "../../libs/utils";
|
||||||
import { useI18n } from "../../hooks/I18n";
|
import { useI18n } from "../../hooks/I18n";
|
||||||
import { UI_LANGS, URL_KISS_WORKER } from "../../config";
|
import { UI_LANGS, URL_KISS_WORKER, TRANS_NEWLINE_LENGTH } from "../../config";
|
||||||
|
|
||||||
export default function Settings() {
|
export default function Settings() {
|
||||||
const i18n = useI18n();
|
const i18n = useI18n();
|
||||||
@@ -31,6 +31,9 @@ export default function Settings() {
|
|||||||
case "maxLength":
|
case "maxLength":
|
||||||
value = limitNumber(value, 100, 10000);
|
value = limitNumber(value, 100, 10000);
|
||||||
break;
|
break;
|
||||||
|
case "newlineLength":
|
||||||
|
value = limitNumber(value, 1, 1000);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
updateSetting({
|
updateSetting({
|
||||||
@@ -50,6 +53,7 @@ export default function Settings() {
|
|||||||
openaiModel,
|
openaiModel,
|
||||||
openaiPrompt,
|
openaiPrompt,
|
||||||
clearCache,
|
clearCache,
|
||||||
|
newlineLength = TRANS_NEWLINE_LENGTH,
|
||||||
} = setting;
|
} = setting;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -107,6 +111,15 @@ export default function Settings() {
|
|||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<TextField
|
||||||
|
size="small"
|
||||||
|
label={i18n("num_of_newline_characters")}
|
||||||
|
type="number"
|
||||||
|
name="newlineLength"
|
||||||
|
value={newlineLength}
|
||||||
|
onChange={handleChange}
|
||||||
|
/>
|
||||||
|
|
||||||
<FormControl size="small">
|
<FormControl size="small">
|
||||||
<InputLabel>{i18n("clear_cache")}</InputLabel>
|
<InputLabel>{i18n("clear_cache")}</InputLabel>
|
||||||
<Select
|
<Select
|
||||||
|
|||||||
Reference in New Issue
Block a user