From 33db6dc5aa83b0c5267c5f9452947ba73bc24405 Mon Sep 17 00:00:00 2001 From: xfy Date: Fri, 26 Jun 2026 11:04:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(doc):=20=E6=96=87=E6=A1=A3=E6=89=98?= =?UTF-8?q?=E7=AE=A1=E5=88=B0=20/doc=20=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - main.rs: static_routes 加 /doc 与 /doc/ 的 301 重定向到 /doc/yggdrasil/index.html,绕开 Router 的 /:..segments 兜底。 文档深层路径由 Dioxus 自动托管 public/ 提供,无需额外代码。 - .gitignore: 忽略 public/doc 构建产物(配合 make doc 拷贝) --- .gitignore | 1 + src/main.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/.gitignore b/.gitignore index c727651..42f82df 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ public/style.css public/highlight.css public/tiptap public/lightbox +public/doc /static .env docs/superpowers/ diff --git a/src/main.rs b/src/main.rs index 732c8a3..50b29c8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -391,6 +391,23 @@ fn main() { "/readyz", axum::routing::get(crate::api::health::readyz), ) + // /doc 与 /doc/ 重定向到文档入口 /doc/yggdrasil/index.html。 + // public/doc/ 由 Dioxus 自动托管,深层路径无需额外处理;仅裸路径需要 + // 重定向,否则会落到 Router 的 /:..segments 兜底返回 404 页面。 + // 放在 static_routes(与 /uploads 同层),不经过 CSRF/超时/缓存中间件, + // 行为与静态资源一致。用 301 永久重定向,让浏览器/书签记住跳转。 + .route( + "/doc", + axum::routing::get(|| async { + axum::response::Redirect::permanent("/doc/yggdrasil/index.html") + }), + ) + .route( + "/doc/", + axum::routing::get(|| async { + axum::response::Redirect::permanent("/doc/yggdrasil/index.html") + }), + ) .route( "/uploads/{*path}", axum::routing::get(crate::api::image::serve_image),