7dd53e95d8
统一推荐页各玩法正式 runtime 的游客鉴权透传。 收口推荐页首页展示队列和嵌入运行态切换队列。 补齐未登录读档、签名资产和个人数据读取的游客态处理。 新增运行态 HUD 小尺寸 logo 资源并更新拼图与抓鹅展示。 补充推荐切换、runtime guest 启动和客户端请求回归测试。 更新玩法链路、后端契约和团队记忆文档。
186 lines
7.1 KiB
Rust
186 lines
7.1 KiB
Rust
use axum::{
|
|
Router, middleware,
|
|
routing::{get, post},
|
|
};
|
|
|
|
use crate::{
|
|
auth::{require_bearer_auth, require_runtime_principal_auth},
|
|
state::AppState,
|
|
vector_engine_audio_generation::{
|
|
create_background_music_task, create_sound_effect_task,
|
|
create_visual_novel_background_music_task, create_visual_novel_sound_effect_task,
|
|
publish_background_music_asset, publish_sound_effect_asset,
|
|
publish_visual_novel_background_music_asset, publish_visual_novel_sound_effect_asset,
|
|
},
|
|
visual_novel::{
|
|
compile_visual_novel_session, create_visual_novel_session, delete_visual_novel_work,
|
|
execute_visual_novel_action, get_visual_novel_run, get_visual_novel_session,
|
|
get_visual_novel_work, list_visual_novel_gallery, list_visual_novel_history,
|
|
list_visual_novel_works, publish_visual_novel_work, regenerate_visual_novel_run,
|
|
start_visual_novel_run, stream_visual_novel_action, stream_visual_novel_message,
|
|
submit_visual_novel_message, update_visual_novel_work,
|
|
},
|
|
};
|
|
|
|
pub fn router(state: AppState) -> Router<AppState> {
|
|
Router::new()
|
|
.route(
|
|
"/api/creation/visual-novel/sessions",
|
|
post(create_visual_novel_session).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/sessions/{session_id}",
|
|
get(get_visual_novel_session).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/sessions/{session_id}/messages",
|
|
post(submit_visual_novel_message).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/sessions/{session_id}/messages/stream",
|
|
post(stream_visual_novel_message).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/sessions/{session_id}/actions",
|
|
post(execute_visual_novel_action).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/sessions/{session_id}/compile",
|
|
post(compile_visual_novel_session).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/works",
|
|
get(list_visual_novel_works).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/works/{profile_id}",
|
|
get(get_visual_novel_work)
|
|
.put(update_visual_novel_work)
|
|
.patch(update_visual_novel_work)
|
|
.delete(delete_visual_novel_work)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/works/{profile_id}/publish",
|
|
post(publish_visual_novel_work).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/audio/background-music",
|
|
post(create_visual_novel_background_music_task).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_bearer_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/audio/background-music/{task_id}/asset",
|
|
post(publish_visual_novel_background_music_asset).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_bearer_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/audio/sound-effect",
|
|
post(create_visual_novel_sound_effect_task).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_bearer_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/audio/sound-effect/{task_id}/asset",
|
|
post(publish_visual_novel_sound_effect_asset).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_bearer_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/api/creation/audio/background-music",
|
|
post(create_background_music_task).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/audio/background-music/{task_id}/asset",
|
|
post(publish_background_music_asset).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/audio/sound-effect",
|
|
post(create_sound_effect_task).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/audio/sound-effect/{task_id}/asset",
|
|
post(publish_sound_effect_asset).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/visual-novel/gallery",
|
|
get(list_visual_novel_gallery),
|
|
)
|
|
.route(
|
|
"/api/runtime/visual-novel/works/{profile_id}/runs",
|
|
post(start_visual_novel_run).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_runtime_principal_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/visual-novel/runs/{run_id}",
|
|
get(get_visual_novel_run).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_runtime_principal_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/visual-novel/runs/{run_id}/actions/stream",
|
|
post(stream_visual_novel_action).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_runtime_principal_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/visual-novel/runs/{run_id}/history",
|
|
get(list_visual_novel_history).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_runtime_principal_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/visual-novel/runs/{run_id}/regenerate",
|
|
post(regenerate_visual_novel_run).route_layer(middleware::from_fn_with_state(
|
|
state,
|
|
require_runtime_principal_auth,
|
|
)),
|
|
)
|
|
}
|