feat: 编辑器与帖子展示布局优化 + 新增个人空间
- 编辑器投稿页布局优化:标题与编辑器高度动态适配,工具栏与内容区视觉对齐 - 稿件展示页布局优化:MD 渲染区与评论区视觉分离,代码块主题微调 - CSRF 中间件:图像上传端点豁免,解决 Vditor 拖拽/粘贴上传 403 - Post 状态映射、GetGinUser、SaveUploadedFile 提取至 common 包,遵循审计建议 - 新增个人空间功能:/space(需登录)重定向到 /space/:uid,/space/:uid 公开访问 - 空间页模板:参考 B 站布局,展示头像、用户名、个性签名、UID、加入时间及稿件列表 - 导航栏:用户名链接指向 /space,新增「设置」入口 - 分层实现:SpaceController → SpaceService → PostRepo.FindByUserID,严格 ISP 接口隔离
This commit is contained in:
20
internal/common/context.go
Normal file
20
internal/common/context.go
Normal file
@ -0,0 +1,20 @@
|
||||
package common
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
// GetGinUser 从 Gin context 中提取当前登录用户的 uid 和 role
|
||||
// 如果用户未登录,ok 返回 false;role 可能为空字符串
|
||||
func GetGinUser(c *gin.Context) (uid uint, role string, ok bool) {
|
||||
if v, exists := c.Get("uid"); exists {
|
||||
if u, isUint := v.(uint); isUint {
|
||||
uid = u
|
||||
ok = true
|
||||
}
|
||||
}
|
||||
if v, exists := c.Get("role"); exists {
|
||||
if r, isStr := v.(string); isStr {
|
||||
role = r
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user