fix templates v3
This commit is contained in:
@@ -127,13 +127,21 @@ func Questioner(ctx context.Context, pageUser *db.User) {
|
||||
// 从后台返回时,把进入时携带的筛选参数(sort/status/type/read/q)原样回传,
|
||||
// 使"返回"跳回带筛选条件的后台列表,避免丢失已选的筛选/搜索条件。
|
||||
// 「下一条未读」同样带上这份参数,否则答完一条后"返回"就掉回箱主页了。
|
||||
// 表单 action 必须在这里拼成「完整 URL」再交给模板:写成 action="...?{{ .NextQuery }}"
|
||||
// 时 html/template 会把这段当成 URL 的查询值编码,= 与 & 变成 %3d / %26,
|
||||
// 服务端再也解析不出来源(实测过)。完整 URL 只会把 & 转成 &,浏览器会还原。
|
||||
if backQuery := adminBackQuery(ctx); backFrom == "admin" {
|
||||
backTo := "/user/questions"
|
||||
answerAction := fmt.Sprintf("/_/%s/%d/answer", pageUser.Domain, question.ID)
|
||||
nextUnreadAction := fmt.Sprintf("/_/%s/%d/next-unread", pageUser.Domain, question.ID)
|
||||
if backQuery != "" {
|
||||
backTo += "?" + backQuery
|
||||
answerAction += "?" + backQuery
|
||||
nextUnreadAction += "?" + backQuery
|
||||
}
|
||||
ctx.Data["BackTo"] = backTo
|
||||
ctx.Data["NextQuery"] = backQuery
|
||||
ctx.Data["AnswerAction"] = answerAction
|
||||
ctx.Data["NextUnreadAction"] = nextUnreadAction
|
||||
}
|
||||
|
||||
ctx.Map(question)
|
||||
|
||||
Reference in New Issue
Block a user