koishi-plugin-rocom 1.0.12 → 1.0.17

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.
Files changed (69) hide show
  1. package/lib/atlas-service.d.ts +33 -0
  2. package/lib/atlas-service.js +439 -0
  3. package/lib/client.d.ts +36 -1
  4. package/lib/client.js +221 -21
  5. package/lib/commands/account.js +1 -0
  6. package/lib/commands/merchant.js +351 -91
  7. package/lib/commands/query.js +162 -14
  8. package/lib/commands/tools.js +104 -0
  9. package/lib/commands/wiki.js +167 -6
  10. package/lib/egg-service.d.ts +2 -0
  11. package/lib/egg-service.js +50 -15
  12. package/lib/index.d.ts +9 -0
  13. package/lib/index.js +3626 -303
  14. package/lib/pet-data-service.d.ts +62 -0
  15. package/lib/pet-data-service.js +468 -0
  16. package/lib/render-templates/home/img/rocomuid/a_title.png +0 -0
  17. package/lib/render-templates/home/img/rocomuid/banner_bg.png +0 -0
  18. package/lib/render-templates/home/img/rocomuid/bg.jpg +0 -0
  19. package/lib/render-templates/home/img/rocomuid/img_head.png +0 -0
  20. package/lib/render-templates/home/img/rocomuid/jindu_bar.png +0 -0
  21. package/lib/render-templates/home/img/rocomuid/jindu_tc.png +0 -0
  22. package/lib/render-templates/home/img/rocomuid/level_icon.png +0 -0
  23. package/lib/render-templates/home/img/rocomuid/pet_bg.png +0 -0
  24. package/lib/render-templates/home/img/rocomuid/plant_bg.png +0 -0
  25. package/lib/render-templates/home/img/rocomuid/star_1.png +0 -0
  26. package/lib/render-templates/home/img/rocomuid/star_8.png +0 -0
  27. package/lib/render-templates/home/img/rocomuid/star_9.png +0 -0
  28. package/lib/render-templates/home/img/rocomuid/title_fg.png +0 -0
  29. package/lib/render-templates/home/img/rocomuid/top_bg.png +0 -0
  30. package/lib/render-templates/home/img/rocomuid/touxiang_mask.png +0 -0
  31. package/lib/render-templates/home/index.html +81 -97
  32. package/lib/render-templates/home/style.css +316 -375
  33. package/lib/render-templates/pet-data/index.html +172 -0
  34. package/lib/render-templates/pet-data/style.css +553 -0
  35. package/lib/render-templates/wiki/detail/index.html +84 -0
  36. package/lib/render-templates/wiki/list/index.html +84 -0
  37. package/lib/render-templates/wiki/menu/index.html +65 -0
  38. package/lib/render-templates/wiki/pet/index.html +158 -0
  39. package/lib/render-templates/wiki/pet/style.css +393 -0
  40. package/lib/render-templates/wiki/shared/style.css +431 -0
  41. package/lib/render-templates/wiki/skill/index.html +79 -0
  42. package/lib/render-templates/wiki/skill/style.css +233 -0
  43. package/lib/render-templates/wiki/suggestions/index.html +84 -0
  44. package/lib/render-templates/yuanxing-shangren/CHANGELOG.md +138 -0
  45. package/lib/render-templates/yuanxing-shangren/README.md +86 -0
  46. package/lib/render-templates/yuanxing-shangren/img/coin.png +0 -0
  47. package/lib/render-templates/yuanxing-shangren/img//345/272/225/351/203/250/344/277/241/346/201/257/346/241/206.png +0 -0
  48. package/lib/render-templates/yuanxing-shangren/img//346/240/207/351/242/230.png +0 -0
  49. package/lib/render-templates/yuanxing-shangren/img//347/203/255/351/224/200.png +0 -0
  50. package/lib/render-templates/yuanxing-shangren/img//347/274/226/345/217/267/350/203/214/346/231/257/346/241/206.png +0 -0
  51. package/lib/render-templates/yuanxing-shangren/index.html +198 -170
  52. package/lib/render-templates/yuanxing-shangren/index.html.backup +356 -0
  53. package/lib/render-templates/yuanxing-shangren/merchant.html +461 -0
  54. package/lib/render-templates/yuanxing-shangren/style.css +201 -256
  55. package/lib/render-templates/yuanxing-shangren/today.html +461 -0
  56. package/lib/render-templates/yuanxing-shangren/today.style.css +366 -0
  57. package/lib/render.js +48 -12
  58. package/lib/subscription-send.js +4 -5
  59. package/lib/ttf/rocom_skill_origin.ttf +0 -0
  60. package/lib/ttf//351/200/240/345/255/227/345/267/245/346/210/277/345/220/257/351/273/221/344/275/223.ttf +0 -0
  61. package/lib/types.d.ts +13 -1
  62. package/lib/user.d.ts +23 -1
  63. package/lib/user.js +32 -1
  64. package/lib/wiki-catalog.d.ts +19 -0
  65. package/lib/wiki-catalog.js +124 -0
  66. package/lib/wiki-service.d.ts +220 -0
  67. package/lib/wiki-service.js +1463 -0
  68. package/package.json +1 -1
  69. package/readme.md +4 -5
