diff --git a/app.go b/app.go index fa45af5..fdb027d 100644 --- a/app.go +++ b/app.go @@ -54,6 +54,7 @@ type Base struct { MeID int64 // Me 的 ID(模板里比较用,未登录为 0) InApp bool // App 内置浏览器(X/微信等) HasBGM bool // static/bgm.m4a 存在才渲染背景音乐 + HomePath string // 左上角站名点回哪:刚才浏览的子站(cookie bhome),否则主站 NoIndex bool // 未收录的子站不让搜索引擎收录 Desc string // 页面描述(站点页用站名 + 口号) OGImage string // 分享缩略图(站点页用 X 头像) @@ -219,6 +220,10 @@ func (a *App) base(r *http.Request) Base { if b.Me != nil { b.MeID = b.Me.ID } + b.HomePath = "/" + if s := cookieVal(r, "bhome"); s != "" && validSlug(s) { + b.HomePath = "/" + s + } return b } diff --git a/handlers_site.go b/handlers_site.go index 5136763..b00992e 100644 --- a/handlers_site.go +++ b/handlers_site.go @@ -75,6 +75,12 @@ func (a *App) handleRoot(w http.ResponseWriter, r *http.Request) { func (a *App) renderSite(w http.ResponseWriter, r *http.Request, status int, site *Site, errMsg, nick, xh, amount, message string) { visitor := a.visitor(w, r) + // 记住「现在在逛哪个碗」:之后点左上角站名、看完排行榜都回到这里,而不是一律跳回总舵 + if site.IsMain() { + a.setCookie(w, "bhome", "", -1) + } else { + a.setCookie(w, "bhome", site.Slug, 24*3600) + } p := sitePage{Base: a.base(r), Site: site, Presets: a.cfg.PresetAmounts, Ready: site.PaymentReady(), Err: errMsg, Nick: nick, XHandle: xh, Amount: amount, Message: message, MinAmount: fmtE8(a.cfg.MinAmountE8), MaxAmount: fmtE8(a.cfg.MaxAmountE8), CoinsPerDay: a.cfg.CoinsPerDay} @@ -525,7 +531,7 @@ type rankPage struct { PgDonors, PgDonorsWeek, PgSites, PgSitesWeek, PgPopular Pager } -const rankPageSize = 35 +const rankPageSize = 10 var rankParams = []string{"da", "dw", "ba", "bw", "pp"} diff --git a/templates/layout.html b/templates/layout.html index bcdc683..01e887c 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -244,7 +244,7 @@ footer a{color:var(--muted)} {{if .HasBGM}}{{end}}