koishi-plugin-booth-get 6.0.0 → 6.0.2

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/card-generator.js +199 -77
  2. package/package.json +1 -1
@@ -317,6 +317,7 @@ class CardGenerator {
317
317
 
318
318
  generateDiscountCardHTML(item) {
319
319
  const savedAmount = item.original_price - item.price;
320
+ const discountRate = Math.round((1 - item.price/item.original_price)*100);
320
321
 
321
322
  return `
322
323
  <html>
@@ -328,70 +329,70 @@ generateDiscountCardHTML(item) {
328
329
  margin: 0;
329
330
  padding: 0;
330
331
  font-family: 'Noto Sans SC', sans-serif;
331
- background: linear-gradient(135deg, #ff6b6b 0%, #ffa502 100%);
332
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
332
333
  display: flex;
333
334
  justify-content: center;
334
335
  align-items: center;
335
336
  min-height: 100vh;
336
337
  }
337
338
  .container {
338
- width: 500px;
339
+ width: 640px;
339
340
  background: white;
340
341
  border-radius: 20px;
341
342
  overflow: hidden;
342
343
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
344
+ position: relative;
343
345
  }
344
346
  .header {
345
347
  background: linear-gradient(90deg, #ff6b6b, #ffa502);
346
- padding: 20px;
348
+ padding: 25px;
347
349
  text-align: center;
348
- color: white;
349
350
  position: relative;
350
- }
351
- .discount-badge {
352
- position: absolute;
353
- top: 15px;
354
- right: 15px;
355
- background: #e74c3c;
356
351
  color: white;
357
- padding: 8px 12px;
358
- border-radius: 20px;
359
- font-weight: 700;
360
- font-size: 14px;
361
- box-shadow: 0 4px 8px rgba(0,0,0,0.2);
362
352
  }
363
- .new-badge {
353
+ .header::before {
354
+ content: "";
364
355
  position: absolute;
365
- top: 15px;
366
- left: 15px;
367
- background: #27ae60;
368
- color: white;
369
- padding: 8px 12px;
370
- border-radius: 20px;
371
- font-weight: 700;
356
+ top: 0;
357
+ left: 0;
358
+ right: 0;
359
+ bottom: 0;
360
+ background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><polygon points="0,0 100,100 0,100" fill="rgba(255,255,255,0.1)"/></svg>');
361
+ background-size: 100px 100px;
362
+ }
363
+ .label {
364
+ background: rgba(255, 255, 255, 0.2);
365
+ backdrop-filter: blur(10px);
366
+ padding: 8px 20px;
367
+ border-radius: 30px;
372
368
  font-size: 14px;
373
- box-shadow: 0 4px 8px rgba(0,0,0,0.2);
369
+ font-weight: 500;
370
+ display: inline-block;
371
+ margin-bottom: 15px;
372
+ border: 1px solid rgba(255, 255, 255, 0.3);
374
373
  }
375
374
  .booth-logo {
376
375
  font-family: 'Montserrat', sans-serif;
377
376
  font-weight: 800;
378
- font-size: 28px;
377
+ font-size: 36px;
379
378
  letter-spacing: 2px;
379
+ text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
380
380
  }
381
381
  .content {
382
- padding: 25px;
382
+ padding: 30px;
383
383
  }
384
384
  .main-image {
385
385
  width: 100%;
386
- height: 250px;
386
+ height: 320px;
387
387
  background: #f0f0f0 url('${item.image_url}') center/cover;
388
- border-radius: 12px;
389
- margin-bottom: 20px;
390
- box-shadow: 0 8px 16px rgba(0,0,0,0.1);
388
+ border-radius: 15px;
389
+ margin-bottom: 25px;
390
+ box-shadow: 0 10px 20px rgba(0,0,0,0.1);
391
+ border: 1px solid rgba(0,0,0,0.05);
391
392
  }
392
393
  .product-title {
393
- font-size: 20px;
394
- margin: 0 0 15px 0;
394
+ font-size: 26px;
395
+ margin: 0 0 20px 0;
395
396
  color: #2c3e50;
396
397
  font-weight: 700;
397
398
  line-height: 1.4;
@@ -399,17 +400,18 @@ generateDiscountCardHTML(item) {
399
400
  .author-section {
400
401
  display: flex;
401
402
  align-items: center;
402
- gap: 12px;
403
- margin-bottom: 20px;
404
- padding: 12px;
403
+ gap: 15px;
404
+ margin-bottom: 25px;
405
+ padding: 15px;
405
406
  background: #f8f9fa;
406
- border-radius: 10px;
407
+ border-radius: 12px;
408
+ border-left: 4px solid #3498db;
407
409
  }
408
410
  .author-avatar {
409
- width: 50px;
410
- height: 50px;
411
+ width: 60px;
412
+ height: 60px;
411
413
  border-radius: 50%;
412
- border: 2px solid #fff;
414
+ border: 3px solid #fff;
413
415
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
414
416
  object-fit: cover;
415
417
  }
@@ -417,72 +419,172 @@ generateDiscountCardHTML(item) {
417
419
  flex: 1;
418
420
  }
419
421
  .author-name {
420
- font-size: 16px;
422
+ font-size: 18px;
421
423
  font-weight: 600;
422
424
  color: #2c3e50;
425
+ margin-bottom: 4px;
426
+ }
427
+ .author-label {
428
+ font-size: 14px;
429
+ color: #7f8c8d;
423
430
  }
424
431
  .price-section {
425
- display: flex;
426
- align-items: center;
427
- justify-content: space-between;
428
- margin-bottom: 15px;
429
- padding: 15px;
432
+ font-size: 32px;
433
+ font-weight: 700;
434
+ color: #e74c3c;
435
+ margin-bottom: 30px;
436
+ text-align: center;
430
437
  background: #fff9f9;
431
- border-radius: 10px;
438
+ padding: 15px;
439
+ border-radius: 12px;
432
440
  border: 2px dashed #e74c3c;
433
441
  }
442
+ /* 新增价格对比样式 */
443
+ .price-comparison {
444
+ display: flex;
445
+ justify-content: center;
446
+ align-items: center;
447
+ gap: 15px;
448
+ margin-bottom: 30px;
449
+ text-align: center;
450
+ }
434
451
  .original-price {
435
- font-size: 18px;
452
+ font-size: 24px;
436
453
  color: #7f8c8d;
437
454
  text-decoration: line-through;
438
455
  }
439
456
  .current-price {
440
- font-size: 24px;
457
+ font-size: 32px;
441
458
  font-weight: 700;
442
459
  color: #e74c3c;
443
460
  }
461
+ .discount-badge {
462
+ background: #e74c3c;
463
+ color: white;
464
+ padding: 5px 10px;
465
+ border-radius: 15px;
466
+ font-size: 16px;
467
+ font-weight: 600;
468
+ }
444
469
  .savings {
445
470
  text-align: center;
446
471
  font-size: 16px;
447
472
  color: #27ae60;
448
473
  font-weight: 600;
449
- margin-bottom: 15px;
474
+ margin-bottom: 20px;
450
475
  }
451
- .tags {
476
+ .description {
477
+ color: #34495e;
478
+ line-height: 1.7;
479
+ padding: 20px;
480
+ background: #f8f9fa;
481
+ border-radius: 12px;
482
+ margin-bottom: 30px;
483
+ font-size: 15px;
484
+ }
485
+ .stats {
452
486
  display: flex;
453
- flex-wrap: wrap;
454
- gap: 6px;
455
- margin-bottom: 20px;
487
+ justify-content: space-around;
488
+ margin-bottom: 30px;
489
+ text-align: center;
456
490
  }
457
- .tag {
458
- background: #e1f0fa;
491
+ .stat-item {
492
+ padding: 15px;
493
+ }
494
+ .stat-value {
495
+ font-size: 24px;
496
+ font-weight: 700;
459
497
  color: #3498db;
460
- padding: 4px 10px;
461
- border-radius: 15px;
462
- font-size: 12px;
463
- font-weight: 500;
498
+ }
499
+ .stat-label {
500
+ font-size: 14px;
501
+ color: #7f8c8d;
502
+ margin-top: 5px;
503
+ }
504
+ .related-works {
505
+ margin-top: 30px;
506
+ border-top: 1px solid #eee;
507
+ padding-top: 25px;
508
+ }
509
+ .related-title {
510
+ font-size: 20px;
511
+ color: #2c3e50;
512
+ margin-bottom: 20px;
513
+ text-align: center;
514
+ font-weight: 600;
515
+ }
516
+ .works-grid {
517
+ display: grid;
518
+ grid-template-columns: repeat(3, 1fr);
519
+ gap: 15px;
520
+ }
521
+ .work-item {
522
+ background: white;
523
+ border-radius: 12px;
524
+ overflow: hidden;
525
+ box-shadow: 0 4px 8px rgba(0,0,0,0.08);
526
+ transition: all 0.3s ease;
527
+ }
528
+ .work-item:hover {
529
+ transform: translateY(-5px);
530
+ box-shadow: 0 10px 20px rgba(0,0,0,0.15);
531
+ }
532
+ .work-image {
533
+ height: 100px;
534
+ background-size: cover;
535
+ background-position: center;
536
+ }
537
+ .work-info {
538
+ padding: 12px;
539
+ }
540
+ .work-title {
541
+ font-size: 13px;
542
+ margin-bottom: 8px;
543
+ color: #2c3e50;
544
+ height: 36px;
545
+ overflow: hidden;
546
+ }
547
+ .work-price {
548
+ font-size: 15px;
549
+ font-weight: 600;
550
+ color: #e74c3c;
464
551
  }
465
552
  .footer {
466
553
  background: #2c3e50;
467
- padding: 15px;
554
+ padding: 20px;
468
555
  text-align: center;
469
556
  color: #ecf0f1;
470
- font-size: 12px;
557
+ font-size: 14px;
471
558
  }
472
559
  .link {
473
560
  color: #3498db;
474
561
  text-decoration: none;
475
562
  font-weight: 500;
476
563
  }
564
+ .link:hover {
565
+ text-decoration: underline;
566
+ }
567
+ .tags {
568
+ display: flex;
569
+ flex-wrap: wrap;
570
+ gap: 8px;
571
+ margin-bottom: 25px;
572
+ }
573
+ .tag {
574
+ background: #e1f0fa;
575
+ color: #3498db;
576
+ padding: 6px 12px;
577
+ border-radius: 20px;
578
+ font-size: 13px;
579
+ font-weight: 500;
580
+ }
477
581
  </style>
478
582
  </head>
479
583
  <body>
480
584
  <div class="container">
481
585
  <div class="header">
482
- <div class="new-badge">NEW</div>
483
- <div class="discount-badge">-${item.discount_rate}%</div>
586
+ <div class="label">折扣商品 -${discountRate}%</div>
484
587
  <div class="booth-logo">BOOTH</div>
485
- <div style="margin-top: 8px; font-size: 14px;">最新折扣商品</div>
486
588
  </div>
487
589
 
488
590
  <div class="content">
@@ -495,35 +597,55 @@ generateDiscountCardHTML(item) {
495
597
  alt="作者头像" onerror="this.src='https://s2.booth.pm/static-images/user/guest-32.png'">
496
598
  <div class="author-info">
497
599
  <div class="author-name">${item.author}</div>
600
+ <div class="author-label">BOOTHクリエイター</div>
498
601
  </div>
499
602
  </div>
500
603
 
501
- <div class="price-section">
604
+ <!-- 折扣价格对比显示 -->
605
+ <div class="price-comparison">
502
606
  <div class="original-price">¥${item.original_price.toLocaleString()}</div>
607
+ <div class="discount-badge">-${discountRate}%</div>
503
608
  <div class="current-price">¥${item.price.toLocaleString()}</div>
504
609
  </div>
505
610
 
506
611
  <div class="savings">
507
- 节省 ¥${savedAmount.toLocaleString()} (${item.discount_rate}% 折扣)
612
+ 节省 ¥${savedAmount.toLocaleString()}
613
+ </div>
614
+
615
+ <div class="stats">
616
+ <div class="stat-item">
617
+ <div class="stat-value">${item.likes || 0}</div>
618
+ <div class="stat-label">收藏数</div>
619
+ </div>
620
+ <div class="stat-item">
621
+ <div class="stat-value">${item.category || '未分类'}</div>
622
+ <div class="stat-label">分类</div>
623
+ </div>
624
+ <div class="stat-item">
625
+ <div class="stat-value">#${item.id}</div>
626
+ <div class="stat-label">商品ID</div>
627
+ </div>
508
628
  </div>
509
629
 
510
- ${item.tags && item.tags.length > 0 ? `
511
630
  <div class="tags">
512
- ${item.tags.slice(0, 5).map(tag => `<div class="tag">${tag.name}</div>`).join('')}
631
+ ${(item.tags || []).slice(0, 5).map(tag => `<div class="tag">${tag.name}</div>`).join('')}
632
+ </div>
633
+
634
+ <div class="description">
635
+ <p>${(item.description || "").slice(0, 300)}${(item.description||"").length > 300 ? '...' : ''}</p>
513
636
  </div>
514
- ` : ''}
515
637
  </div>
516
638
 
517
639
  <div class="footer">
518
- 由VRCBBS提供 | BOOTH链接:
519
- <a href="https://booth.pm/zh-cn/items/${item.id}"
520
- class="link">
521
- https://booth.pm/zh-cn/items/${item.id}
522
- </a>
640
+ 由VRCBBS提供 | BOOTH链接:
641
+ <a href="https://booth.pm/zh-cn/items/${item.id}"
642
+ class="link">
643
+ https://booth.pm/zh-cn/items/${item.id}
644
+ </a>
523
645
  </div>
524
646
  </div>
525
647
  </body>
526
- </html>`;
648
+ </html>\``;
527
649
  }
528
650
 
529
651
  async captureCardHTML(html, config) {
@@ -532,10 +654,10 @@ generateDiscountCardHTML(item) {
532
654
 
533
655
  await page.setContent(html, {
534
656
  waitUntil: 'networkidle0',
535
- timeout: config.loadTimeout
657
+ timeout: config.loadTimeout || 30000
536
658
  });
537
659
 
538
- await new Promise(resolve => setTimeout(resolve, 3000));
660
+ await new Promise(resolve => setTimeout(resolve, 2000));
539
661
 
540
662
  await page.setViewport({ width: 640, height: 1200 });
541
663
  const container = await page.$('.container') || await page.$('body');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-booth-get",
3
3
  "description": "通过url与名称检查摊位物品并反馈用户搜索的图片",
4
- "version": "6.0.0",
4
+ "version": "6.0.2",
5
5
  "contributors": [
6
6
  "rixiang <1148147857@qq.com>"
7
7
  ],