koishi-plugin-rocom 1.0.12 → 1.0.13

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 (42) hide show
  1. package/lib/client.d.ts +17 -1
  2. package/lib/client.js +121 -21
  3. package/lib/commands/merchant.js +340 -89
  4. package/lib/commands/query.js +22 -6
  5. package/lib/index.d.ts +4 -0
  6. package/lib/index.js +480 -122
  7. package/lib/render-templates/home/img/rocomuid/a_title.png +0 -0
  8. package/lib/render-templates/home/img/rocomuid/banner_bg.png +0 -0
  9. package/lib/render-templates/home/img/rocomuid/bg.jpg +0 -0
  10. package/lib/render-templates/home/img/rocomuid/img_head.png +0 -0
  11. package/lib/render-templates/home/img/rocomuid/jindu_bar.png +0 -0
  12. package/lib/render-templates/home/img/rocomuid/jindu_tc.png +0 -0
  13. package/lib/render-templates/home/img/rocomuid/level_icon.png +0 -0
  14. package/lib/render-templates/home/img/rocomuid/pet_bg.png +0 -0
  15. package/lib/render-templates/home/img/rocomuid/plant_bg.png +0 -0
  16. package/lib/render-templates/home/img/rocomuid/star_1.png +0 -0
  17. package/lib/render-templates/home/img/rocomuid/star_8.png +0 -0
  18. package/lib/render-templates/home/img/rocomuid/star_9.png +0 -0
  19. package/lib/render-templates/home/img/rocomuid/title_fg.png +0 -0
  20. package/lib/render-templates/home/img/rocomuid/top_bg.png +0 -0
  21. package/lib/render-templates/home/img/rocomuid/touxiang_mask.png +0 -0
  22. package/lib/render-templates/home/index.html +81 -97
  23. package/lib/render-templates/home/style.css +316 -375
  24. package/lib/render-templates/yuanxing-shangren/CHANGELOG.md +138 -0
  25. package/lib/render-templates/yuanxing-shangren/README.md +86 -0
  26. package/lib/render-templates/yuanxing-shangren/img/coin.png +0 -0
  27. 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
  28. package/lib/render-templates/yuanxing-shangren/img//346/240/207/351/242/230.png +0 -0
  29. package/lib/render-templates/yuanxing-shangren/img//347/203/255/351/224/200.png +0 -0
  30. 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
  31. package/lib/render-templates/yuanxing-shangren/index.html +198 -170
  32. package/lib/render-templates/yuanxing-shangren/index.html.backup +356 -0
  33. package/lib/render-templates/yuanxing-shangren/merchant.html +461 -0
  34. package/lib/render-templates/yuanxing-shangren/style.css +201 -256
  35. package/lib/render-templates/yuanxing-shangren/today.html +461 -0
  36. package/lib/render-templates/yuanxing-shangren/today.style.css +366 -0
  37. package/lib/render.js +11 -4
  38. package/lib/subscription-send.js +4 -5
  39. package/lib/ttf/rocom_skill_origin.ttf +0 -0
  40. 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
  41. package/lib/types.d.ts +4 -0
  42. package/package.json +1 -1
