mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
fix: enhance hotkey handling in lightweight mode and improve window management
This commit is contained in:
@@ -153,13 +153,22 @@ impl Hotkey {
|
||||
"=== Hotkey Dashboard Window Operation Start ==="
|
||||
);
|
||||
|
||||
// 使用异步操作避免阻塞
|
||||
// 检查是否在轻量模式下,如果是,需要同步处理
|
||||
if crate::module::lightweight::is_in_lightweight_mode() {
|
||||
logging!(
|
||||
info,
|
||||
Type::Hotkey,
|
||||
true,
|
||||
"In lightweight mode, calling open_or_close_dashboard directly"
|
||||
);
|
||||
crate::feat::open_or_close_dashboard();
|
||||
} else {
|
||||
AsyncHandler::spawn(move || async move {
|
||||
logging!(
|
||||
debug,
|
||||
Type::Hotkey,
|
||||
true,
|
||||
"Toggle dashboard window visibility"
|
||||
"Toggle dashboard window visibility (async)"
|
||||
);
|
||||
|
||||
// 检查窗口是否存在
|
||||
@@ -213,6 +222,7 @@ impl Hotkey {
|
||||
resolve::create_window(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
logging!(
|
||||
debug,
|
||||
|
||||
@@ -13,6 +13,19 @@ pub fn open_or_close_dashboard() {
|
||||
println!("Attempting to open/close dashboard");
|
||||
log::info!(target: "app", "Attempting to open/close dashboard");
|
||||
|
||||
// 检查是否在轻量模式下
|
||||
if crate::module::lightweight::is_in_lightweight_mode() {
|
||||
println!("Currently in lightweight mode, exiting lightweight mode");
|
||||
log::info!(target: "app", "Currently in lightweight mode, exiting lightweight mode");
|
||||
|
||||
crate::module::lightweight::exit_lightweight_mode();
|
||||
|
||||
println!("Creating new window after exiting lightweight mode");
|
||||
log::info!(target: "app", "Creating new window after exiting lightweight mode");
|
||||
resolve::create_window(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(window) = handle::Handle::global().get_window() {
|
||||
println!("Found existing window");
|
||||
log::info!(target: "app", "Found existing window");
|
||||
|
||||
@@ -119,6 +119,10 @@ pub fn exit_lightweight_mode() {
|
||||
set_lightweight_mode(false);
|
||||
logging!(info, Type::Lightweight, true, "正在退出轻量模式");
|
||||
|
||||
// macOS激活策略
|
||||
#[cfg(target_os = "macos")]
|
||||
AppHandleManager::global().set_activation_policy_regular();
|
||||
|
||||
// 重置UI就绪状态
|
||||
crate::utils::resolve::reset_ui_ready();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user