feat(frontend): 控制台 next-intl 中英双语

接入无 URL 前缀的 zh-CN/en,顶栏与外观设置可切换语言;选择写入 cookie 后刷新生效。
This commit is contained in:
ryan
2026-08-16 16:49:16 +08:00
parent 64fbaa7ef1
commit 5a8722ff07
219 changed files with 21437 additions and 5212 deletions
@@ -3,6 +3,8 @@
import { useCallback, useState } from 'react';
import { toast } from 'sonner';
import { useTranslations } from 'next-intl';
import type {
ProxyRouteItem,
ProxyRouteMutationPayload,
@@ -19,6 +21,7 @@ export function useRouteSectionSave(
onRouteUpdate: (route: ProxyRouteItem) => void,
onSavingChange?: (saving: boolean) => void,
) {
const t = useTranslations('proxyRoutes');
const [saving, setSaving] = useState(false);
const save = useCallback(
@@ -33,13 +36,15 @@ export function useRouteSectionSave(
onRouteUpdate(updated);
toast.success(message);
} catch (error) {
toast.error('保存失败', { description: getErrorMessage(error) });
toast.error(t('saveFailed'), {
description: getErrorMessage(error, t('requestFailed')),
});
} finally {
setSaving(false);
onSavingChange?.(false);
}
},
[onRouteUpdate, onSavingChange, route],
[onRouteUpdate, onSavingChange, route, t],
);
return { saving, save };