refactor: 重写导航栏布局与交互

- 导航项重新排序:首页、投稿、信封图标、头像下拉菜单
- 铃铛图标替换为信封图标
- 用户名/设置/退出移入头像 hover 下拉菜单
- 设置改名为个人中心,退出改名为退出登录
- 头像点击跳转 /space,hover 展开下拉菜单
- 无头像时显示用户名首字彩色圆形占位
- Avatar 数据链路打通:Session→Middleware→BuildPageData→模板
- FindByIDForAuth 查询增加 avatar 列
- 新增 substr 模板函数
This commit is contained in:
2026-05-31 16:17:35 +08:00
parent a3f787ddaf
commit 9fe87a7003
8 changed files with 174 additions and 44 deletions

View File

@ -74,11 +74,10 @@ func (r *UserRepo) ExistsByEmailExclude(email string, excludeUID uint) (bool, er
return count > 0, err
}
// FindByIDForAuth 认证专用查询:返回 uid/email/username/role/status
// 比 FindByID 轻量(不查 avatar、bio 等无用字段),避免全量 SELECT *
// FindByIDForAuth 认证专用查询:返回 uid/email/username/avatar/role/status
func (r *UserRepo) FindByIDForAuth(userID uint) (*model.User, error) {
var user model.User
err := r.db.Select("uid", "email", "username", "role", "status").
err := r.db.Select("uid", "email", "username", "avatar", "role", "status").
First(&user, userID).Error
if err != nil {
return nil, err