Files
jiang13-forum/docs/rebuild-spec/08-gitea-ssr-architecture.md
freefire 3f50316ad0 fix: 完成 Gitea 目录改组收尾(import、构建与 LICENSE)
同步包路径与路由,去掉 SPA 构建步骤,对齐 Gitea 式 LICENSE,并更新规格/规则与占位 SSR。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-29 04:01:20 +08:00

69 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 08 · Gitea 式 SSR 架构(开发约定)
> **读者**:在本仓库 `rebuild/gitea-ssr` 分支上开发的 AI / 开发者
> **前置**[README.md](README.md)
> **对照上游**[go-gitea/gitea](https://github.com/go-gitea/gitea)
---
## 目标栈(已确认)
| 层 | 选择 |
|----|------|
| 公开页渲染 | Go `html/template` **真 SSR**(完整 HTML含帖文/列表 DOM |
| 渐进增强 | `web_src/` 少量 CSS/JS构建后嵌入 |
| 发布 | 单二进制 + `go:embed` |
| 业务语义 | 仍以本目录 `01``07` 为准 |
| 不做 | React/Next 公开页 SPA用户与爬虫双轨 HTML |
---
## 开发分支与对照
| 分支 | 用途 |
|------|------|
| `main` | 现网 **React SPA** 对照,勿在此做破坏性 SSR 替换 |
| `rebuild/gitea-ssr` | **唯一** Gitea 式重构开发分支 |
对照运行:
```bash
git checkout main # 旧 SPA
# 或
git worktree add ../jiang13-spa main
```
---
## 目录职责(本分支已落地)
```text
cmd/jiang13/ # 入口
config/ # 配置
models/ # GORM 模型(原 model/
services/ # 业务逻辑(原 service/
routers/
setup.go # 路由总装(原 router/
web/ # HTML SSR
api/ # JSON API原 handler/
modules/
auth/ # JWT / 限流等(原 middleware/
webrender/ # 模板渲染
seo/ # PageMeta 等
templates/ # Go 模板embed
web_src/ # CSS/JS 源码
public/assets/ # 构建产物URL 前缀 `/ssr-assets/`
docs/rebuild-spec/ # 产品规格
.cursor/rules/ # AI 开发规则
```
**已删除(勿恢复):** `frontend/``embed_static/`。SPA 对照仅看 `main`
---
## 渲染原则
1. 用户访问已迁移路径时,「查看源代码」须可见内容 DOM而非空壳。
2. JSON `/api` 留给交互增强与后台;**不得**作为公开页首屏唯一数据来源。
3. 模板默认 HTML 转义;可信 HTML已消毒正文用明确的安全管道禁止随意 `| safe`