From 1661344070a4c79ca4302bee86c5894979044699 Mon Sep 17 00:00:00 2001 From: ddiu8081 Date: Sun, 2 Oct 2022 20:05:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=80=E6=92=AD/=E4=B8=8B=E6=92=AD?= =?UTF-8?q?=E6=97=B6=E6=9B=B4=E6=96=B0Footer=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- src/App.vue | 12 ++++++++++++ src/components/CliFooter.vue | 6 +++--- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 0b4cfa8..b8e1f71 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a7400d8..8f408a6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,7 +7,7 @@ specifiers: '@temir/tab': ^0.0.20 '@types/node': ^18.7.23 '@types/yargs': ^17.0.13 - blive-message-listener: ^0.2.0 + blive-message-listener: ^0.2.1 dayjs: ^1.11.5 ohmyfetch: ^0.4.19 tsup: ^6.2.3 @@ -19,7 +19,7 @@ dependencies: '@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 @@ -704,8 +704,8 @@ packages: engines: {node: '>=8'} dev: true - /blive-message-listener/0.2.0: - resolution: {integrity: sha512-vPTieno3qWQmrS/m6S9Ej3d2mVl6KnjgqRSQgWOe8d7xmomogHCGtrFL3n9Uy5dKd73K0SPgggy3ZDLl24K0Wg==} + /blive-message-listener/0.2.1: + resolution: {integrity: sha512-ITd7/doenWfhr6X+rDpf/pFvWm33gkYKI2rAlsM/1PjNfn/m6uTiHW904S15D2dONB/GHVyL81LGA86Cxy6bvg==} dependencies: tiny-bilibili-ws: 0.0.2 transitivePeerDependencies: diff --git a/src/App.vue b/src/App.vue index 19eecd3..408a763 100644 --- a/src/App.vue +++ b/src/App.vue @@ -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) diff --git a/src/components/CliFooter.vue b/src/components/CliFooter.vue index 343b9bd..9d82472 100644 --- a/src/components/CliFooter.vue +++ b/src/components/CliFooter.vue @@ -22,8 +22,8 @@ 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 } @@ -31,7 +31,7 @@ watch(() => props.liveStatus, liveStatus => { 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) })