diff --git a/src/App.tsx b/src/App.tsx index 9025499..3fd7737 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -114,7 +114,7 @@ function App() { unlisten(); } }; - }, [activeApp, isAutoSyncEnabled]); // 依赖自动同步状态,确保拿到最新开关 + }, [activeApp, isAutoSyncEnabled]); const loadProviders = async () => { const loadedProviders = await window.api.getProviders(activeApp); @@ -183,7 +183,7 @@ function App() { }); }; - // 同步Codex供应商到VS Code设置 + // 同步Codex供应商到VS Code设置(静默覆盖) const syncCodexToVSCode = async (providerId: string, silent = false) => { try { const status = await window.api.getVSCodeSettingsStatus(); diff --git a/src/components/SettingsModal.tsx b/src/components/SettingsModal.tsx index e183e29..e4f5b42 100644 --- a/src/components/SettingsModal.tsx +++ b/src/components/SettingsModal.tsx @@ -11,7 +11,6 @@ import { getVersion } from "@tauri-apps/api/app"; import "../lib/tauri-api"; import { relaunchApp } from "../lib/updater"; import { useUpdate } from "../contexts/UpdateContext"; -import { useVSCodeAutoSync } from "../hooks/useVSCodeAutoSync"; import type { Settings } from "../types"; interface SettingsModalProps { @@ -29,7 +28,6 @@ export default function SettingsModal({ onClose }: SettingsModalProps) { const [showUpToDate, setShowUpToDate] = useState(false); const { hasUpdate, updateInfo, updateHandle, checkUpdate, resetDismiss } = useUpdate(); - const { isAutoSyncEnabled, toggleAutoSync } = useVSCodeAutoSync(); useEffect(() => { loadSettings(); @@ -203,28 +201,7 @@ export default function SettingsModal({ onClose }: SettingsModalProps) { */} - {/* VS Code 自动同步设置 */} -
-

- Codex 设置 -

- -
+ {/* VS Code 自动同步设置已移除 */} {/* 配置文件位置 */}
diff --git a/src/hooks/useVSCodeAutoSync.ts b/src/hooks/useVSCodeAutoSync.ts index 42564a4..c762eab 100644 --- a/src/hooks/useVSCodeAutoSync.ts +++ b/src/hooks/useVSCodeAutoSync.ts @@ -4,7 +4,8 @@ const VSCODE_AUTO_SYNC_KEY = "vscode-auto-sync-enabled"; const VSCODE_AUTO_SYNC_EVENT = "vscode-auto-sync-changed"; export function useVSCodeAutoSync() { - const [isAutoSyncEnabled, setIsAutoSyncEnabled] = useState(false); + // 默认开启自动同步;若本地存储存在记录,则以记录为准 + const [isAutoSyncEnabled, setIsAutoSyncEnabled] = useState(true); // 从 localStorage 读取初始状态 useEffect(() => { @@ -22,7 +23,9 @@ export function useVSCodeAutoSync() { useEffect(() => { const onCustom = (e: Event) => { try { - const detail = (e as CustomEvent).detail as { enabled?: boolean } | undefined; + const detail = (e as CustomEvent).detail as + | { enabled?: boolean } + | undefined; if (detail && typeof detail.enabled === "boolean") { setIsAutoSyncEnabled(detail.enabled); } else { @@ -42,7 +45,10 @@ export function useVSCodeAutoSync() { window.addEventListener(VSCODE_AUTO_SYNC_EVENT, onCustom as EventListener); window.addEventListener("storage", onStorage); return () => { - window.removeEventListener(VSCODE_AUTO_SYNC_EVENT, onCustom as EventListener); + window.removeEventListener( + VSCODE_AUTO_SYNC_EVENT, + onCustom as EventListener, + ); window.removeEventListener("storage", onStorage); }; }, []);