新增头部导航链接配置与多语言支持
- 迁移 v10 新增 nav_links 与 nav_link_translations 两张表,文案按语言存储 - 公开 GET /api/nav-links 返回启用链接(按 sort/id 排序);管理员可增删改查与启停 - URL 仅允许站内路径、http(s) 与 mailto,拒绝 javascript: 等危险协议;译文替换与校验 - 前端删除写死的“主页”按钮,头部按当前语言渲染动态链接,新窗口加 rel=noopener noreferrer - 后台管理页新增“头部导航链接”卡片(三语文案、URL、打开方式、排序、状态),改动即时生效 - 补充 nav 接口与迁移测试、三语文案,重新生成 Swagger 文档
This commit is contained in:
19 files changed
+2198
-13
No files matched your search
+8
-1
@@ -15,13 +15,14 @@ import (
|
||||
"rill/internal/config"
|
||||
"rill/internal/database"
|
||||
"rill/internal/file"
|
||||
"rill/internal/nav"
|
||||
"rill/internal/note"
|
||||
"rill/internal/site"
|
||||
"rill/internal/user"
|
||||
"rill/internal/usergroup"
|
||||
)
|
||||
|
||||
// RegisterRoutes 注册 API 路由。health、swagger、auth、站点信息与文件查看公开;notes、个人资料与文件上传删除需登录;站点信息更新、用户与用户组管理仅限管理员。
|
||||
// RegisterRoutes 注册 API 路由。health、swagger、auth、站点信息、文件查看与头部导航读取公开;notes、个人资料与文件上传删除需登录;站点信息更新、导航维护、用户与用户组管理仅限管理员。
|
||||
func RegisterRoutes(rg *gin.RouterGroup, db *gorm.DB, cfg *config.Config) {
|
||||
authn := auth.NewAuthenticator(cfg)
|
||||
|
||||
@@ -43,6 +44,7 @@ func RegisterRoutes(rg *gin.RouterGroup, db *gorm.DB, cfg *config.Config) {
|
||||
|
||||
rg.GET("/site", site.Get(db))
|
||||
rg.GET("/files/:id", file.View(db, cfg))
|
||||
rg.GET("/nav-links", nav.List(db))
|
||||
|
||||
authed := rg.Group("", authn.RequireAuth(db))
|
||||
{
|
||||
@@ -69,6 +71,11 @@ func RegisterRoutes(rg *gin.RouterGroup, db *gorm.DB, cfg *config.Config) {
|
||||
admin.PUT("/site/logo", site.UploadLogo(db, cfg))
|
||||
admin.DELETE("/site/logo", site.DeleteLogo(db, cfg))
|
||||
|
||||
admin.GET("/nav-links/list", nav.ListAll(db))
|
||||
admin.POST("/nav-links", nav.Create(db))
|
||||
admin.PUT("/nav-links/:id", nav.Update(db))
|
||||
admin.DELETE("/nav-links/:id", nav.Delete(db))
|
||||
|
||||
users := admin.Group("/users")
|
||||
{
|
||||
users.GET("", user.List(db))
|
||||
|
||||
Reference in New Issue
Block a user