Refactor UUID generation, remove unused logger and encryption utilities, and clean up request handling

- Updated `generateUUID` function for improved readability and performance.
- Deleted `logger.ts`, `other.ts`, `request.ts`, `storage.ts`, `tansParams.ts`, and `validate.ts` as they were no longer needed.
- Simplified TypeScript configuration by removing unnecessary paths and aliases.
- Enhanced Vite configuration for better project structure and maintainability.
This commit is contained in:
DEV_DSW
2026-04-17 15:38:08 +08:00
parent b1dea9a5c2
commit 79bea4f107
360 changed files with 14495 additions and 30856 deletions

View File

@@ -1,21 +1,12 @@
import { SUPPORTED_LANGUAGE_CODES, type LanguageCode } from './constants';
import { SUPPORTED_LANGUAGE_CODES } from './constants';
import type { LanguageCode } from '../types/runtime';
// 创建语言代码集合用于快速查找
const SUPPORTED_LANGUAGE_CODE_SET = new Set<string>(SUPPORTED_LANGUAGE_CODES);
const SUPPORTED_LANGUAGE_SET = new Set<string>(SUPPORTED_LANGUAGE_CODES);
/**
* 标准化语言代码(处理 zh-CN、zh_TW 等变体)
*/
export function normalizeLocale(locale: string | null | undefined): string {
return locale?.trim().toLowerCase().replaceAll('_', '-') ?? '';
return locale?.trim().toLowerCase().split('_').join('-') ?? '';
}
/**
* 解析支持的语言代码
* @param locale 原始语言代码(如 'zh-CN', 'en-US'
* @param fallback 回退语言代码,默认为 'zh'
* @returns 支持的语言代码
*/
export function resolveSupportedLanguage(
locale: string | null | undefined,
fallback: LanguageCode = 'zh',
@@ -24,15 +15,10 @@ export function resolveSupportedLanguage(
if (!normalizedLocale) return fallback;
const [baseLanguage] = normalizedLocale.split('-');
return SUPPORTED_LANGUAGE_CODE_SET.has(baseLanguage)
? (baseLanguage as LanguageCode)
: fallback;
return SUPPORTED_LANGUAGE_SET.has(baseLanguage) ? (baseLanguage as LanguageCode) : fallback;
}
/**
* 检测系统语言
*/
export function detectSystemLanguage(): LanguageCode {
if (typeof navigator === 'undefined') return 'zh';
return resolveSupportedLanguage(navigator.language);
}
}