Skip to content

Commit

Permalink
fix: 未开播时的重复弹窗
Browse files Browse the repository at this point in the history
  • Loading branch information
orangelckc committed Jan 25, 2023
1 parent d312bb7 commit c6173e7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

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

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bili-bot"
version = "1.2.0"
version = "1.2.1"
description = "哔哩哔哩直播间弹幕机器人"
authors = ["半糖人类"]
license = "MIT"
Expand Down
9 changes: 6 additions & 3 deletions src/views/Robot/message/robot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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);
Expand All @@ -260,9 +264,8 @@ watch(active, async (value) => {
}
}, 1000 * 3);
} else {
clearInterval(msgInterval);
messages.push(offline);
clearInterval(clockInterval);
sendMessage(offline);
}
});

Expand Down
5 changes: 3 additions & 2 deletions src/views/Robot/room.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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];
};
Expand Down Expand Up @@ -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}]`
// 创建录制器
Expand Down

0 comments on commit c6173e7

Please sign in to comment.