Skip to content

Commit 8f30f0a

Browse files
committed
feat(settings): add auto-restart option for core on config changes
1 parent 9a86aed commit 8f30f0a

File tree

6 files changed

+23
-0
lines changed

6 files changed

+23
-0
lines changed

frontend/src/lang/locale/en.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,10 @@ export default {
609609
proxyBypassListTips: 'Separate with semicolons',
610610
autoStartKernel: 'Start core on launch',
611611
realMemoryUsage: 'Show actual core memory usage',
612+
autoRestartKernel: {
613+
name: 'Auto-restart core on config changes',
614+
tips: 'It will interrupt all connections and may fail to restart',
615+
},
612616
admin: 'Run as admin',
613617
addPluginToMenu: 'Add plugin to tray menu',
614618
addGroupToMenu: 'Add proxy group to tray menu',

frontend/src/lang/locale/zh.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,10 @@ export default {
608608
proxyBypassListTips: '分号分隔',
609609
autoStartKernel: '程序启动时开启核心',
610610
realMemoryUsage: '显示真实的核心内存占用',
611+
autoRestartKernel: {
612+
name: '相关配置变化时自动重启核心',
613+
tips: '会中断所有连接,且可能重启失败',
614+
},
611615
admin: '以管理员身份运行',
612616
addPluginToMenu: '将插件添加到托盘菜单',
613617
addGroupToMenu: '将代理组添加到托盘菜单',

frontend/src/stores/appSettings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export const useAppSettingsStore = defineStore('app-settings', () => {
7575
autoSetSystemProxy: true,
7676
proxyBypassList: '',
7777
autoStartKernel: false,
78+
autoRestartKernel: false,
7879
userAgent: '',
7980
startupDelay: 30,
8081
connections: DefaultConnections(),

frontend/src/stores/kernelApi.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,12 @@ export const useKernelApiStore = defineStore('kernelApi', () => {
425425
}
426426
})
427427

428+
watch(needRestart, (v) => {
429+
if (v && appSettingsStore.app.autoRestartKernel) {
430+
restartCore()
431+
}
432+
})
433+
428434
const watchSources = computed(() => {
429435
const source = [config.value.mode, config.value.tun.enable]
430436
if (!appSettingsStore.app.addGroupToMenu) return source.join('')

frontend/src/types/app.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ type AppSettings = {
5656
autoSetSystemProxy: boolean
5757
proxyBypassList: string
5858
autoStartKernel: boolean
59+
autoRestartKernel: boolean
5960
userAgent: string
6061
startupDelay: number
6162
connections: {

frontend/src/views/SettingsView/components/GeneralSettings.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,13 @@ if (envStore.env.os === 'windows') {
375375
<div class="text-16 font-bold">{{ t('settings.realMemoryUsage') }}</div>
376376
<Switch v-model="appSettings.app.kernel.realMemoryUsage" />
377377
</div>
378+
<div class="px-8 py-12 flex items-center justify-between">
379+
<div class="text-16 font-bold">
380+
{{ t('settings.autoRestartKernel.name') }}
381+
<span class="font-normal text-12">({{ t('settings.autoRestartKernel.tips') }})</span>
382+
</div>
383+
<Switch v-model="appSettings.app.autoRestartKernel" />
384+
</div>
378385
<div class="px-8 py-12 flex items-center justify-between">
379386
<div class="text-16 font-bold">
380387
{{ t('settings.githubapi.name') }}

0 commit comments

Comments
 (0)