From f39cb35a31fd1d7f85174f7ef805b1955f5caf5b Mon Sep 17 00:00:00 2001 From: xfy Date: Thu, 16 Jul 2026 14:24:38 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E8=A1=A5=E5=85=85=E6=95=B0=E5=AD=A6?= =?UTF-8?q?=E5=85=AC=E5=BC=8F=E4=B8=8E=E6=B5=81=E7=A8=8B=E5=9B=BE=E6=9E=B6?= =?UTF-8?q?=E6=9E=84=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AGENTS.md 新增 'Math & Diagrams' 章节详述两条渲染路径: - KaTeX 服务端渲染:katex-rs + pulldown-cmark ENABLE_MATH + sanitizer span 白名单 + 自托管 CSS/字体(make katex-css) - mermaid 客户端懒加载:IntersectionObserver + 动态 import 独立 bundle 同步更新:Server-only deps 加 katex-rs、Frontend Lib 表加 mermaid-renderer 行、 Build Artifacts 加 public/{katex,mermaid}、markdown.rs 描述。 --- AGENTS.md | 30 ++++++++++++++++++++++++++---- Dockerfile | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 7fd2956..a495e3d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -125,7 +125,7 @@ Dioxus 0.7 fullstack project with **two independent gates** — the most common **Server-only helpers**: `src/auth/password.rs`, `src/auth/session.rs`, `src/api/auth.rs`, `src/api/comments/helpers.rs`, and several model helper methods are gated with `#[cfg(feature = "server")]` because they are only called from server function bodies, which are stripped in WASM builds. -**Server-only dependencies**: Crates that are only used behind `#[cfg(feature = "server")]` (e.g., `argon2`, `uuid`, `regex`, `pulldown-cmark`, `rand`, `http`, `sha2`, `hex`, `sysinfo`, `sqlparser`, `dashmap`, plus the rest of the server stack) are declared as `optional = true` in `Cargo.toml` and enabled only through the `server` feature. They are not compiled into the WASM frontend. The `generate_highlight_css` binary is `required-features = ["server"]` (uses `syntect`). +**Server-only dependencies**: Crates that are only used behind `#[cfg(feature = "server")]` (e.g., `argon2`, `uuid`, `regex`, `pulldown-cmark`, `katex-rs`, `rand`, `http`, `sha2`, `hex`, `sysinfo`, `sqlparser`, `dashmap`, plus the rest of the server stack) are declared as `optional = true` in `Cargo.toml` and enabled only through the `server` feature. They are not compiled into the WASM frontend. The `generate_highlight_css` binary is `required-features = ["server"]` (uses `syntect`). **Shared types that compile on both targets**: bridges like `src/tiptap_bridge.rs` and `src/codemirror_bridge.rs` keep shared structs (e.g. `UploadsInFlight`, `SqlSchema`/`SqlTable`) outside cfg gates, while wasm-bindgen externs + `EditorHandle` live in inner `#[cfg(target_arch = "wasm32")] mod wasm`. Similarly `src/sysinfo_sampler.rs` exposes `SystemSnapshot` on both targets but gates the actual sampler + `RwLock` behind `server`. @@ -148,7 +148,7 @@ src/api/ — server functions + Axum handlers auth.rs — login, register, session validation comments/ — comment CRUD + approval/spam/trash server functions database/ — /admin/system backend (status/system_status/sql_console/schema/export/backup/tasks) - markdown.rs — Markdown→HTML rendering (pulldown-cmark + ammonia sanitization) + markdown.rs — Markdown→HTML rendering (pulldown-cmark + ammonia sanitization + KaTeX math) image.rs — image serving with processing pipeline + disk+memory cache upload.rs — image upload, auto-converts to WebP rate_limit.rs — governor-based rate limiting (6 tiers: strict/upload/image/comment/unknown/code_exec) @@ -192,15 +192,16 @@ Readers can execute fenced code blocks in isolated Docker containers; authors ge ## Frontend Lib Subprojects -Five Vite-built IIFE libraries under `libs/` (plus `libs/shared/`, an internal source-shared package with no `public/` artifact — see below), managed as a **pnpm workspace** (single `libs/pnpm-lock.yaml`, shared `libs/tsconfig.base.json` + `libs/biome.json`, hoisted devDeps). Built artifacts go to `public//` — **do not edit `public//` files; they are build artifacts**. Each `build` script is `tsc --noEmit && vite build` (type-check before bundle). Output is IIFE because Dioxus `[web.resource] script` injects bare `