diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index dbf49caa..5b4eddf7 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -1067,6 +1067,7 @@ "title": "Config Panel", "editor_title": "Configuration File", "reload": "Reload", + "reload_confirm_message": "Reloading will discard your unsaved changes. Do you want to continue?", "save": "Save", "description": "Edit config.yaml via visual editor or source file", "status_idle": "Waiting for action", diff --git a/src/i18n/locales/ru.json b/src/i18n/locales/ru.json index 48ddb139..a414c72d 100644 --- a/src/i18n/locales/ru.json +++ b/src/i18n/locales/ru.json @@ -1070,6 +1070,7 @@ "title": "Панель конфигурации", "editor_title": "Файл конфигурации", "reload": "Перезагрузить", + "reload_confirm_message": "Перезагрузка отбросит ваши несохранённые изменения. Продолжить?", "save": "Сохранить", "description": "Редактируйте config.yaml через визуальный редактор или исходный файл", "status_idle": "Ожидание действия", diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json index 0a198be5..5ce2fa9c 100644 --- a/src/i18n/locales/zh-CN.json +++ b/src/i18n/locales/zh-CN.json @@ -1067,6 +1067,7 @@ "title": "配置面板", "editor_title": "配置文件", "reload": "重新加载", + "reload_confirm_message": "重新加载将丢弃你当前未保存的修改,确定继续吗?", "save": "保存", "description": "通过可视化或者源文件方式编辑 config.yaml 配置文件", "status_idle": "等待操作", diff --git a/src/pages/ConfigPage.tsx b/src/pages/ConfigPage.tsx index 75214979..a57c1576 100644 --- a/src/pages/ConfigPage.tsx +++ b/src/pages/ConfigPage.tsx @@ -31,7 +31,8 @@ function readCommercialModeFromYaml(yamlContent: string): boolean { export function ConfigPage() { const { t } = useTranslation(); - const { showNotification } = useNotificationStore(); + const showNotification = useNotificationStore((state) => state.showNotification); + const showConfirmation = useNotificationStore((state) => state.showConfirmation); const connectionStatus = useAuthStore((state) => state.connectionStatus); const resolvedTheme = useThemeStore((state) => state.resolvedTheme); @@ -401,6 +402,24 @@ export function ConfigPage() { return ''; }; + const handleReload = useCallback(() => { + if (!isDirty) { + void loadConfig(); + return; + } + + showConfirmation({ + title: t('common.unsaved_changes_title'), + message: t('config_management.reload_confirm_message'), + confirmText: t('config_management.reload'), + cancelText: t('common.cancel'), + variant: 'danger', + onConfirm: async () => { + await loadConfig(); + }, + }); + }, [isDirty, loadConfig, showConfirmation, t]); + const floatingActions = (
@@ -408,8 +427,8 @@ export function ConfigPage() {