feat: support blur window

This commit is contained in:
GyDi
2022-01-12 02:27:29 +08:00
parent fb6a97789e
commit 148547de95
9 changed files with 68 additions and 5 deletions

12
src-tauri/Cargo.lock generated
View File

@@ -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"

View File

@@ -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"] }

View File

@@ -9,6 +9,10 @@ pub struct VergeConfig {
/// `light` or `dark`
pub theme_mode: Option<String>,
/// enable blur mode
/// maybe be able to set the alpha
pub theme_blur: Option<bool>,
/// can the app auto startup
pub enable_self_startup: Option<bool>,
@@ -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() {

View File

@@ -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());

View File

@@ -67,7 +67,7 @@
"resizable": true,
"fullscreen": false,
"decorations": false,
"transparent": false,
"transparent": true,
"minWidth": 600,
"minHeight": 520
}