feat: 实现设备注册和精准控制功能,支持双屏管理;更新相关逻辑以优化设备状态跟踪

This commit is contained in:
Pine
2026-08-19 14:19:37 +08:00
parent 93b27cf227
commit e72442dae0
15 changed files with 264 additions and 53 deletions
+1 -1
View File
@@ -5135,7 +5135,7 @@ dependencies = [
[[package]]
name = "昆明大学生创业园展播系统"
version = "0.1.0"
version = "0.1.2"
dependencies = [
"serde",
"tauri",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "昆明大学生创业园展播系统"
version = "0.1.0"
version = "0.1.2"
description = "大屏媒体轮播系统 - Tauri App"
authors = ["Pine"]
edition = "2021"
+1
View File
@@ -5,6 +5,7 @@
"windows": ["main", "secondary"],
"permissions": [
"core:default",
"core:app:default",
"core:window:default",
"core:window:allow-minimize",
"core:window:allow-set-fullscreen",
+6 -1
View File
@@ -9,7 +9,7 @@ use tauri::{AppHandle, Manager, WebviewUrl, WebviewWindowBuilder};
/// 双屏控制:on=true 在第二块屏幕上新建一个全屏窗口(加载前端首页),on=false 关闭它。
/// 用于 admin 端「启动双屏」,让展播内容同时投到电脑的另一块显示器。
#[tauri::command]
fn set_dual_screen(app: AppHandle, on: bool) -> Result<String, String> {
fn set_dual_screen(app: AppHandle, on: bool, parent_id: Option<String>) -> Result<String, String> {
if !on {
if let Some(w) = app.get_webview_window("secondary") {
let _ = w.close();
@@ -52,6 +52,11 @@ fn set_dual_screen(app: AppHandle, on: bool) -> Result<String, String> {
.title("OPC 运营中心 · 双屏")
.position(x as f64, y as f64)
.inner_size(w as f64, h as f64)
// 由 Rust 明确告知副窗:它的身份是 secondary,且从属于主屏 device_idparent_id
.initialization_script(format!(
"window.__DPM_WINDOW_LABEL__='secondary';window.__DPM_PARENT_ID__='{}';",
parent_id.unwrap_or_default().replace('\'', "")
))
.build()
.map_err(|e| format!("创建副窗失败: {e}"))?;
// 等窗口内容就绪后再全屏(避免过早全屏导致白屏/布局异常)
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "云超服昆创园OPC运营中心",
"version": "0.1.1",
"version": "0.1.2",
"identifier": "com.pine.dpm",
"build": {
"beforeDevCommand": "yarn build && yarn dev",