refactor: 简化运行时与服务协调

提取运行时生命周期管理,集中远程访问与 USB 协调,并缩小 Web 路由状态依赖。
This commit is contained in:
mofeng-git
2026-08-26 10:53:08 +08:00
parent 827d24fde4
commit 37af369b43
24 changed files with 2016 additions and 1771 deletions

View File

@@ -1,19 +1,18 @@
use axum::{extract::State, Json};
use std::sync::Arc;
use crate::config::HidConfig;
use crate::error::Result;
use crate::state::AppState;
use crate::web::state::UsbApiState;
use super::types::HidConfigUpdate;
use super::usb_update::{stage_hid_config_update, update_usb_config};
pub async fn get_hid_config(State(state): State<Arc<AppState>>) -> Json<HidConfig> {
pub async fn get_hid_config(State(state): State<UsbApiState>) -> Json<HidConfig> {
Json(state.config.get().hid.clone())
}
pub async fn update_hid_config(
State(state): State<Arc<AppState>>,
State(state): State<UsbApiState>,
Json(req): Json<HidConfigUpdate>,
) -> Result<Json<HidConfig>> {
let config = update_usb_config(&state, move |staged| {