@@ -281,20 +281,30 @@ class EggService {
281
281
  };
282
282
  }
283
283
  formatSizeApiCard(item) {
284
- const probability = num(item?.probability);
284
+ // 新版 /wiki/pet-size/query 返回 items[].pet / egg_size / match 结构;旧接口是平铺字段。
285
+ const petInfo = item?.pet && typeof item.pet === 'object' ? item.pet : {};
286
+ const eggSize = item?.egg_size && typeof item.egg_size === 'object' ? item.egg_size : {};
287
+ const heightRange = eggSize?.height && typeof eggSize.height === 'object' ? eggSize.height : {};
288
+ const weightRange = eggSize?.weight && typeof eggSize.weight === 'object' ? eggSize.weight : {};
289
+ const match = item?.match && typeof item.match === 'object' ? item.match : {};
290
+ const petId = petInfo?.pet_id || item?.petId || item?.pet_id || '-';
291
+ const petName = petInfo?.name || (typeof item?.pet === 'string' ? item.pet : '') || item?.name || '未知精灵';
292
+ const typeNames = Array.isArray(petInfo?.type_names) ? petInfo.type_names.filter(Boolean) : [];
293
+ const eggGroupNames = Array.isArray(petInfo?.egg_group_names) ? petInfo.egg_group_names.filter(Boolean) : [];
294
+ const probability = num(item?.probability) ?? num(match?.percent);
285
295
  const matchCount = num(item?.matchCount);
286
- const heightMin = num(item?.diameterMin);
287
- const heightMax = num(item?.diameterMax);
288
- const weightMin = num(item?.weightMin);
289
- const weightMax = num(item?.weightMax);
296
+ const heightMin = num(heightRange?.min_m ?? item?.diameterMin);
297
+ const heightMax = num(heightRange?.max_m ?? item?.diameterMax);
298
+ const weightMin = num(weightRange?.min_kg ?? item?.weightMin);
299
+ const weightMax = num(weightRange?.max_kg ?? item?.weightMax);
290
300
  return {
291
- id: item?.petId || '-',
292
- name: item?.pet || '未知精灵',
293
- icon: item?.petIcon || petIconUrl(item?.petId),
294
- image: item?.petImage || petImageUrl(item?.petId),
295
- type_label: '后端未提供',
301
+ id: petId,
302
+ name: petName,
303
+ icon: petInfo?.icon || item?.petIcon || petIconUrl(petId),
304
+ image: petInfo?.small_icon || item?.petImage || petImageUrl(petId),
305
+ type_label: typeNames.length ? typeNames.join(' / ') : '后端未提供',
296
306
  egg_group_ids: [],
297
- egg_groups_label: '后端未提供',
307
+ egg_groups_label: eggGroupNames.length ? eggGroupNames.join(' / ') : '后端未提供',
298
308
  height_min: heightMin,
299
309
  height_max: heightMax,
300
310
  height_label: fmtRange(heightMin, heightMax, 'm'),
@@ -303,7 +313,32 @@ class EggService {
303
313
  weight_label: fmtRange(weightMin, weightMax, 'kg'),
304
314
  probability,
305
315
  match_count: matchCount,
306
- match_info_label: this.formatMatchSummary(probability, matchCount),
316
+ match_info_label: String(match?.match_percent_text || '') || this.formatMatchSummary(probability, matchCount),
317
+ };
318
+ }
319
+ // 新版尺寸反查按 match.layer 划分完美/范围匹配。
320
+ splitNewSizeApiItems(items) {
321
+ const perfect = [];
322
+ const ranged = [];
323
+ for (const item of items) {
324
+ const match = item?.match && typeof item.match === 'object' ? item.match : {};
325
+ const layer = String(match?.layer || '').toLowerCase();
326
+ const displayOnly = Boolean(match?.display_only);
327
+ if (['strict', 'exact'].includes(layer) && !displayOnly)
328
+ perfect.push(item);
329
+ else
330
+ ranged.push(item);
331
+ }
332
+ return [perfect, ranged];
333
+ }
334
+ sizeApiResultGroups(results) {
335
+ if (Array.isArray(results?.items)) {
336
+ const [perfect, ranged] = this.splitNewSizeApiItems(results.items);
337
+ return { exact: perfect, candidates: ranged };
338
+ }
339
+ return {
340
+ exact: Array.isArray(results?.exactResults) ? results.exactResults : [],
341
+ candidates: Array.isArray(results?.candidates) ? results.candidates : [],
307
342
  };
308
343
  }
309
344
  formatEggSearchCard(item) {
@@ -495,8 +530,7 @@ class EggService {
495
530
  if (weight != null)
496
531
  cond.push(`体重=${weight}kg`);
497
532
  const condStr = cond.join(' + ') || '当前条件';
498
- const exact = results?.exactResults || [];
499
- const candidates = results?.candidates || [];
533
+ const { exact, candidates } = this.sizeApiResultGroups(results);
500
534
  if (!exact.length && !candidates.length)
501
535
  return `❌ 未找到符合 ${condStr} 的精灵。`;
502
536
  const lines = [];
@@ -712,7 +746,8 @@ class EggService {
712
746
  conditions.push(`身高 ${heightDisplay || fmtRange(ht(height), ht(height), 'm')}`);
713
747
  if (weight != null)
714
748
  conditions.push(`体重 ${weight} kg`);
715
- const [perfect, ranged] = this.mergeCardsByName((results?.exactResults || []).map((item) => this.formatSizeApiCard(item)), (results?.candidates || []).map((item) => this.formatSizeApiCard(item)));
749
+ const groups = this.sizeApiResultGroups(results);
750
+ const [perfect, ranged] = this.mergeCardsByName(groups.exact.map((item) => this.formatSizeApiCard(item)), groups.candidates.map((item) => this.formatSizeApiCard(item)));
716
751
  const searchMode = results?.searchMode || '';
717
752
  const queryLabel = `${conditions.join(' / ') || '尺寸反查'}${searchMode ? ` · 模式 ${searchMode}` : ''}`;
718
753
  return {
package/lib/index.d.ts CHANGED
@@ -12,12 +12,21 @@ export interface Config {
12
12
  autoRefreshTime: string[];
13
13
  merchantSubscriptionEnabled: boolean;
14
14
  merchantSubscriptionItems: string[];
15
+ merchantUiStyle: 'new' | 'old';
15
16
  merchantPrivateSubscriptionEnabled: boolean;
16
17
  merchantCheckMode: 'interval' | 'times';
17
18
  merchantCheckInterval: number;
18
19
  merchantCheckTimes: string[];
19
20
  homeSubscriptionEnabled: boolean;
20
21
  homeSubscriptionIntervalMinutes: number;
22
+ announcementSubscriptionEnabled: boolean;
23
+ announcementPollIntervalMinutes: number;
24
+ homeQueryWaitMs: number;
25
+ homeQueryPollIntervalMs: number;
26
+ homeQueryTimeoutMs: number;
27
+ lowBandwidthMode: boolean;
28
+ atlasZipUrls: string[];
29
+ atlasGitUrl: string;
21
30
  imageCompressionEnabled: boolean;
22
31
  imageCompressionMinBytes: number;
23
32
  imageCompressionLevel: number;