koishi-plugin-group-analysis-mx 1.3.0 → 1.3.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.
@@ -155,6 +155,17 @@ class RendererService extends koishi_1.Service {
155
155
  ? path_1.default.resolve(this.templateDir, 'original', skin, 'emptyHtml.html')
156
156
  : path_1.default.resolve(this.templateDir, skin, 'emptyHtml.html');
157
157
  }
158
+ /** 确保用于建立 file:// base 的空 HTML 占位存在(不依赖 init 顺序)。 */
159
+ async ensureEmptyHtml() {
160
+ const p = this.emptyHtmlPath();
161
+ try {
162
+ await fs_1.promises.access(p);
163
+ }
164
+ catch (e) {
165
+ await fs_1.promises.mkdir(path_1.default.dirname(p), { recursive: true });
166
+ await fs_1.promises.writeFile(p, '');
167
+ }
168
+ }
158
169
  async renderGroupAnalysisToPdf(data) {
159
170
  let theme = this.config.theme;
160
171
  if (theme === 'auto') {
@@ -241,6 +252,7 @@ class RendererService extends koishi_1.Service {
241
252
  this.ctx.logger.info('HTML 模板填充完成,正在调用 Puppeteer 进行渲染...');
242
253
  const page = await this.ctx.puppeteer.page();
243
254
  // 先 goto 空 HTML 建立 file:// base,再 setContent 注入内容(@font-face 相对字体才能被加载)
255
+ await this.ensureEmptyHtml();
244
256
  await page.goto('file://' + this.emptyHtmlPath(), {
245
257
  waitUntil: 'domcontentloaded'
246
258
  });
@@ -316,6 +328,7 @@ class RendererService extends koishi_1.Service {
316
328
  this.ctx.logger.info(`原项目皮肤 ${skin} HTML 生成完成,正在调用 Puppeteer 渲染...`);
317
329
  const page = await this.ctx.puppeteer.page();
318
330
  await page.setViewport({ width: 1080, height: 1920, deviceScaleFactor: 2 });
331
+ await this.ensureEmptyHtml();
319
332
  await page.goto('file://' + this.emptyHtmlPath(), {
320
333
  waitUntil: 'domcontentloaded'
321
334
  });
@@ -535,6 +548,7 @@ class RendererService extends koishi_1.Service {
535
548
  this.ctx.logger.info('用户画像 HTML 模板填充完成,正在调用 Puppeteer 进行渲染...');
536
549
  const page = await this.ctx.puppeteer.page();
537
550
  // 先 goto 空 HTML 建立 file:// base,再 setContent 注入内容(@font-face 相对字体才能被加载)
551
+ await this.ensureEmptyHtml();
538
552
  await page.goto('file://' + this.emptyHtmlPath(), {
539
553
  waitUntil: 'domcontentloaded'
540
554
  });
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.3.0",
4
+ "version": "1.3.1",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.mjs",
7
7
  "typings": "lib/index.d.ts",