fix: 应用 xhigh 代码评审的跨端修复
ci / server (push) Failing after 13s
ci / design-tokens (push) Failing after 11s

来自 xhigh code review 的正确性/健壮性修复,覆盖全部五端:
- server:鉴权 fail-closed、计量交叉校验与配额扣穿处理、WS 网关并发与关闭顺序、
  billing 行锁、redis Lua 过期与设备槽刷新、config 解析
- desktop:会话 epoch 防串话、WS 重连与 401 处理、api 客户端复用、统一 usePoll 轮询
- android:握手时序、请求头封装、账户状态派生、按需重组
- ios:finalize 宽限、串行采集、错误文案服务端优先、删除死代码 CommitController

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-13 11:50:08 +08:00
parent 50b49f3cbe
commit b5ab92a57e
42 changed files with 2125 additions and 469 deletions
+5 -16
View File
@@ -3,11 +3,8 @@ package user
import (
"net/http"
"os"
"time"
"encoding/json"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
"gorm.io/gorm/clause"
@@ -21,6 +18,8 @@ import (
type Handlers struct {
DB *gorm.DB
Quota *quota.Manager
// AppVersions 启动时由 config 解析好的平台→版本信息(17G);nil/空表示未配置。
AppVersions map[string]protocol.AppLatestResponse
}
// Me GET /v1/me(需登录):余额/试用/账户态聚合 + 设备心跳登记。
@@ -75,20 +74,10 @@ func (h *Handlers) touchDevice(c *gin.Context, uid string) {
}
// AppLatest GET /v1/app/latest?platform=mac|win|android|ios 🔓
// 版本信息来自 APP_LATEST_JSON 环境变量{"mac":{"version":...,"url":...},...}),
// MVP 不建表;未配置平台返回 204。
// 版本信息来自启动时 config 解析好的 APP_LATEST_JSON17G{"mac":{"version":...,"url":...},...}),
// MVP 不建表;未配置/未知平台返回 204。
func (h *Handlers) AppLatest(c *gin.Context) {
raw := os.Getenv("APP_LATEST_JSON")
if raw == "" {
c.Status(http.StatusNoContent)
return
}
var all map[string]protocol.AppLatestResponse
if err := json.Unmarshal([]byte(raw), &all); err != nil {
c.Status(http.StatusNoContent)
return
}
if v, ok := all[c.Query("platform")]; ok {
if v, ok := h.AppVersions[c.Query("platform")]; ok {
c.JSON(http.StatusOK, v)
return
}