From 9697fabae5296e054f7e99dd261204a6182f38fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BF=AF=E5=A2=A8?= <1362446747@qq.com> Date: Sat, 21 May 2022 14:00:44 +0800 Subject: [PATCH] fix: fix resend bug --- package.json | 2 +- src/ipc.js | 4 ++-- src/plugins/axios.js | 4 ++++ src/plugins/config.js | 11 +---------- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 2cba61d..a13ad4f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "material-douden-tool", - "version": "1.1.4", + "version": "1.1.5", "private": true, "author": "濯墨", "scripts": { diff --git a/src/ipc.js b/src/ipc.js index 9a613f7..ec1ff32 100644 --- a/src/ipc.js +++ b/src/ipc.js @@ -29,8 +29,8 @@ const Stacks = { const { code, message } = await SendComment(roomid.id, roomid.msg); if (code === 10030) { clearInterval(Stacks.timer); - Stacks.RoomIds.unshift({ id: roomid, msg }); - Stacks.timer = setInterval(Stacks.interval, 1000); + Stacks.RoomIds.unshift(roomid); + Stacks.timer = setInterval(Stacks.interval, 1750); } else if (message === "f") { await writeFile( join(app.getPath("exe"), "../forbidden-words.txt"), diff --git a/src/plugins/axios.js b/src/plugins/axios.js index 2006da3..95f82d8 100644 --- a/src/plugins/axios.js +++ b/src/plugins/axios.js @@ -1,6 +1,7 @@ import axios from "axios"; import QS from "qs"; import { Bilibili, Music163, MusicQQ, Baidu, API, Login } from "./config"; +import { BrowserWindow } from "electron"; export const SendComment = async (roomid, msg) => { try { @@ -56,6 +57,9 @@ export const GetWebSocket = async (roomid) => { ruid: up_medal && up_medal.uid, }; } catch (error) { + const wins = BrowserWindow.getAllWindows(); + const win = wins[wins.length - 1]; + win.webContents.send("CookieOverdue"); return { host_list: [], comments: [], admin: false, roomid }; } }; diff --git a/src/plugins/config.js b/src/plugins/config.js index 6d0336f..9cd53e7 100644 --- a/src/plugins/config.js +++ b/src/plugins/config.js @@ -1,5 +1,4 @@ import axios from "axios"; -import { BrowserWindow } from "electron"; export const Bilibili = axios.create({ baseURL: "https://api.live.bilibili.com/", @@ -13,16 +12,8 @@ export const Bilibili = axios.create({ }); Bilibili.interceptors.response.use((response) => { - const { - data, - config: { url }, - } = response; + const { data } = response; if (data.code !== 0 && data.code !== 1200000) { - if (!url.includes("send")) { - const wins = BrowserWindow.getAllWindows(); - const win = wins[wins.length - 1]; - win.webContents.send("CookieOverdue"); - } throw data; } data.data.message = data.message || data.msg;