feat: add default styles example
This commit is contained in:
@@ -1588,4 +1588,9 @@ export const I18N = {
|
||||
en: `2. The plug-in has built-in basic segmentation logic. If it is not ideal, you can enable AI intelligent segmentation. However, you need to consider the video length and the processing power of the AI interface. The waiting time may be very long or even fail.`,
|
||||
zh_TW: `2.插件內建基礎斷句邏輯,如不理想,可以啟用AI智能斷句,但需考慮視訊長度與AI介面的處理能力,可能等待的時間會很長,甚至失敗。`,
|
||||
},
|
||||
default_styles_example: {
|
||||
zh: `默认样式参考:`,
|
||||
en: `Default styles reference:`,
|
||||
zh_TW: `認樣式參考:`,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -33,10 +33,10 @@ const genLineStyle = (style, color) => `
|
||||
}
|
||||
`;
|
||||
|
||||
export const genStyles = ({
|
||||
const genStyles = ({
|
||||
textDiyStyle = DEFAULT_DIY_STYLE,
|
||||
bgColor = DEFAULT_COLOR,
|
||||
}) => ({
|
||||
} = {}) => ({
|
||||
// 无样式
|
||||
[OPT_STYLE_NONE]: ``,
|
||||
// 下划线
|
||||
@@ -82,7 +82,9 @@ export const genStyles = ({
|
||||
}
|
||||
`,
|
||||
// 自定义
|
||||
[OPT_STYLE_DIY]: textDiyStyle,
|
||||
[OPT_STYLE_DIY]: `
|
||||
${textDiyStyle}
|
||||
`,
|
||||
});
|
||||
|
||||
export const genTextClass = ({ textDiyStyle, bgColor = DEFAULT_COLOR }) => {
|
||||
@@ -103,3 +105,5 @@ export const genTextClass = ({ textDiyStyle, bgColor = DEFAULT_COLOR }) => {
|
||||
});
|
||||
return [textClass, textStyles];
|
||||
};
|
||||
|
||||
export const defaultStyles = genStyles();
|
||||
|
||||
@@ -63,6 +63,7 @@ import { kissLog } from "../../libs/log";
|
||||
import { useApiList } from "../../hooks/Api";
|
||||
import ShowMoreButton from "./ShowMoreButton";
|
||||
import { useConfirm } from "../../hooks/Confirm";
|
||||
import { defaultStyles } from "../../libs/style";
|
||||
|
||||
const calculateInitialValues = (rule) => {
|
||||
const base = rule?.pattern === "*" ? GLOBLA_RULE : DEFAULT_RULE;
|
||||
@@ -128,6 +129,13 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
|
||||
return JSON.stringify(initialFormValues) !== JSON.stringify(formValues);
|
||||
}, [initialFormValues, formValues]);
|
||||
|
||||
const stylesExample = useMemo(() => {
|
||||
return Object.entries(defaultStyles)
|
||||
.filter(([_, v]) => v)
|
||||
.map(([k, v]) => `${i18n(k)}:${v}`)
|
||||
.join("\n");
|
||||
}, [i18n]);
|
||||
|
||||
const hasSamePattern = (str) => {
|
||||
for (const item of rules.list) {
|
||||
if (item.pattern === str && rule?.pattern !== str) {
|
||||
@@ -484,7 +492,27 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
|
||||
<TextField
|
||||
size="small"
|
||||
label={i18n("diy_style")}
|
||||
helperText={i18n("diy_style_helper")}
|
||||
FormHelperTextProps={{
|
||||
component: "div",
|
||||
}}
|
||||
helperText={
|
||||
<Box>
|
||||
<Box component="div">{i18n("default_styles_example")}</Box>
|
||||
<Box
|
||||
component="pre"
|
||||
sx={{
|
||||
overflowX: "auto",
|
||||
height: 200,
|
||||
resize: "vertical",
|
||||
minHeight: 100,
|
||||
margin: 0,
|
||||
// border: "1px solid #ccc",
|
||||
}}
|
||||
>
|
||||
{stylesExample}
|
||||
</Box>
|
||||
</Box>
|
||||
}
|
||||
name="textDiyStyle"
|
||||
value={textDiyStyle}
|
||||
disabled={disabled}
|
||||
|
||||
Reference in New Issue
Block a user