yz-yuki-plugin 1.0.3-rc.1 → 1.0.3-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,6 +55,12 @@ class BiliQuery {
55
55
  pics = pics.map((item) => { return { url: item?.url, width: item?.width, height: item?.height }; });
56
56
  formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text) || "";
57
57
  }
58
+ else if (majorType === "MAJOR_TYPE_DRAW") {
59
+ desc = data?.modules?.module_dynamic?.desc;
60
+ pics = data?.modules?.module_dynamic?.major?.draw?.items;
61
+ pics = pics.map((item) => { return { url: item?.url, width: item?.width, height: item?.height }; });
62
+ formatData.data.content = this.parseRichTextNodes(desc?.rich_text_nodes || desc?.text) || "";
63
+ }
58
64
  else {
59
65
  desc = data?.modules?.module_dynamic?.desc;
60
66
  pics = data?.modules?.module_dynamic?.major?.draw?.items;
@@ -89,6 +95,13 @@ class BiliQuery {
89
95
  formatData.data.pics = pics;
90
96
  }
91
97
  }
98
+ else if (majorType === "MAJOR_TYPE_ARTICLE") {
99
+ desc = data?.modules?.module_dynamic?.major?.article || {};
100
+ pics = desc?.covers;
101
+ pics = pics.map((item) => { return { url: item }; }) || [];
102
+ formatData.data.title = desc?.title;
103
+ formatData.data.content = this.parseRichTextNodes(desc?.desc);
104
+ }
92
105
  else {
93
106
  desc = data?.modules?.module_dynamic?.major?.article || {};
94
107
  if (desc.covers && desc.covers.length) {
@@ -139,6 +152,7 @@ class BiliQuery {
139
152
  ;
140
153
  static parseRichTextNodes = (nodes) => {
141
154
  if (typeof nodes === 'string') {
155
+ nodes = nodes.replace(/\t/g, ' ');
142
156
  return nodes.replace(/\n/g, '<br>');
143
157
  }
144
158
  else if (Array.isArray(nodes)) {
@@ -194,7 +208,7 @@ class BiliQuery {
194
208
  }
195
209
  }
196
210
  static praseFullArticleContent(content) {
197
- content = content.replace(/\n/g, '<br>');
211
+ content = String(content).replace(/\n/g, '<br>');
198
212
  const imgTagRegex = /<img[^>]*data-src="([^"]*)"[^>]*>/g;
199
213
  content = content.replace(imgTagRegex, (match, p1) => {
200
214
  const newSrc = this.formatUrl(p1);
@@ -263,6 +277,12 @@ class BiliQuery {
263
277
  });
264
278
  content = desc?.summary?.text || "";
265
279
  }
280
+ else if (majorType === "MAJOR_TYPE_DRAW") {
281
+ desc = data?.modules?.module_dynamic?.desc;
282
+ pics = data?.modules?.module_dynamic?.major?.draw?.items;
283
+ pics = pics.map((item) => { return item?.src; });
284
+ content = desc?.text || "";
285
+ }
266
286
  else {
267
287
  desc = data?.modules?.module_dynamic?.desc;
268
288
  pics = data?.modules?.module_dynamic?.major?.draw?.items;
@@ -298,6 +318,12 @@ class BiliQuery {
298
318
  dynamicTitle = desc?.title;
299
319
  content = desc?.summary?.text || "";
300
320
  }
321
+ else if (majorType === "MAJOR_TYPE_ARTICLE") {
322
+ desc = data?.modules?.module_dynamic?.major?.article || {};
323
+ pics = desc?.covers || [];
324
+ dynamicTitle = desc?.title;
325
+ content = desc?.desc;
326
+ }
301
327
  else {
302
328
  desc = data?.modules?.module_dynamic?.major?.article || {};
303
329
  if (desc.covers && desc.covers.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yz-yuki-plugin",
3
- "version": "1.0.3-rc.1",
3
+ "version": "1.0.3-rc.2",
4
4
  "description": "优纪插件,yunzaijs 关于 微博推送、B站推送 等功能的拓展插件",
5
5
  "author": "snowtafir",
6
6
  "type": "module",