- 更新前端支持触控操作
This commit is contained in:
@@ -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 })
|
||||
|
||||
Reference in New Issue
Block a user