koishi-plugin-ll-mc 3.0.7 → 3.0.9

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/index.js +16 -12
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -174,7 +174,7 @@ var Config = import_koishi.Schema.intersect([
174
174
  import_koishi.Schema.object({
175
175
  defaultMaxDisplayCount: import_koishi.Schema.number().min(0).default(20).description("排行榜默认显示的人数。设置为 0 则显示所有。"),
176
176
  isTimeInfoSupplementEnabled: import_koishi.Schema.boolean().default(true).description("是否在排行榜标题中显示生成时间。"),
177
- isUserMessagePercentageVisible: import_koishi.Schema.boolean().default(true).description("是否在排行榜中显示用户的消息数占比。"),
177
+ isUserMessagePercentageVisible: import_koishi.Schema.boolean().default(false).description("是否在排行榜中显示用户的消息数占比。"),
178
178
  hiddenUserIdsInLeaderboard: import_koishi.Schema.array(String).role("table").description("全局隐藏的用户 ID 列表,在所有用户排行榜中生效。"),
179
179
  hiddenChannelIdsInLeaderboard: import_koishi.Schema.array(String).role("table").description("全局隐藏的频道 ID 列表,在群排行榜中生效。")
180
180
  }).description("排行榜设置"),
@@ -384,6 +384,19 @@ async function apply(ctx, config) {
384
384
  fontFile
385
385
  );
386
386
  }
387
+ // 官机补丁:强制覆盖 NotoEmoji 字体(纯 emoji 版),
388
+ // 防止旧版本(带数字字形)缓存在 data/messageCounter/fonts/ 里导致数字被加宽
389
+ try {
390
+ const emojiSrc = import_path.default.join(assetsDir, "fonts", "NotoEmoji.ttf");
391
+ const emojiDest = import_path.default.join(fontsPath, "NotoEmoji.ttf");
392
+ await fs.copyFile(emojiSrc, emojiDest);
393
+ // 删除旧版补丁字体(避免旧版带数字字形的 patched 文件被继续加载、家族名冲突)
394
+ const patched = import_path.default.join(fontsPath, "NotoEmoji-patched.ttf");
395
+ await fs.rm(patched, { force: true });
396
+ logger.info("[ll-mc] 已强制更新 NotoEmoji 字体为纯 emoji 版,并清理旧补丁字体。");
397
+ } catch (error) {
398
+ logger.warn("[ll-mc] 强制更新 NotoEmoji 字体失败:", error?.message);
399
+ }
387
400
  const avatarCache = /* @__PURE__ */ new Map();
388
401
  let iconCache = [];
389
402
  let barBgImgCache = [];
@@ -1866,11 +1879,7 @@ ${targetUserRecord[0].username}
1866
1879
  // 找到拥有最大发言数的条目,因为它的文本通常最长
1867
1880
  const maxCountData = rankingData.find(d => d.count === maxCount) || rankingData[0] || { count: 1, percentage: 0 };
1868
1881
  let maxCountText = maxCount.toString();
1869
- if (config.isUserMessagePercentageVisible && maxCountData) {
1870
- const percentage = maxCountData.percentage;
1871
- let percentageStr = percentage < 0.01 && percentage > 0 ? '<0.01' : percentage.toFixed(percentage < 1 ? 2 : 0);
1872
- maxCountText += \` ( \${percentageStr}%)\`;
1873
- }
1882
+ // 原版 message-counter 渲染:不显示百分比(数字保持纯数字,避免混合字符导致字体回退错位)
1874
1883
  const maxCountTextWidth = context.measureText(maxCountText).width;
1875
1884
 
1876
1885
  // 最长进度条的宽度是固定的
@@ -1956,12 +1965,7 @@ ${targetUserRecord[0].username}
1956
1965
 
1957
1966
  // 绘制发言次数和百分比
1958
1967
  let countText = data.count.toString();
1959
- if (config.isUserMessagePercentageVisible) {
1960
- const percentage = data.percentage;
1961
- let percentageStr = percentage < 0.01 && percentage > 0 ? '<0.01' : percentage.toFixed(percentage < 1 ? 2 : 0);
1962
- countText += \` ( \${percentageStr}%)\`;
1963
- }
1964
-
1968
+ // 原版 message-counter 渲染:不显示百分比(数字保持纯数字,避免混合字符回退错位)
1965
1969
  const countTextWidth = context.measureText(countText).width;
1966
1970
  const countTextX = barX + barWidth + 10;
1967
1971
 
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.7",
4
+ "version": "3.0.9",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [