feat: MBTI头像与用户规则链路升级,三端页面与接口同步

Made-with: Cursor
This commit is contained in:
卡若
2026-03-24 01:22:50 +08:00
parent fa3da12b16
commit 1d56d0336c
71 changed files with 3848 additions and 1621 deletions

View File

@@ -685,8 +685,34 @@ func userTrackActionLabelCN(action string) string {
return "绑定微信"
case "fill_profile":
return "完善资料"
case "fill_avatar":
return "设置头像"
case "visit_page":
return "访问页面"
case "first_pay":
return "首次付款"
case "vip_activate":
return "开通会员"
case "click_super":
return "点击超级个体"
case "lead_submit":
return "提交留资"
case "withdraw":
return "申请提现"
case "referral_bind":
return "绑定推荐人"
case "card_click":
return "点击名片"
case "btn_click":
return "按钮点击"
case "tab_click":
return "切换标签"
case "nav_click":
return "导航点击"
case "page_view":
return "页面浏览"
case "search":
return "搜索"
default:
if action == "" {
return "行为"
@@ -695,6 +721,41 @@ func userTrackActionLabelCN(action string) string {
}
}
// userTrackModuleLabelCN 埋点 module 英文字段 → 中文位置(与用户旅程、群播报一致)
func userTrackModuleLabelCN(module string) string {
m := strings.TrimSpace(strings.ToLower(module))
switch m {
case "":
return ""
case "home", "index":
return "首页"
case "chapters":
return "目录"
case "match":
return "找伙伴"
case "my":
return "我的"
case "read", "reading":
return "阅读"
case "vip":
return "会员中心"
case "referral":
return "推广中心"
case "member_detail", "member-detail", "memberdetail":
return "超级个体详情"
case "profile", "profile_show", "profile-show":
return "个人资料"
case "search":
return "搜索"
case "wallet":
return "钱包"
case "settings":
return "设置"
default:
return module
}
}
func humanTimeAgoCN(t time.Time) string {
if t.IsZero() {
return ""
@@ -803,6 +864,16 @@ func UserTrackGet(c *gin.Context) {
chapterTitle = v
}
}
var extra map[string]interface{}
if len(t.ExtraData) > 0 {
_ = json.Unmarshal(t.ExtraData, &extra)
}
module := ""
if extra != nil {
if m, ok := extra["module"].(string); ok {
module = m
}
}
var createdAt time.Time
if t.CreatedAt != nil {
createdAt = *t.CreatedAt
@@ -813,6 +884,8 @@ func UserTrackGet(c *gin.Context) {
"actionLabel": userTrackActionLabelCN(t.Action),
"target": target,
"chapterTitle": chapterTitle,
"module": module,
"moduleLabel": userTrackModuleLabelCN(module),
"createdAt": t.CreatedAt,
"timeAgo": humanTimeAgoCN(createdAt),
})
@@ -865,6 +938,7 @@ func DBUserTracksList(c *gin.Context) {
out = append(out, gin.H{
"id": t.ID, "action": t.Action, "actionLabel": userTrackActionLabelCN(t.Action),
"target": target, "chapterTitle": chTitle, "module": module,
"moduleLabel": userTrackModuleLabelCN(module),
"createdAt": t.CreatedAt, "timeAgo": humanTimeAgoCN(createdAt),
})
}
@@ -905,10 +979,11 @@ func GetUserRecentTracks(db *gorm.DB, userId string, limit int) []string {
}
}
var line string
modCN := userTrackModuleLabelCN(module)
if target != "" {
line = fmt.Sprintf("%s: %s", label, sanitizeDisplayOneLine(target))
} else if module != "" {
line = fmt.Sprintf("%s (%s)", label, module)
} else if modCN != "" {
line = fmt.Sprintf("%s · %s", label, modCN)
} else {
line = label
}