koishi-plugin-fimtale-api 1.0.2 → 1.0.3

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 (2) hide show
  1. package/lib/index.js +9 -18
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -193,9 +193,10 @@ function apply(ctx, config) {
193
193
  const renderCard = /* @__PURE__ */ __name(async (info, parent) => {
194
194
  const isChapter = info.IsChapter || !!parent && parent.ID !== info.ID;
195
195
  const displayTitle = isChapter && parent ? parent.Title : info.Title;
196
- let displayCover = null;
197
- if (isChapter && parent) displayCover = parent.Background || extractImage(parent.Content);
198
- if (!displayCover) displayCover = info.Background || extractImage(info.Content);
196
+ let displayCover = info.Background || extractImage(info.Content);
197
+ if (!displayCover && isChapter && parent) {
198
+ displayCover = parent.Background || extractImage(parent.Content);
199
+ }
199
200
  const displayTagsObj = isChapter && parent ? parent.Tags : info.Tags;
200
201
  const subTitle = isChapter ? info.Title : null;
201
202
  const bgStyle = displayCover ? `background-image: url('${displayCover}');` : `background: ${generateGradient(displayTitle)};`;
@@ -207,6 +208,7 @@ function apply(ctx, config) {
207
208
  if (displayTagsObj?.Type) tagsArr.push(displayTagsObj.Type);
208
209
  if (displayTagsObj?.Rating && displayTagsObj.Rating !== "E") tagsArr.push(displayTagsObj.Rating);
209
210
  if (displayTagsObj?.OtherTags) tagsArr.push(...displayTagsObj.OtherTags);
211
+ const likes = isChapter && parent ? parent.Upvotes || 0 : info.Upvotes || 0;
210
212
  const html = `<!DOCTYPE html><html><head><style>
211
213
  body { margin: 0; padding: 0; font-family: ${fontStack}; background: transparent; }
212
214
  .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; }
@@ -230,7 +232,7 @@ function apply(ctx, config) {
230
232
  <div class="summary-box"><div class="summary">${summary}</div></div>
231
233
  <div class="footer">
232
234
  <span class="stat"><b style="color:#009688">热度</b>${info.Views || 0}</span><span class="stat"><b style="color:#673ab7">评论</b>${info.Comments || 0}</span>
233
- <span class="stat"><b style="color:#4caf50">赞</b>${info.Upvotes || 0}</span><span class="stat"><b style="color:#795548">字数</b>${info.WordCount || 0}</span>
235
+ <span class="stat"><b style="color:#4caf50">赞</b>${likes}</span><span class="stat"><b style="color:#795548">字数</b>${info.WordCount || 0}</span>
234
236
  </div></div></div></body></html>`;
235
237
  const page = await ctx.puppeteer.page();
236
238
  await injectCookies(page);
@@ -295,25 +297,14 @@ function apply(ctx, config) {
295
297
  .fixed-header { position: absolute; top: 0; left: 0; width: 100%; height: ${headerHeight}px; border-bottom: 1px solid #d7ccc8; box-sizing: border-box; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: #8d6e63; background: #f6f4ec; z-index: 5; font-weight: bold; }
296
298
  .fixed-footer { position: absolute; bottom: 0; left: 0; width: 100%; height: ${footerHeight}px; display: flex; align-items: center; justify-content: center; font-size: 12px; color: #aaa; background: #f6f4ec; z-index: 5; }
297
299
  #viewport { position: absolute; top: ${marginTop}px; left: ${paddingX}px; width: ${contentWidth}px; height: ${optimalContentHeight}px; overflow: hidden; }
300
+ #content-scroller { height: 100%; width: 100%; column-width: ${contentWidth}px; column-gap: ${columnGap}px; column-fill: auto; padding: ${paddingY}px 0; box-sizing: border-box; font-size: ${config.fontSize}px; line-height: ${lineHeightRatio}; text-align: left; transform: translateX(0); transition: none; }
298
301
 
299
- #content-scroller {
300
- height: 100%; width: 100%;
301
- column-width: ${contentWidth}px; column-gap: ${columnGap}px; column-fill: auto;
302
- padding: ${paddingY}px 0; box-sizing: border-box;
303
- font-size: ${config.fontSize}px; line-height: ${lineHeightRatio};
304
- text-align: left; /* 修正:左对齐防止空格拉伸 */
305
- transform: translateX(0); transition: none;
306
- }
307
-
308
- /* 基础文本 */
309
302
  p, div { margin: 0 0 0.2em 0; text-indent: 2em; word-wrap: break-word; overflow-wrap: break-word; }
310
303
 
311
- /* 辅助类 */
312
304
  .align-center { text-align: center !important; text-align-last: center !important; text-indent: 0 !important; margin: 0.8em 0; font-weight: bold; color: #5d4037; }
313
305
  .align-right { text-align: right !important; text-indent: 0 !important; margin-top: 0.5em; color: #666; font-style: italic; }
314
306
  .no-indent { text-indent: 0 !important; }
315
307
 
316
- /* 富文本支持 */
317
308
  blockquote { margin: 1em 0.5em; padding-left: 1em; border-left: 4px solid #d7ccc8; color: #666; }
318
309
  blockquote p { text-indent: 0; margin: 0.3em 0; }
319
310
 
@@ -337,11 +328,9 @@ function apply(ctx, config) {
337
328
 
338
329
  a { color: #0277bd; text-decoration: none; }
339
330
 
340
- /* 图片 (使用 figure 替代 div) */
341
331
  figure.img-box { display: flex; justify-content: center; align-items: center; margin: 0.5em 0; width: 100%; }
342
332
  img { max-width: 100%; height: auto; display: block; border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
343
333
 
344
- /* 标题 */
345
334
  h1, h2, h3 { font-size: 1.1em; margin: 0.8em 0; color: #5d4037; text-indent: 0; font-weight: bold; text-align: center; text-align-last: center; break-after: avoid; }
346
335
 
347
336
  strong, b { font-weight: 900; color: #3e2723; }
@@ -412,6 +401,8 @@ function apply(ctx, config) {
412
401
  const pages = await renderReadPages(res.data);
413
402
  const nodes = pages.map((buf) => (0, import_koishi.h)("message", import_koishi.h.image(buf, "image/jpeg")));
414
403
  const navs = [];
404
+ const mainId = res.parent ? res.parent.ID : res.data.ID;
405
+ navs.push(`[目录] /ft.info ${mainId}`);
415
406
  if (res.menu?.length) {
416
407
  const idx = res.menu.findIndex((m) => m.ID.toString() === threadId);
417
408
  if (idx > 0) navs.push(`[上一章] /ft.read ${res.menu[idx - 1].ID}`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-fimtale-api",
3
3
  "description": "Koishi插件,从fimtale搜索/订阅/随机获取小说/解析链接等",
4
- "version": "1.0.2",
4
+ "version": "1.0.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [