From 23f964e768243d2d1d37702d00de84d6b7deae71 Mon Sep 17 00:00:00 2001 From: yml2213 Date: Sat, 17 Oct 2026 18:58:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(config):=20=E5=B0=86=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=20SID=20=E6=9B=B4=E6=96=B0=E4=B8=BA=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E6=B4=BB=E5=8A=A8=202277?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 后端默认值与测试:DefaultConfig 默认 SID 改为 2277(旧活动 2203 已停止返回商品),更新单元测试断言 - 前端默认值与平滑迁移:pickConfig 默认 SID 设为 2277,localStorage 自动将旧版 2203 迁移至 2277 - 验证:Go 单测与 Vite 前端打包干净通过 --- frontend/src/App.tsx | 14 +++++++++++++- internal/gui/app.go | 2 +- internal/gui/app_test.go | 3 +++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 07cbbd5..7e0e3c1 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -66,6 +66,9 @@ const leadDefaultMigrationBase = 'huya-go.gui.lead-default.v1' const legacyDefaultLeadMs = 2500 const concurrencyDefaultMigrationBase = 'huya-go.gui.concurrency-v30.v1' const defaultConcurrency = 30 +const legacyDefaultSID = 2203 +const defaultSID = 2277 +const sidDefaultMigrationBase = 'huya-go.gui.sid-v2277.v1' // 界面本地存储保留的日志上限,与后端的增量拉取配合使用。 const maxClientLogs = 1000 @@ -561,6 +564,15 @@ function readSavedConfig(): Partial { localStorage.setItem(concurrencyMigrationKey, '1') } + const sidMigrationKey = scopedKey(sidDefaultMigrationBase) + if (!localStorage.getItem(sidMigrationKey)) { + if (Number(saved.sid || 0) === legacyDefaultSID || !saved.sid) { + saved.sid = defaultSID + dirty = true + } + localStorage.setItem(sidMigrationKey, '1') + } + if (dirty) { // 迁移必须立即落盘,否则下一次 readSavedConfig 又会读回旧值。 localStorage.setItem(configKey, JSON.stringify(saved)) @@ -668,7 +680,7 @@ function pickConfig(values: Partial): UiConfig { return { transport: values.transport || 'wss', wssHost: values.wssHost || '', - sid: Number(values.sid || 2203), + sid: Number(values.sid || defaultSID), pid: Number(values.pid || 0), name: values.name || '', category: values.category || '', diff --git a/internal/gui/app.go b/internal/gui/app.go index 5ce0890..8f6a6d9 100644 --- a/internal/gui/app.go +++ b/internal/gui/app.go @@ -299,7 +299,7 @@ func (a *App) DefaultConfig() Config { return Config{ Transport: "wss", WSSHost: "", - SID: 2203, + SID: 2277, DelayMS: 120, // 线程是「同时在途请求数」上限。单机单实例默认 30, // 5 个多开实例整机约 150 并发(与斗鱼单机 150 吞吐相当)。 diff --git a/internal/gui/app_test.go b/internal/gui/app_test.go index 42f2607..c4ea6e0 100644 --- a/internal/gui/app_test.go +++ b/internal/gui/app_test.go @@ -70,6 +70,9 @@ func TestParseAccountsRequiresExplicitSelection(t *testing.T) { func TestDefaultConfigUsesWindowMode(t *testing.T) { cfg := (&App{}).DefaultConfig() + if cfg.SID != 2277 { + t.Fatalf("SID=%d, want 2277(最新活动 SID)", cfg.SID) + } if cfg.LeadMS != 0 { t.Fatalf("LeadMS=%d, want 0(动态提前量)", cfg.LeadMS) }