client: Windows 客户端(WinUI3 壳 + agent-core;调试用 Electron 壳存档);localserver token 改为常数时间比较

This commit is contained in:
Qiufeng
2026-08-20 20:38:21 +08:00
parent 33b7d57498
commit 9abf7f8213
60 changed files with 10025 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
package config
import (
"encoding/json"
"os"
"path/filepath"
)
// Config 客户端配置(data/config.json)
type Config struct {
Server string `json:"server"`
DeviceID uint64 `json:"deviceId"`
Name string `json:"name"`
Proxy string `json:"proxy"`
SimMS int `json:"simMs"`
FakeAll bool `json:"fakeAll"` // 全平台模拟执行(无真实账号联调用)
}
// Default 默认配置
func Default() *Config {
return &Config{Server: "http://127.0.0.1:8090", SimMS: 50}
}
// Load 读取配置(不存在则返回默认)
func Load(dir string) (*Config, error) {
cfg := Default()
raw, err := os.ReadFile(filepath.Join(dir, "config.json"))
if err != nil {
if os.IsNotExist(err) {
return cfg, nil
}
return nil, err
}
_ = json.Unmarshal(raw, cfg)
return cfg, nil
}
// Save 持久化配置
func (c *Config) Save(dir string) error {
if err := os.MkdirAll(dir, 0o700); err != nil {
return err
}
raw, _ := json.MarshalIndent(c, "", " ")
return os.WriteFile(filepath.Join(dir, "config.json"), raw, 0o600)
}