diff --git a/src/components/setting/mods/service-viewer.tsx b/src/components/setting/mods/service-viewer.tsx index 2bfbeb0..839c8c2 100644 --- a/src/components/setting/mods/service-viewer.tsx +++ b/src/components/setting/mods/service-viewer.tsx @@ -24,7 +24,11 @@ export const ServiceViewer = forwardRef((props, ref) => { const { data: status, mutate: mutateCheck } = useSWR( "checkService", checkService, - { revalidateIfStale: false, shouldRetryOnError: false } + { + revalidateIfStale: false, + shouldRetryOnError: false, + focusThrottleInterval: 36e5, // 1 hour + } ); useImperativeHandle(ref, () => ({ @@ -64,9 +68,14 @@ export const ServiceViewer = forwardRef((props, ref) => { // fix unhandled error of the service mode const onDisable = useLockFn(async () => { - await patchVergeConfig({ enable_service_mode: false }); - mutateCheck(); - setOpen(false); + try { + await patchVergeConfig({ enable_service_mode: false }); + mutateCheck(); + setOpen(false); + } catch (err: any) { + mutateCheck(); + Notice.error(err.message || err.toString()); + } }); return ( @@ -81,8 +90,8 @@ export const ServiceViewer = forwardRef((props, ref) => { {(state === "unknown" || state === "uninstall") && ( - Information: Please make sure the Clash Verge Service is installed and - enabled + Information: Please make sure that the Clash Verge Service is + installed and enabled )} diff --git a/src/components/setting/setting-system.tsx b/src/components/setting/setting-system.tsx index 0dbf326..7fdeb8f 100644 --- a/src/components/setting/setting-system.tsx +++ b/src/components/setting/setting-system.tsx @@ -27,7 +27,11 @@ const SettingSystem = ({ onError }: Props) => { const { data: serviceStatus } = useSWR( isWIN ? "checkService" : null, checkService, - { revalidateIfStale: false, shouldRetryOnError: false } + { + revalidateIfStale: false, + shouldRetryOnError: false, + focusThrottleInterval: 36e5, // 1 hour + } ); const serviceRef = useRef(null); @@ -70,47 +74,49 @@ const SettingSystem = ({ onError }: Props) => { serviceRef.current?.open()} - /> - ) - } - > - {serviceStatus === "active" || serviceStatus === "installed" ? ( - onChangeData({ enable_service_mode: e })} - onGuard={(e) => patchVerge({ enable_service_mode: e })} - > - - - ) : ( serviceRef.current?.open()} > - + - )} + } + > + onChangeData({ enable_service_mode: e })} + onGuard={(e) => patchVerge({ enable_service_mode: e })} + > + + )} sysproxyRef.current?.open()} - /> + > + + } >