feat: 新增浮动列表窗口和弹出窗口功能

添加浮动列表窗口,支持拖拽、吸附和折叠功能,包含课程互动和辅导工具菜单
新增弹出窗口,提供主窗口、画板和退出等快捷操作
优化窗口创建逻辑,添加日志记录和焦点设置
This commit is contained in:
2026-03-13 11:32:05 +08:00
parent 3d215110fa
commit 745dc0e8fa
9 changed files with 1544 additions and 7 deletions

View File

@ -1,8 +1,8 @@
use crate::constants::window::*;
use crate::window::{
WindowLabel,
derive::{PopupLocation, PopupSize, TargetLocation},
util::get_monitor_for_window,
WindowLabel,
};
use tauri::{AppHandle, Manager, Runtime, WebviewUrl, WebviewWindowBuilder};
@ -23,6 +23,7 @@ pub async fn create_popup_window_impl<R: Runtime>(app: &AppHandle<R>, target: &T
// 如果窗口已存在,直接关闭它
let _ = popup_window.close();
}
log::info!("创建弹出框窗口: {:?}", popup_location);
let url = format!("popup-window.html?placement={}", popup_location.placement); // 创建弹出框窗口
WebviewWindowBuilder::new(app, label, WebviewUrl::App(url.into()))
@ -34,6 +35,7 @@ pub async fn create_popup_window_impl<R: Runtime>(app: &AppHandle<R>, target: &T
.decorations(false)
.shadow(false)
.focusable(true)
.focused(true)
.accept_first_mouse(true)
.skip_taskbar(true)
.always_on_top(true)
@ -60,12 +62,7 @@ pub fn calculate_popup_size_sync() -> PopupSize {
}
/// 计算弹出框位置
pub async fn calculate_placement(
target: &TargetLocation,
popup_size: &PopupSize,
placement: &str,
page_size: &tauri::LogicalSize<i32>,
) -> Result<PopupLocation, String> {
pub async fn calculate_placement(target: &TargetLocation, popup_size: &PopupSize, placement: &str, page_size: &tauri::LogicalSize<i32>) -> Result<PopupLocation, String> {
let margin = 12; // 箭头距离触发元素的距离
let mar = 12; // 距离屏幕边缘的最小距离