From f5f63bcc91bc555a8e2716b9afcb8617c43c7dec Mon Sep 17 00:00:00 2001 From: OPPO9008 <41640509+OPPO9008@users.noreply.github.com> Date: Tue, 6 May 2025 14:58:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=98=E6=96=B9=E6=8A=BD=E5=A5=96?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=9C=AA=E8=8E=B7=E5=8F=96=E5=88=B0=E5=86=85?= =?UTF-8?q?=E5=AE=B9=20(#445)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed #445 增加ditem?.modules?.module_dynamic?.major?.opus?.summary?.rich_text_nodes 判断 --- lib/core/searcher.js | 75 ++++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 23 deletions(-) diff --git a/lib/core/searcher.js b/lib/core/searcher.js index e64b988..5318c5e 100644 --- a/lib/core/searcher.js +++ b/lib/core/searcher.js @@ -103,22 +103,41 @@ function parseDynamicCard(data) { /* 转发描述 */ obj.description = ''; let _total_len = 0; - ditem?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => { - if (node.type === 'RICH_TEXT_NODE_TYPE_AT') { - obj.ctrl.push({ - data: node.rid, - location: _total_len, - length: node.text.length, - type: 1 - }); - } - /* 是否有官方抽奖 */ - if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') { - obj.hasOfficialLottery = true; - } - obj.description += node.orig_text; - _total_len += node.text.length; - }); + if (Array.isArray(ditem?.modules?.module_dynamic?.desc?.rich_text_nodes)) { + ditem?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => { + if (node.type === 'RICH_TEXT_NODE_TYPE_AT') { + obj.ctrl.push({ + data: node.rid, + location: _total_len, + length: node.text.length, + type: 1 + }); + } + /* 是否有官方抽奖 */ + if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') { + obj.hasOfficialLottery = true; + } + obj.description += node.orig_text; + _total_len += node.text.length; + }); + } else { + ditem?.modules?.module_dynamic?.major?.opus?.summary?.rich_text_nodes.forEach(node => { + if (node.type === 'RICH_TEXT_NODE_TYPE_AT') { + obj.ctrl.push({ + data: node.rid, + location: _total_len, + length: node.text.length, + type: 1 + }); + } + /* 是否有官方抽奖 */ + if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') { + obj.hasOfficialLottery = true; + } + obj.description += node.orig_text; + _total_len += node.text.length; + }); + } /* 预约抽奖信息 */ obj.reserve_id = ditem?.modules?.module_dynamic?.additional?.reserve?.rid || 0; obj.reserve_lottery_text = ditem?.modules?.module_dynamic?.additional?.reserve?.title || '信息丢失'; @@ -166,13 +185,23 @@ function parseDynamicCard(data) { obj.origin_hasOfficialLottery = false; /* 转发描述 */ obj.origin_description = ''; - ditem?.orig?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => { - /* 是否有官方抽奖 */ - if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') { - obj.origin_hasOfficialLottery = true; - } - obj.origin_description += node.orig_text; - }); + if (Array.isArray(ditem?.orig?.modules?.module_dynamic?.desc?.rich_text_nodes)) { + ditem?.orig?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => { + /* 是否有官方抽奖 */ + if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') { + obj.origin_hasOfficialLottery = true; + } + obj.origin_description += node.orig_text; + }); + } else { + ditem?.orig.modules?.module_dynamic?.major?.opus?.summary?.rich_text_nodes.forEach(node => { + /* 是否有官方抽奖 */ + if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') { + obj.origin_hasOfficialLottery = true; + } + obj.origin_description += node.orig_text; + }); + } } } catch (e) { log.error('动态卡片解析', e);