From 0f180f17c351641d515b98b58eaec201f41b0cac Mon Sep 17 00:00:00 2001 From: AskaEth Date: Tue, 23 Jun 2026 18:55:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=97=A7=E9=85=8D=E7=BD=AE=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=BF=81=E7=A7=BB=20=E2=80=94=20=E8=A1=A5ID=20+=20qq?= =?UTF-8?q?=E2=86=92obv11=20+=20platform=5Fconfigs.json=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - load() 自动为无ID旧配置生成唯一标识符 - 自动迁移 platform: qq→obv11, config名 qq→obv11 - platform_configs.json 已迁移: qq→obv11-main - OBv11 adapter 已连接 (NapCat client模式) Co-Authored-By: Claude --- .../platform-bridge/internal/config/store.go | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/backend/platform-bridge/internal/config/store.go b/backend/platform-bridge/internal/config/store.go index 64dabc7..8e2cf50 100644 --- a/backend/platform-bridge/internal/config/store.go +++ b/backend/platform-bridge/internal/config/store.go @@ -4,6 +4,7 @@ import ( "crypto/rand" "encoding/hex" "encoding/json" + "strings" "fmt" "os" "sync" @@ -57,10 +58,30 @@ func (s *Store) load() error { return fmt.Errorf("parse config file: %w", err) } // Backward compat: old configs without platform field default to Name. + // Also migrate: generate IDs, rename qq→obv11. + needsSave := false for _, c := range s.configs { if c.Platform == "" { c.Platform = c.Name + needsSave = true } + if c.ID == "" { + c.ID = generateConfigID() + c.CreatedAt = time.Now() + needsSave = true + } + if c.Platform == "qq" { + c.Platform = "obv11" + needsSave = true + } + if strings.Contains(c.Name, "qq") { + c.Name = strings.ReplaceAll(c.Name, "qq", "obv11") + c.Label = strings.ReplaceAll(c.Label, "QQ", "OBv11") + needsSave = true + } + } + if needsSave { + s.save() } return nil }