From c6173e75d8c9d6f52140b62b33a592aafd6f062c Mon Sep 17 00:00:00 2001 From: Kaichen <276126767@qq.com> Date: Wed, 25 Jan 2023 15:40:09 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9C=AA=E5=BC=80=E6=92=AD=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E9=87=8D=E5=A4=8D=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src/views/Robot/message/robot.ts | 9 ++++++--- src/views/Robot/room.vue | 5 +++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 98ba64e..a932f1c 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "tauri": "tauri" }, "dependencies": { - "@tauri-apps/api": "^1.2.0", + "@tauri-apps/api": "^1.2.1", "dayjs": "^1.11.7", "flv.js": "^1.6.2", "nanoid": "^4.0.0", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index dd4eeeb..1bbc4fa 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -98,7 +98,7 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "bili-bot" -version = "1.2.0" +version = "1.2.1" dependencies = [ "fix-path-env", "serde", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index a99d195..1f06190 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bili-bot" -version = "1.2.0" +version = "1.2.1" description = "哔哩哔哩直播间弹幕机器人" authors = ["半糖人类"] license = "MIT" diff --git a/src/views/Robot/message/robot.ts b/src/views/Robot/message/robot.ts index 7f76aef..4168b13 100644 --- a/src/views/Robot/message/robot.ts +++ b/src/views/Robot/message/robot.ts @@ -229,8 +229,8 @@ let msgInterval: SetInterval; let clockInterval: SetInterval; watch(active, async (value) => { - messages.length = 0; if (value) { + messages.length = 0; // 开播后轮询直到获取到直播间信息再上线 let loopLimit = 20; const liveInfoIntever = setInterval(async () => { @@ -242,6 +242,10 @@ watch(active, async (value) => { console.log("已得到直播间信息"); clearInterval(liveInfoIntever); msgInterval = setInterval(() => { + if (!active.value && messages.length === 0) { + clearInterval(msgInterval); + return; + } const message = messages.shift(); if (!message) return; sendMessage(message); @@ -260,9 +264,8 @@ watch(active, async (value) => { } }, 1000 * 3); } else { - clearInterval(msgInterval); + messages.push(offline); clearInterval(clockInterval); - sendMessage(offline); } }); diff --git a/src/views/Robot/room.vue b/src/views/Robot/room.vue index fedf40a..279c027 100644 --- a/src/views/Robot/room.vue +++ b/src/views/Robot/room.vue @@ -20,7 +20,7 @@ const getUrl = async () => { const { live_status, uname, title } = by_room_ids[manage.roomid]; if (live_status !== 1) { message(`${uname}直播间未开播!`) - return + return false } const res = await getLiveStreamUrlApi("10000", manage.roomid); if (!res) return; @@ -30,7 +30,7 @@ const getUrl = async () => { const openPreview = async () => { const res = await getUrl(); - if (!res?.urls.length) return; + if (!res || !res?.urls.length) return url.value = res?.urls[0]; }; @@ -67,6 +67,7 @@ const startRecord = async (order = 0) => { return } const res = await getUrl(); + if (!res || !res?.urls.length) return const streamUrl = res?.urls[order] const folder = `${res?.uname}-[${manage.roomid}]` // 创建录制器