feat(remote): 支持单行连接与同机实例继承
- 远端地址和注册令牌合并为单行填写\n- 同机实例通过机器级配置继承远端连接\n- 实例令牌仍按实例独立保存
This commit is contained in:
@@ -187,6 +187,14 @@ func (a *App) Startup(ctx context.Context) {
|
||||
|
||||
// 优先初始化调度器和账号库,避免前端首屏请求早于启动网络探测时读到 nil。
|
||||
cfg := config.LoadConfig(a.paths.ConfigFile)
|
||||
profileFound := false
|
||||
if profile, ok, err := config.LoadMachineRemoteProfile(); err != nil {
|
||||
logger.LogEvent("配置", "warn", "读取本机共享远端配置失败: %v", err)
|
||||
} else if ok {
|
||||
config.ApplyMachineRemoteProfile(&cfg, profile)
|
||||
profileFound = true
|
||||
logger.LogEvent("配置", "success", "已继承本机共享远端配置")
|
||||
}
|
||||
sharedPath := strings.TrimSpace(cfg.SharedProxyConfigFile)
|
||||
if sharedPath == "" {
|
||||
if inheritedPath, err := config.LoadSharedProxyConfigPointer(); err != nil {
|
||||
@@ -205,6 +213,11 @@ func (a *App) Startup(ctx context.Context) {
|
||||
logger.LogEvent("配置", "success", "已加载共享代理配置: %s", sharedPath)
|
||||
}
|
||||
}
|
||||
if !profileFound && cfg.RemoteEnabled {
|
||||
if err := config.SaveMachineRemoteProfile(cfg); err != nil {
|
||||
logger.LogEvent("配置", "warn", "初始化本机共享远端配置失败: %v", err)
|
||||
}
|
||||
}
|
||||
a.setCfg(cfg)
|
||||
logger.SetMinLevel(cfg.LogLevel)
|
||||
a.replaceTrace(cfg)
|
||||
|
||||
@@ -180,6 +180,9 @@ func (a *App) SaveSettings(cfg types.Config) types.ErrorResult {
|
||||
cfg.RemoteToken != oldCfg.RemoteToken ||
|
||||
cfg.RemoteMachineName != oldCfg.RemoteMachineName
|
||||
if remoteChanged {
|
||||
if err := config.SaveMachineRemoteProfile(cfg); err != nil {
|
||||
logger.LogEvent("配置", "warn", "保存本机共享远端配置失败: %v", err)
|
||||
}
|
||||
a.configureRemote(cfg)
|
||||
}
|
||||
if clientChanged {
|
||||
|
||||
Reference in New Issue
Block a user