fix: patch clash config

This commit is contained in:
GyDi 2022-11-18 18:37:17 +08:00
parent d759f48ee8
commit b7c3863882
No known key found for this signature in database
GPG Key ID: 9C3AD40F1F99880A
2 changed files with 10 additions and 4 deletions

View File

@ -169,7 +169,9 @@ pub async fn patch_clash(patch: Mapping) -> Result<()> {
|| patch.get("secret").is_some() || patch.get("secret").is_some()
|| patch.get("external-controller").is_some() || patch.get("external-controller").is_some()
{ {
Config::generate()?;
CoreManager::global().run_core().await?; CoreManager::global().run_core().await?;
handle::Handle::refresh_clash();
} }
// 更新系统代理 // 更新系统代理

View File

@ -61,10 +61,14 @@ const ClashPortViewer = ({ handler }: Props) => {
setOpen(false); setOpen(false);
if (port === config?.["mixed-port"]) return; if (port === config?.["mixed-port"]) return;
try {
await patchClashConfig({ "mixed-port": port }); await patchClashConfig({ "mixed-port": port });
setGlobalClashPort(port); setGlobalClashPort(port);
Notice.success("Change Clash port successfully!", 1000); Notice.success("Change Clash port successfully!", 1000);
mutateClash(); mutateClash();
} catch (err: any) {
Notice.error(err.message || err.toString(), 5000);
}
}); });
return ( return (