Repo .git was damaged (refs/ missing, index truncated, object store near-empty). Repaired via git init (rebuilt refs), stale index preserved as .git/index.corrupt-20260910.bak, then full worktree committed as a rollback baseline.
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
// Copyright 2022 E99p1ant. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package route
|
|
|
|
import (
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"github.com/tamakyi/TamaBox/internal/context"
|
|
"github.com/tamakyi/TamaBox/internal/i18n"
|
|
"github.com/tamakyi/TamaBox/internal/stats"
|
|
)
|
|
|
|
func Home(ctx context.Context) {
|
|
if v, err := stats.Get(ctx.Request().Context()); err != nil {
|
|
logrus.WithContext(ctx.Request().Context()).WithError(err).Warn("Failed to compute site stats")
|
|
} else {
|
|
ctx.Data["SiteStats"] = v
|
|
}
|
|
ctx.Success("home")
|
|
}
|
|
|
|
// SiteStatsAPI 返回首页"提问箱信息统计"的 JSON(服务端 30 分钟缓存),
|
|
// 供前端 setInterval 定时刷新,避免重新加载整页。
|
|
func SiteStatsAPI(ctx context.Context) error {
|
|
v, err := stats.Get(ctx.Request().Context())
|
|
if err != nil {
|
|
return ctx.JSONError(50000, i18n.T(ctx.Lang(), "home.errStats"))
|
|
}
|
|
return ctx.JSON(v)
|
|
}
|
|
|
|
func Sponsor(ctx context.Context) {
|
|
ctx.Success("sponsor")
|
|
}
|
|
|
|
func AboutMe(ctx context.Context) {
|
|
ctx.Success("about-me")
|
|
}
|
|
|
|
func ChangeLogs(ctx context.Context) {
|
|
ctx.Success("change-logs")
|
|
}
|