From f4b20ba2bf51e1b3cbbdb6293ebf8a0756d11c8c Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Sat, 14 Sep 2024 20:19:51 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20pref:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=93=94=E5=93=A9=E5=93=94=E5=93=A9=E8=A7=86=E9=A2=91=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整哔哩哔哩视频信息构造顺序,先判断是否显示信息,再构造数据 - 优化简介和在线人数信息的显示逻辑,确保信息展示的一致性和准确性 - 移除冗余的代码段,提高代码的整洁性和可维护性 --- apps/tools.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 7a9e4c5..be9d7be 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -629,32 +629,32 @@ export class tools extends plugin { const { title, desc, bvid, cid, pic } = videoInfo; // 视频信息 const { view, danmaku, reply, favorite, coin, share, like } = videoInfo.stat; - // 构造一个可扩展的Map - const dataProcessMap = { - "点赞": like, - "硬币": coin, - "收藏": favorite, - "分享": share, - "总播放量": view, - "弹幕数量": danmaku, - "评论": reply - }; - // 过滤简介中的一些链接 - const filteredDesc = await filterBiliDescLink(desc); - // 拼接在线人数 - const onlineTotal = await this.biliOnlineTotal(bvid, cid); // 格式化数据 let combineContent = ""; // 是否显示信息 if (this.biliDisplayInfo) { + // 构造一个可扩展的Map + const dataProcessMap = { + "点赞": like, + "硬币": coin, + "收藏": favorite, + "分享": share, + "总播放量": view, + "弹幕数量": danmaku, + "评论": reply + }; combineContent += `\n${ formatBiliInfo(dataProcessMap) }`; } // 是否显示简介 if (this.biliDisplayIntro) { + // 过滤简介中的一些链接 + const filteredDesc = await filterBiliDescLink(desc); combineContent += `\n📝 简介:${ truncateString(filteredDesc, this.toolsConfig.biliIntroLenLimit || BILI_DEFAULT_INTRO_LEN_LIMIT) }`; } // 是否显示在线人数 if (this.biliDisplayOnline) { + // 拼接在线人数 + const onlineTotal = await this.biliOnlineTotal(bvid, cid); combineContent += `\n🏄‍♂️️ 当前视频有 ${ onlineTotal.total } 人在观看,其中 ${ onlineTotal.count } 人在网页端观看`; } let biliInfo = [`${ this.identifyPrefix } 识别:哔哩哔哩:${ title }`, combineContent]