diff --git a/changelog.md b/changelog.md index 08aabef..6526bc1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,7 @@ ### New Features -- 支持应用内自动更新 +- 支持设置是否存储选择节点 ### Bug Fixes -- 修复某些Mac设备无法开启虚拟网卡的问题 +- 修复单例检测与一键导入冲突的问题 diff --git a/src/main/utils/template.ts b/src/main/utils/template.ts index 6bb874c..6e88e4c 100644 --- a/src/main/utils/template.ts +++ b/src/main/utils/template.ts @@ -40,6 +40,7 @@ export const defaultControledMihomoConfig: Partial = { 'tproxy-port': 0, 'allow-lan': false, 'unified-delay': false, + 'tcp-concurrent': false, 'log-level': 'info', 'find-process-mode': 'strict', tun: { @@ -82,6 +83,10 @@ export const defaultControledMihomoConfig: Partial = { }, 'skip-domain': ['+.push.apple.com'] }, + profile: { + 'store-selected': true, + 'store-fake-ip': true + }, 'geo-auto-update': false, 'geo-update-interval': 24, 'geodata-mode': false, diff --git a/src/renderer/src/pages/mihomo.tsx b/src/renderer/src/pages/mihomo.tsx index 7976b54..6a83825 100644 --- a/src/renderer/src/pages/mihomo.tsx +++ b/src/renderer/src/pages/mihomo.tsx @@ -5,7 +5,7 @@ import SettingItem from '@renderer/components/base/base-setting-item' import { useAppConfig } from '@renderer/hooks/use-app-config' import { useControledMihomoConfig } from '@renderer/hooks/use-controled-mihomo-config' import { platform } from '@renderer/utils/init' -import { patchMihomoConfig, restartCore } from '@renderer/utils/ipc' +import { restartCore } from '@renderer/utils/ipc' import React, { useState } from 'react' const CoreMap = { @@ -21,16 +21,19 @@ const Mihomo: React.FC = () => { ipv6, 'external-controller': externalController, secret, - 'log-level': level = 'info', - 'find-process-mode': mode = 'strict', - 'allow-lan': lan, - 'unified-delay': delay, + 'log-level': logLevel = 'info', + 'find-process-mode': findProcessMode = 'strict', + 'allow-lan': allowLan, + 'unified-delay': unifiedDelay, + 'tcp-concurrent': tcpConcurrent, 'mixed-port': mixedPort = 7890, 'socks-port': socksPort = 7891, port: httpPort = 7892, 'redir-port': redirPort = 0, - 'tproxy-port': tproxyPort = 0 + 'tproxy-port': tproxyPort = 0, + profile = {} } = controledMihomoConfig || {} + const { 'store-selected': storeSelected, 'store-fake-ip': storeFakeIp } = profile const [mixedPortInput, setMixedPortInput] = useState(mixedPort) const [socksPortInput, setSocksPortInput] = useState(socksPort) @@ -40,11 +43,6 @@ const Mihomo: React.FC = () => { const [externalControllerInput, setExternalControllerInput] = useState(externalController) const [secretInput, setSecretInput] = useState(secret) - const onChange = async (patch: Partial): Promise => { - await patchControledMihomoConfig(patch) - await patchMihomoConfig(patch) - } - const onChangeNeedRestart = async (patch: Partial): Promise => { await patchControledMihomoConfig(patch) await restartCore() @@ -271,25 +269,52 @@ const Mihomo: React.FC = () => { size="sm" isSelected={ipv6} onValueChange={(v) => { - onChange({ ipv6: v }) + onChangeNeedRestart({ ipv6: v }) }} /> { - onChange({ 'allow-lan': v }) + onChangeNeedRestart({ 'allow-lan': v }) }} /> { - onChange({ 'unified-delay': v }) + onChangeNeedRestart({ 'unified-delay': v }) + }} + /> + + + { + onChangeNeedRestart({ 'tcp-concurrent': v }) + }} + /> + + + { + onChangeNeedRestart({ profile: { 'store-selected': v } }) + }} + /> + + + { + onChangeNeedRestart({ profile: { 'store-fake-ip': v } }) }} /> @@ -297,9 +322,9 @@ const Mihomo: React.FC = () => { { - onChange({ 'find-process-mode': v.currentKey as FindProcessMode }) + onChangeNeedRestart({ 'find-process-mode': v.currentKey as FindProcessMode }) }} > 自动 diff --git a/src/shared/types.d.ts b/src/shared/types.d.ts index 707a685..663a6f8 100644 --- a/src/shared/types.d.ts +++ b/src/shared/types.d.ts @@ -296,6 +296,12 @@ interface IMihomoSnifferConfig { } } } + +interface IMihomoProfileConfig { + 'store-selected'?: boolean + 'store-fake-ip'?: boolean +} + interface IMihomoConfig { 'external-controller': string secret?: string @@ -304,6 +310,7 @@ interface IMihomoConfig { 'mixed-port': number 'allow-lan': boolean 'unified-delay': boolean + 'tcp-concurrent': boolean 'log-level': LogLevel 'find-process-mode': FindProcessMode 'socks-port'?: number @@ -326,6 +333,7 @@ interface IMihomoConfig { tun: IMihomoTunConfig dns: IMihomoDNSConfig sniffer: IMihomoSnifferConfig + profile: IMihomoProfileConfig } interface IProfileConfig {