mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-04-10 13:10:14 +08:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user