feat: 优化类型处理

This commit is contained in:
alger
2025-08-07 22:57:17 +08:00
parent daa8e7514d
commit 3ba85f34ed
62 changed files with 104 additions and 88 deletions
+2 -2
View File
@@ -3,7 +3,7 @@
// 语言显示名称映射
export const LANGUAGE_DISPLAY_NAMES: Record<string, string> = {
'zh-CN': '简体中文',
'zh-Hant': '繁體中文',
'zh-Hant': '繁體中文',
'en-US': 'English',
'ja-JP': '日本語',
'ko-KR': '한국어'
@@ -22,4 +22,4 @@ export const LANGUAGE_PRIORITY: Record<string, number> = {
'en-US': 3,
'ja-JP': 4,
'ko-KR': 5
};
};
+5 -5
View File
@@ -10,7 +10,7 @@ export const buildLanguageMessages = () => {
const match = path.match(/\.\/lang\/([^/]+)\/([^/]+)\.ts$/);
if (match) {
const [, langCode, moduleName] = match;
// 跳过 index 文件
if (moduleName !== 'index') {
if (!messages[langCode]) {
@@ -45,16 +45,16 @@ export const getLanguageDisplayNames = (): Record<string, string> => {
export const getLanguageOptions = () => {
const supportedLanguages = getSupportedLanguages();
const displayNames = getLanguageDisplayNames();
// 按优先级排序
const sortedLanguages = supportedLanguages.sort((a, b) => {
const priorityA = LANGUAGE_PRIORITY[a] || 999;
const priorityB = LANGUAGE_PRIORITY[b] || 999;
return priorityA - priorityB;
});
return sortedLanguages.map(lang => ({
return sortedLanguages.map((lang) => ({
label: displayNames[lang] || lang,
value: lang
}));
};
};