This commit is contained in:
stardrophere
2026-03-12 01:50:08 +08:00
parent 966bcfbba4
commit e28b893a12
7 changed files with 123 additions and 14 deletions
+3
View File
@@ -135,6 +135,9 @@ function getHotLevel(score: number): { label: string; color: string; bg: string
}
function formatRelativeTime(dateStr: string): string {
if (!dateStr.endsWith('Z') && !dateStr.includes('+')) {
dateStr += 'Z' // 补偿 SQLite 丢失的 UTC 时区标识
}
const now = Date.now()
const target = new Date(dateStr).getTime()
const diff = now - target
+10 -3
View File
@@ -47,8 +47,15 @@ function getPlatformIcon(name: string): string {
}
/** 格式化时间 */
function safeParseTime(dateStr: string): number {
if (!dateStr.endsWith('Z') && !dateStr.includes('+')) {
dateStr += 'Z'
}
return new Date(dateStr).getTime()
}
function formatTime(dateStr: string): string {
const d = new Date(dateStr)
const d = new Date(safeParseTime(dateStr))
const now = Date.now()
const diff = now - d.getTime()
const minutes = Math.floor(diff / 60000)
@@ -75,7 +82,7 @@ const revisionChains = computed<RevisionChain[]>(() => {
const chains: RevisionChain[] = []
for (const [event_id, items] of groups) {
// 组内按时间升序
items.sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime())
items.sort((a, b) => safeParseTime(a.created_at) - safeParseTime(b.created_at))
// 拼接标题链,避免重复(相邻记录的 revised 与下一条 previous 通常相同)
const titles: string[] = [items[0].previous_headline]
@@ -102,7 +109,7 @@ const revisionChains = computed<RevisionChain[]>(() => {
}
// 最终按最新修改时间降序
chains.sort((a, b) => new Date(b.last_at).getTime() - new Date(a.last_at).getTime())
chains.sort((a, b) => safeParseTime(b.last_at) - safeParseTime(a.last_at))
return chains
})