koishi-plugin-bilibili-notify 1.0.2 → 1.0.4-alpha.0
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/0.html +0 -0
- package/lib/biliAPI.d.ts +1 -1
- package/lib/biliAPI.js +18 -6
- package/lib/comRegister.d.ts +1 -1
- package/lib/comRegister.js +66 -62
- package/lib/generateImg.d.ts +21 -4
- package/lib/generateImg.js +576 -519
- package/lib/index.d.ts +2 -0
- package/lib/index.js +25 -8
- package/package.json +1 -1
- package/readme.md +1 -0
package/lib/generateImg.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const koishi_1 = require("koishi");
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const url_1 = require("url");
|
|
4
6
|
// 动态类型
|
|
5
7
|
const DYNAMIC_TYPE_NONE = 'DYNAMIC_TYPE_NONE';
|
|
6
8
|
const DYNAMIC_TYPE_FORWARD = 'DYNAMIC_TYPE_FORWARD';
|
|
@@ -45,134 +47,164 @@ class GenerateImg extends koishi_1.Service {
|
|
|
45
47
|
this.logger.info('GenerateImg已被注册到Context中');
|
|
46
48
|
}
|
|
47
49
|
async generateLiveImg(data, userData, liveStatus /*0未开播 1刚开播 2已开播 */) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
<
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
50
|
+
const [titleStatus, liveTime, cover] = await this.getLiveStatus(data.live_time, liveStatus);
|
|
51
|
+
// 加载字体
|
|
52
|
+
const fontURL = (0, url_1.pathToFileURL)((0, path_1.resolve)(__dirname, '../font/HYZhengYuan-55W.ttf'));
|
|
53
|
+
// 卡片内容
|
|
54
|
+
const html = `
|
|
55
|
+
<!DOCTYPE html>
|
|
56
|
+
<html>
|
|
57
|
+
<head>
|
|
58
|
+
<title>直播通知</title>
|
|
59
|
+
<style>
|
|
60
|
+
@font-face {
|
|
61
|
+
font-family: "Custom Font";
|
|
62
|
+
src: url(${fontURL});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
* {
|
|
66
|
+
margin: 0;
|
|
67
|
+
padding: 0;
|
|
68
|
+
font-family: "${this.config.font}", "Custom Font", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
|
|
69
|
+
}
|
|
65
70
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
overflow: hidden;
|
|
71
|
-
}
|
|
71
|
+
html {
|
|
72
|
+
width: 770px;
|
|
73
|
+
height: auto;
|
|
74
|
+
}
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
overflow: hidden;
|
|
80
|
-
background-color: #FFF5EE;
|
|
81
|
-
}
|
|
76
|
+
.background {
|
|
77
|
+
width: 770px;
|
|
78
|
+
height: auto;
|
|
79
|
+
background: linear-gradient(to right bottom, ${this.config.cardColorStart}, ${this.config.cardColorEnd});
|
|
80
|
+
overflow: hidden;
|
|
81
|
+
}
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
.card {
|
|
84
|
+
width: 740px;
|
|
85
|
+
height: auto;
|
|
86
|
+
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
|
|
87
|
+
border-radius: 5px;
|
|
88
|
+
margin: 15px auto;
|
|
89
|
+
overflow: hidden;
|
|
90
|
+
background-color: #FFF5EE;
|
|
91
|
+
}
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
.base-plate {
|
|
94
|
+
width: 704px;
|
|
95
|
+
height: auto;
|
|
96
|
+
margin: 20px auto;
|
|
97
|
+
border-radius: 10px;
|
|
98
|
+
background-color: #fff;
|
|
99
|
+
}
|
|
98
100
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
.card img {
|
|
102
|
+
border-radius: 5px 5px 0 0;
|
|
103
|
+
max-width: 100%;
|
|
104
|
+
/* 设置最大宽度为容器宽度的100% */
|
|
105
|
+
max-height: 80%;
|
|
106
|
+
/* 设置最大高度为容器高度的90% */
|
|
107
|
+
}
|
|
106
108
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
.card-header {
|
|
110
|
+
display: flex;
|
|
111
|
+
justify-content: space-between;
|
|
112
|
+
align-items: center;
|
|
113
|
+
margin-top: 5px;
|
|
114
|
+
margin-bottom: 10px;
|
|
115
|
+
}
|
|
110
116
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
117
|
+
.card-title {
|
|
118
|
+
line-height: 50px;
|
|
119
|
+
}
|
|
115
120
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
+
.card-body {
|
|
122
|
+
padding: 2px 16px;
|
|
123
|
+
margin-bottom: 10px;
|
|
124
|
+
}
|
|
121
125
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
126
|
+
.live-broadcast-info {
|
|
127
|
+
display: flex;
|
|
128
|
+
align-items: center;
|
|
129
|
+
margin-bottom: 10px;
|
|
130
|
+
}
|
|
128
131
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
.anchor-avatar {
|
|
133
|
+
width: 50px;
|
|
134
|
+
/* 主播头像大小 */
|
|
135
|
+
height: auto;
|
|
136
|
+
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
|
|
137
|
+
}
|
|
135
138
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
.broadcast-message {
|
|
140
|
+
display: inline-block;
|
|
141
|
+
margin-left: 10px;
|
|
142
|
+
font-size: 20px;
|
|
143
|
+
color: #333;
|
|
144
|
+
}
|
|
140
145
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
margin-bottom: 10px;
|
|
146
|
-
}
|
|
147
|
-
</style>
|
|
148
|
-
</head>
|
|
146
|
+
.card-text {
|
|
147
|
+
color: grey;
|
|
148
|
+
font-size: 20px;
|
|
149
|
+
}
|
|
149
150
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
151
|
+
.card-link {
|
|
152
|
+
text-decoration: none;
|
|
153
|
+
font-size: 20px;
|
|
154
|
+
margin-top: 10px;
|
|
155
|
+
margin-bottom: 10px;
|
|
156
|
+
}
|
|
157
|
+
</style>
|
|
158
|
+
</head>
|
|
159
|
+
<body>
|
|
160
|
+
<div class="background">
|
|
161
|
+
<div class="card">
|
|
162
|
+
<div class="base-plate">
|
|
163
|
+
<img src="${cover ? data.user_cover : data.keyframe}"
|
|
164
|
+
alt="封面">
|
|
165
|
+
<div class="card-body">
|
|
166
|
+
<div class="card-header">
|
|
167
|
+
<h1 class="card-title">${data.title}</h1>
|
|
168
|
+
<div class="live-broadcast-info">
|
|
169
|
+
<!-- 主播头像 -->
|
|
170
|
+
<img style="border-radius: 10px; margin-left: 10px" class="anchor-avatar"
|
|
171
|
+
src="${userData.info.face}" alt="主播头像">
|
|
172
|
+
<span class="broadcast-message">${userData.info.uname}${titleStatus}</span>
|
|
173
|
+
</div>
|
|
164
174
|
</div>
|
|
175
|
+
<p class="card-text">${data.description ? data.description : '这个主播很懒,什么都简介都没写'}</p>
|
|
176
|
+
<p class="card-link">${liveTime}</p>
|
|
165
177
|
</div>
|
|
166
|
-
<p class="card-text">${data.description ? data.description : '这个主播很懒,什么都简介都没写'}</p>
|
|
167
|
-
<p class="card-link">${liveTime}</p>
|
|
168
178
|
</div>
|
|
169
179
|
</div>
|
|
170
180
|
</div>
|
|
171
|
-
</
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
181
|
+
</body>
|
|
182
|
+
</html>
|
|
183
|
+
`;
|
|
184
|
+
// 判断渲染方式
|
|
185
|
+
if (this.config.renderType) { // 为1则为真,进入page模式
|
|
186
|
+
const htmlPath = 'file://' + __dirname.replaceAll('\\', '/') + '/0.html';
|
|
187
|
+
const page = await this.ctx.puppeteer.page();
|
|
188
|
+
await page.goto(htmlPath);
|
|
189
|
+
await page.setContent(html, { waitUntil: 'networkidle0' });
|
|
190
|
+
const elementHandle = await page.$('html');
|
|
191
|
+
const boundingBox = await elementHandle.boundingBox();
|
|
192
|
+
const buffer = await page.screenshot({
|
|
193
|
+
type: 'png',
|
|
194
|
+
clip: {
|
|
195
|
+
x: boundingBox.x,
|
|
196
|
+
y: boundingBox.y,
|
|
197
|
+
width: boundingBox.width,
|
|
198
|
+
height: boundingBox.height
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
await elementHandle.dispose();
|
|
202
|
+
await page.close();
|
|
203
|
+
return { buffer };
|
|
204
|
+
}
|
|
205
|
+
// 使用render模式渲染
|
|
206
|
+
const pic = await this.ctx.puppeteer.render(html);
|
|
207
|
+
return { pic };
|
|
176
208
|
}
|
|
177
209
|
async generateDynamicImg(data) {
|
|
178
210
|
// module_author
|
|
@@ -463,409 +495,438 @@ class GenerateImg extends koishi_1.Service {
|
|
|
463
495
|
return [main, link, forwardInfo];
|
|
464
496
|
}
|
|
465
497
|
const [main, link] = await getDynamicMajor(data, false);
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
<div class="
|
|
810
|
-
<
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
<svg style="width: 18px; height: 18px;" xmlns="http://www.w3.org/2000/svg"
|
|
828
|
-
xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 18 18" width="18"
|
|
829
|
-
height="18">
|
|
830
|
-
<path
|
|
831
|
-
d="M9.789075 2.2956175C8.97235 1.6308450000000003 7.74999 2.212005 7.74999 3.26506L7.74999 5.3915500000000005C6.642015000000001 5.5780325 5.3073725 6.040405 4.141735000000001 7.11143C2.809155 8.335825 1.751515 10.3041 1.45716 13.404099999999998C1.409905 13.9018 1.7595399999999999 14.22505 2.105415 14.317499999999999C2.442215 14.40755 2.8807175 14.314625 3.127745 13.92915C3.9664525 12.620249999999999 4.89282 11.894575 5.765827499999999 11.50585C6.4628049999999995 11.19545 7.14528 11.093125 7.74999 11.0959L7.74999 13.235025C7.74999 14.2881 8.97235 14.869250000000001 9.789075 14.2045L15.556199999999999 9.510425000000001C16.355075 8.860149999999999 16.355075 7.640124999999999 15.556199999999999 6.989840000000001L9.789075 2.2956175zM9.165099999999999 3.0768275000000003L14.895025 7.739050000000001C15.227975 7.980475 15.235775 8.468875 14.943874999999998 8.7142L9.17615 13.416800000000002C8.979474999999999 13.562024999999998 8.75 13.4269 8.75 13.227375000000002L8.75 10.638175C8.75 10.326975000000001 8.542125 10.134725 8.2544 10.1118C7.186765 10.02955 6.1563175 10.2037 5.150895 10.69295C4.14982 11.186925 3.2102250000000003 12.096525 2.573625 13.00995C2.54981 13.046975 2.52013 13.046025 2.5211725 12.986C2.8971525 10.0573 3.9373475 8.652125 4.807025 7.85305C5.87747 6.8694775 7.213197500000001 6.444867500000001 8.2272 6.33056C8.606525 6.287802500000001 8.74805 6.0849325 8.74805 5.7032275L8.74805 3.2615475C8.74805 3.0764875000000007 8.993175 2.9321925 9.165099999999999 3.0768275000000003z"
|
|
832
|
-
fill="currentColor"></path>
|
|
833
|
-
</svg>
|
|
834
|
-
<span>${forward}</span>
|
|
835
|
-
</div>
|
|
836
|
-
<div class="stat-item">
|
|
837
|
-
<svg style="width: 18px; height: 18px;" xmlns="http://www.w3.org/2000/svg"
|
|
838
|
-
xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 18 18" width="18"
|
|
839
|
-
height="18">
|
|
840
|
-
<path
|
|
841
|
-
d="M1.5625 7.875C1.5625 4.595807499999999 4.220807499999999 1.9375 7.5 1.9375L10.5 1.9375C13.779175 1.9375 16.4375 4.595807499999999 16.4375 7.875C16.4375 11.0504 13.944675 13.6435 10.809275 13.80405C10.097025 14.722974999999998 8.920875 15.880675 7.267095 16.331325C6.9735075 16.4113 6.704762499999999 16.286224999999998 6.55411 16.092325C6.40789 15.904149999999998 6.3561 15.634350000000001 6.4652449999999995 15.383025C6.72879 14.776249999999997 6.776465 14.221025000000001 6.7340175 13.761800000000001C3.8167675 13.387125 1.5625 10.894475 1.5625 7.875zM7.5 2.9375C4.773095 2.9375 2.5625 5.148095 2.5625 7.875C2.5625 10.502575 4.61524 12.651075000000002 7.2041924999999996 12.8038C7.4305875 12.817174999999999 7.619625000000001 12.981200000000001 7.664724999999999 13.203475C7.772575 13.734575000000001 7.8012 14.405425000000001 7.5884275 15.148399999999999C8.748325 14.6682 9.606 13.759825 10.151275 13.016475C10.24445 12.889475 10.392050000000001 12.8138 10.54955 12.812275C13.253575 12.785725 15.4375 10.58535 15.4375 7.875C15.4375 5.148095 13.226899999999999 2.9375 10.5 2.9375L7.5 2.9375z"
|
|
842
|
-
fill="currentColor"></path>
|
|
843
|
-
</svg>
|
|
844
|
-
<span>${comment}</span>
|
|
845
|
-
</div>
|
|
846
|
-
<div class="stat-item">
|
|
847
|
-
<svg style="width: 18px; height: 18px;" xmlns="http://www.w3.org/2000/svg"
|
|
848
|
-
xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 18 18" width="18"
|
|
849
|
-
height="18">
|
|
850
|
-
<path
|
|
851
|
-
d="M10.4511 2.2220125C10.218425 2.194885 10.002175 2.2953725 9.884175 2.433395C9.4264 2.9688525 9.321875 3.7501399999999996 8.978575 4.3581725C8.533574999999999 5.146395 8.1198 5.6213375 7.609775000000001 6.068507499999999C7.1751375 6.449565 6.738407499999999 6.697442499999999 6.3125 6.8050575L6.3125 14.854575C6.9198900000000005 14.868174999999999 7.572900000000001 14.876875 8.25 14.876875C9.936425 14.876875 11.367025 14.823325 12.33115 14.773699999999998C13.03235 14.737575 13.646025000000002 14.390075 13.966750000000001 13.81945C14.401900000000001 13.04535 14.9387 11.909650000000001 15.264174999999998 10.571200000000001C15.56665 9.327275 15.704699999999999 8.304325 15.766675 7.582224999999999C15.7988 7.208262500000001 15.50165 6.875019999999999 15.059999999999999 6.875019999999999L11.323274999999999 6.875019999999999C11.156575 6.875019999999999 11.000800000000002 6.791952499999999 10.907975 6.653499999999999C10.783725 6.468192500000001 10.82855 6.2670175 10.9037 6.07485C11.059 5.675084999999999 11.29355 4.9974475 11.382425000000001 4.4018275C11.470875000000001 3.80917 11.450999999999999 3.32219 11.212050000000001 2.86913C10.9571 2.3857825 10.66065 2.2464475 10.4511 2.2220125zM12.034300000000002 5.87502L15.059999999999999 5.87502C16.02035 5.87502 16.850875 6.64489 16.763 7.667825C16.697100000000002 8.435525 16.55155 9.5092 16.235825000000002 10.807500000000001C15.882625 12.259950000000002 15.3035 13.482225 14.838450000000002 14.309474999999999C14.32695 15.2194 13.377475 15.721150000000002 12.38255 15.772375C11.405125 15.822725 9.956949999999999 15.876875000000002 8.25 15.876875000000002C6.5961925 15.876875000000002 5.0846825 15.826025000000001 4.0136674999999995 15.77715C2.8370825 15.723474999999999 1.8519999999999999 14.850000000000001 1.725645 13.654824999999999C1.6404649999999998 12.849274999999999 1.5625 11.80725 1.5625 10.689375C1.5625 9.665175000000001 1.6279400000000002 8.736175 1.7045524999999997 7.998975C1.8351224999999998 6.7427075 2.9137075 5.87502 4.130655 5.87502L5.8125 5.87502C6.072015 5.87502 6.457235 5.7490675 6.9505175 5.316582499999999C7.377705000000001 4.942045 7.7193000000000005 4.5546075 8.107775 3.8665374999999997C8.492075 3.18585 8.605825 2.389785 9.124075 1.783595C9.452975 1.3988800000000001 9.99475 1.162025 10.5669 1.228745C11.16225 1.29816 11.717425 1.683875 12.09655 2.4025825000000003C12.478275 3.1262375000000002 12.474075 3.8618225 12.371500000000001 4.54938C12.302149999999997 5.0139949999999995 12.155425000000001 5.510059999999999 12.034300000000002 5.87502zM5.3125 14.82705L5.3125 6.875019999999999L4.130655 6.875019999999999C3.3792199999999997 6.875019999999999 2.77211 7.400795 2.6991975000000004 8.10235C2.6253525 8.812875 2.5625 9.70665 2.5625 10.689375C2.5625 11.762875 2.6374975 12.768475 2.7200975 13.549700000000001C2.7919925 14.229675 3.3521950000000005 14.74595 4.05924 14.778224999999999C4.4278775 14.795 4.849985 14.812050000000001 5.3125 14.82705z"
|
|
498
|
+
// 加载字体
|
|
499
|
+
const fontURL = (0, url_1.pathToFileURL)((0, path_1.resolve)(__dirname, '../font/HYZhengYuan-55W.ttf'));
|
|
500
|
+
// 定义卡片内容
|
|
501
|
+
const html = `
|
|
502
|
+
<!DOCTYPE html>
|
|
503
|
+
<html>
|
|
504
|
+
<head>
|
|
505
|
+
<title>动态通知</title>
|
|
506
|
+
<style>
|
|
507
|
+
@font-face {
|
|
508
|
+
font-family: "Custom Font";
|
|
509
|
+
src: url(${fontURL});
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
* {
|
|
513
|
+
margin: 0;
|
|
514
|
+
padding: 0;
|
|
515
|
+
font-family: "${this.config.font}", "Custom Font", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
html {
|
|
519
|
+
width: 770px;
|
|
520
|
+
height: auto;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.background {
|
|
524
|
+
width: 770px;
|
|
525
|
+
height: auto;
|
|
526
|
+
background: linear-gradient(to right bottom, ${this.config.cardColorStart}, ${this.config.cardColorEnd});
|
|
527
|
+
overflow: hidden;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.card {
|
|
531
|
+
width: 740px;
|
|
532
|
+
height: auto;
|
|
533
|
+
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
|
|
534
|
+
border-radius: 5px;
|
|
535
|
+
margin: 15px auto;
|
|
536
|
+
overflow: hidden;
|
|
537
|
+
background-color: #FFF5EE;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
.base-plate {
|
|
541
|
+
width: 704px;
|
|
542
|
+
height: auto;
|
|
543
|
+
margin: 20px auto;
|
|
544
|
+
border-radius: 10px;
|
|
545
|
+
background-color: #fff;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
.card-body {
|
|
549
|
+
display: flex;
|
|
550
|
+
padding: 15px;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
.card .anchor-avatar {
|
|
554
|
+
border-radius: 5px 5px 0 0;
|
|
555
|
+
max-width: 50px;
|
|
556
|
+
/* 设置最大宽度为容器宽度的100% */
|
|
557
|
+
max-height: 50px;
|
|
558
|
+
/* 设置最大高度为容器高度的90% */
|
|
559
|
+
margin-right: 20px;
|
|
560
|
+
border-radius: 10px;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
.card .card-body .card-content {
|
|
564
|
+
width: 100%;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
.card .card-body .card-content .card-header {
|
|
568
|
+
width: 100%;
|
|
569
|
+
display: flex;
|
|
570
|
+
justify-content: space-between;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
.card .up-info {
|
|
574
|
+
display: flex;
|
|
575
|
+
flex-direction: column;
|
|
576
|
+
justify-content: space-between;
|
|
577
|
+
height: 50px;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
.card .up-info .up-name {
|
|
581
|
+
font-size: 20px;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
.card .pub-time {
|
|
585
|
+
font-size: 12px;
|
|
586
|
+
color: grey;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
.card .card-header img {
|
|
590
|
+
height: 50px;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
.card .dress-up {
|
|
594
|
+
position: relative;
|
|
595
|
+
max-width: 110px;
|
|
596
|
+
max-height: 34px;
|
|
597
|
+
/* background-image: url('${dynamicCardUrl}');
|
|
598
|
+
background-size: cover; */
|
|
599
|
+
font-size: 12px;
|
|
600
|
+
line-height: 33px;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
.card .dress-up img {
|
|
604
|
+
max-width: 100%;
|
|
605
|
+
max-height: 100%;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
.card .dress-up span {
|
|
609
|
+
position: absolute;
|
|
610
|
+
color: ${dynamicCardColor};
|
|
611
|
+
right: 37px;
|
|
612
|
+
top: 5px;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
.card .card-topic {
|
|
616
|
+
display: flex;
|
|
617
|
+
align-items: center;
|
|
618
|
+
margin-top: 10px;
|
|
619
|
+
color: #008AC5;
|
|
620
|
+
gap: 3px;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
.card .card-details {
|
|
624
|
+
margin-bottom: 15px;
|
|
625
|
+
width: 90%;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
.card .card-major {
|
|
629
|
+
display: flex;
|
|
630
|
+
flex-wrap: wrap;
|
|
631
|
+
gap: 5px;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
.card .card-major .photo-item {
|
|
635
|
+
border-radius: 10px;
|
|
636
|
+
overflow: hidden;
|
|
637
|
+
width: 170px;
|
|
638
|
+
height: 170px;
|
|
639
|
+
object-fit: cover;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
.card .card-major .single-photo-item {
|
|
643
|
+
max-width: 500px;
|
|
644
|
+
border-radius: 10px;
|
|
645
|
+
overflow: hidden;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
.card .card-major .four-photo-item {
|
|
649
|
+
width: 170px;
|
|
650
|
+
height: 170px;
|
|
651
|
+
object-fit: cover;
|
|
652
|
+
border-radius: 10px;
|
|
653
|
+
overflow: hidden;
|
|
654
|
+
flex-basis: 20%; /* or any value less than 50% */
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
.card .card-stat {
|
|
658
|
+
display: flex;
|
|
659
|
+
justify-content: space-between;
|
|
660
|
+
width: 90%;
|
|
661
|
+
margin-top: 15px;
|
|
662
|
+
color: gray;
|
|
663
|
+
font-size: 14px;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
.card .card-stat .stat-item {
|
|
667
|
+
display: flex;
|
|
668
|
+
align-items: center;
|
|
669
|
+
gap: 3px;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
.card .card-video {
|
|
673
|
+
display: flex;
|
|
674
|
+
overflow: hidden;
|
|
675
|
+
border-radius: 5px 0 0 5px;
|
|
676
|
+
margin-top: 10px;
|
|
677
|
+
height: 132px;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
.card .video-cover {
|
|
681
|
+
position: relative;
|
|
682
|
+
flex: 2;
|
|
683
|
+
overflow: hidden;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
.card .video-cover img {
|
|
687
|
+
width: 236px;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
.card .cover-mask {
|
|
691
|
+
position: absolute;
|
|
692
|
+
width: 100%;
|
|
693
|
+
height: 100%;
|
|
694
|
+
top: 0;
|
|
695
|
+
left: 0;
|
|
696
|
+
background: linear-gradient(to top, rgba(0, 0, 0, 0.5) 0%, transparent 30%);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
.card .video-cover span {
|
|
700
|
+
position: absolute;
|
|
701
|
+
color: #fff;
|
|
702
|
+
font-size: 14px;
|
|
703
|
+
right: 10px;
|
|
704
|
+
bottom: 8px;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
.card .video-info {
|
|
708
|
+
display: flex;
|
|
709
|
+
justify-content: space-between;
|
|
710
|
+
flex-direction: column;
|
|
711
|
+
flex: 3;
|
|
712
|
+
border: #e5e7e9 1px solid;
|
|
713
|
+
border-left: none;
|
|
714
|
+
border-radius: 0 5px 5px 0;
|
|
715
|
+
padding: 12px 16px 10px;
|
|
716
|
+
background-color: #fff;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
.card .video-info-header .video-title {
|
|
720
|
+
font-size: 16px;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
.card .video-info-header .video-introduction {
|
|
724
|
+
margin-top: 5px;
|
|
725
|
+
font-size: 12px;
|
|
726
|
+
color: #AAA;
|
|
727
|
+
display: -webkit-box;
|
|
728
|
+
/* 必须设置为 -webkit-box 或 -webkit-inline-box */
|
|
729
|
+
-webkit-box-orient: vertical;
|
|
730
|
+
/* 必须设置为 vertical */
|
|
731
|
+
-webkit-line-clamp: 2;
|
|
732
|
+
/* 显示的文本行数 */
|
|
733
|
+
overflow: hidden;
|
|
734
|
+
/* 必须设置为 hidden */
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
.card .video-stat {
|
|
738
|
+
font-size: 12px;
|
|
739
|
+
color: #AAA;
|
|
740
|
+
display: flex;
|
|
741
|
+
gap: 35px
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
.card .video-stat .video-stat-item {
|
|
745
|
+
display: flex;
|
|
746
|
+
align-items: center;
|
|
747
|
+
gap: 3px;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
.card .card-forward {
|
|
751
|
+
margin: 0 -15px 0 -85px;
|
|
752
|
+
padding: 12px 15px 14px 85px;
|
|
753
|
+
background-color: #F6F7F8;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
.card-forward .forward-userinfo {
|
|
757
|
+
display: flex;
|
|
758
|
+
align-items: center;
|
|
759
|
+
gap: 5px;
|
|
760
|
+
height: 30px;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
.forward-userinfo img {
|
|
764
|
+
width: 20px;
|
|
765
|
+
height: 20px;
|
|
766
|
+
border-radius: 50%;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
.forward-userinfo span {
|
|
770
|
+
color: #61666D;
|
|
771
|
+
font-size: 15px;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
.card .card-reserve {
|
|
775
|
+
display: flex;
|
|
776
|
+
justify-content: space-between;
|
|
777
|
+
align-items: center;
|
|
778
|
+
padding: 10px 20px 10px 20px;
|
|
779
|
+
margin-top: 10px;
|
|
780
|
+
border-radius: 10px;
|
|
781
|
+
background-color: #F6F7F8;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
.card-reserve .reserve-title {
|
|
785
|
+
font-size: 14px;
|
|
786
|
+
color: #18191C;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
.card-reserve .reserve-desc {
|
|
790
|
+
margin-top: 7px;
|
|
791
|
+
font-size: 12px;
|
|
792
|
+
color: #9499A0;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
.reserve-info .reserve-time {
|
|
796
|
+
margin-right: 7px;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
.card-reserve .reserve-prize {
|
|
800
|
+
display: flex;
|
|
801
|
+
align-items: center;
|
|
802
|
+
margin-top: 3px;
|
|
803
|
+
gap: 3px;
|
|
804
|
+
color: #00AEEC;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
.card .card-reserve .reserve-button button {
|
|
808
|
+
border: none;
|
|
809
|
+
height: 30px;
|
|
810
|
+
width: 72px;
|
|
811
|
+
font-size: 13px;
|
|
812
|
+
border-radius: 7px;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
.card .card-reserve .reserve-button .reserve-button-end {
|
|
816
|
+
display: flex;
|
|
817
|
+
align-items: center;
|
|
818
|
+
justify-content: center;
|
|
819
|
+
color: #9499A0;
|
|
820
|
+
background-color: #E3E5E7;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
.card .card-reserve .reserve-button .reserve-button-ing {
|
|
824
|
+
display: flex;
|
|
825
|
+
align-items: center;
|
|
826
|
+
justify-content: center;
|
|
827
|
+
color: #FFF;
|
|
828
|
+
background-color: #00A0D8;
|
|
829
|
+
}
|
|
830
|
+
</style>
|
|
831
|
+
</head>
|
|
832
|
+
<body>
|
|
833
|
+
<div class="background">
|
|
834
|
+
<div class="card">
|
|
835
|
+
<div class="base-plate">
|
|
836
|
+
<div class="card-body">
|
|
837
|
+
<!-- 主播头像 -->
|
|
838
|
+
<img class="anchor-avatar"
|
|
839
|
+
src="${avatarUrl}"
|
|
840
|
+
alt="主播头像">
|
|
841
|
+
<div class="card-content">
|
|
842
|
+
<div class="card-header">
|
|
843
|
+
<div class="up-info">
|
|
844
|
+
<div class="up-name" style="${module_author.vip.type !== 0 ? 'color: #FB7299' : ''}">${upName}</div>
|
|
845
|
+
<div class="pub-time">${pubTime}</div>
|
|
846
|
+
</div>
|
|
847
|
+
${module_author.decorate ? `
|
|
848
|
+
<div class="dress-up">
|
|
849
|
+
<img src="${dynamicCardUrl}" />
|
|
850
|
+
<span>${dynamicCardId}</span>
|
|
851
|
+
</div>
|
|
852
|
+
` : ''}
|
|
853
|
+
</div>
|
|
854
|
+
<div class="card-topic">
|
|
855
|
+
${topic ? `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"
|
|
856
|
+
class="bili-dyn-topic__icon">
|
|
857
|
+
<path fill-rule="evenodd" clip-rule="evenodd"
|
|
858
|
+
d="M11.4302 2.57458C11.4416 2.51023 11.4439 2.43974 11.4218 2.3528C11.3281 1.98196 10.9517 1.72037 10.5284 1.7527C10.432 1.76018 10.3599 1.78383 10.297 1.81376C10.2347 1.84398 10.1832 1.88155 10.1401 1.92465C10.1195 1.94485 10.1017 1.96692 10.0839 1.98897L10.0808 1.99289L10.0237 2.06277L9.91103 2.2033C9.76177 2.39141 9.61593 2.58191 9.47513 2.77556C9.33433 2.96936 9.19744 3.16585 9.06672 3.36638C9.00275 3.46491 8.93968 3.56401 8.87883 3.66461L8.56966 3.6613C8.00282 3.6574 7.43605 3.65952 6.86935 3.67034C6.80747 3.56778 6.74325 3.46677 6.67818 3.3664C6.54732 3.16585 6.41045 2.96934 6.26968 2.77568C6.12891 2.58186 5.98309 2.39134 5.83387 2.20322L5.72122 2.06268L5.66416 1.99279L5.6622 1.99036C5.64401 1.96783 5.62586 1.94535 5.60483 1.92454C5.56192 1.88144 5.51022 1.84388 5.44797 1.81364C5.38522 1.78386 5.31305 1.76006 5.21665 1.75273C4.80555 1.72085 4.4203 1.97094 4.32341 2.35273C4.30147 2.43968 4.30358 2.51018 4.31512 2.57453C4.32715 2.63859 4.34975 2.69546 4.38112 2.74649C4.39567 2.77075 4.41283 2.79315 4.42999 2.81557C4.43104 2.81694 4.43209 2.81831 4.43314 2.81968L4.48759 2.89122L4.59781 3.03355C4.74589 3.22242 4.89739 3.40905 5.05377 3.59254C5.09243 3.63788 5.13136 3.68306 5.17057 3.72785C4.99083 3.73681 4.81112 3.7467 4.63143 3.75756C4.41278 3.771 4.19397 3.78537 3.97547 3.80206L3.64757 3.82786L3.48362 3.84177L3.39157 3.85181C3.36984 3.8543 3.34834 3.8577 3.32679 3.86111C3.31761 3.86257 3.30843 3.86402 3.29921 3.86541C3.05406 3.90681 2.81526 3.98901 2.59645 4.10752C2.37765 4.22603 2.17867 4.38039 2.00992 4.56302C1.84117 4.74565 1.70247 4.95593 1.60144 5.18337C1.50025 5.4105 1.43687 5.65447 1.41362 5.90153C1.33103 6.77513 1.27663 7.6515 1.25742 8.5302C1.23758 9.40951 1.25835 10.2891 1.3098 11.1655C1.32266 11.3846 1.33738 11.6035 1.35396 11.8223L1.38046 12.1505L1.39472 12.3144L1.39658 12.335L1.39906 12.3583L1.40417 12.4048C1.40671 12.4305 1.41072 12.4558 1.41473 12.4811C1.41561 12.4866 1.41648 12.4922 1.41734 12.4977C1.45717 12.7449 1.53806 12.9859 1.65567 13.2074C1.77314 13.4289 1.92779 13.6304 2.11049 13.8022C2.29319 13.974 2.50441 14.1159 2.73329 14.2197C2.96201 14.3235 3.2084 14.3901 3.45836 14.4135C3.47066 14.415 3.48114 14.4159 3.49135 14.4167C3.49477 14.417 3.49817 14.4173 3.50159 14.4176L3.5425 14.4212L3.62448 14.4283L3.78843 14.4417L4.11633 14.4674C4.33514 14.4831 4.55379 14.4983 4.7726 14.5111C6.52291 14.6145 8.27492 14.6346 10.0263 14.5706C10.4642 14.5547 10.9019 14.5332 11.3396 14.5062C11.5584 14.4923 11.7772 14.4776 11.9959 14.4604L12.3239 14.434L12.4881 14.4196L12.5813 14.4093C12.6035 14.4065 12.6255 14.403 12.6474 14.3995C12.6565 14.3981 12.6655 14.3966 12.6746 14.3952C12.9226 14.3527 13.1635 14.2691 13.3844 14.1486C13.6052 14.0284 13.8059 13.8716 13.9759 13.6868C14.1463 13.5022 14.2861 13.2892 14.3874 13.0593C14.4381 12.9444 14.4793 12.8253 14.5108 12.7037C14.519 12.6734 14.5257 12.6428 14.5322 12.612L14.5421 12.566L14.55 12.5196C14.5556 12.4887 14.5607 12.4578 14.5641 12.4266C14.5681 12.3959 14.5723 12.363 14.5746 12.3373C14.6642 11.4637 14.7237 10.5864 14.7435 9.70617C14.764 8.825 14.7347 7.94337 14.6719 7.06715C14.6561 6.8479 14.6385 6.62896 14.6183 6.41033L14.5867 6.08246L14.5697 5.91853L14.5655 5.87758C14.5641 5.86445 14.5618 5.8473 14.5599 5.83231C14.5588 5.8242 14.5578 5.81609 14.5567 5.80797C14.5538 5.78514 14.5509 5.76229 14.5466 5.7396C14.5064 5.49301 14.4252 5.25275 14.3067 5.03242C14.1886 4.81208 14.0343 4.61153 13.8519 4.44095C13.6695 4.27038 13.4589 4.12993 13.2311 4.02733C13.0033 3.92458 12.7583 3.85907 12.5099 3.83636C12.4974 3.83492 12.4865 3.83394 12.4759 3.833C12.4729 3.83273 12.4698 3.83246 12.4668 3.83219L12.4258 3.82879L12.3438 3.82199L12.1798 3.80886L11.8516 3.78413C11.633 3.76915 11.4143 3.75478 11.1955 3.74288C10.993 3.73147 10.7904 3.72134 10.5878 3.71243L10.6914 3.59236C10.8479 3.40903 10.9992 3.22242 11.1473 3.03341L11.2576 2.89124L11.312 2.81971C11.3136 2.81773 11.3151 2.81575 11.3166 2.81377C11.3333 2.79197 11.3501 2.77013 11.3641 2.74653C11.3954 2.6955 11.418 2.63863 11.4302 2.57458ZM9.33039 5.49268C9.38381 5.16945 9.67705 4.95281 9.98536 5.00882L9.98871 5.00944C10.2991 5.06783 10.5063 5.37802 10.4524 5.70377L10.2398 6.99039L11.3846 6.9904C11.7245 6.9904 12 7.27925 12 7.63557C12 7.99188 11.7245 8.28073 11.3846 8.28073L10.0266 8.28059L9.7707 9.82911L11.0154 9.82913C11.3553 9.82913 11.6308 10.118 11.6308 10.4743C11.6308 10.8306 11.3553 11.1195 11.0154 11.1195L9.55737 11.1195L9.32807 12.5073C9.27465 12.8306 8.98141 13.0472 8.6731 12.9912L8.66975 12.9906C8.35937 12.9322 8.1522 12.622 8.20604 12.2962L8.40041 11.1195H6.89891L6.66961 12.5073C6.61619 12.8306 6.32295 13.0472 6.01464 12.9912L6.01129 12.9906C5.7009 12.9322 5.49374 12.622 5.54758 12.2962L5.74196 11.1195L4.61538 11.1195C4.27552 11.1195 4 10.8306 4 10.4743C4 10.118 4.27552 9.82913 4.61538 9.82913L5.95514 9.82911L6.21103 8.28059L4.98462 8.28073C4.64475 8.28073 4.36923 7.99188 4.36923 7.63557C4.36923 7.27925 4.64475 6.9904 4.98462 6.9904L6.42421 6.99039L6.67193 5.49268C6.72535 5.16945 7.01859 4.95281 7.3269 5.00882L7.33025 5.00944C7.64063 5.06783 7.8478 5.37802 7.79396 5.70377L7.58132 6.99039H9.08281L9.33039 5.49268ZM8.61374 9.82911L8.86963 8.28059H7.36813L7.11225 9.82911H8.61374Z"
|
|
852
859
|
fill="currentColor"></path>
|
|
853
|
-
|
|
854
|
-
|
|
860
|
+
</svg>
|
|
861
|
+
${topic}` : ''}
|
|
862
|
+
</div>
|
|
863
|
+
${main}
|
|
864
|
+
<div class="card-stat">
|
|
865
|
+
<div class="stat-item">
|
|
866
|
+
<svg style="width: 18px; height: 18px;" xmlns="http://www.w3.org/2000/svg"
|
|
867
|
+
xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 18 18" width="18"
|
|
868
|
+
height="18">
|
|
869
|
+
<path
|
|
870
|
+
d="M9.789075 2.2956175C8.97235 1.6308450000000003 7.74999 2.212005 7.74999 3.26506L7.74999 5.3915500000000005C6.642015000000001 5.5780325 5.3073725 6.040405 4.141735000000001 7.11143C2.809155 8.335825 1.751515 10.3041 1.45716 13.404099999999998C1.409905 13.9018 1.7595399999999999 14.22505 2.105415 14.317499999999999C2.442215 14.40755 2.8807175 14.314625 3.127745 13.92915C3.9664525 12.620249999999999 4.89282 11.894575 5.765827499999999 11.50585C6.4628049999999995 11.19545 7.14528 11.093125 7.74999 11.0959L7.74999 13.235025C7.74999 14.2881 8.97235 14.869250000000001 9.789075 14.2045L15.556199999999999 9.510425000000001C16.355075 8.860149999999999 16.355075 7.640124999999999 15.556199999999999 6.989840000000001L9.789075 2.2956175zM9.165099999999999 3.0768275000000003L14.895025 7.739050000000001C15.227975 7.980475 15.235775 8.468875 14.943874999999998 8.7142L9.17615 13.416800000000002C8.979474999999999 13.562024999999998 8.75 13.4269 8.75 13.227375000000002L8.75 10.638175C8.75 10.326975000000001 8.542125 10.134725 8.2544 10.1118C7.186765 10.02955 6.1563175 10.2037 5.150895 10.69295C4.14982 11.186925 3.2102250000000003 12.096525 2.573625 13.00995C2.54981 13.046975 2.52013 13.046025 2.5211725 12.986C2.8971525 10.0573 3.9373475 8.652125 4.807025 7.85305C5.87747 6.8694775 7.213197500000001 6.444867500000001 8.2272 6.33056C8.606525 6.287802500000001 8.74805 6.0849325 8.74805 5.7032275L8.74805 3.2615475C8.74805 3.0764875000000007 8.993175 2.9321925 9.165099999999999 3.0768275000000003z"
|
|
871
|
+
fill="currentColor"></path>
|
|
872
|
+
</svg>
|
|
873
|
+
<span>${forward}</span>
|
|
874
|
+
</div>
|
|
875
|
+
<div class="stat-item">
|
|
876
|
+
<svg style="width: 18px; height: 18px;" xmlns="http://www.w3.org/2000/svg"
|
|
877
|
+
xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 18 18" width="18"
|
|
878
|
+
height="18">
|
|
879
|
+
<path
|
|
880
|
+
d="M1.5625 7.875C1.5625 4.595807499999999 4.220807499999999 1.9375 7.5 1.9375L10.5 1.9375C13.779175 1.9375 16.4375 4.595807499999999 16.4375 7.875C16.4375 11.0504 13.944675 13.6435 10.809275 13.80405C10.097025 14.722974999999998 8.920875 15.880675 7.267095 16.331325C6.9735075 16.4113 6.704762499999999 16.286224999999998 6.55411 16.092325C6.40789 15.904149999999998 6.3561 15.634350000000001 6.4652449999999995 15.383025C6.72879 14.776249999999997 6.776465 14.221025000000001 6.7340175 13.761800000000001C3.8167675 13.387125 1.5625 10.894475 1.5625 7.875zM7.5 2.9375C4.773095 2.9375 2.5625 5.148095 2.5625 7.875C2.5625 10.502575 4.61524 12.651075000000002 7.2041924999999996 12.8038C7.4305875 12.817174999999999 7.619625000000001 12.981200000000001 7.664724999999999 13.203475C7.772575 13.734575000000001 7.8012 14.405425000000001 7.5884275 15.148399999999999C8.748325 14.6682 9.606 13.759825 10.151275 13.016475C10.24445 12.889475 10.392050000000001 12.8138 10.54955 12.812275C13.253575 12.785725 15.4375 10.58535 15.4375 7.875C15.4375 5.148095 13.226899999999999 2.9375 10.5 2.9375L7.5 2.9375z"
|
|
881
|
+
fill="currentColor"></path>
|
|
882
|
+
</svg>
|
|
883
|
+
<span>${comment}</span>
|
|
884
|
+
</div>
|
|
885
|
+
<div class="stat-item">
|
|
886
|
+
<svg style="width: 18px; height: 18px;" xmlns="http://www.w3.org/2000/svg"
|
|
887
|
+
xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 18 18" width="18"
|
|
888
|
+
height="18">
|
|
889
|
+
<path
|
|
890
|
+
d="M10.4511 2.2220125C10.218425 2.194885 10.002175 2.2953725 9.884175 2.433395C9.4264 2.9688525 9.321875 3.7501399999999996 8.978575 4.3581725C8.533574999999999 5.146395 8.1198 5.6213375 7.609775000000001 6.068507499999999C7.1751375 6.449565 6.738407499999999 6.697442499999999 6.3125 6.8050575L6.3125 14.854575C6.9198900000000005 14.868174999999999 7.572900000000001 14.876875 8.25 14.876875C9.936425 14.876875 11.367025 14.823325 12.33115 14.773699999999998C13.03235 14.737575 13.646025000000002 14.390075 13.966750000000001 13.81945C14.401900000000001 13.04535 14.9387 11.909650000000001 15.264174999999998 10.571200000000001C15.56665 9.327275 15.704699999999999 8.304325 15.766675 7.582224999999999C15.7988 7.208262500000001 15.50165 6.875019999999999 15.059999999999999 6.875019999999999L11.323274999999999 6.875019999999999C11.156575 6.875019999999999 11.000800000000002 6.791952499999999 10.907975 6.653499999999999C10.783725 6.468192500000001 10.82855 6.2670175 10.9037 6.07485C11.059 5.675084999999999 11.29355 4.9974475 11.382425000000001 4.4018275C11.470875000000001 3.80917 11.450999999999999 3.32219 11.212050000000001 2.86913C10.9571 2.3857825 10.66065 2.2464475 10.4511 2.2220125zM12.034300000000002 5.87502L15.059999999999999 5.87502C16.02035 5.87502 16.850875 6.64489 16.763 7.667825C16.697100000000002 8.435525 16.55155 9.5092 16.235825000000002 10.807500000000001C15.882625 12.259950000000002 15.3035 13.482225 14.838450000000002 14.309474999999999C14.32695 15.2194 13.377475 15.721150000000002 12.38255 15.772375C11.405125 15.822725 9.956949999999999 15.876875000000002 8.25 15.876875000000002C6.5961925 15.876875000000002 5.0846825 15.826025000000001 4.0136674999999995 15.77715C2.8370825 15.723474999999999 1.8519999999999999 14.850000000000001 1.725645 13.654824999999999C1.6404649999999998 12.849274999999999 1.5625 11.80725 1.5625 10.689375C1.5625 9.665175000000001 1.6279400000000002 8.736175 1.7045524999999997 7.998975C1.8351224999999998 6.7427075 2.9137075 5.87502 4.130655 5.87502L5.8125 5.87502C6.072015 5.87502 6.457235 5.7490675 6.9505175 5.316582499999999C7.377705000000001 4.942045 7.7193000000000005 4.5546075 8.107775 3.8665374999999997C8.492075 3.18585 8.605825 2.389785 9.124075 1.783595C9.452975 1.3988800000000001 9.99475 1.162025 10.5669 1.228745C11.16225 1.29816 11.717425 1.683875 12.09655 2.4025825000000003C12.478275 3.1262375000000002 12.474075 3.8618225 12.371500000000001 4.54938C12.302149999999997 5.0139949999999995 12.155425000000001 5.510059999999999 12.034300000000002 5.87502zM5.3125 14.82705L5.3125 6.875019999999999L4.130655 6.875019999999999C3.3792199999999997 6.875019999999999 2.77211 7.400795 2.6991975000000004 8.10235C2.6253525 8.812875 2.5625 9.70665 2.5625 10.689375C2.5625 11.762875 2.6374975 12.768475 2.7200975 13.549700000000001C2.7919925 14.229675 3.3521950000000005 14.74595 4.05924 14.778224999999999C4.4278775 14.795 4.849985 14.812050000000001 5.3125 14.82705z"
|
|
891
|
+
fill="currentColor"></path>
|
|
892
|
+
</svg>
|
|
893
|
+
<span>${like}</span>
|
|
894
|
+
</div>
|
|
895
|
+
</div>
|
|
855
896
|
</div>
|
|
856
897
|
</div>
|
|
857
898
|
</div>
|
|
858
899
|
</div>
|
|
859
900
|
</div>
|
|
860
|
-
</
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
901
|
+
</body>
|
|
902
|
+
</html>
|
|
903
|
+
`;
|
|
904
|
+
// 判断渲染方式
|
|
905
|
+
if (this.config.renderType) { // 为1则为真,进入page模式
|
|
906
|
+
const htmlPath = 'file://' + __dirname.replaceAll('\\', '/') + '/0.html';
|
|
907
|
+
const page = await this.ctx.puppeteer.page();
|
|
908
|
+
await page.goto(htmlPath);
|
|
909
|
+
await page.setContent(html, { waitUntil: 'networkidle0' });
|
|
910
|
+
const elementHandle = await page.$('html');
|
|
911
|
+
const boundingBox = await elementHandle.boundingBox();
|
|
912
|
+
const buffer = await page.screenshot({
|
|
913
|
+
type: 'png',
|
|
914
|
+
clip: {
|
|
915
|
+
x: boundingBox.x,
|
|
916
|
+
y: boundingBox.y,
|
|
917
|
+
width: boundingBox.width,
|
|
918
|
+
height: boundingBox.height
|
|
919
|
+
}
|
|
920
|
+
});
|
|
921
|
+
await elementHandle.dispose();
|
|
922
|
+
await page.close();
|
|
923
|
+
return { buffer, link };
|
|
924
|
+
}
|
|
925
|
+
// 使用render模式渲染
|
|
926
|
+
const pic = await this.ctx.puppeteer.render(html);
|
|
927
|
+
return { pic, link };
|
|
867
928
|
}
|
|
868
|
-
getLiveStatus(time, liveStatus) {
|
|
929
|
+
async getLiveStatus(time, liveStatus) {
|
|
869
930
|
let titleStatus;
|
|
870
931
|
let liveTime;
|
|
871
932
|
let cover;
|
|
@@ -884,22 +945,22 @@ class GenerateImg extends koishi_1.Service {
|
|
|
884
945
|
}
|
|
885
946
|
case 2: {
|
|
886
947
|
titleStatus = '正在直播';
|
|
887
|
-
liveTime = `直播时长:${this.getTimeDifference(time)}`;
|
|
948
|
+
liveTime = `直播时长:${await this.getTimeDifference(time)}`;
|
|
888
949
|
cover = false;
|
|
889
950
|
break;
|
|
890
951
|
}
|
|
891
952
|
}
|
|
892
953
|
return [titleStatus, liveTime, cover];
|
|
893
954
|
}
|
|
894
|
-
getTimeDifference(dateString) {
|
|
955
|
+
async getTimeDifference(dateString) {
|
|
895
956
|
// 将日期字符串转换为Date对象
|
|
896
957
|
const date = new Date(dateString);
|
|
897
958
|
// 获取Unix时间戳(以毫秒为单位)
|
|
898
|
-
const unixTime = date.getTime();
|
|
959
|
+
const unixTime = date.getTime() / 1000;
|
|
899
960
|
// 获取当前Unix时间戳
|
|
900
|
-
const now = this.ctx.biliAPI.
|
|
961
|
+
const now = await this.ctx.biliAPI.getServerUTCTime();
|
|
901
962
|
// 计算时间差(以秒为单位)
|
|
902
|
-
const differenceInSeconds = Math.floor(
|
|
963
|
+
const differenceInSeconds = Math.floor(now - unixTime);
|
|
903
964
|
// 获取yyyy:MM:dd HH:mm:ss
|
|
904
965
|
const days = Math.floor(differenceInSeconds / (24 * 60 * 60));
|
|
905
966
|
const hours = Math.floor((differenceInSeconds % (24 * 60 * 60)) / (60 * 60));
|
|
@@ -923,14 +984,10 @@ class GenerateImg extends koishi_1.Service {
|
|
|
923
984
|
}
|
|
924
985
|
(function (GenerateImg) {
|
|
925
986
|
GenerateImg.Config = koishi_1.Schema.object({
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
cardColorEnd: koishi_1.Schema.string()
|
|
931
|
-
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
932
|
-
.default('#F9CCDF')
|
|
933
|
-
.description('推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/')
|
|
987
|
+
renderType: koishi_1.Schema.number(),
|
|
988
|
+
cardColorStart: koishi_1.Schema.string(),
|
|
989
|
+
cardColorEnd: koishi_1.Schema.string(),
|
|
990
|
+
font: koishi_1.Schema.string()
|
|
934
991
|
});
|
|
935
992
|
})(GenerateImg || (GenerateImg = {}));
|
|
936
993
|
exports.default = GenerateImg;
|