mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-14 02:46:37 +08:00
feat(frontend): 控制台 next-intl 中英双语
接入无 URL 前缀的 zh-CN/en,顶栏与外观设置可切换语言;选择写入 cookie 后刷新生效。
This commit is contained in:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user