- 更新前端支持触控操作
This commit is contained in:
Generated
+74
-8
@@ -227,6 +227,17 @@ version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||
|
||||
[[package]]
|
||||
name = "auto-launch"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f012b8cc0c850f34117ec8252a44418f2e34a2cf501de89e29b241ae5f79471"
|
||||
dependencies = [
|
||||
"dirs 4.0.0",
|
||||
"thiserror 1.0.69",
|
||||
"winreg 0.10.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.0"
|
||||
@@ -859,13 +870,33 @@ dependencies = [
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "4.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
|
||||
dependencies = [
|
||||
"dirs-sys 0.3.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
"dirs-sys 0.5.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_users 0.4.6",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -876,7 +907,7 @@ checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users",
|
||||
"redox_users 0.5.2",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
@@ -956,7 +987,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"chrono",
|
||||
"dirs",
|
||||
"dirs 6.0.0",
|
||||
"futures",
|
||||
"once_cell",
|
||||
"rust-embed",
|
||||
@@ -964,6 +995,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tauri-plugin-autostart",
|
||||
"tauri-plugin-opener",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
@@ -1026,7 +1058,7 @@ dependencies = [
|
||||
"rustc_version",
|
||||
"toml 1.1.2+spec-1.1.0",
|
||||
"vswhom",
|
||||
"winreg",
|
||||
"winreg 0.55.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2970,6 +3002,17 @@ dependencies = [
|
||||
"bitflags 2.11.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
|
||||
dependencies = [
|
||||
"getrandom 0.2.17",
|
||||
"libredox",
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.5.2"
|
||||
@@ -3713,7 +3756,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
"cookie",
|
||||
"dirs",
|
||||
"dirs 6.0.0",
|
||||
"dunce",
|
||||
"embed_plist",
|
||||
"getrandom 0.3.4",
|
||||
@@ -3763,7 +3806,7 @@ checksum = "3a318b234cc2dea65f575467bafcfb76286bce228ebc3778e337d61d03213007"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cargo_toml",
|
||||
"dirs",
|
||||
"dirs 6.0.0",
|
||||
"glob",
|
||||
"heck 0.5.0",
|
||||
"json-patch",
|
||||
@@ -3833,6 +3876,20 @@ dependencies = [
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-autostart"
|
||||
version = "2.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "459383cebc193cdd03d1ba4acc40f2c408a7abce419d64bdcd2d745bc2886f70"
|
||||
dependencies = [
|
||||
"auto-launch",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"tauri-plugin",
|
||||
"thiserror 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-opener"
|
||||
version = "2.5.4"
|
||||
@@ -4341,7 +4398,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15edbb0d80583e85ee8df283410038e17314df5cba30da2087a54a85216c0773"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"dirs",
|
||||
"dirs 6.0.0",
|
||||
"libappindicator",
|
||||
"muda",
|
||||
"objc2",
|
||||
@@ -5153,6 +5210,15 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.55.0"
|
||||
@@ -5273,7 +5339,7 @@ dependencies = [
|
||||
"block2",
|
||||
"cookie",
|
||||
"crossbeam-channel",
|
||||
"dirs",
|
||||
"dirs 6.0.0",
|
||||
"dom_query",
|
||||
"dpi",
|
||||
"dunce",
|
||||
|
||||
@@ -15,6 +15,7 @@ tauri-build = { version = "2", features = [] }
|
||||
[dependencies]
|
||||
tauri = { version = "2", features = [] }
|
||||
tauri-plugin-opener = "2"
|
||||
tauri-plugin-autostart = "2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
"windows": ["main"],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"opener:default"
|
||||
"core:window:default",
|
||||
"core:window:allow-minimize",
|
||||
"core:window:allow-set-fullscreen",
|
||||
"opener:default",
|
||||
"autostart:default"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -42,6 +42,10 @@ pub fn run() {
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.plugin(tauri_plugin_autostart::init(
|
||||
tauri_plugin_autostart::MacosLauncher::LaunchAgent,
|
||||
Some(vec![]),
|
||||
))
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ pub struct Settings {
|
||||
pub auto_play: bool,
|
||||
pub play_mode: String,
|
||||
pub image_duration: u32,
|
||||
pub fullscreen: bool,
|
||||
pub autostart: bool,
|
||||
}
|
||||
|
||||
impl Default for Settings {
|
||||
@@ -20,6 +22,8 @@ impl Default for Settings {
|
||||
auto_play: true,
|
||||
play_mode: "sequential".into(),
|
||||
image_duration: 5,
|
||||
fullscreen: true,
|
||||
autostart: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,6 +92,10 @@ pub struct ServerEvent {
|
||||
pub play_mode: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub image_duration: Option<u32>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub fullscreen: Option<bool>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub autostart: Option<bool>,
|
||||
}
|
||||
|
||||
// ============ Playlist Response ============
|
||||
@@ -116,6 +124,8 @@ pub struct SettingsUpdate {
|
||||
pub volume: Option<u32>,
|
||||
pub play_mode: Option<String>,
|
||||
pub image_duration: Option<u32>,
|
||||
pub fullscreen: Option<bool>,
|
||||
pub autostart: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
||||
@@ -169,6 +169,7 @@ pub fn create_router(state: AppState) -> Router {
|
||||
Router::new()
|
||||
.route("/api/login", post(login_handler))
|
||||
.route("/api/settings", get(get_settings).post(update_settings))
|
||||
.route("/api/display-command", post(display_command_handler))
|
||||
.route("/media", get(list_media))
|
||||
.route("/upload", post(upload_handler))
|
||||
.route("/api/delete", post(delete_handler))
|
||||
@@ -221,6 +222,8 @@ async fn get_settings() -> Json<serde_json::Value> {
|
||||
"volume": s.volume,
|
||||
"play_mode": s.play_mode,
|
||||
"image_duration": s.image_duration,
|
||||
"fullscreen": s.fullscreen,
|
||||
"autostart": s.autostart,
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -231,6 +234,8 @@ async fn update_settings(
|
||||
volume: body.volume,
|
||||
play_mode: body.play_mode.clone(),
|
||||
image_duration: body.image_duration,
|
||||
fullscreen: body.fullscreen,
|
||||
autostart: body.autostart,
|
||||
});
|
||||
|
||||
EVENTS.broadcast(&ServerEvent {
|
||||
@@ -239,6 +244,8 @@ async fn update_settings(
|
||||
volume: body.volume,
|
||||
play_mode: body.play_mode,
|
||||
image_duration: body.image_duration,
|
||||
fullscreen: body.fullscreen,
|
||||
autostart: body.autostart,
|
||||
});
|
||||
|
||||
Json(serde_json::json!({"ok": true}))
|
||||
@@ -356,6 +363,8 @@ async fn delete_handler(
|
||||
volume: None,
|
||||
play_mode: None,
|
||||
image_duration: None,
|
||||
fullscreen: None,
|
||||
autostart: None,
|
||||
});
|
||||
|
||||
Json(OkResponse { ok: true })
|
||||
@@ -439,6 +448,8 @@ async fn add_playlist(
|
||||
volume: None,
|
||||
play_mode: None,
|
||||
image_duration: None,
|
||||
fullscreen: None,
|
||||
autostart: None,
|
||||
});
|
||||
Json(OkResponse { ok: true })
|
||||
}
|
||||
@@ -453,6 +464,8 @@ async fn remove_playlist(
|
||||
volume: None,
|
||||
play_mode: None,
|
||||
image_duration: None,
|
||||
fullscreen: None,
|
||||
autostart: None,
|
||||
});
|
||||
Json(OkResponse { ok: true })
|
||||
}
|
||||
@@ -472,6 +485,8 @@ async fn control_handler(
|
||||
volume: None,
|
||||
play_mode: None,
|
||||
image_duration: None,
|
||||
fullscreen: None,
|
||||
autostart: None,
|
||||
});
|
||||
|
||||
let mut playback = state.playback.lock().await;
|
||||
@@ -489,11 +504,34 @@ async fn control_handler(
|
||||
volume: None,
|
||||
play_mode: None,
|
||||
image_duration: None,
|
||||
fullscreen: None,
|
||||
autostart: None,
|
||||
});
|
||||
|
||||
Ok(Json(serde_json::json!({"ok": true, "action": body.action})))
|
||||
}
|
||||
|
||||
// ===================== Handler: 显示命令(最小化、全屏等) =====================
|
||||
async fn display_command_handler(
|
||||
Json(body): Json<ActionBody>,
|
||||
) -> Result<Json<serde_json::Value>, (StatusCode, String)> {
|
||||
match body.action.as_str() {
|
||||
"minimize" => {
|
||||
EVENTS.broadcast(&ServerEvent {
|
||||
action: "minimize_window".into(),
|
||||
state: None,
|
||||
volume: None,
|
||||
play_mode: None,
|
||||
image_duration: None,
|
||||
fullscreen: None,
|
||||
autostart: None,
|
||||
});
|
||||
Ok(Json(serde_json::json!({"ok": true, "action": "minimize"})))
|
||||
}
|
||||
_ => Err((StatusCode::BAD_REQUEST, "不支持的显示命令".into())),
|
||||
}
|
||||
}
|
||||
|
||||
// ===================== Handler: 状态 =====================
|
||||
async fn get_state(
|
||||
State(state): State<AppState>,
|
||||
@@ -527,6 +565,8 @@ async fn update_state(
|
||||
volume: None,
|
||||
play_mode: None,
|
||||
image_duration: None,
|
||||
fullscreen: None,
|
||||
autostart: None,
|
||||
});
|
||||
|
||||
Json(OkResponse { ok: true })
|
||||
|
||||
@@ -86,6 +86,12 @@ impl Storage {
|
||||
if let Some(d) = update.image_duration {
|
||||
s.image_duration = d;
|
||||
}
|
||||
if let Some(f) = update.fullscreen {
|
||||
s.fullscreen = f;
|
||||
}
|
||||
if let Some(a) = update.autostart {
|
||||
s.autostart = a;
|
||||
}
|
||||
}
|
||||
}
|
||||
self.save();
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
```
|
||||
src-tauri/
|
||||
├── src/
|
||||
│ ├── commands/ # 所有 Tauri 命令(前端调用的 Rust 函数)
|
||||
│ │ ├── mod.rs # 命令模块导出
|
||||
│ │ ├── file.rs # 文件操作命令
|
||||
│ │ ├── system.rs # 系统信息/权限命令
|
||||
│ │ └── app.rs # 应用控制(窗口、托盘、重启)
|
||||
│ ├── core/ # 核心业务逻辑(纯 Rust,不依赖 Tauri)
|
||||
│ │ ├── mod.rs
|
||||
│ │ ├── config.rs # 配置管理
|
||||
│ │ ├── storage.rs # 本地数据存储
|
||||
│ │ └── service.rs # 业务服务
|
||||
│ ├── utils/ # 工具函数
|
||||
│ │ ├── mod.rs
|
||||
│ │ ├── error.rs # 统一错误处理
|
||||
│ │ └── helpers.rs # 通用工具
|
||||
│ ├── window.rs # 窗口管理(创建、样式、行为)
|
||||
│ ├── tray.rs # 系统托盘逻辑
|
||||
│ ├── lib.rs # 库入口(导出所有模块)
|
||||
│ └── main.rs # 程序入口(轻量,只做初始化)
|
||||
├── Cargo.toml
|
||||
└── tauri.conf.json
|
||||
```
|
||||
Reference in New Issue
Block a user