mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
feat: change window style
This commit is contained in:
@@ -1,24 +1,10 @@
|
||||
use super::{init, server};
|
||||
use crate::{core::Profiles, states};
|
||||
use tauri::{App, AppHandle, Manager};
|
||||
use tauri_plugin_shadows::Shadows;
|
||||
|
||||
/// handle something when start app
|
||||
pub fn resolve_setup(app: &App) {
|
||||
// set shadow when window decorations
|
||||
let window = app.get_window("main").unwrap();
|
||||
window.set_shadow(true);
|
||||
|
||||
// enable system blur
|
||||
use tauri_plugin_vibrancy::Vibrancy;
|
||||
#[cfg(target_os = "windows")]
|
||||
window.apply_blur();
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
use tauri_plugin_vibrancy::MacOSVibrancy;
|
||||
#[allow(deprecated)]
|
||||
window.apply_vibrancy(MacOSVibrancy::AppearanceBased);
|
||||
}
|
||||
resolve_window(app);
|
||||
|
||||
// setup a simple http server for singleton
|
||||
server::embed_server(&app.handle());
|
||||
@@ -58,3 +44,34 @@ pub fn resolve_reset(app_handle: &AppHandle) {
|
||||
|
||||
verge.reset_sysproxy();
|
||||
}
|
||||
|
||||
/// customize the window theme
|
||||
fn resolve_window(app: &App) {
|
||||
let window = app.get_window("main").unwrap();
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
use tauri_plugin_shadows::Shadows;
|
||||
use tauri_plugin_vibrancy::Vibrancy;
|
||||
|
||||
window.set_decorations(false).unwrap();
|
||||
window.set_shadow(true);
|
||||
window.apply_blur();
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
use tauri::LogicalSize;
|
||||
use tauri::Size::Logical;
|
||||
window.set_decorations(true).unwrap();
|
||||
window
|
||||
.set_size(Logical(LogicalSize {
|
||||
width: 800.0,
|
||||
height: 610.0,
|
||||
}))
|
||||
.unwrap();
|
||||
// use tauri_plugin_vibrancy::MacOSVibrancy;
|
||||
// #[allow(deprecated)]
|
||||
// window.apply_vibrancy(MacOSVibrancy::AppearanceBased);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user