diff --git a/Makefile b/Makefile
index f99488f..a6c9222 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ build:
@$(MAKE) build-core
@$(MAKE) highlight-css
@tailwindcss -i input.css -o public/style.css --minify
+ @$(MAKE) doc
@dx build --release --debug-symbols=false
build-linux:
@@ -75,8 +76,21 @@ test:
# RUSTDOCFLAGS 把 rustdoc 的 --default-theme=ayu 透传过去——cargo doc 本身
# 无主题参数,但会把该环境变量转交给底层 rustdoc。注意它是默认值,浏览器
# 若已记住上次的主题选择(localStorage)则不会被覆盖。
+#
+# 生成后拷贝到 public/doc/,让文档随 Dioxus 静态目录发布。先清空旧目录再
+# 整体拷贝,避免删除模块后残留旧文件。rustdoc 内部用相对路径引用资源
+# (如 ../../static.files/),原样挂载不会断链。
+#
+# 额外生成 public/doc/index.html 重定向页:Dioxus 在 dev 用
+# nest_service("/doc", ServeDir) 托管该目录,ServeDir 访问目录根时默认
+# 返回 index.html。用 meta refresh + JS 跳转到真正的文档入口
+# yggdrasil/index.html,这样裸路径 /doc 也能直达文档,且不与 Dioxus 的
+# /doc/* 路由冲突(手动注册 /doc 会在 merge 时 panic)。
doc:
@RUSTDOCFLAGS="--default-theme=ayu" cargo doc --no-deps --document-private-items
+ @rm -rf public/doc
+ @cp -r target/doc public/doc
+ @printf '
Redirecting…' > public/doc/index.html
# 同 doc,生成完自动用浏览器打开。
doc-open:
@@ -85,4 +99,5 @@ doc-open:
clean:
@cargo clean
@rm -f public/style.css public/highlight.css
+ @rm -rf public/doc
@rm -rf uploads/.cache
diff --git a/src/main.rs b/src/main.rs
index 50b29c8..732c8a3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -391,23 +391,6 @@ 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),