日志
This commit is contained in:
@@ -492,11 +492,19 @@ function resetLogFilters() {
|
||||
searchLogs()
|
||||
}
|
||||
|
||||
/** 解析时间戳:兼容 "2026-11-04T10:30:00"(ISO)与 "2026-11-04 10:30:00"(空格)两种格式 */
|
||||
function parseTime(s?: string | null): number {
|
||||
if (!s) return 0
|
||||
const d = new Date(s.replace('T', ' ').replace(/-/g, '/'))
|
||||
const t = d.getTime()
|
||||
return Number.isNaN(t) ? 0 : t
|
||||
}
|
||||
|
||||
/** 在线时长:未退出按当前时间算,已退出按退出时间算 */
|
||||
function onlineDuration(row: LoginLog): string {
|
||||
const start = row.loginTime ? new Date(row.loginTime).getTime() : 0
|
||||
const start = parseTime(row.loginTime)
|
||||
if (!start) return '-'
|
||||
const end = row.logoutTime ? new Date(row.logoutTime).getTime() : Date.now()
|
||||
const end = parseTime(row.logoutTime) || Date.now()
|
||||
const mins = Math.max(0, Math.floor((end - start) / 60000))
|
||||
if (mins < 60) return `${mins} 分钟`
|
||||
const hours = Math.floor(mins / 60)
|
||||
|
||||
Reference in New Issue
Block a user