feat: support css injection
This commit is contained in:
parent
eab671d102
commit
0290d9ddfc
@ -63,7 +63,7 @@ pub struct VergeTheme {
|
|||||||
pub success_color: Option<String>,
|
pub success_color: Option<String>,
|
||||||
|
|
||||||
pub font_family: Option<String>,
|
pub font_family: Option<String>,
|
||||||
pub font_face: Option<String>,
|
pub css_injection: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VergeConfig {
|
impl VergeConfig {
|
||||||
|
@ -40,12 +40,25 @@ export default function useCustomTheme() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
typography: {
|
typography: {
|
||||||
|
// todo
|
||||||
fontFamily: setting.font_family
|
fontFamily: setting.font_family
|
||||||
? `"${setting.font_family}", ${dt.font_family}`
|
? `${setting.font_family}, ${dt.font_family}`
|
||||||
: dt.font_family,
|
: dt.font_family,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// inject css
|
||||||
|
let style = document.querySelector("style#verge-theme");
|
||||||
|
if (!style) {
|
||||||
|
style = document.createElement("style");
|
||||||
|
style.id = "verge-theme";
|
||||||
|
document.head.appendChild(style!);
|
||||||
|
}
|
||||||
|
if (style) {
|
||||||
|
style.innerHTML = setting.css_injection || "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// update svg icon
|
||||||
const { palette } = theme;
|
const { palette } = theme;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -65,6 +65,7 @@ const SettingTheme = (props: Props) => {
|
|||||||
try {
|
try {
|
||||||
await patchVergeConfig({ theme_setting: theme });
|
await patchVergeConfig({ theme_setting: theme });
|
||||||
mutate();
|
mutate();
|
||||||
|
onClose();
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
onError?.(err);
|
onError?.(err);
|
||||||
}
|
}
|
||||||
@ -186,12 +187,12 @@ const SettingTheme = (props: Props) => {
|
|||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
<Item>
|
<Item>
|
||||||
<ListItemText primary="Font Face" />
|
<ListItemText primary="CSS Injection" />
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
{...textProps}
|
{...textProps}
|
||||||
value={theme.font_face ?? ""}
|
value={theme.css_injection ?? ""}
|
||||||
onChange={handleChange("font_face")}
|
onChange={handleChange("css_injection")}
|
||||||
/>
|
/>
|
||||||
</Item>
|
</Item>
|
||||||
</List>
|
</List>
|
||||||
|
@ -139,8 +139,8 @@ export namespace CmdType {
|
|||||||
error_color?: string;
|
error_color?: string;
|
||||||
warning_color?: string;
|
warning_color?: string;
|
||||||
success_color?: string;
|
success_color?: string;
|
||||||
font_face?: string;
|
|
||||||
font_family?: string;
|
font_family?: string;
|
||||||
|
css_injection?: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user