feat(date): enhance date formatting and timezone handling

- Update formatDateTime function to handle timezone-aware date strings directly.
- Introduce utcToBeijingISOString function for consistent Beijing time formatting in ISO string.
- Modify BidsService to utilize the new utcToBeijingISOString for date conversions.
- Add unit tests for AuthGuard to validate API key authentication and access control.
- Create end-to-end tests for API key handling in various scenarios.
- Update .gitignore to exclude 'qingyun' directory.
- Add environment configuration for production settings in .env.production.
- Include Tailwind CSS setup in the uni-app version for styling.
This commit is contained in:
dmy
2026-01-16 23:31:58 +08:00
parent 300e930c64
commit 810a420a46
9 changed files with 528 additions and 4 deletions

View File

@@ -28,6 +28,17 @@ export function formatDate(dateStr: string | null | undefined): string {
*/
export function formatDateTime(dateStr: string | null | undefined): string {
if (!dateStr) return '-'
// 如果时间字符串已经包含时区信息(如 +08:00说明已经是正确的北京时间
// 直接从字符串中提取日期和时间部分,避免时区转换问题
const timezoneMatch = dateStr.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}):\d{2}(?:\.\d{3})?[+-]\d{2}:\d{2}$/)
if (timezoneMatch) {
// 时间字符串已包含时区,直接提取日期和时间
return `${timezoneMatch[1]} ${timezoneMatch[2]}`
}
// 没有时区信息或格式不匹配,使用 Date 对象解析并转换
const date = new Date(dateStr)
if (isNaN(date.getTime())) return '-'