feat: light mode wip (#96)

* 关闭窗口释放UI资源

* windows 还有左键点击事件

* 兼容enhance profile

* bug 修复
This commit is contained in:
ctaoist
2022-05-25 16:06:39 +08:00
committed by GitHub
parent 54b0828c20
commit 2c97eb4115
6 changed files with 70 additions and 32 deletions

View File

@@ -44,10 +44,23 @@ fn main() -> std::io::Result<()> {
.on_system_tray_event(move |app_handle, event| match event {
SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() {
"open_window" => {
let window = app_handle.get_window("main").unwrap();
window.unminimize().unwrap();
window.show().unwrap();
window.set_focus().unwrap();
tauri::window::WindowBuilder::new(
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" => {
let core = app_handle.state::<core::Core>();
@@ -91,10 +104,23 @@ fn main() -> std::io::Result<()> {
},
#[cfg(target_os = "windows")]
SystemTrayEvent::LeftClick { .. } => {
let window = app_handle.get_window("main").unwrap();
window.unminimize().unwrap();
window.show().unwrap();
window.set_focus().unwrap();
tauri::window::WindowBuilder::new(
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)
});
}
_ => {}
})
@@ -156,17 +182,8 @@ fn main() -> std::io::Result<()> {
.build(tauri::generate_context!())
.expect("error while running tauri application")
.run(|app_handle, e| match e {
tauri::RunEvent::WindowEvent { label, event, .. } => match event {
tauri::WindowEvent::CloseRequested { api, .. } => {
let app_handle = app_handle.clone();
api.prevent_close();
app_handle.get_window(&label).unwrap().hide().unwrap();
}
_ => {}
},
tauri::RunEvent::ExitRequested { .. } => {
resolve::resolve_reset(app_handle);
api::process::kill_children();
tauri::RunEvent::ExitRequested { api, .. } => {
api.prevent_exit();
}
tauri::RunEvent::Exit => {
resolve::resolve_reset(app_handle);