feat: 门户网站初始提交
- Go + Gin + html/template 服务端渲染 - 主页:Google 风格搜索框 + 导航卡片 - 后台:卡片 CRUD、搜索引擎配置、主页背景/标题配置 - 图片上传:支持 jpg/jpeg/png/gif,自动压缩,缩略图参数 ?thumb=1 - 安全:登录日志、修改密码、IP 自动封禁、IP 白名单 - 访问统计:主页访问/卡片点击/搜索追踪、实时流量、IP 统计 - SQLite 存储(modernc.org/sqlite,纯 Go) - 内存 Session + bcrypt 密码哈希
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
classDiagram
|
||||
direction LR
|
||||
|
||||
class Card {
|
||||
+int ID
|
||||
+string Icon
|
||||
+string Title
|
||||
+string Subtitle
|
||||
+string URL
|
||||
+int Sort
|
||||
+bool Enabled
|
||||
+time Time CreatedAt
|
||||
}
|
||||
|
||||
class Setting {
|
||||
+string Key
|
||||
+string Value
|
||||
}
|
||||
|
||||
class Admin {
|
||||
+int ID
|
||||
+string Username
|
||||
+string Password
|
||||
}
|
||||
|
||||
class SessionData {
|
||||
+int AdminID
|
||||
+string Username
|
||||
+time Time CreatedAt
|
||||
}
|
||||
|
||||
class SessionStore {
|
||||
-map~string-SessionData~ store
|
||||
-sync.RWMutex mu
|
||||
+Create(adminID int, username string) string
|
||||
+Get(sessionID string) *SessionData
|
||||
+Delete(sessionID string)
|
||||
}
|
||||
|
||||
class CardModel {
|
||||
+GetAllCards() []Card
|
||||
+GetEnabledCards() []Card
|
||||
+GetCardByID(id int) *Card
|
||||
+CreateCard(card *Card) error
|
||||
+UpdateCard(card *Card) error
|
||||
+DeleteCard(id int) error
|
||||
+ToggleCard(id int) error
|
||||
+MoveCardUp(id int) error
|
||||
+MoveCardDown(id int) error
|
||||
}
|
||||
|
||||
class SettingModel {
|
||||
+GetSetting(key string) string
|
||||
+SetSetting(key string, value string) error
|
||||
+GetSearchEngines() map~string-string
|
||||
+SetSearchEngine(name string, url string) error
|
||||
}
|
||||
|
||||
class AdminModel {
|
||||
+GetAdminByUsername(username string) *Admin
|
||||
+CreateAdmin(username string, password string) error
|
||||
+VerifyPassword(username string, password string) bool
|
||||
+ChangePassword(adminID int, newPassword string) error
|
||||
}
|
||||
|
||||
class HandlerHome {
|
||||
+HomeHandler(c *gin.Context)
|
||||
}
|
||||
|
||||
class HandlerAdmin {
|
||||
+LoginGet(c *gin.Context)
|
||||
+LoginPost(c *gin.Context)
|
||||
+Logout(c *gin.Context)
|
||||
+AdminIndex(c *gin.Context)
|
||||
}
|
||||
|
||||
class HandlerCards {
|
||||
+CardsList(c *gin.Context)
|
||||
+CardCreateGet(c *gin.Context)
|
||||
+CardCreatePost(c *gin.Context)
|
||||
+CardEditGet(c *gin.Context)
|
||||
+CardEditPost(c *gin.Context)
|
||||
+CardDelete(c *gin.Context)
|
||||
+CardToggle(c *gin.Context)
|
||||
+CardMoveUp(c *gin.Context)
|
||||
+CardMoveDown(c *gin.Context)
|
||||
}
|
||||
|
||||
class HandlerSettings {
|
||||
+SettingsGet(c *gin.Context)
|
||||
+SettingsPost(c *gin.Context)
|
||||
}
|
||||
|
||||
class AuthMiddleware {
|
||||
+AuthRequired() gin.HandlerFunc
|
||||
}
|
||||
|
||||
CardModel --> Card : returns
|
||||
SettingModel --> Setting : returns
|
||||
AdminModel --> Admin : returns
|
||||
SessionStore --> SessionData : stores
|
||||
HandlerHome --> CardModel : uses
|
||||
HandlerHome --> SettingModel : uses
|
||||
HandlerAdmin --> AdminModel : uses
|
||||
HandlerAdmin --> SessionStore : uses
|
||||
HandlerCards --> CardModel : uses
|
||||
HandlerSettings --> SettingModel : uses
|
||||
AuthMiddleware --> SessionStore : uses
|
||||
Reference in New Issue
Block a user