mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Add live status (#1493)
This commit is contained in:
parent
db52e8b9a8
commit
75e451de33
2
min/custom-navbar-history-list.min.js
vendored
2
min/custom-navbar-history-list.min.js
vendored
File diff suppressed because one or more lines are too long
2
min/custom-navbar.min.css
vendored
2
min/custom-navbar.min.css
vendored
File diff suppressed because one or more lines are too long
@ -258,10 +258,14 @@
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
.live-status,
|
||||
.time {
|
||||
font-size: 11px;
|
||||
grid-area: time;
|
||||
padding-right: 6px;
|
||||
&.live {
|
||||
color: var(--theme-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,10 @@ interface HistoryItem {
|
||||
upID: number
|
||||
href: string
|
||||
}
|
||||
interface LiveData {
|
||||
liveStatus: number
|
||||
liveStatusText: string
|
||||
}
|
||||
interface TimeData {
|
||||
timestamp: number
|
||||
time: Date
|
||||
@ -81,11 +85,14 @@ const historyTimeGrouper = (historyItems: HistoryItem[]) => {
|
||||
}
|
||||
}
|
||||
const formatTime = (date: Date) => {
|
||||
const { yesterday } = getTimeData()
|
||||
const { yesterday, today } = getTimeData()
|
||||
const timestamp = Number(date)
|
||||
if (timestamp >= yesterday) {
|
||||
if (timestamp >= today) {
|
||||
return `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`
|
||||
}
|
||||
if (timestamp >= yesterday) {
|
||||
return `昨天 ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`
|
||||
}
|
||||
return `${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`
|
||||
}
|
||||
const tabs: HistoryTab[] = [
|
||||
@ -163,7 +170,13 @@ const tabs: HistoryTab[] = [
|
||||
upName: item.uname,
|
||||
coverUrl: item.user_cover,
|
||||
title: item.title,
|
||||
} as HistoryItem
|
||||
liveStatus: item.live_status,
|
||||
liveStatusText: ({
|
||||
0: '未开播',
|
||||
1: '直播中',
|
||||
2: '轮播中',
|
||||
} as Record<number, string>)[item.live_status],
|
||||
} as HistoryItem & LiveData
|
||||
})
|
||||
return historyItems
|
||||
}
|
||||
@ -224,6 +237,9 @@ export class HistoryList extends NavbarComponent {
|
||||
<div v-if="h.timeText" class="time" :title="h.time.toLocaleString()">
|
||||
{{h.timeText}}
|
||||
</div>
|
||||
<div v-if="h.liveStatus !== undefined" class="live-status" :class="{ live: h.liveStatus === 1 }">
|
||||
{{h.liveStatusText}}
|
||||
</div>
|
||||
</div>
|
||||
</transition-group>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user