koishi-plugin-ll-mc 3.1.1 → 3.1.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.
- package/lib/index.js +22 -27
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -2519,39 +2519,33 @@ ${targetUserRecord[0].username}
|
|
|
2519
2519
|
}[ch]));
|
|
2520
2520
|
}
|
|
2521
2521
|
__name(escapeHtml, "escapeHtml");
|
|
2522
|
-
const
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
{ bar: "#B2DFDB", fill: "#80CBC4", text: "#374151" },
|
|
2535
|
-
{ bar: "#BBDEFB", fill: "#90CAF9", text: "#374151" },
|
|
2536
|
-
{ bar: "#E1BEE7", fill: "#CE93D8", text: "#374151" },
|
|
2537
|
-
{ bar: "#FFCCBC", fill: "#FFAB91", text: "#374151" },
|
|
2538
|
-
{ bar: "#F0F4C3", fill: "#E6EE9C", text: "#374151" },
|
|
2539
|
-
{ bar: "#BCAAA4", fill: "#A1887F", text: "#374151" },
|
|
2540
|
-
{ bar: "#EEEEEE", fill: "#BDBDBD", text: "#374151" },
|
|
2541
|
-
{ bar: "#CFD8DC", fill: "#90A4AE", text: "#374151" }
|
|
2522
|
+
const BAR_LIGHT_TRACK = "#F3F4F6";
|
|
2523
|
+
const BAR_FILL_COLORS = [
|
|
2524
|
+
"#F472B6", // pink
|
|
2525
|
+
"#A78BFA", // violet
|
|
2526
|
+
"#60A5FA", // blue
|
|
2527
|
+
"#34D399", // emerald
|
|
2528
|
+
"#FBBF24", // amber
|
|
2529
|
+
"#F87171", // red
|
|
2530
|
+
"#22D3EE", // cyan
|
|
2531
|
+
"#A3E635", // lime
|
|
2532
|
+
"#FB923C", // orange
|
|
2533
|
+
"#818CF8" // indigo
|
|
2542
2534
|
];
|
|
2543
|
-
function buildLeaderboardRow(item, index) {
|
|
2544
|
-
const pal = LEADERBOARD_ROW_PALETTES[index % LEADERBOARD_ROW_PALETTES.length];
|
|
2535
|
+
function buildLeaderboardRow(item, index, maxCount) {
|
|
2545
2536
|
const isHero = index === 0;
|
|
2546
|
-
const
|
|
2537
|
+
const fillColor = BAR_FILL_COLORS[((index - 1) % BAR_FILL_COLORS.length + BAR_FILL_COLORS.length) % BAR_FILL_COLORS.length];
|
|
2538
|
+
// 发言(数据)部分相对第一名缩放,确保柱子占比直观;0 发言使用极细条
|
|
2539
|
+
const width = item.count > 0 ? Math.max((item.count / maxCount) * 100, 2) : 1;
|
|
2547
2540
|
const avatar = escapeHtml(item.avatar || "");
|
|
2548
2541
|
const name = escapeHtml(item.name || "");
|
|
2549
2542
|
const count = item.count;
|
|
2550
|
-
|
|
2543
|
+
// 柱子总背景固定为浅色,发言部分单独用颜色区分,这样更显眼
|
|
2544
|
+
const barBg = BAR_LIGHT_TRACK;
|
|
2551
2545
|
const fill = isHero
|
|
2552
2546
|
? 'linear-gradient(to right, #6366F1, #A855F7, #EC4899)'
|
|
2553
|
-
:
|
|
2554
|
-
const textColor = isHero ? "#FFFFFF" :
|
|
2547
|
+
: fillColor;
|
|
2548
|
+
const textColor = isHero ? "#FFFFFF" : "#1F2937";
|
|
2555
2549
|
const star = isHero
|
|
2556
2550
|
? `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="row-star"><path fill-rule="evenodd" d="M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z" clip-rule="evenodd"/></svg>`
|
|
2557
2551
|
: "";
|
|
@@ -2568,7 +2562,8 @@ ${targetUserRecord[0].username}
|
|
|
2568
2562
|
}
|
|
2569
2563
|
__name(buildLeaderboardRow, "buildLeaderboardRow");
|
|
2570
2564
|
function buildLeaderboardHtml(title, date, items, backgroundCss) {
|
|
2571
|
-
const
|
|
2565
|
+
const maxCount = Math.max(1, ...items.map((item) => item.count || 0));
|
|
2566
|
+
const rows = items.map((item, index) => buildLeaderboardRow(item, index, maxCount)).join("\n");
|
|
2572
2567
|
return `<!DOCTYPE html>
|
|
2573
2568
|
<html lang="zh-CN">
|
|
2574
2569
|
<head>
|