fix: 旧配置自动迁移 — 补ID + qq→obv11 + platform_configs.json同步
- load() 自动为无ID旧配置生成唯一标识符 - 自动迁移 platform: qq→obv11, config名 qq→obv11 - platform_configs.json 已迁移: qq→obv11-main - OBv11 adapter 已连接 (NapCat client模式) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"strings"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -57,10 +58,30 @@ func (s *Store) load() error {
|
|||||||
return fmt.Errorf("parse config file: %w", err)
|
return fmt.Errorf("parse config file: %w", err)
|
||||||
}
|
}
|
||||||
// Backward compat: old configs without platform field default to Name.
|
// Backward compat: old configs without platform field default to Name.
|
||||||
|
// Also migrate: generate IDs, rename qq→obv11.
|
||||||
|
needsSave := false
|
||||||
for _, c := range s.configs {
|
for _, c := range s.configs {
|
||||||
if c.Platform == "" {
|
if c.Platform == "" {
|
||||||
c.Platform = c.Name
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user