mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-05-18 03:17:29 +08:00
feat: 优化类型处理
This commit is contained in:
@@ -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
@@ -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
|
||||
}));
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user