- Go + Gin + html/template 服务端渲染 - 主页:Google 风格搜索框 + 导航卡片 - 后台:卡片 CRUD、搜索引擎配置、主页背景/标题配置 - 图片上传:支持 jpg/jpeg/png/gif,自动压缩,缩略图参数 ?thumb=1 - 安全:登录日志、修改密码、IP 自动封禁、IP 白名单 - 访问统计:主页访问/卡片点击/搜索追踪、实时流量、IP 统计 - SQLite 存储(modernc.org/sqlite,纯 Go) - 内存 Session + bcrypt 密码哈希
26 lines
745 B
Plaintext
26 lines
745 B
Plaintext
sequenceDiagram
|
|
participant U as 用户浏览器
|
|
participant G as Gin Router
|
|
participant H as HandlerAdmin
|
|
participant AM as AdminModel
|
|
participant SS as SessionStore
|
|
|
|
U->>G: GET /admin/login
|
|
G->>H: LoginGet(c)
|
|
H-->>U: 登录页 HTML
|
|
|
|
U->>G: POST /admin/login {username, password}
|
|
G->>H: LoginPost(c)
|
|
H->>AM: VerifyPassword(username, password)
|
|
AM->>AM: bcrypt.CompareHashAndPassword()
|
|
AM-->>H: true/false
|
|
|
|
alt 验证成功
|
|
H->>SS: Create(adminID, username)
|
|
SS-->>H: sessionID
|
|
H->>H: c.SetCookie("session_id", sessionID, 86400, "/", "", false, true)
|
|
H-->>U: 302 Redirect → /admin
|
|
else 验证失败
|
|
H-->>U: 200 + 登录页(错误提示)
|
|
end
|