fix templates v2

This commit is contained in:
tamakyi
2026-10-22 17:49:25 +08:00
parent bd02eb7ed2
commit b939d26ff0
11 changed files with 436 additions and 60 deletions
+6 -2
View File
@@ -276,7 +276,7 @@ func PublishAnswer(ctx context.Context, pageUser *db.User, question *db.Question
return
}
}
ctx.Redirect(fmt.Sprintf("/_/%s/%d", pageUser.Domain, question.ID))
ctx.Redirect(questionPath(ctx, pageUser.Domain, question.ID))
}
func Delete(ctx context.Context, pageUser *db.User, question *db.Question, canDelete bool) {
@@ -459,12 +459,16 @@ func questionPath(ctx context.Context, domain string, questionID uint) string {
// adminBackQuery 提取后台列表的筛选参数(仅 from=admin 时有效),供单题页的
// 「返回」「下一条未读」沿用。POST 请求从表单 action 的 query 里读取。
// 返回值始终带 from=admin:调用方会把它重新写进表单 action 与跳转地址,
// 少一个 from,下一次 POST 就认不出来源了。
func adminBackQuery(ctx context.Context) string {
if ctx.Query("from") != "admin" {
return ""
}
backQuery := url.Values{}
// from 必须随表单 action 回到 POST:ctx.Query 只读 URL query,
// 少了它就认不出来源,「返回」会掉回箱主页。
backQuery := url.Values{"from": {"admin"}}
for _, key := range []string{"sort", "status", "type", "read", "q"} {
if v := ctx.Query(key); v != "" {
backQuery.Set(key, v)