编辑调整、对比模块

This commit is contained in:
zhongluofeng committed 2026-10-16 13:18:32 +08:00
1 parent c9e61f38c5
commit 6cfa74c901
76 files changed
+9514 -626

No files matched your search

+26 -2
View File
@@ -163,6 +163,30 @@ pub fn ensure_popup_window(app: &AppHandle) {
create_popup_window(app);
}
/// 把已显示的弹窗强制置前。
///
/// 只调 `set_focus` 不够:它内部是 `SetForegroundWindow`,受 Windows **前台锁定**限制 ——
/// 从别的应用按 Alt+V(本进程不拥有前台)时会被静默忽略,弹窗「出来了但拿不到焦点」,
/// 键盘导航 / 搜索都用不了。这里改用原生强制置前(模拟 Alt 释放重置前台锁定 +
/// SetForegroundWindow + BringWindowToTop),与快速面板 / 托盘 / 下载窗口同一套做法。
///
/// 调用前窗口应已 `show()`。置前失败(拿不到 hwnd)时退回普通 `set_focus`。
fn focus_force(win: &tauri::WebviewWindow) {
#[cfg(windows)]
{
match win.hwnd() {
Ok(hwnd) => crate::win32_util::force_foreground(hwnd.0 as isize),
Err(_) => {
let _ = win.set_focus();
}
}
}
#[cfg(not(windows))]
{
let _ = win.set_focus();
}
}
/// 在鼠标当前位置显示弹窗。
/// 窗口不存在则创建(隐藏状态,等前端挂载后调用 show_window 显示)。
/// 窗口已存在则移动到鼠标位置并显示。
@@ -200,7 +224,7 @@ pub fn show_popup(app: &AppHandle) {
}));
let _ = win.show();
mark_shown();
let _ = win.set_focus();
focus_force(&win);
// 通知前端刷新数据
let _ = app.emit(crate::constants::events::CLIPBOARD_POPUP_SHOW, ());
return;
@@ -232,7 +256,7 @@ pub fn show_window(app: &AppHandle) {
}
let _ = win.show();
mark_shown();
let _ = win.set_focus();
focus_force(&win);
// 通知前端刷新数据
let _ = app.emit(crate::constants::events::CLIPBOARD_POPUP_SHOW, ());
}