feat(websocket): 优化投屏状态管理并新增全员禁麦功能
- 重构 Redis 投屏状态存储,统一使用 screenShareOwnerUid 字段 - 移除冗余的 screenShareUid 字段,简化房间状态数据结构 - 新增 client_mute_all_students 消息类型支持全员禁麦功能 - 实现创建者权限验证的全员禁麦逻辑,排除老师角色用户 - 优化 Tauri 桌面应用悬浮窗创建接口,支持状态参数传递 - 添加悬浮窗关闭功能及教师端静音状态同步机制 - 修复学生端界面中投屏状态变量命名不一致问题 - 统一按钮样式规范,提升界面组件一致性
This commit is contained in:
@ -37,6 +37,7 @@ pub fn register_commands(builder: Builder<tauri::Wry>) -> Builder<tauri::Wry> {
|
||||
stop_prompt_tone,
|
||||
// 窗口相关命令
|
||||
create_float_list_window,
|
||||
close_float_list_window,
|
||||
create_popup_window,
|
||||
create_main_window,
|
||||
// 系统托盘相关命令
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use crate::window::create_float_list_window::create_float_list_window_impl;
|
||||
use crate::window::create_float_list_window::{close_float_list_window_impl, create_float_list_window_impl};
|
||||
use crate::window::create_main_window::create_main_window_impl;
|
||||
use crate::window::create_popup_window::create_popup_window_impl;
|
||||
use crate::window::derive::TargetLocation;
|
||||
@ -6,8 +6,17 @@ use tauri::{AppHandle, Window};
|
||||
|
||||
/// 创建悬浮列表窗口
|
||||
#[tauri::command]
|
||||
pub async fn create_float_list_window(app: AppHandle) -> Result<String, String> {
|
||||
create_float_list_window_impl(std::sync::Arc::new(app)).await.map(|_| "success".to_string())
|
||||
pub async fn create_float_list_window(app: AppHandle, is_teacher_muted: bool) -> Result<String, String> {
|
||||
create_float_list_window_impl(std::sync::Arc::new(app), is_teacher_muted)
|
||||
.await
|
||||
.map(|_| "success".to_string())
|
||||
}
|
||||
|
||||
/// 关闭悬浮列表窗口
|
||||
#[tauri::command]
|
||||
pub fn close_float_list_window(app: AppHandle) -> Result<String, String> {
|
||||
close_float_list_window_impl(std::sync::Arc::new(app))
|
||||
.map(|_| "success".to_string())
|
||||
}
|
||||
|
||||
/// 创建弹出框窗口
|
||||
|
||||
@ -11,20 +11,21 @@ use crate::{
|
||||
use tauri::{AppHandle, LogicalPosition, LogicalSize, Runtime, WebviewUrl, WebviewWindowBuilder, utils::config::BackgroundThrottlingPolicy};
|
||||
|
||||
/// 创建悬浮列表窗口(内部实现)
|
||||
pub async fn create_float_list_window_impl<R: Runtime>(app: Arc<AppHandle<R>>) -> Result<(), String> {
|
||||
pub async fn create_float_list_window_impl<R: Runtime>(app: Arc<AppHandle<R>>, is_teacher_muted: bool) -> Result<(), String> {
|
||||
if show_windows_by_label(app.as_ref(), WindowLabel::FLOAT_LIST) {
|
||||
return Ok(());
|
||||
}
|
||||
// 悬浮列表尺寸
|
||||
let float_info = calculate_float_info_sync();
|
||||
// 获取屏幕尺寸,优先为main窗口所在屏幕,主窗口没有打开时,才找主屏幕
|
||||
// 获取屏幕尺寸,优先为 main 窗口所在屏幕,主窗口没有打开时,才找主屏幕
|
||||
let monitor = get_monitor_for_window(app.as_ref())?;
|
||||
// 获取屏幕缩放因子
|
||||
let scale_factor = monitor.scale_factor();
|
||||
let page_size: LogicalSize<f64> = monitor.work_area().size.to_logical(scale_factor);
|
||||
let screen_width = page_size.width;
|
||||
let screen_height = page_size.height;
|
||||
let url = format!("floating-list-window.html");
|
||||
// 构建 URL 时附加状态参数
|
||||
let url = format!("floating-list-window.html?isTeacherMuted={}", is_teacher_muted);
|
||||
|
||||
let label = WindowLabel::FLOAT_LIST.as_ref();
|
||||
// 创建悬浮球窗口,直接在初始化时设置好位置和尺寸
|
||||
@ -64,7 +65,7 @@ pub async fn create_float_list_window_impl<R: Runtime>(app: Arc<AppHandle<R>>) -
|
||||
let _ = window.set_size(LogicalSize::new(float_info.width as f64, float_info.height as f64));
|
||||
}
|
||||
|
||||
// 窗口显示后等待200毫秒再执行动画
|
||||
// 窗口显示后等待 200 毫秒再执行动画
|
||||
tokio::spawn(async move {
|
||||
tokio::time::sleep(tokio::time::Duration::from_millis(200)).await;
|
||||
let _ = animate_to_bottom_right(window, screen_width as i32, screen_height as i32).await;
|
||||
@ -72,6 +73,22 @@ pub async fn create_float_list_window_impl<R: Runtime>(app: Arc<AppHandle<R>>) -
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 关闭悬浮列表窗口(内部实现)
|
||||
pub fn close_float_list_window_impl<R: Runtime>(app: Arc<AppHandle<R>>) -> Result<(), String> {
|
||||
use tauri::Manager;
|
||||
|
||||
// 尝试获取悬浮列表窗口
|
||||
if let Some(window) = app.get_webview_window(WindowLabel::FLOAT_LIST.as_ref()) {
|
||||
// 关闭窗口
|
||||
window.close().map_err(|e| format!("关闭悬浮列表窗口失败:{}", e))?;
|
||||
log::info!("已成功关闭悬浮列表窗口");
|
||||
} else {
|
||||
log::warn!("悬浮列表窗口不存在,无需关闭");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 根据用户登录状态和课程选择情况动态计算弹出窗口高度
|
||||
pub fn calculate_float_info_sync() -> FloatListInfo {
|
||||
// 默认基础项目数
|
||||
|
||||
Reference in New Issue
Block a user