@@ -0,0 +1,366 @@
1
+ /* 今日远行商人样式 - 从today.html中提取 */
2
+
3
+ @font-face {
4
+ font-family: "fzlant";
5
+ src: url("../../ttf/fzlant.D5FI9Et0.ttf");
6
+ }
7
+
8
+ @font-face {
9
+ font-family: "dundun";
10
+ src: url("../../ttf/dundun.xHd_Ee5-.woff2");
11
+ }
12
+
13
+ * {
14
+ margin: 0;
15
+ padding: 0;
16
+ box-sizing: border-box;
17
+ }
18
+
19
+ :root {
20
+ --font-family: "fzlant", "Microsoft YaHei", "PingFang SC", sans-serif;
21
+ --font-family-accent: "dundun", "fzlant", "Microsoft YaHei", sans-serif;
22
+ --text-1: #332719;
23
+ --text-2: #6b5846;
24
+ --line: rgba(118, 97, 74, 0.22);
25
+ --panel-bg: rgba(243, 237, 227, 0.94);
26
+ --card-bg: rgba(255, 252, 247, 0.82);
27
+ --tag-bg: rgba(255, 214, 153, 0.4);
28
+ --tag-text: #9a5f19;
29
+ --round-current-bg: rgba(255, 214, 153, 0.25);
30
+ --round-current-border: rgba(200, 140, 40, 0.4);
31
+ --round-current-text: #b06800;
32
+ --accent-color: #a0631d;
33
+ --warning-color: #bf5f3f;
34
+ --border-color: rgba(179, 123, 45, 0.2);
35
+ --border-color-light: rgba(118, 97, 74, 0.12);
36
+ --weekend-color: #c04030;
37
+ --normal-color: #2a8040;
38
+ --round-color: #2a60b0;
39
+ --weekend-bg: rgba(220, 80, 60, 0.15);
40
+ --normal-bg: rgba(60, 160, 80, 0.15);
41
+ --round-bg: rgba(60, 120, 220, 0.15);
42
+ }
43
+
44
+ html,
45
+ body {
46
+ width: 100%;
47
+ height: auto;
48
+ font-family: var(--font-family);
49
+ color: var(--text-1);
50
+ background: #ece3d3;
51
+ }
52
+
53
+ .merchant-page {
54
+ position: relative;
55
+ width: min(1040px, calc(100vw - 24px));
56
+ margin: 0 auto;
57
+ padding: 14px;
58
+ overflow: hidden;
59
+ background: #ece3d3;
60
+ border-radius: 30px;
61
+ }
62
+
63
+ .background {
64
+ position: absolute;
65
+ inset: 0;
66
+ background-size: cover;
67
+ background-position: center top;
68
+ background-repeat: no-repeat;
69
+ opacity: 0.24;
70
+ filter: saturate(0.9);
71
+ }
72
+
73
+ .content-container {
74
+ position: relative;
75
+ z-index: 1;
76
+ width: 100%;
77
+ padding: 2px 0 4px;
78
+ }
79
+
80
+ .header {
81
+ display: flex;
82
+ justify-content: space-between;
83
+ gap: 16px;
84
+ padding: 20px 22px;
85
+ border: 1px solid var(--line);
86
+ border-radius: 24px;
87
+ background: linear-gradient(135deg, rgba(255,255,255,0.86), rgba(245,236,221,0.9));
88
+ box-shadow: 0 14px 36px rgba(58, 39, 21, 0.08);
89
+ }
90
+
91
+ .title-section {
92
+ display: flex;
93
+ flex-direction: column;
94
+ gap: 10px;
95
+ }
96
+
97
+ .title-main {
98
+ display: flex;
99
+ align-items: center;
100
+ gap: 12px;
101
+ }
102
+
103
+ .title-badge {
104
+ width: 60px;
105
+ height: 60px;
106
+ display: flex;
107
+ align-items: center;
108
+ justify-content: center;
109
+ background: transparent;
110
+ color: #fffaf0;
111
+ font-size: 28px;
112
+ font-weight: 900;
113
+ }
114
+
115
+ .title-badge img {
116
+ width: 60px;
117
+ height: 60px;
118
+ object-fit: contain;
119
+ }
120
+
121
+ .title-text {
122
+ font-family: var(--font-family-accent);
123
+ font-size: 36px;
124
+ font-weight: 900;
125
+ letter-spacing: 1px;
126
+ }
127
+
128
+ .subtitle {
129
+ color: var(--text-2);
130
+ font-size: 16px;
131
+ }
132
+
133
+ .header-side {
134
+ min-width: 200px;
135
+ display: flex;
136
+ flex-direction: column;
137
+ align-items: flex-end;
138
+ justify-content: center;
139
+ gap: 12px;
140
+ }
141
+
142
+ .summary-chip {
143
+ padding: 9px 14px;
144
+ border-radius: 999px;
145
+ background: rgba(255,255,255,0.72);
146
+ border: 1px solid var(--border-color);
147
+ color: var(--text-2);
148
+ font-size: 16px;
149
+ }
150
+
151
+ .summary-chip strong {
152
+ font-family: var(--font-family-accent);
153
+ color: var(--accent-color);
154
+ font-size: 24px;
155
+ margin-left: 8px;
156
+ }
157
+
158
+ .category-section {
159
+ margin-top: 18px;
160
+ }
161
+
162
+ .category-header {
163
+ display: flex;
164
+ align-items: center;
165
+ gap: 12px;
166
+ margin-bottom: 12px;
167
+ padding: 0 4px;
168
+ }
169
+
170
+ .category-title {
171
+ font-family: var(--font-family-accent);
172
+ font-size: 24px;
173
+ font-weight: 800;
174
+ color: var(--text-1);
175
+ }
176
+
177
+ .category-count {
178
+ padding: 4px 10px;
179
+ border-radius: 999px;
180
+ font-size: 14px;
181
+ font-weight: 700;
182
+ }
183
+
184
+ .category-count.normal {
185
+ background: var(--normal-bg);
186
+ color: var(--normal-color);
187
+ }
188
+
189
+ .category-count.round {
190
+ background: var(--round-bg);
191
+ color: var(--round-color);
192
+ }
193
+
194
+ .category-count.weekend {
195
+ background: var(--weekend-bg);
196
+ color: var(--weekend-color);
197
+ }
198
+
199
+ .round-section {
200
+ padding: 14px 18px;
201
+ border: 1px solid var(--round-current-border);
202
+ border-radius: 16px;
203
+ background: linear-gradient(135deg, rgba(255,248,235,0.88), rgba(255,240,210,0.9));
204
+ box-shadow: 0 6px 22px rgba(180, 120, 20, 0.08);
205
+ margin-bottom: 10px;
206
+ }
207
+
208
+ .round-section:last-child {
209
+ margin-bottom: 0;
210
+ }
211
+
212
+ .round-section.is-current {
213
+ background: linear-gradient(135deg, rgba(255,248,235,1), rgba(255,240,210,1));
214
+ border-color: rgba(200, 140, 40, 0.6);
215
+ box-shadow: 0 6px 28px rgba(180, 120, 20, 0.12);
216
+ }
217
+
218
+ .round-header {
219
+ display: flex;
220
+ align-items: center;
221
+ gap: 10px;
222
+ margin-bottom: 10px;
223
+ }
224
+
225
+ .round-title {
226
+ font-family: var(--font-family-accent);
227
+ font-size: 18px;
228
+ font-weight: 700;
229
+ color: var(--text-2);
230
+ }
231
+
232
+ .round-badge {
233
+ padding: 3px 8px;
234
+ border-radius: 999px;
235
+ background: var(--tag-bg);
236
+ color: var(--tag-text);
237
+ font-size: 12px;
238
+ font-weight: 700;
239
+ }
240
+
241
+ .round-badge.current {
242
+ background: var(--round-current-bg);
243
+ color: var(--round-current-text);
244
+ }
245
+
246
+ .products-grid {
247
+ display: grid;
248
+ grid-template-columns: 1fr;
249
+ gap: 14px;
250
+ }
251
+
252
+ .product-card {
253
+ display: grid;
254
+ grid-template-columns: 80px 1fr auto;
255
+ gap: 14px;
256
+ align-items: center;
257
+ min-height: 96px;
258
+ padding: 12px 16px;
259
+ border: 1px solid rgba(200, 140, 40, 0.3);
260
+ border-radius: 16px;
261
+ background: linear-gradient(135deg, rgba(255,248,235,0.75), rgba(255,240,210,0.85));
262
+ box-shadow: 0 4px 14px rgba(180, 120, 20, 0.06);
263
+ }
264
+
265
+ .product-image-container {
266
+ width: 80px;
267
+ height: 80px;
268
+ border-radius: 12px;
269
+ background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.94), rgba(255,240,210,0.92));
270
+ display: flex;
271
+ align-items: center;
272
+ justify-content: center;
273
+ overflow: hidden;
274
+ }
275
+
276
+ .product-image {
277
+ width: 100%;
278
+ height: 100%;
279
+ object-fit: contain;
280
+ }
281
+
282
+ .product-main {
283
+ min-width: 0;
284
+ }
285
+
286
+ .product-name {
287
+ font-family: var(--font-family-accent);
288
+ font-size: 22px;
289
+ font-weight: 800;
290
+ line-height: 1.2;
291
+ word-break: break-word;
292
+ }
293
+
294
+ .product-time {
295
+ display: inline-flex;
296
+ margin-top: 8px;
297
+ padding: 5px 10px;
298
+ border-radius: 999px;
299
+ background: var(--tag-bg);
300
+ color: var(--tag-text);
301
+ font-size: 14px;
302
+ font-weight: 700;
303
+ }
304
+
305
+ .product-side {
306
+ align-self: stretch;
307
+ display: flex;
308
+ align-items: center;
309
+ justify-content: flex-end;
310
+ }
311
+
312
+ .product-slot {
313
+ padding: 7px 10px;
314
+ border-radius: 12px;
315
+ background: rgba(255,255,255,0.72);
316
+ border: 1px solid var(--border-color);
317
+ color: var(--accent-color);
318
+ font-size: 14px;
319
+ font-weight: 700;
320
+ }
321
+
322
+ .round-empty {
323
+ text-align: center;
324
+ padding: 18px 14px;
325
+ border-radius: 14px;
326
+ border: 1px dashed rgba(200, 140, 40, 0.3);
327
+ color: #8b7a66;
328
+ font-size: 16px;
329
+ background: rgba(255,248,235,0.5);
330
+ }
331
+
332
+ .all-empty {
333
+ text-align: center;
334
+ padding: 40px 18px;
335
+ margin-top: 18px;
336
+ border-radius: 20px;
337
+ border: 1px dashed rgba(200, 140, 40, 0.35);
338
+ color: #5c4a37;
339
+ font-size: 20px;
340
+ background: rgba(255,248,235,0.6);
341
+ }
342
+
343
+ .category-label {
344
+ display: inline-flex;
345
+ padding: 3px 8px;
346
+ border-radius: 999px;
347
+ font-size: 12px;
348
+ font-weight: 700;
349
+ margin-left: 8px;
350
+ vertical-align: middle;
351
+ }
352
+
353
+ .category-label.weekend {
354
+ background: var(--weekend-bg);
355
+ color: var(--weekend-color);
356
+ }
357
+
358
+ .category-label.normal {
359
+ background: var(--normal-bg);
360
+ color: var(--normal-color);
361
+ }
362
+
363
+ .category-label.round {
364
+ background: var(--round-bg);
365
+ color: var(--round-color);
366
+ }
package/lib/render.js CHANGED
@@ -50,6 +50,11 @@ const TEMPLATE_CAPTURE_PADDING = {
50
50
  const TEMPLATE_VIEWPORTS = {
51
51
  activities: { width: 1600, height: 1200, deviceScaleFactor: 2 },
52
52
  };
53
+ const VISUAL_BOUNDS_TEMPLATES = new Set([
54
+ 'home',
55
+ 'yuanxing-shangren/merchant',
56
+ 'yuanxing-shangren/today',
57
+ ]);
53
58
  const DEFAULT_SCREENSHOT_OPTIONS = {
54
59
  type: 'jpeg',
55
60
  quality: 82,
@@ -177,6 +182,7 @@ class Renderer {
177
182
  '.student-perks-page',
178
183
  '.student-page',
179
184
  '.merchant-page',
185
+ '.page',
180
186
  '.home-page',
181
187
  '.pet-panel-page',
182
188
  '.pet-detail-page',
@@ -194,16 +200,17 @@ class Renderer {
194
200
  if (target) {
195
201
  const box = await target.boundingBox();
196
202
  if (box && box.width > 0 && box.height > 0) {
197
- const elementMetrics = await page.evaluate((el) => {
203
+ const useVisualBounds = VISUAL_BOUNDS_TEMPLATES.has(templateName);
204
+ const elementMetrics = await page.evaluate((el, visualBounds) => {
198
205
  const rect = el.getBoundingClientRect();
199
206
  const element = el;
200
207
  return {
201
208
  x: rect.left + window.scrollX,
202
209
  y: rect.top + window.scrollY,
203
- width: Math.max(rect.width, element.scrollWidth, element.offsetWidth),
204
- height: Math.max(rect.height, element.scrollHeight, element.offsetHeight),
210
+ width: visualBounds ? rect.width : Math.max(rect.width, element.scrollWidth, element.offsetWidth),
211
+ height: visualBounds ? rect.height : Math.max(rect.height, element.scrollHeight, element.offsetHeight),
205
212
  };
206
- }, target);
213
+ }, target, useVisualBounds);
207
214
  const capturePadding = TEMPLATE_CAPTURE_PADDING[templateName] || { left: 0, right: 0, top: 0, bottom: 0 };
208
215
  await page.setViewport({
209
216
  width: Math.max(Math.ceil(elementMetrics.x + elementMetrics.width + capturePadding.right) + 8, 200),
@@ -49,14 +49,13 @@ async function sendScheduledMessage(ctx, target, message) {
49
49
  return false;
50
50
  }
51
51
  async function sendScheduledImageWithFallback(ctx, target, image, fallbackText, mentionAll = false) {
52
- const prefix = mentionAll ? '@全体\n' : '';
52
+ const buildContent = (body) => mentionAll ? (0, koishi_1.h)('message', {}, (0, koishi_1.h)('at', { type: 'all' }), koishi_1.h.text('\n'), body) : body;
53
53
  if (!image) {
54
- return sendScheduledMessage(ctx, target, `${prefix}${fallbackText}`);
54
+ return sendScheduledMessage(ctx, target, buildContent(koishi_1.h.text(fallbackText)));
55
55
  }
56
56
  const imageSegment = koishi_1.h.image(image, (0, send_image_1.detectImageMime)(image));
57
- const content = mentionAll ? `${prefix}${imageSegment}` : imageSegment;
58
- const sent = await sendScheduledMessage(ctx, target, content);
57
+ const sent = await sendScheduledMessage(ctx, target, buildContent(imageSegment));
59
58
  if (sent)
60
59
  return true;
61
- return sendScheduledMessage(ctx, target, `${prefix}${fallbackText}`);
60
+ return sendScheduledMessage(ctx, target, buildContent(koishi_1.h.text(fallbackText)));
62
61
  }
Binary file
package/lib/types.d.ts CHANGED
@@ -12,12 +12,16 @@ export interface PluginConfig {
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
+ homeQueryWaitMs: number;
23
+ homeQueryPollIntervalMs: number;
24
+ homeQueryTimeoutMs: number;
21
25
  imageCompressionEnabled: boolean;
22
26
  imageCompressionMinBytes: number;
23
27
  imageCompressionLevel: number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-rocom",
3
3
  "description": "洛克王国查询与订阅插件",
4
- "version": "1.0.12",
4
+ "version": "1.0.13",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "homepage": "https://github.com/staytomorrow/koishi-plugin-rocom",