fix typo error

This commit is contained in:
tamakyi
2026-09-10 19:27:21 +08:00
parent 8e2325eda5
commit e683e798aa
9 changed files with 176 additions and 109 deletions
+5 -1
View File
@@ -28,6 +28,10 @@ const (
ProfileTabQuestion = db.FeatureQuestion
ProfileTabChat = db.FeatureChat
ProfileTabVote = db.FeatureVote
// ProfileTabSecurity 与受控功能无关:聚合「内容防护」类设置
// (防骚扰、屏蔽词、审核严格度、页面访问密码、提问密码),
// 这些设置横跨多个功能,原先散落在提问/私聊/投票面板(屏蔽词与审核严格度还被重复渲染 3 份)。
ProfileTabSecurity = "security"
)
// profileURLWithTab 账号设置页 + 指定面板的回跳地址,用于保存后停留在原面板。
@@ -38,7 +42,7 @@ func profileURLWithTab(tab string) string {
// ProfileTab 归一化账号设置页的 tab 参数,非法值回落到用户设置面板。
func ProfileTab(tab string) string {
switch tab {
case ProfileTabQuestion, ProfileTabChat, ProfileTabVote:
case ProfileTabQuestion, ProfileTabChat, ProfileTabVote, ProfileTabSecurity:
return tab
}
return ProfileTabAccount
+7 -5
View File
@@ -17,7 +17,8 @@ import (
func UpdatePagePassword(ctx context.Context, f form.UpdatePagePassword) {
// 反序列化失败(如请求体超限)时零值 Password="" 会把密码静默解除——先中止,
// 不触碰现有密码。govalid 校验失败(如密码超长)同样在此拦截,避免绕过前端限制。
if abortOnFormError(ctx, "/user/profile") {
// 该表单已随「内容防护」聚合迁入 security 面板,回跳地址跟随表单携带的 ?tab=。
if abortOnFormError(ctx, returnTab(ctx)) {
return
}
@@ -31,13 +32,14 @@ func UpdatePagePassword(ctx context.Context, f form.UpdatePagePassword) {
ctx.SetSuccessFlash(i18n.T(ctx.Lang(), "admin.flash.pagePwdUpdated"))
}
}
ctx.Redirect("/user/profile")
ctx.Redirect(returnTab(ctx))
}
// UpdateAskPassword 更新提问密码
func UpdateAskPassword(ctx context.Context, f form.UpdateAskPassword) {
// 同上:反序列化失败或校验失败时零值 Password="" 会把提问密码静默解除。
if abortOnFormError(ctx, profileURLWithTab(ProfileTabQuestion)) {
// 回跳地址跟随表单携带的 ?tab=(该表单已迁入「内容防护」security 面板)。
if abortOnFormError(ctx, returnTab(ctx)) {
return
}
@@ -51,6 +53,6 @@ func UpdateAskPassword(ctx context.Context, f form.UpdateAskPassword) {
ctx.SetSuccessFlash(i18n.T(ctx.Lang(), "admin.flash.askPwdUpdated"))
}
}
// 提问密码属于提问功能的专属设置,保存后回到「提问」面板
ctx.Redirect(profileURLWithTab(ProfileTabQuestion))
// 保存后回到提交时所在的面板(内容防护面板)
ctx.Redirect(returnTab(ctx))
}