diff --git a/src-tauri/src/core/verge.rs b/src-tauri/src/core/verge.rs index b659dc0..7dcd0d5 100644 --- a/src-tauri/src/core/verge.rs +++ b/src-tauri/src/core/verge.rs @@ -63,7 +63,7 @@ pub struct VergeTheme { pub success_color: Option, pub font_family: Option, - pub font_face: Option, + pub css_injection: Option, } impl VergeConfig { diff --git a/src/components/layout/use-custom-theme.ts b/src/components/layout/use-custom-theme.ts index de936a9..89a79b5 100644 --- a/src/components/layout/use-custom-theme.ts +++ b/src/components/layout/use-custom-theme.ts @@ -40,12 +40,25 @@ export default function useCustomTheme() { }, }, typography: { + // todo fontFamily: setting.font_family - ? `"${setting.font_family}", ${dt.font_family}` + ? `${setting.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; setTimeout(() => { diff --git a/src/components/setting/setting-theme.tsx b/src/components/setting/setting-theme.tsx index 2dc3ec2..5fb6c2c 100644 --- a/src/components/setting/setting-theme.tsx +++ b/src/components/setting/setting-theme.tsx @@ -65,6 +65,7 @@ const SettingTheme = (props: Props) => { try { await patchVergeConfig({ theme_setting: theme }); mutate(); + onClose(); } catch (err: any) { onError?.(err); } @@ -186,12 +187,12 @@ const SettingTheme = (props: Props) => { - + diff --git a/src/services/types.ts b/src/services/types.ts index b098c0f..0d5bf3c 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -139,8 +139,8 @@ export namespace CmdType { error_color?: string; warning_color?: string; success_color?: string; - font_face?: string; font_family?: string; + css_injection?: string; }; }