koishi-plugin-group-analysis-mx 1.5.0 → 1.5.1

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.
@@ -201,6 +201,30 @@ class RendererService extends koishi_1.Service {
201
201
  if (!this.ctx.puppeteer) {
202
202
  throw new Error('Puppeteer service is not available.');
203
203
  }
204
+ // 头像转 base64 内联:避免部分用户头像 URL 加载失败导致空白;失败用默认头像兜底
205
+ const DEFAULT_AVATAR = 'data:image/svg+xml;base64,' + Buffer.from('<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80"><rect width="80" height="80" fill="#d9dee5"/><circle cx="40" cy="31" r="15" fill="#aab3bf"/><path d="M10 76c4-17 16-26 30-26s26 9 30 26z" fill="#aab3bf"/></svg>').toString('base64');
206
+ const avatarCache = new Map();
207
+ const inlineAvatar = async (obj) => {
208
+ if (!obj)
209
+ return obj;
210
+ const url = obj.avatar;
211
+ if (!url)
212
+ return { ...obj, avatar: DEFAULT_AVATAR };
213
+ if (!avatarCache.has(url)) {
214
+ let b64 = '';
215
+ try {
216
+ b64 = await this.imageToBase64(url);
217
+ }
218
+ catch (e) { }
219
+ avatarCache.set(url, b64 || DEFAULT_AVATAR);
220
+ }
221
+ return { ...obj, avatar: avatarCache.get(url) };
222
+ };
223
+ data = {
224
+ ...data,
225
+ userStats: await Promise.all((data.userStats || []).map(inlineAvatar)),
226
+ userTitles: await Promise.all((data.userTitles || []).map(inlineAvatar)),
227
+ };
204
228
  const templatePath = this.getSkinPath('template_group.html');
205
229
  const randomId = Math.random().toString(36).substring(2, 15);
206
230
  const skin = this.config.skin || 'md3';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-group-analysis-mx",
3
3
  "description": "群聊分析插件 - 生成精美群聊统计报告,支持 AI 话题总结(独立版,不依赖 ChatLuna)",
4
- "version": "1.5.0",
4
+ "version": "1.5.1",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.mjs",
7
7
  "typings": "lib/index.d.ts",
@@ -91,8 +91,7 @@
91
91
  ${activeHoursChart}
92
92
 
93
93
  <div class="footer">
94
- Generated by Koishi Group Analysis | Nahida Theme Ver. 3.0
95
- </div>
94
+ 由《剑灵》怀旧服机器人-若汐生成</div>
96
95
  </div>
97
96
  </div>
98
97
 
@@ -105,4 +104,4 @@
105
104
  }
106
105
  </script>
107
106
  </body>
108
- </html>
107
+ </html>
@@ -82,8 +82,7 @@
82
82
  </div>
83
83
 
84
84
  <div class="footer">
85
- Generated by Koishi Group Analysis | Nahida Theme Ver. 3.0
86
- </div>
85
+ 由《剑灵》怀旧服机器人-若汐生成</div>
87
86
  </div>
88
87
  </div>
89
88
 
@@ -96,4 +95,4 @@
96
95
  }
97
96
  </script>
98
97
  </body>
99
- </html>
98
+ </html>
@@ -107,9 +107,8 @@
107
107
 
108
108
  <!-- Footer -->
109
109
  <div class="footer">
110
- Generated by Koishi Group Analysis · Scrapbook Theme
111
- </div>
110
+ 由《剑灵》怀旧服机器人-若汐生成</div>
112
111
  </div>
113
112
  </body>
114
113
 
115
- </html>
114
+ </html>
@@ -111,9 +111,8 @@
111
111
 
112
112
  <!-- Footer -->
113
113
  <div class="footer">
114
- Generated by Koishi Group Analysis · User Persona
115
- </div>
114
+ 由《剑灵》怀旧服机器人-若汐生成</div>
116
115
  </div>
117
116
  </body>
118
117
 
119
- </html>
118
+ </html>