refactor(security): 重构安全配置并优化测试环境
- 移除旧的测试套件和UAT测试文件 - 更新密码编码器配置使用BCrypt strength=12 - 添加用户角色关联表和相关服务 - 优化前端日期显示格式 - 清理无用资源和配置文件 - 增强测试数据管理和清理功能
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
export const formatDateTime = (dateTime: string | Date | null | undefined): string => {
|
||||
if (!dateTime) return '-'
|
||||
|
||||
try {
|
||||
const date = typeof dateTime === 'string' ? new Date(dateTime) : dateTime
|
||||
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
const hours = String(date.getHours()).padStart(2, '0')
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||
const seconds = String(date.getSeconds()).padStart(2, '0')
|
||||
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
||||
} catch (error) {
|
||||
console.error('时间格式化失败:', error)
|
||||
return String(dateTime)
|
||||
}
|
||||
}
|
||||
|
||||
export const formatDate = (date: string | Date | null | undefined): string => {
|
||||
if (!date) return '-'
|
||||
|
||||
try {
|
||||
const d = typeof date === 'string' ? new Date(date) : date
|
||||
|
||||
const year = d.getFullYear()
|
||||
const month = String(d.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(d.getDate()).padStart(2, '0')
|
||||
|
||||
return `${year}-${month}-${day}`
|
||||
} catch (error) {
|
||||
console.error('日期格式化失败:', error)
|
||||
return String(date)
|
||||
}
|
||||
}
|
||||
|
||||
export const formatTime = (time: string | Date | null | undefined): string => {
|
||||
if (!time) return '-'
|
||||
|
||||
try {
|
||||
const t = typeof time === 'string' ? new Date(time) : time
|
||||
|
||||
const hours = String(t.getHours()).padStart(2, '0')
|
||||
const minutes = String(t.getMinutes()).padStart(2, '0')
|
||||
const seconds = String(t.getSeconds()).padStart(2, '0')
|
||||
|
||||
return `${hours}:${minutes}:${seconds}`
|
||||
} catch (error) {
|
||||
console.error('时间格式化失败:', error)
|
||||
return String(time)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user