refactor(proxy): remove global auto-start flag

- Remove global proxy auto-start flag from config and UI.
- Simplify per-app takeover start/stop and stop server when the last takeover is disabled.
- Restore live takeover detection used for crash recovery.
- Keep proxy_config.enabled column but always write 0 for compatibility.
- Tests: not run (not requested).
This commit is contained in:
Jason
2025-12-20 08:48:59 +08:00
parent b6ff721d67
commit ba59483b33
7 changed files with 60 additions and 142 deletions
+11 -9
View File
@@ -26,8 +26,11 @@ import { useTranslation } from "react-i18next";
import type { TFunction } from "i18next";
import type { ProxyConfig } from "@/types/proxy";
// 表单数据类型(包含 enabled 字段,该字段由后端自动管理
type ProxyConfigForm = Omit<ProxyConfig, "enabled">;
// 表单数据类型(包含可编辑字段
type ProxyConfigForm = Pick<
ProxyConfig,
"listen_address" | "listen_port" | "max_retries" | "request_timeout" | "enable_logging"
>;
const createProxyConfigSchema = (t: TFunction) => {
const requestTimeoutSchema = z
@@ -120,19 +123,18 @@ export function ProxySettingsDialog({
useEffect(() => {
if (config) {
form.reset({
...config,
listen_address: config.listen_address,
listen_port: config.listen_port,
max_retries: config.max_retries,
request_timeout: config.request_timeout,
enable_logging: config.enable_logging,
});
}
}, [config, form]);
const onSubmit = async (data: ProxyConfigForm) => {
try {
// 添加 enabled 字段(从当前配置中获取,保持不变)
const configToSave: ProxyConfig = {
...data,
enabled: config?.enabled ?? true,
};
await updateConfig(configToSave);
await updateConfig(data);
closePanel();
} catch (error) {
console.error("Save config failed:", error);