diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index bbf899a..143642a 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -54,6 +54,7 @@ dependencies = [ "tauri", "tauri-build", "tauri-plugin-shadows", + "tauri-plugin-vibrancy", "tokio", "warp", "winreg 0.10.1", @@ -3369,6 +3370,17 @@ dependencies = [ "windows 0.29.0", ] +[[package]] +name = "tauri-plugin-vibrancy" +version = "0.0.0" +source = "git+https://github.com/tauri-apps/tauri-plugin-vibrancy#b4fceab0d4a6d024f1b9916c126f10f513101128" +dependencies = [ + "cocoa", + "objc", + "tauri", + "windows 0.29.0", +] + [[package]] name = "tauri-runtime" version = "0.2.1" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 5df4a0a..70d52e9 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -22,6 +22,7 @@ serde = { version = "1.0", features = ["derive"] } # tauri = { git = "https://github.com/tauri-apps/tauri", rev = "5e0d59ec", features = ["api-all", "system-tray"] } tauri = { git = "https://github.com/tauri-apps/tauri", branch = "next", features = ["api-all", "system-tray", "updater"] } tauri-plugin-shadows = { git = "https://github.com/tauri-apps/tauri-plugin-shadows", features = ["tauri-impl"] } +tauri-plugin-vibrancy = { git = "https://github.com/tauri-apps/tauri-plugin-vibrancy", features = ["tauri-impl"] } reqwest = { version = "0.11", features = ["json"] } tokio = { version = "1", features = ["full"] } diff --git a/src-tauri/src/core/verge.rs b/src-tauri/src/core/verge.rs index 9a7ecea..3a1077a 100644 --- a/src-tauri/src/core/verge.rs +++ b/src-tauri/src/core/verge.rs @@ -9,6 +9,10 @@ pub struct VergeConfig { /// `light` or `dark` pub theme_mode: Option, + /// enable blur mode + /// maybe be able to set the alpha + pub theme_blur: Option, + /// can the app auto startup pub enable_self_startup: Option, @@ -157,6 +161,9 @@ impl Verge { if patch.theme_mode.is_some() { self.config.theme_mode = patch.theme_mode; } + if patch.theme_blur.is_some() { + self.config.theme_blur = patch.theme_blur; + } // should update system startup if patch.enable_self_startup.is_some() { diff --git a/src-tauri/src/utils/resolve.rs b/src-tauri/src/utils/resolve.rs index 1266f64..281fecb 100644 --- a/src-tauri/src/utils/resolve.rs +++ b/src-tauri/src/utils/resolve.rs @@ -9,6 +9,15 @@ pub fn resolve_setup(app: &App) { let window = app.get_window("main").unwrap(); window.set_shadow(true); + use tauri_plugin_vibrancy::Vibrancy; + #[cfg(target_os = "windows")] + window.apply_blur(); + #[cfg(target_os = "macos")] + { + use tauri_plugin_vibrancy::MacOSVibrancy; + window.apply_vibrancy(MacOSVibrancy::AppearanceBased); + } + // setup a simple http server for singleton server::embed_server(&app.handle()); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 585a2de..511eaef 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -67,7 +67,7 @@ "resizable": true, "fullscreen": false, "decorations": false, - "transparent": false, + "transparent": true, "minWidth": 600, "minHeight": 520 } diff --git a/src/components/setting-verge.tsx b/src/components/setting-verge.tsx index 288fc8a..5b27553 100644 --- a/src/components/setting-verge.tsx +++ b/src/components/setting-verge.tsx @@ -23,6 +23,7 @@ const SettingVerge = ({ onError }: Props) => { const { theme_mode: mode = "light", + theme_blur: blur = false, enable_self_startup: startup = false, enable_system_proxy: proxy = false, } = vergeConfig ?? {}; @@ -54,6 +55,20 @@ const SettingVerge = ({ onError }: Props) => { + + + onChangeData({ theme_blur: e })} + onGuard={(e) => patchVergeConfig({ theme_blur: e })} + > + + + + { const [mode, setMode] = useRecoilState(atomPaletteMode); + const [blur, setBlur] = useRecoilState(atomThemeBlur); const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig); const { data: updateInfo } = useSWR("checkUpdate", checkUpdate, { errorRetryCount: 2, @@ -63,8 +65,10 @@ const Layout = () => { const [dialogOpen, setDialogOpen] = useState(false); useEffect(() => { - setMode(vergeConfig?.theme_mode ?? "light"); - }, [vergeConfig?.theme_mode]); + if (!vergeConfig) return; + setBlur(!!vergeConfig.theme_blur); + setMode(vergeConfig.theme_mode ?? "light"); + }, [vergeConfig]); const theme = useMemo(() => { // const background = mode === "light" ? "#f5f5f5" : "#000"; @@ -89,7 +93,16 @@ const Layout = () => { return ( - + ({ + bgcolor: alpha(theme.palette.background.paper, blur ? 0.85 : 1), + }), + ]} + >
({ key: "atomPaletteMode", default: "light", }); + +export const atomThemeBlur = atom({ + key: "atomThemeBlur", + default: false, +});