koishi-plugin-fimtale-api 0.0.98 → 0.0.99
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/index.js +23 -33
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -78,7 +78,7 @@ function apply(ctx, config) {
|
|
|
78
78
|
}, "generateGradient");
|
|
79
79
|
const cleanContent = /* @__PURE__ */ __name((html) => {
|
|
80
80
|
if (!html) return "";
|
|
81
|
-
return html.replace(/style
|
|
81
|
+
return html.replace(/style\s*=\s*['"][^'"]*['"]/gi, "").replace(/<p[^>]*>\s*(?:<br\s*\/?>| | |\s| )*\s*<\/p>/gi, "").replace(/<br\s*\/?>\s*<\/p>/gi, "</p>").replace(/<\/p>\s*(?:<br\s*\/?>\s*)+\s*<p/gi, "</p><p>").replace(/(?:<br\s*\/?>\s*){2,}/gi, "<br>").replace(/(?:<br\s*\/?>| |\s)+$/gi, "").trim();
|
|
82
82
|
}, "cleanContent");
|
|
83
83
|
const fontStack = '"Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif';
|
|
84
84
|
const fontSerif = '"Noto Serif SC", "Source Han Serif SC", "SimSun", serif';
|
|
@@ -231,10 +231,8 @@ function apply(ctx, config) {
|
|
|
231
231
|
<style>
|
|
232
232
|
body { margin: 0; padding: 0; font-family: ${fontStack}; background: transparent; }
|
|
233
233
|
.card { width: 620px; height: 360px; background: #fff; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); display: flex; overflow: hidden; }
|
|
234
|
-
|
|
235
234
|
.cover { width: 220px; height: 100%; ${bgStyle} background-size: cover; background-position: center; position: relative; flex-shrink: 0; }
|
|
236
235
|
.id-tag { position: absolute; top: 12px; left: 12px; background: rgba(0,0,0,0.6); color: #fff; padding: 4px 10px; border-radius: 6px; font-size: 13px; font-weight: bold; backdrop-filter: blur(4px); font-family: monospace; }
|
|
237
|
-
|
|
238
236
|
.info { flex: 1; padding: 24px; display: flex; flex-direction: column; overflow: hidden; position: relative; }
|
|
239
237
|
|
|
240
238
|
.header-group { flex-shrink: 0; margin-bottom: 10px; }
|
|
@@ -255,29 +253,17 @@ function apply(ctx, config) {
|
|
|
255
253
|
.tag { background: #eff2f5; color: #5c6b7f; padding: 3px 9px; border-radius: 4px; font-size: 11px; font-weight: 500; }
|
|
256
254
|
.tag-imp { background: #e3f2fd; color: #1565c0; }
|
|
257
255
|
|
|
258
|
-
|
|
259
|
-
.summary-box {
|
|
260
|
-
flex: 1;
|
|
261
|
-
position: relative;
|
|
262
|
-
overflow: hidden;
|
|
263
|
-
min-height: 0;
|
|
264
|
-
}
|
|
256
|
+
.summary-box { flex: 1; position: relative; overflow: hidden; min-height: 0; }
|
|
265
257
|
.summary {
|
|
266
258
|
font-size: 13px; color: #666; line-height: 1.6;
|
|
267
|
-
display: -webkit-box;
|
|
268
|
-
-
|
|
269
|
-
-webkit-box-orient: vertical;
|
|
270
|
-
overflow: hidden;
|
|
271
|
-
padding-bottom: 3px; /* 关键修复:防止下行字母(如g,j,p,q,y)被切掉 */
|
|
259
|
+
display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
|
|
260
|
+
padding-bottom: 3px;
|
|
272
261
|
}
|
|
273
262
|
|
|
274
263
|
.footer {
|
|
275
|
-
border-top: 1px solid #eee;
|
|
276
|
-
padding-top: 14px;
|
|
264
|
+
border-top: 1px solid #eee; padding-top: 14px;
|
|
277
265
|
display: flex; justify-content: space-between;
|
|
278
|
-
font-size: 12px; color: #888;
|
|
279
|
-
margin-top: auto; /* 确保页脚始终在底部 */
|
|
280
|
-
flex-shrink: 0;
|
|
266
|
+
font-size: 12px; color: #888; margin-top: auto; flex-shrink: 0;
|
|
281
267
|
}
|
|
282
268
|
.stat b { color: #555; font-weight: bold; margin-right: 2px;}
|
|
283
269
|
</style>
|
|
@@ -401,40 +387,43 @@ function apply(ctx, config) {
|
|
|
401
387
|
font-size: 12px; color: #aaa; background: #f6f4ec; z-index: 5;
|
|
402
388
|
}
|
|
403
389
|
|
|
404
|
-
/*
|
|
390
|
+
/* 视口容器:限定只显示一页内容 */
|
|
405
391
|
#viewport {
|
|
406
392
|
position: absolute;
|
|
407
393
|
top: ${marginTop}px;
|
|
408
|
-
left: ${paddingX}px;
|
|
409
|
-
width: ${contentWidth}px;
|
|
394
|
+
left: ${paddingX}px;
|
|
395
|
+
width: ${contentWidth}px;
|
|
410
396
|
height: ${optimalContentHeight}px;
|
|
411
|
-
overflow: hidden;
|
|
397
|
+
overflow: hidden;
|
|
412
398
|
}
|
|
413
399
|
|
|
414
|
-
/*
|
|
400
|
+
/* 长条容器:包含所有列 */
|
|
415
401
|
#content-scroller {
|
|
416
402
|
height: 100%;
|
|
417
|
-
width: 100%;
|
|
403
|
+
width: 100%;
|
|
418
404
|
|
|
419
405
|
/* CSS Columns 布局 */
|
|
420
406
|
column-width: ${contentWidth}px;
|
|
421
407
|
column-gap: ${columnGap}px;
|
|
422
408
|
column-fill: auto;
|
|
423
409
|
|
|
424
|
-
padding: ${paddingY}px 0;
|
|
410
|
+
padding: ${paddingY}px 0;
|
|
425
411
|
box-sizing: border-box;
|
|
426
412
|
|
|
427
413
|
font-size: ${config.fontSize}px;
|
|
428
414
|
line-height: ${lineHeightRatio};
|
|
429
415
|
text-align: justify;
|
|
430
416
|
|
|
431
|
-
/* 关键:使用 transform 移动,初始位置为 0 */
|
|
432
417
|
transform: translateX(0);
|
|
433
418
|
transition: none;
|
|
434
419
|
}
|
|
435
420
|
|
|
436
|
-
|
|
437
|
-
|
|
421
|
+
/* 段落间距微调:更紧凑 */
|
|
422
|
+
p { margin: 0 0 0.6em 0; text-indent: 2em; }
|
|
423
|
+
/* 防止最后一段下边距导致额外分页 */
|
|
424
|
+
p:last-child { margin-bottom: 0; }
|
|
425
|
+
|
|
426
|
+
img { max-width: 100%; height: auto; display: block; margin: 10px auto; border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
|
|
438
427
|
h1, h2, h3 { font-size: 1.1em; margin: 0.8em 0; color: #5d4037; text-indent: 0; font-weight: bold; break-after: avoid; break-inside: avoid; }
|
|
439
428
|
</style>
|
|
440
429
|
</head>
|
|
@@ -459,14 +448,15 @@ function apply(ctx, config) {
|
|
|
459
448
|
await page.setViewport({ width: config.deviceWidth, height: config.deviceHeight, deviceScaleFactor: 2 });
|
|
460
449
|
const scrollWidth = await page.$eval("#content-scroller", (el) => el.scrollWidth);
|
|
461
450
|
const step = contentWidth + columnGap;
|
|
462
|
-
const totalPages = Math.
|
|
451
|
+
const totalPages = Math.floor((scrollWidth + columnGap - 10) / step) + 1;
|
|
452
|
+
const finalPages = Math.max(1, totalPages);
|
|
463
453
|
const imgs = [];
|
|
464
|
-
for (let i = 0; i <
|
|
454
|
+
for (let i = 0; i < finalPages; i++) {
|
|
465
455
|
await page.evaluate((idx, stepPx, curr, total) => {
|
|
466
456
|
const offset = -(idx * stepPx);
|
|
467
457
|
document.getElementById("content-scroller").style.transform = `translateX(${offset}px)`;
|
|
468
458
|
document.getElementById("page-indicator").innerText = `- ${curr} / ${total} -`;
|
|
469
|
-
}, i, step, i + 1,
|
|
459
|
+
}, i, step, i + 1, finalPages);
|
|
470
460
|
const img = await page.screenshot({ type: "jpeg", quality: 80 });
|
|
471
461
|
imgs.push(img);
|
|
472
462
|
}
|