mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-18 18:50:49 +08:00
fix: address language review feedback
This commit is contained in:
@@ -47,8 +47,8 @@
|
|||||||
"model_alias_placeholder": "Псевдоним модели (необязательно)"
|
"model_alias_placeholder": "Псевдоним модели (необязательно)"
|
||||||
},
|
},
|
||||||
"title": {
|
"title": {
|
||||||
"main": "CLI Proxy API Management Center",
|
"main": "Центр управления CLI Proxy API",
|
||||||
"login": "CLI Proxy API Management Center",
|
"login": "Центр управления CLI Proxy API",
|
||||||
"abbr": "CPAMC"
|
"abbr": "CPAMC"
|
||||||
},
|
},
|
||||||
"auto_login": {
|
"auto_login": {
|
||||||
@@ -108,7 +108,7 @@
|
|||||||
},
|
},
|
||||||
"dashboard": {
|
"dashboard": {
|
||||||
"title": "Панель управления",
|
"title": "Панель управления",
|
||||||
"subtitle": "Добро пожаловать в CLI Proxy API Management Center",
|
"subtitle": "Добро пожаловать в Центр управления CLI Proxy API",
|
||||||
"openai_providers": "Поставщики OpenAI",
|
"openai_providers": "Поставщики OpenAI",
|
||||||
"quick_actions": "Быстрые действия",
|
"quick_actions": "Быстрые действия",
|
||||||
"current_config": "Текущая конфигурация",
|
"current_config": "Текущая конфигурация",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { Input } from '@/components/ui/Input';
|
|||||||
import { IconEye, IconEyeOff } from '@/components/ui/icons';
|
import { IconEye, IconEyeOff } from '@/components/ui/icons';
|
||||||
import { useAuthStore, useLanguageStore, useNotificationStore } from '@/stores';
|
import { useAuthStore, useLanguageStore, useNotificationStore } from '@/stores';
|
||||||
import { detectApiBaseFromLocation, normalizeApiBase } from '@/utils/connection';
|
import { detectApiBaseFromLocation, normalizeApiBase } from '@/utils/connection';
|
||||||
|
import { LANGUAGE_LABEL_KEYS, LANGUAGE_ORDER } from '@/utils/constants';
|
||||||
import { INLINE_LOGO_JPEG } from '@/assets/logoInline';
|
import { INLINE_LOGO_JPEG } from '@/assets/logoInline';
|
||||||
import type { ApiError, Language } from '@/types';
|
import type { ApiError, Language } from '@/types';
|
||||||
import styles from './LoginPage.module.scss';
|
import styles from './LoginPage.module.scss';
|
||||||
@@ -78,14 +79,9 @@ export function LoginPage() {
|
|||||||
const [error, setError] = useState('');
|
const [error, setError] = useState('');
|
||||||
|
|
||||||
const detectedBase = useMemo(() => detectApiBaseFromLocation(), []);
|
const detectedBase = useMemo(() => detectApiBaseFromLocation(), []);
|
||||||
const nextLanguage: Language = language === 'zh-CN' ? 'en' : language === 'en' ? 'ru' : 'zh-CN';
|
const nextLanguageIndex = LANGUAGE_ORDER.indexOf(language);
|
||||||
const nextLanguageLabel = t(
|
const nextLanguage: Language = LANGUAGE_ORDER[(nextLanguageIndex + 1) % LANGUAGE_ORDER.length];
|
||||||
nextLanguage === 'zh-CN'
|
const nextLanguageLabel = t(LANGUAGE_LABEL_KEYS[nextLanguage]);
|
||||||
? 'language.chinese'
|
|
||||||
: nextLanguage === 'en'
|
|
||||||
? 'language.english'
|
|
||||||
: 'language.russian'
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
import { create } from 'zustand';
|
import { create } from 'zustand';
|
||||||
import { persist } from 'zustand/middleware';
|
import { persist } from 'zustand/middleware';
|
||||||
import type { Language } from '@/types';
|
import type { Language } from '@/types';
|
||||||
import { STORAGE_KEY_LANGUAGE } from '@/utils/constants';
|
import { LANGUAGE_ORDER, STORAGE_KEY_LANGUAGE } from '@/utils/constants';
|
||||||
import i18n from '@/i18n';
|
import i18n from '@/i18n';
|
||||||
import { getInitialLanguage } from '@/utils/language';
|
import { getInitialLanguage } from '@/utils/language';
|
||||||
|
|
||||||
@@ -29,9 +29,8 @@ export const useLanguageStore = create<LanguageState>()(
|
|||||||
|
|
||||||
toggleLanguage: () => {
|
toggleLanguage: () => {
|
||||||
const { language, setLanguage } = get();
|
const { language, setLanguage } = get();
|
||||||
const order: Language[] = ['zh-CN', 'en', 'ru'];
|
const currentIndex = LANGUAGE_ORDER.indexOf(language);
|
||||||
const currentIndex = order.indexOf(language);
|
const nextLanguage = LANGUAGE_ORDER[(currentIndex + 1) % LANGUAGE_ORDER.length];
|
||||||
const nextLanguage = order[(currentIndex + 1) % order.length];
|
|
||||||
setLanguage(nextLanguage);
|
setLanguage(nextLanguage);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
* 从原项目 src/utils/constants.js 迁移
|
* 从原项目 src/utils/constants.js 迁移
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import type { Language } from '@/types';
|
||||||
|
|
||||||
// 缓存过期时间(毫秒)
|
// 缓存过期时间(毫秒)
|
||||||
export const CACHE_EXPIRY_MS = 30 * 1000; // 与基线保持一致,减少管理端压力
|
export const CACHE_EXPIRY_MS = 30 * 1000; // 与基线保持一致,减少管理端压力
|
||||||
|
|
||||||
@@ -33,6 +35,15 @@ export const STORAGE_KEY_LANGUAGE = 'cli-proxy-language';
|
|||||||
export const STORAGE_KEY_SIDEBAR = 'cli-proxy-sidebar-collapsed';
|
export const STORAGE_KEY_SIDEBAR = 'cli-proxy-sidebar-collapsed';
|
||||||
export const STORAGE_KEY_AUTH_FILES_PAGE_SIZE = 'cli-proxy-auth-files-page-size';
|
export const STORAGE_KEY_AUTH_FILES_PAGE_SIZE = 'cli-proxy-auth-files-page-size';
|
||||||
|
|
||||||
|
// 语言配置
|
||||||
|
export const LANGUAGE_ORDER: Language[] = ['zh-CN', 'en', 'ru'];
|
||||||
|
export const LANGUAGE_LABEL_KEYS: Record<Language, string> = {
|
||||||
|
'zh-CN': 'language.chinese',
|
||||||
|
en: 'language.english',
|
||||||
|
ru: 'language.russian'
|
||||||
|
};
|
||||||
|
export const SUPPORTED_LANGUAGES: Language[] = LANGUAGE_ORDER;
|
||||||
|
|
||||||
// 通知持续时间
|
// 通知持续时间
|
||||||
export const NOTIFICATION_DURATION_MS = 3000;
|
export const NOTIFICATION_DURATION_MS = 3000;
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import type { Language } from '@/types';
|
import type { Language } from '@/types';
|
||||||
import { STORAGE_KEY_LANGUAGE } from '@/utils/constants';
|
import { STORAGE_KEY_LANGUAGE, SUPPORTED_LANGUAGES } from '@/utils/constants';
|
||||||
|
|
||||||
const parseStoredLanguage = (value: string): Language | null => {
|
const parseStoredLanguage = (value: string): Language | null => {
|
||||||
try {
|
try {
|
||||||
const parsed = JSON.parse(value);
|
const parsed = JSON.parse(value);
|
||||||
const candidate = parsed?.state?.language ?? parsed?.language ?? parsed;
|
const candidate = parsed?.state?.language ?? parsed?.language ?? parsed;
|
||||||
if (candidate === 'zh-CN' || candidate === 'en' || candidate === 'ru') {
|
if (SUPPORTED_LANGUAGES.includes(candidate as Language)) {
|
||||||
return candidate;
|
return candidate as Language;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
if (value === 'zh-CN' || value === 'en' || value === 'ru') {
|
if (SUPPORTED_LANGUAGES.includes(value as Language)) {
|
||||||
return value;
|
return value as Language;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user