Skip to content

Commit

Permalink
feat: 开播/下播时更新Footer状态
Browse files Browse the repository at this point in the history
  • Loading branch information
ddiu8081 committed Oct 2, 2022
1 parent 5176e25 commit 1661344
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@temir/core": "^0.0.20",
"@temir/link": "^0.0.20",
"@temir/tab": "^0.0.20",
"blive-message-listener": "^0.2.0",
"blive-message-listener": "^0.2.1",
"dayjs": "^1.11.5",
"ohmyfetch": "^0.4.19",
"vue": "^3.2.40",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ onMounted(async () => {
onWatchedChange: ({ body }) => {
watchers.value = body.num
},
onLiveStart: async ({ body }) => {
const roomInfo = await getRoomInfo(inputRoomId)
if (roomInfo) {
liveStatus.value = {
isLive: roomInfo.live_status === 1,
startTime: roomInfo.live_time,
}
}
},
onLiveEnd: () => {
liveStatus.value.isLive = false
},
onIncomeDanmu: (msg) => {
allList.value.push(msg)
danmuList.value.push(msg)
Expand Down
6 changes: 3 additions & 3 deletions src/components/CliFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ const attentionHighlight = ref(false)
const timer = ref(0)
const timeText = ref(' ')
watch(() => props.liveStatus, liveStatus => {
if (!liveStatus.isLive) {
watch(() => [props.liveStatus.isLive, props.liveStatus.startTime], () => {
if (!props.liveStatus.isLive) {
clearInterval(timer.value)
return
}
timer.value = 0
clearInterval(timer.value)
// @ts-ignore
timer.value = setInterval(() => {
const liveSeconds = dayjs().diff(liveStatus.startTime, 'second')
const liveSeconds = dayjs().diff(props.liveStatus.startTime, 'second')
timeText.value = formatSeconds(liveSeconds)
}, 1000)
})
Expand Down

0 comments on commit 1661344

Please sign in to comment.