feat(failover): add auto-failover master switch with proxy integration (#427)

* feat(failover): add auto-failover master switch with proxy integration

- Add persistent auto_failover_enabled setting in database
- Add get/set_auto_failover_enabled commands
- Provider router respects master switch state
- Proxy shutdown automatically disables failover
- Enabling failover auto-starts proxy server
- Optimistic updates for failover queue toggle

* feat(proxy): persist proxy takeover state across app restarts

- Add proxy_takeover_{app_type} settings for per-app state tracking
- Restore proxy takeover state automatically on app startup
- Preserve state on normal exit, clear on manual stop
- Add stop_with_restore_keep_state method for graceful shutdown

* fix(proxy): set takeover state for all apps in start_with_takeover
This commit is contained in:
YoVinchen
2025-12-21 22:39:50 +08:00
committed by GitHub
parent f047960a33
commit a1537807eb
25 changed files with 479 additions and 141 deletions
+8 -4
View File
@@ -51,7 +51,8 @@ export function useProxyStatus() {
},
onError: (error: Error) => {
const detail =
extractErrorMessage(error) || t("common.unknown", { defaultValue: "未知错误" });
extractErrorMessage(error) ||
t("common.unknown", { defaultValue: "未知错误" });
toast.error(
t("proxy.server.startFailed", {
defaultValue: `启动代理服务失败: ${detail}`,
@@ -77,7 +78,8 @@ export function useProxyStatus() {
},
onError: (error: Error) => {
const detail =
extractErrorMessage(error) || t("common.unknown", { defaultValue: "未知错误" });
extractErrorMessage(error) ||
t("common.unknown", { defaultValue: "未知错误" });
toast.error(
t("proxy.stopWithRestoreFailed", {
defaultValue: `停止失败: ${detail}`,
@@ -114,7 +116,8 @@ export function useProxyStatus() {
},
onError: (error: Error) => {
const detail =
extractErrorMessage(error) || t("common.unknown", { defaultValue: "未知错误" });
extractErrorMessage(error) ||
t("common.unknown", { defaultValue: "未知错误" });
toast.error(
t("proxy.takeover.failed", {
defaultValue: `操作失败: ${detail}`,
@@ -137,7 +140,8 @@ export function useProxyStatus() {
},
onError: (error: Error) => {
const detail =
extractErrorMessage(error) || t("common.unknown", { defaultValue: "未知错误" });
extractErrorMessage(error) ||
t("common.unknown", { defaultValue: "未知错误" });
toast.error(
t("proxy.switchFailed", {
error: detail,