fix(proxy): disable auto-start on app launch by resetting enabled flag on stop

Previously, when proxy was started, the enabled flag was set to true and
persisted to database. However, stopping the proxy didn't reset this flag,
causing the proxy to auto-start on every subsequent app launch.

Now the enabled flag is set to false when proxy stops, ensuring the proxy
remains off after restart unless explicitly started by the user.
This commit is contained in:
Jason
2025-12-11 12:32:02 +08:00
parent 9a8f12a490
commit 404ab5a1ae

View File

@@ -260,6 +260,13 @@ impl ProxyService {
.stop()
.await
.map_err(|e| format!("停止代理服务器失败: {e}"))?;
// 将 enabled 设为 false避免下次启动时自动开启
if let Ok(mut config) = self.db.get_proxy_config().await {
config.enabled = false;
let _ = self.db.update_proxy_config(config).await;
}
log::info!("代理服务器已停止");
Ok(())
} else {