koishi-plugin-ll-mc 3.0.1 → 3.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.
@@ -0,0 +1 @@
1
+ 404: Not Found
Binary file
package/lib/index.js CHANGED
@@ -335,13 +335,6 @@ function sanitizeText(text) {
335
335
  if (typeof text !== "string") return text ?? "";
336
336
  return text.replace(/[\u0000-\u001F\u007F-\u009F]/g, "").replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])/g, "").replace(/(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "").trim();
337
337
  }
338
- // 官机补丁:去掉 emoji(画图时字体无 emoji 字形会显示"?"),保留 ★ 等符号
339
- function stripEmoji(text) {
340
- return String(text == null ? "" : text)
341
- .replace(/[\u{1F000}-\u{1FAFF}\u{1F1E6}-\u{1F1FF}\u{FE0F}\u{200D}\u{20E3}\u{00A9}\u{00AE}\u{2122}\u{3030}\u{2B50}]/gu, "")
342
- .replace(/\s+/g, " ")
343
- .trim();
344
- }
345
338
  __name(sanitizeText, "sanitizeText");
346
339
  var periodMapping = {
347
340
  today: { field: "todayPostCount", name: "今日" },
@@ -383,7 +376,7 @@ async function apply(ctx, config) {
383
376
  } catch (error) {
384
377
  logger.warn("无法加载 fallbackBase64.json,将使用空的回退头像。", error);
385
378
  }
386
- const fontFiles = ["HarmonyOS_Sans_Medium.ttf"];
379
+ const fontFiles = ["HarmonyOS_Sans_Medium.ttf", "NotoEmoji.ttf"];
387
380
  for (const fontFile of fontFiles) {
388
381
  await copyAssetIfNotExists(
389
382
  import_path.default.join(assetsDir, "fonts"),
@@ -1869,7 +1862,7 @@ ${targetUserRecord[0].username}
1869
1862
  let context = canvas.getContext('2d');
1870
1863
 
1871
1864
  // 根据最大计数的文本宽度动态调整画布宽度,以防数字溢出
1872
- context.font = \`30px "\${config.chartNicknameFont}", HarmonyOS_Sans_Medium, "Microsoft YaHei", sans-serif\`;
1865
+ context.font = \`30px "\${config.chartNicknameFont}", HarmonyOS_Sans_Medium, "Microsoft YaHei", "NotoEmoji", sans-serif\`;
1873
1866
  // 找到拥有最大发言数的条目,因为它的文本通常最长
1874
1867
  const maxCountData = rankingData.find(d => d.count === maxCount) || rankingData[0] || { count: 1, percentage: 0 };
1875
1868
  let maxCountText = maxCount.toString();
@@ -1957,7 +1950,7 @@ ${targetUserRecord[0].username}
1957
1950
 
1958
1951
  async function drawTextAndIcons(context, data, index, avgColor, barX, barY, barWidth, barHeight) {
1959
1952
  // 字体栈包含了用户选择的字体、插件内置字体和通用字体,以确保兼容性。
1960
- context.font = \`30px "\${config.chartNicknameFont}", HarmonyOS_Sans_Medium, "Microsoft YaHei", sans-serif\`;
1953
+ context.font = \`30px "\${config.chartNicknameFont}", HarmonyOS_Sans_Medium, "Microsoft YaHei", "NotoEmoji", sans-serif\`;
1961
1954
  const textY = barY + barHeight / 2 + 10.5;
1962
1955
 
1963
1956
 
@@ -2523,8 +2516,7 @@ ${targetUserRecord[0].username}
2523
2516
  if (!config.showStarInChart && newItem.name.startsWith("★")) {
2524
2517
  newItem.name = newItem.name.substring(1);
2525
2518
  }
2526
- // 官机补丁:emoji 在画图字体里显示为 "?",剥掉
2527
- newItem.name = stripEmoji(newItem.name);
2519
+ // 官机补丁:emoji NotoEmoji 字体回退(画布字体栈里加了 NotoEmoji),真正显示 emoji
2528
2520
  return newItem;
2529
2521
  });
2530
2522
  await Promise.all(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ll-mc",
3
3
  "description": "消息数量统计插件(基于 koishi-plugin-message-counter 重做,官方QQ机器人兼容)",
4
- "version": "3.0.1",
4
+ "version": "3.0.2",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [