feat: change window style

This commit is contained in:
GyDi
2022-02-20 23:46:13 +08:00
parent 3b54eeb1c5
commit 489ae6c9b6
5 changed files with 51 additions and 24 deletions

View File

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