fix: create main window
This commit is contained in:
parent
72f10aaed1
commit
ae94993b09
@ -44,23 +44,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
.on_system_tray_event(move |app_handle, event| match event {
|
.on_system_tray_event(move |app_handle, event| match event {
|
||||||
SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() {
|
SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() {
|
||||||
"open_window" => {
|
"open_window" => {
|
||||||
tauri::window::WindowBuilder::new(
|
resolve::create_window(app_handle);
|
||||||
app_handle,
|
|
||||||
"main".to_string(),
|
|
||||||
tauri::WindowUrl::App("index.html".into()),
|
|
||||||
)
|
|
||||||
.title("Clash Verge")
|
|
||||||
.center()
|
|
||||||
.decorations(false)
|
|
||||||
.fullscreen(false)
|
|
||||||
.inner_size(800.0, 636.0)
|
|
||||||
.min_inner_size(600.0, 520.0)
|
|
||||||
.build()
|
|
||||||
.err()
|
|
||||||
.and_then(|e| {
|
|
||||||
log::error!("{e}");
|
|
||||||
Some(0)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
"system_proxy" => {
|
"system_proxy" => {
|
||||||
let core = app_handle.state::<core::Core>();
|
let core = app_handle.state::<core::Core>();
|
||||||
@ -104,23 +88,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
},
|
},
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
SystemTrayEvent::LeftClick { .. } => {
|
SystemTrayEvent::LeftClick { .. } => {
|
||||||
tauri::window::WindowBuilder::new(
|
resolve::create_window(app_handle);
|
||||||
app_handle,
|
|
||||||
"main".to_string(),
|
|
||||||
tauri::WindowUrl::App("index.html".into()),
|
|
||||||
)
|
|
||||||
.title("Clash Verge")
|
|
||||||
.center()
|
|
||||||
.decorations(false)
|
|
||||||
.fullscreen(false)
|
|
||||||
.inner_size(800.0, 636.0)
|
|
||||||
.min_inner_size(600.0, 520.0)
|
|
||||||
.build()
|
|
||||||
.err()
|
|
||||||
.and_then(|e| {
|
|
||||||
log::error!("{e}");
|
|
||||||
Some(0)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{core::Core, utils::init, utils::server};
|
use crate::{core::Core, log_if_err, utils::init, utils::server};
|
||||||
use tauri::{App, AppHandle, Manager};
|
use tauri::{App, AppHandle, Manager};
|
||||||
|
|
||||||
/// handle something when start app
|
/// handle something when start app
|
||||||
@ -61,3 +61,47 @@ fn resolve_window(app: &App) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// create main window
|
||||||
|
pub fn create_window(app_handle: &AppHandle) {
|
||||||
|
if let Some(window) = app_handle.get_window("main") {
|
||||||
|
let _ = window.unminimize();
|
||||||
|
let _ = window.show();
|
||||||
|
let _ = window.set_focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let builder = tauri::window::WindowBuilder::new(
|
||||||
|
app_handle,
|
||||||
|
"main".to_string(),
|
||||||
|
tauri::WindowUrl::App("index.html".into()),
|
||||||
|
)
|
||||||
|
.title("Clash Verge")
|
||||||
|
.center()
|
||||||
|
.fullscreen(false)
|
||||||
|
.min_inner_size(600.0, 520.0);
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
{
|
||||||
|
use crate::utils::winhelp;
|
||||||
|
use window_shadows::set_shadow;
|
||||||
|
use window_vibrancy::apply_blur;
|
||||||
|
|
||||||
|
match builder.decorations(false).inner_size(800.0, 636.0).build() {
|
||||||
|
Ok(window) => {
|
||||||
|
let _ = set_shadow(&window, true);
|
||||||
|
|
||||||
|
if !winhelp::is_win11() {
|
||||||
|
let _ = apply_blur(&window, None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => log::error!("{err}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
log_if_err!(builder.decorations(true).inner_size(800.0, 620.0).build());
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
log_if_err!(builder.decorations(false).inner_size(800.0, 636.0).build());
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user