koishi-plugin-rocom 1.0.13 → 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.
- package/lib/atlas-service.d.ts +33 -0
- package/lib/atlas-service.js +439 -0
- package/lib/client.d.ts +19 -0
- package/lib/client.js +101 -1
- package/lib/commands/account.js +1 -0
- package/lib/commands/merchant.js +11 -2
- package/lib/commands/query.js +141 -9
- package/lib/commands/tools.js +104 -0
- package/lib/commands/wiki.js +167 -6
- package/lib/egg-service.d.ts +2 -0
- package/lib/egg-service.js +50 -15
- package/lib/index.d.ts +5 -0
- package/lib/index.js +3153 -188
- package/lib/pet-data-service.d.ts +62 -0
- package/lib/pet-data-service.js +468 -0
- package/lib/render-templates/pet-data/index.html +172 -0
- package/lib/render-templates/pet-data/style.css +553 -0
- package/lib/render-templates/wiki/detail/index.html +84 -0
- package/lib/render-templates/wiki/list/index.html +84 -0
- package/lib/render-templates/wiki/menu/index.html +65 -0
- package/lib/render-templates/wiki/pet/index.html +158 -0
- package/lib/render-templates/wiki/pet/style.css +393 -0
- package/lib/render-templates/wiki/shared/style.css +431 -0
- package/lib/render-templates/wiki/skill/index.html +79 -0
- package/lib/render-templates/wiki/skill/style.css +233 -0
- package/lib/render-templates/wiki/suggestions/index.html +84 -0
- package/lib/render.js +37 -8
- package/lib/types.d.ts +9 -1
- package/lib/user.d.ts +23 -1
- package/lib/user.js +32 -1
- package/lib/wiki-catalog.d.ts +19 -0
- package/lib/wiki-catalog.js +124 -0
- package/lib/wiki-service.d.ts +220 -0
- package/lib/wiki-service.js +1463 -0
- package/package.json +1 -1
- package/readme.md +4 -5
package/lib/egg-service.js
CHANGED
|
@@ -281,20 +281,30 @@ class EggService {
|
|
|
281
281
|
};
|
|
282
282
|
}
|
|
283
283
|
formatSizeApiCard(item) {
|
|
284
|
-
|
|
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:
|
|
292
|
-
name:
|
|
293
|
-
icon: item?.petIcon || petIconUrl(
|
|
294
|
-
image: item?.petImage || petImageUrl(
|
|
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
|
|
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
|
|
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
|
@@ -19,9 +19,14 @@ export interface Config {
|
|
|
19
19
|
merchantCheckTimes: string[];
|
|
20
20
|
homeSubscriptionEnabled: boolean;
|
|
21
21
|
homeSubscriptionIntervalMinutes: number;
|
|
22
|
+
announcementSubscriptionEnabled: boolean;
|
|
23
|
+
announcementPollIntervalMinutes: number;
|
|
22
24
|
homeQueryWaitMs: number;
|
|
23
25
|
homeQueryPollIntervalMs: number;
|
|
24
26
|
homeQueryTimeoutMs: number;
|
|
27
|
+
lowBandwidthMode: boolean;
|
|
28
|
+
atlasZipUrls: string[];
|
|
29
|
+
atlasGitUrl: string;
|
|
25
30
|
imageCompressionEnabled: boolean;
|
|
26
31
|
imageCompressionMinBytes: number;
|
|
27
32
|
imageCompressionLevel: number;
|