koishi-plugin-monetary-bank 2.1.0 → 2.2.0

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,8 @@
1
+ # Fonts
2
+
3
+ Place Roboto Mono font files here:
4
+
5
+ - RobotoMono-Regular.ttf
6
+ - RobotoMono-Bold.ttf
7
+
8
+ Source: https://fonts.google.com/specimen/Roboto+Mono (SIL OPEN FONT LICENSE Version 1.1)
Binary file
@@ -0,0 +1,7 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <rect width="64" height="64" rx="14" fill="#fef9c3"/>
3
+ <ellipse cx="26" cy="28" rx="12" ry="8" fill="#fbbf24"/>
4
+ <ellipse cx="38" cy="36" rx="12" ry="8" fill="#f59e0b"/>
5
+ <ellipse cx="26" cy="28" rx="7" ry="4" fill="#fde68a"/>
6
+ <ellipse cx="38" cy="36" rx="7" ry="4" fill="#fde68a"/>
7
+ </svg>
@@ -0,0 +1,9 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <rect width="64" height="64" rx="14" fill="#e0f2fe"/>
3
+ <polygon points="32,10 10,22 54,22" fill="#3b82f6"/>
4
+ <rect x="14" y="22" width="36" height="28" rx="4" fill="#60a5fa"/>
5
+ <rect x="18" y="26" width="6" height="20" fill="#e0f2fe"/>
6
+ <rect x="29" y="26" width="6" height="20" fill="#e0f2fe"/>
7
+ <rect x="40" y="26" width="6" height="20" fill="#e0f2fe"/>
8
+ <rect x="14" y="50" width="36" height="6" rx="3" fill="#2563eb"/>
9
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <rect width="64" height="64" rx="14" fill="#dcfce7"/>
3
+ <rect x="14" y="20" width="36" height="24" rx="6" fill="#16a34a"/>
4
+ <rect x="20" y="26" width="24" height="12" rx="6" fill="#86efac"/>
5
+ <circle cx="32" cy="32" r="4" fill="#16a34a"/>
6
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <rect width="64" height="64" rx="14" fill="#dbeafe"/>
3
+ <circle cx="32" cy="32" r="18" fill="#3b82f6"/>
4
+ <rect x="31" y="20" width="2" height="14" fill="#eff6ff"/>
5
+ <rect x="32" y="32" width="10" height="2" fill="#eff6ff"/>
6
+ </svg>
@@ -0,0 +1,7 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <rect width="64" height="64" rx="14" fill="#ecfeff"/>
3
+ <ellipse cx="26" cy="28" rx="12" ry="8" fill="#22d3ee"/>
4
+ <ellipse cx="38" cy="36" rx="12" ry="8" fill="#06b6d4"/>
5
+ <ellipse cx="26" cy="28" rx="7" ry="4" fill="#cffafe"/>
6
+ <ellipse cx="38" cy="36" rx="7" ry="4" fill="#cffafe"/>
7
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <rect width="64" height="64" rx="14" fill="#ccfbf1"/>
3
+ <rect x="14" y="42" width="36" height="8" rx="4" fill="#0f766e"/>
4
+ <polygon points="32,16 22,28 28,28 28,38 36,38 36,28 42,28" fill="#0f766e"/>
5
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <rect width="64" height="64" rx="14" fill="#ede9fe"/>
3
+ <rect x="18" y="28" width="28" height="22" rx="6" fill="#7c3aed"/>
4
+ <rect x="24" y="16" width="16" height="14" rx="7" fill="#c4b5fd"/>
5
+ <rect x="28" y="20" width="8" height="10" rx="4" fill="#7c3aed"/>
6
+ </svg>
@@ -0,0 +1,9 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <rect width="64" height="64" rx="14" fill="#e2e8f0"/>
3
+ <rect x="14" y="20" width="36" height="6" rx="3" fill="#64748b"/>
4
+ <rect x="14" y="32" width="36" height="6" rx="3" fill="#64748b"/>
5
+ <rect x="14" y="44" width="36" height="6" rx="3" fill="#64748b"/>
6
+ <circle cx="26" cy="23" r="6" fill="#0ea5e9"/>
7
+ <circle cx="42" cy="35" r="6" fill="#0ea5e9"/>
8
+ <circle cx="22" cy="47" r="6" fill="#0ea5e9"/>
9
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <rect width="64" height="64" rx="14" fill="#dcfce7"/>
3
+ <circle cx="32" cy="32" r="18" fill="#22c55e"/>
4
+ <polygon points="26,32 30,36 42,24 46,28 30,44 22,36" fill="#ecfdf3"/>
5
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <rect width="64" height="64" rx="14" fill="#fef3c7"/>
3
+ <polygon points="32,12 54,50 10,50" fill="#f59e0b"/>
4
+ <rect x="30" y="24" width="4" height="14" fill="#fff7ed"/>
5
+ <rect x="30" y="42" width="4" height="4" fill="#fff7ed"/>
6
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <rect width="64" height="64" rx="14" fill="#ffedd5"/>
3
+ <rect x="14" y="42" width="36" height="8" rx="4" fill="#ea580c"/>
4
+ <polygon points="32,38 22,26 28,26 28,16 36,16 36,26 42,26" fill="#ea580c"/>
5
+ </svg>
package/lib/index.js CHANGED
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
8
  var __export = (target, all) => {
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
@@ -30,7 +40,57 @@ module.exports = __toCommonJS(src_exports);
30
40
  var import_koishi = require("koishi");
31
41
 
32
42
  // src/templates.ts
43
+ var import_fs = __toESM(require("fs"));
44
+ var import_path = __toESM(require("path"));
45
+ var import_url = require("url");
46
+ var ASSET_BASE_PATH = import_path.default.resolve(__dirname, "..", "assets");
47
+ var ASSET_BASE_URL = (0, import_url.pathToFileURL)(ASSET_BASE_PATH).toString().replace(/\/$/, "");
48
+ var ICON_MAP = {
49
+ bank: "icons/bank.svg",
50
+ balance: "icons/balance.svg",
51
+ cash: "icons/cash.svg",
52
+ demand: "icons/demand.svg",
53
+ fixed: "icons/fixed.svg",
54
+ deposit: "icons/deposit.svg",
55
+ withdraw: "icons/withdraw.svg",
56
+ manage: "icons/manage.svg",
57
+ success: "icons/success.svg",
58
+ warning: "icons/warning.svg",
59
+ clock: "icons/clock.svg"
60
+ };
61
+ function getAssetUrl(relativePath) {
62
+ return `${ASSET_BASE_URL}/${relativePath}`;
63
+ }
64
+ __name(getAssetUrl, "getAssetUrl");
65
+ var ICON_DATA_URLS = {};
66
+ for (const [key, file] of Object.entries(ICON_MAP)) {
67
+ try {
68
+ const absolutePath = import_path.default.resolve(ASSET_BASE_PATH, file);
69
+ const buffer = import_fs.default.readFileSync(absolutePath);
70
+ ICON_DATA_URLS[key] = `data:image/svg+xml;base64,${buffer.toString("base64")}`;
71
+ } catch {
72
+ ICON_DATA_URLS[key] = "";
73
+ }
74
+ }
75
+ function getIconUrl(iconName) {
76
+ const key = String(iconName || "").toLowerCase();
77
+ const dataUrl = ICON_DATA_URLS[key];
78
+ if (dataUrl) return dataUrl;
79
+ const file = ICON_MAP[key];
80
+ return file ? getAssetUrl(file) : "";
81
+ }
82
+ __name(getIconUrl, "getIconUrl");
83
+ function renderIcon(iconName, className, alt) {
84
+ const src = getIconUrl(iconName);
85
+ if (!src) {
86
+ return `<span class="${className} icon-fallback" aria-hidden="true">?</span>`;
87
+ }
88
+ return `<img class="${className}" src="${src}" alt="${alt}" />`;
89
+ }
90
+ __name(renderIcon, "renderIcon");
33
91
  function getBaseTemplate(content, width = 520, isDark = false) {
92
+ const fontRegularUrl = getAssetUrl("fonts/RobotoMono-Regular.ttf");
93
+ const fontBoldUrl = getAssetUrl("fonts/RobotoMono-Bold.ttf");
34
94
  const darkVars = `
35
95
  /* 统一配色 - 深色玻璃拟态 */
36
96
  --bg-color: #0c0f15;
@@ -92,6 +152,22 @@ function getBaseTemplate(content, width = 520, isDark = false) {
92
152
  <head>
93
153
  <meta charset="UTF-8">
94
154
  <style>
155
+ @font-face {
156
+ font-family: 'Roboto Mono';
157
+ src: url('${fontRegularUrl}') format('truetype');
158
+ font-weight: 400;
159
+ font-style: normal;
160
+ font-display: swap;
161
+ }
162
+
163
+ @font-face {
164
+ font-family: 'Roboto Mono';
165
+ src: url('${fontBoldUrl}') format('truetype');
166
+ font-weight: 700;
167
+ font-style: normal;
168
+ font-display: swap;
169
+ }
170
+
95
171
  :root {
96
172
  ${isDark ? darkVars : lightVars}
97
173
  }
@@ -102,7 +178,7 @@ function getBaseTemplate(content, width = 520, isDark = false) {
102
178
  position: relative;
103
179
  margin: 0;
104
180
  padding: 32px;
105
- font-family: 'Roboto Mono', 'Trebuchet MS', 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
181
+ font-family: 'Roboto Mono', 'PingFang SC', 'Microsoft YaHei', sans-serif;
106
182
  ${bgStyle}
107
183
  width: ${width}px;
108
184
  box-sizing: border-box;
@@ -144,6 +220,12 @@ function getBaseTemplate(content, width = 520, isDark = false) {
144
220
  box-shadow: 0 8px 16px rgba(88, 166, 255, 0.3);
145
221
  flex-shrink: 0;
146
222
  }
223
+
224
+ .avatar-icon {
225
+ width: 24px;
226
+ height: 24px;
227
+ display: block;
228
+ }
147
229
 
148
230
  .header-content {
149
231
  flex: 1;
@@ -287,7 +369,9 @@ function getBaseTemplate(content, width = 520, isDark = false) {
287
369
  }
288
370
 
289
371
  .item-icon {
290
- font-size: 18px;
372
+ width: 18px;
373
+ height: 18px;
374
+ display: block;
291
375
  }
292
376
 
293
377
  .item-title {
@@ -367,11 +451,14 @@ function getBaseTemplate(content, width = 520, isDark = false) {
367
451
  .cmd-item {
368
452
  background: var(--item-bg);
369
453
  border-radius: 12px;
370
- padding: 20px 16px;
371
- text-align: center;
454
+ padding: 16px;
455
+ text-align: left;
372
456
  border: 1px solid var(--border-color);
373
457
  transition: all 0.2s ease;
374
458
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
459
+ display: flex;
460
+ align-items: center;
461
+ gap: 14px;
375
462
  }
376
463
 
377
464
  .cmd-item:hover {
@@ -381,20 +468,31 @@ function getBaseTemplate(content, width = 520, isDark = false) {
381
468
  }
382
469
 
383
470
  .cmd-icon {
384
- font-size: 28px;
385
- margin-bottom: 10px;
471
+ width: 32px;
472
+ height: 32px;
473
+ display: block;
474
+ flex-shrink: 0;
475
+ }
476
+
477
+ .cmd-content {
478
+ flex: 1;
479
+ min-width: 0;
386
480
  }
387
481
 
388
482
  .cmd-name {
389
- font-size: 14px;
390
- font-weight: 600;
483
+ font-size: 15px;
484
+ font-weight: 700;
391
485
  color: var(--text-primary);
392
- margin-bottom: 6px;
486
+ margin-bottom: 4px;
487
+ letter-spacing: -0.2px;
393
488
  }
394
489
 
395
490
  .cmd-desc {
396
491
  font-size: 12px;
397
492
  color: var(--text-secondary);
493
+ white-space: nowrap;
494
+ overflow: hidden;
495
+ text-overflow: ellipsis;
398
496
  }
399
497
 
400
498
  /* Prompt Box */
@@ -542,6 +640,14 @@ function getBaseTemplate(content, width = 520, isDark = false) {
542
640
  background: rgba(88, 166, 255, 0.15);
543
641
  color: var(--accent-color);
544
642
  }
643
+
644
+ .icon-fallback {
645
+ display: inline-flex;
646
+ align-items: center;
647
+ justify-content: center;
648
+ color: var(--text-secondary);
649
+ font-size: 14px;
650
+ }
545
651
  </style>
546
652
  </head>
547
653
  <body>
@@ -557,7 +663,7 @@ __name(getBaseTemplate, "getBaseTemplate");
557
663
  function renderHeader(icon, title, username) {
558
664
  return `
559
665
  <div class="header">
560
- <div class="avatar">${icon}</div>
666
+ <div class="avatar">${renderIcon(icon, "avatar-icon", `${title} 图标`)}</div>
561
667
  <div class="header-content">
562
668
  <div class="title">${title}</div>
563
669
  </div>
@@ -580,7 +686,7 @@ function renderGridItem(icon, title, value, subtitle, type) {
580
686
  return `
581
687
  <div class="grid-item ${type}">
582
688
  <div class="item-header">
583
- <span class="item-icon">${icon}</span>
689
+ ${renderIcon(icon, "item-icon", `${title} 图标`)}
584
690
  <span class="item-title">${title}</span>
585
691
  </div>
586
692
  <div class="item-value">${value.toLocaleString()}</div>
@@ -599,13 +705,17 @@ function renderInfoRow(label, value, valueClass = "") {
599
705
  }
600
706
  __name(renderInfoRow, "renderInfoRow");
601
707
  function renderCommandGrid(commands) {
602
- const items = commands.map((cmd) => `
708
+ const items = commands.map(
709
+ (cmd) => `
603
710
  <div class="cmd-item">
604
- <div class="cmd-icon">${cmd.icon}</div>
605
- <div class="cmd-name">${cmd.name}</div>
606
- <div class="cmd-desc">${cmd.desc}</div>
711
+ ${renderIcon(cmd.icon, "cmd-icon", `${cmd.name} 图标`)}
712
+ <div class="cmd-content">
713
+ <div class="cmd-name">${cmd.name}</div>
714
+ <div class="cmd-desc">${cmd.desc}</div>
715
+ </div>
607
716
  </div>
608
- `).join("");
717
+ `
718
+ ).join("");
609
719
  return `<div class="cmd-grid">${items}</div>`;
610
720
  }
611
721
  __name(renderCommandGrid, "renderCommandGrid");
@@ -619,12 +729,14 @@ function renderPromptBox(title, message, type = "info") {
619
729
  }
620
730
  __name(renderPromptBox, "renderPromptBox");
621
731
  function renderConfirmDialog(title, items) {
622
- const rows = items.map((item) => `
732
+ const rows = items.map(
733
+ (item) => `
623
734
  <div class="confirm-row">
624
735
  <span class="confirm-label">${item.label}</span>
625
736
  <span class="confirm-value">${item.value}</span>
626
737
  </div>
627
- `).join("");
738
+ `
739
+ ).join("");
628
740
  return `
629
741
  <div class="confirm-dialog">
630
742
  <div class="confirm-title">${title}</div>
@@ -1478,22 +1590,22 @@ async function apply(ctx, config) {
1478
1590
  __name(renderToImage, "renderToImage");
1479
1591
  async function renderBankHomePage(username, balance, cash, currency, interestEnabled) {
1480
1592
  const commands = [
1481
- { icon: "💰", name: "bank.bal", desc: "查询存款余额" },
1482
- { icon: "📥", name: "bank.in", desc: "存入现金" },
1483
- { icon: "📤", name: "bank.out", desc: "取出现金" }
1593
+ { icon: "balance", name: "bank.bal", desc: "查询存款余额" },
1594
+ { icon: "deposit", name: "bank.in", desc: "存入现金" },
1595
+ { icon: "withdraw", name: "bank.out", desc: "取出现金" }
1484
1596
  ];
1485
1597
  if (interestEnabled) {
1486
1598
  commands.push(
1487
- { icon: "🔒", name: "bank.fixed", desc: "申请定期存款" },
1488
- { icon: "⚙️", name: "bank.fixed.manage", desc: "管理定期存款" }
1599
+ { icon: "fixed", name: "bank.fixed", desc: "申请定期存款" },
1600
+ { icon: "manage", name: "bank.fixed.manage", desc: "管理定期存款" }
1489
1601
  );
1490
1602
  }
1491
1603
  const content = `
1492
- ${renderHeader("🏦", "欢迎使用银行", username)}
1604
+ ${renderHeader("bank", "欢迎使用银行", username)}
1493
1605
 
1494
1606
  <div class="grid">
1495
- ${renderGridItem("💵", "现金余额", cash, "可用于存款", "cash")}
1496
- ${renderGridItem("🏦", "银行总资产", balance.total, `活期 ${balance.demand} + 定期 ${balance.fixed}`, "bank")}
1607
+ ${renderGridItem("cash", "现金余额", cash, "可用于存款", "cash")}
1608
+ ${renderGridItem("bank", "银行总资产", balance.total, `活期 ${balance.demand} + 定期 ${balance.fixed}`, "bank")}
1497
1609
  </div>
1498
1610
 
1499
1611
  ${renderPromptBox("可用命令", "点击下方命令查看详情或直接输入使用", "info")}
@@ -1501,7 +1613,7 @@ async function apply(ctx, config) {
1501
1613
  ${renderCommandGrid(commands)}
1502
1614
  `;
1503
1615
  const html = getBaseTemplate(content, 800, getTheme(config));
1504
- const fallback = `🏦 银行服务中心
1616
+ const fallback = `银行服务中心
1505
1617
 
1506
1618
  账户信息:
1507
1619
  现金:${cash} ${currency}
@@ -1510,13 +1622,13 @@ async function apply(ctx, config) {
1510
1622
  - 定期:${balance.fixed} ${currency}
1511
1623
 
1512
1624
  可用命令:
1513
- ${commands.map((c) => `${c.icon} ${c.name} - ${c.desc}`).join("\n")}`;
1625
+ ${commands.map((c) => `${c.name} - ${c.desc}`).join("\n")}`;
1514
1626
  return await renderToImage(html, fallback);
1515
1627
  }
1516
1628
  __name(renderBankHomePage, "renderBankHomePage");
1517
1629
  async function renderDepositConfirmPage(username, amount, currency, cash) {
1518
1630
  const content = `
1519
- ${renderHeader("💰", "存款确认", username)}
1631
+ ${renderHeader("deposit", "存款确认", username)}
1520
1632
 
1521
1633
  ${renderConfirmDialog("请确认存款信息", [
1522
1634
  { label: "存款金额", value: `${amount.toLocaleString()} ${currency}` },
@@ -1534,7 +1646,7 @@ ${commands.map((c) => `${c.icon} ${c.name} - ${c.desc}`).join("\n")}`;
1534
1646
  __name(renderDepositConfirmPage, "renderDepositConfirmPage");
1535
1647
  async function renderWithdrawConfirmPage(username, amount, currency, balance) {
1536
1648
  const content = `
1537
- ${renderHeader("💸", "取款确认", username)}
1649
+ ${renderHeader("withdraw", "取款确认", username)}
1538
1650
 
1539
1651
  ${renderConfirmDialog("请确认取款信息", [
1540
1652
  { label: "取款金额", value: `${amount.toLocaleString()} ${currency}` },
@@ -1554,11 +1666,11 @@ ${commands.map((c) => `${c.icon} ${c.name} - ${c.desc}`).join("\n")}`;
1554
1666
  const demandPercent = balance.total > 0 ? (balance.demand / balance.total * 100).toFixed(1) : "0";
1555
1667
  const fixedPercent = balance.total > 0 ? (balance.fixed / balance.total * 100).toFixed(1) : "0";
1556
1668
  const content = `
1557
- ${renderHeader("🏦", "银行资产", username)}
1669
+ ${renderHeader("balance", "银行资产", username)}
1558
1670
  ${renderBalanceCard("总资产", balance.total, currency)}
1559
1671
  <div class="grid">
1560
- ${renderGridItem("💵", "可用资产(活期)", balance.demand, `利率 ${demandRate}% | 占比 ${demandPercent}%`, "demand")}
1561
- ${renderGridItem("🔒", "不可用资产(定期)", balance.fixed, `占比 ${fixedPercent}%`, "fixed")}
1672
+ ${renderGridItem("demand", "可用资产(活期)", balance.demand, `利率 ${demandRate}% | 占比 ${demandPercent}%`, "demand")}
1673
+ ${renderGridItem("fixed", "不可用资产(定期)", balance.fixed, `占比 ${fixedPercent}%`, "fixed")}
1562
1674
  </div>
1563
1675
  `;
1564
1676
  const html = getBaseTemplate(content, 520, getTheme(config));
@@ -1571,7 +1683,7 @@ ${commands.map((c) => `${c.icon} ${c.name} - ${c.desc}`).join("\n")}`;
1571
1683
  __name(renderBankBalanceImage, "renderBankBalanceImage");
1572
1684
  async function renderDepositSuccessImage(username, amount, currency, newCash, newBalance) {
1573
1685
  const content = `
1574
- ${renderHeader("💰", "存款成功", username)}
1686
+ ${renderHeader("success", "存款成功", username)}
1575
1687
  ${renderBalanceCard("存入金额", amount, currency)}
1576
1688
  <div class="card success">
1577
1689
  ${renderInfoRow("存款类型", "活期存款")}
@@ -1579,8 +1691,8 @@ ${commands.map((c) => `${c.icon} ${c.name} - ${c.desc}`).join("\n")}`;
1579
1691
  ${renderInfoRow("银行总资产", `${newBalance.total.toLocaleString()} ${currency}`, "success")}
1580
1692
  </div>
1581
1693
  <div class="grid">
1582
- ${renderGridItem("💵", "活期资产", newBalance.demand, "可随时取出", "demand")}
1583
- ${renderGridItem("🔒", "定期资产", newBalance.fixed, "到期自动转活期", "fixed")}
1694
+ ${renderGridItem("demand", "活期资产", newBalance.demand, "可随时取出", "demand")}
1695
+ ${renderGridItem("fixed", "定期资产", newBalance.fixed, "到期自动转活期", "fixed")}
1584
1696
  </div>
1585
1697
  `;
1586
1698
  const html = getBaseTemplate(content, 520, getTheme(config));
@@ -1592,7 +1704,7 @@ ${commands.map((c) => `${c.icon} ${c.name} - ${c.desc}`).join("\n")}`;
1592
1704
  __name(renderDepositSuccessImage, "renderDepositSuccessImage");
1593
1705
  async function renderWithdrawSuccessImage(username, amount, currency, newCash, newBalance) {
1594
1706
  const content = `
1595
- ${renderHeader("💸", "取款成功", username)}
1707
+ ${renderHeader("success", "取款成功", username)}
1596
1708
  ${renderBalanceCard("取出金额", amount, currency)}
1597
1709
  <div class="card success">
1598
1710
  ${renderInfoRow("取款来源", "活期存款")}
@@ -1600,8 +1712,8 @@ ${commands.map((c) => `${c.icon} ${c.name} - ${c.desc}`).join("\n")}`;
1600
1712
  ${renderInfoRow("银行总资产", `${newBalance.total.toLocaleString()} ${currency}`)}
1601
1713
  </div>
1602
1714
  <div class="grid">
1603
- ${renderGridItem("💰", "现金余额", newCash, "可用于消费", "cash")}
1604
- ${renderGridItem("🏦", "银行余额", newBalance.total, "继续生息", "bank")}
1715
+ ${renderGridItem("cash", "现金余额", newCash, "可用于消费", "cash")}
1716
+ ${renderGridItem("bank", "银行余额", newBalance.total, "继续生息", "bank")}
1605
1717
  </div>
1606
1718
  `;
1607
1719
  const html = getBaseTemplate(content, 520, getTheme(config));
@@ -1633,7 +1745,7 @@ ${commands.map((c) => `${c.icon} ${c.name} - ${c.desc}`).join("\n")}`;
1633
1745
  });
1634
1746
  const totalAmount = records.reduce((sum, r) => sum + r.amount, 0);
1635
1747
  const content = `
1636
- ${renderHeader("📋", "定期存款管理", username)}
1748
+ ${renderHeader("manage", "定期存款管理", username)}
1637
1749
  ${renderBalanceCard("定期总额", totalAmount, currency)}
1638
1750
  ${renderPromptBox("管理说明", "请输入编号选择要管理的定期存款,输入 0 退出", "info")}
1639
1751
  <div style="margin-bottom: 20px;">
@@ -1663,11 +1775,11 @@ ${commands.map((c) => `${c.icon} ${c.name} - ${c.desc}`).join("\n")}`;
1663
1775
  `;
1664
1776
  }).join("");
1665
1777
  const content = `
1666
- ${renderHeader("🔒", "申请定期存款", username)}
1778
+ ${renderHeader("fixed", "申请定期存款", username)}
1667
1779
 
1668
1780
  <div class="grid">
1669
- ${renderGridItem("💵", "可用现金", cash, "优先扣除", "cash")}
1670
- ${renderGridItem("🏦", "活期存款", demand, "现金不足时扣除", "demand")}
1781
+ ${renderGridItem("cash", "可用现金", cash, "优先扣除", "cash")}
1782
+ ${renderGridItem("demand", "活期存款", demand, "现金不足时扣除", "demand")}
1671
1783
  </div>
1672
1784
 
1673
1785
  ${renderPromptBox("方案选择", "请输入方案编号,或输入 0 取消", "info")}
@@ -1687,7 +1799,7 @@ ${commands.map((c) => `${c.icon} ${c.name} - ${c.desc}`).join("\n")}`;
1687
1799
  const cycleText = cycle === "day" ? "日" : cycle === "week" ? "周" : "月";
1688
1800
  const dueDate = settlementDate.toLocaleDateString("zh-CN", { year: "numeric", month: "2-digit", day: "2-digit" });
1689
1801
  const content = `
1690
- ${renderHeader("🔒", "定期存款成功", username)}
1802
+ ${renderHeader("success", "定期存款成功", username)}
1691
1803
  ${renderBalanceCard("存入金额", amount, currency)}
1692
1804
 
1693
1805
  <div class="card success">
@@ -1697,8 +1809,8 @@ ${commands.map((c) => `${c.icon} ${c.name} - ${c.desc}`).join("\n")}`;
1697
1809
  </div>
1698
1810
 
1699
1811
  <div class="grid">
1700
- ${renderGridItem("💵", "当前现金", newCash, "可用于消费", "cash")}
1701
- ${renderGridItem("🏦", "银行总资产", newBalance.total, `活期 ${newBalance.demand} + 定期 ${newBalance.fixed}`, "bank")}
1812
+ ${renderGridItem("cash", "当前现金", newCash, "可用于消费", "cash")}
1813
+ ${renderGridItem("bank", "银行总资产", newBalance.total, `活期 ${newBalance.demand} + 定期 ${newBalance.fixed}`, "bank")}
1702
1814
  </div>
1703
1815
 
1704
1816
  ${renderPromptBox("温馨提示", "定期存款到期后将自动转为活期,或可在管理中申请延期续存", "info")}
@@ -1730,7 +1842,7 @@ ${commands.map((c) => `${c.icon} ${c.name} - ${c.desc}`).join("\n")}`;
1730
1842
  `;
1731
1843
  }).join("");
1732
1844
  const content = `
1733
- ${renderHeader("⚙️", "申请延期续存", username)}
1845
+ ${renderHeader("clock", "申请延期续存", username)}
1734
1846
  ${renderBalanceCard("当前定期金额", currentAmount, currency)}
1735
1847
  ${renderPromptBox("延期说明", "到期后将按选择的新方案继续存款,本金+利息自动续存", "info")}
1736
1848
  <div style="margin-bottom: 20px;">
@@ -1747,7 +1859,7 @@ ${commands.map((c) => `${c.icon} ${c.name} - ${c.desc}`).join("\n")}`;
1747
1859
  __name(renderExtensionPlanSelectionPage, "renderExtensionPlanSelectionPage");
1748
1860
  async function renderCancelExtensionPage(username, amount, currency, currentPlan) {
1749
1861
  const content = `
1750
- ${renderHeader("⚠️", "取消延期申请", username)}
1862
+ ${renderHeader("warning", "取消延期申请", username)}
1751
1863
  ${renderBalanceCard("定期金额", amount, currency)}
1752
1864
 
1753
1865
  ${renderConfirmDialog("请确认取消延期", [
@@ -1768,7 +1880,7 @@ ${commands.map((c) => `${c.icon} ${c.name} - ${c.desc}`).join("\n")}`;
1768
1880
  async function renderExtensionSuccessPage(username, action, amount, currency, planName, rate, cycle) {
1769
1881
  if (action === "cancel") {
1770
1882
  const content = `
1771
- ${renderHeader("✅", "取消成功", username)}
1883
+ ${renderHeader("success", "取消成功", username)}
1772
1884
  ${renderBalanceCard("定期金额", amount, currency)}
1773
1885
 
1774
1886
  <div class="card success">
@@ -1786,7 +1898,7 @@ ${commands.map((c) => `${c.icon} ${c.name} - ${c.desc}`).join("\n")}`;
1786
1898
  } else {
1787
1899
  const cycleText = cycle === "day" ? "日" : cycle === "week" ? "周" : "月";
1788
1900
  const content = `
1789
- ${renderHeader("✅", "延期申请成功", username)}
1901
+ ${renderHeader("success", "延期申请成功", username)}
1790
1902
  ${renderBalanceCard("定期金额", amount, currency)}
1791
1903
 
1792
1904
  <div class="card success">
@@ -1,8 +1,3 @@
1
- /**
2
- * HTML模板工具文件
3
- * 提供统一的样式和布局模板
4
- * 设计风格:深色玻璃拟态,与 monetary-bourse 保持一致
5
- */
6
1
  /**
7
2
  * 通用HTML模板基础
8
3
  */
@@ -18,11 +13,11 @@ export declare function renderBalanceCard(label: string, value: number, currency
18
13
  /**
19
14
  * 网格项
20
15
  */
21
- export declare function renderGridItem(icon: string, title: string, value: number, subtitle: string, type: 'demand' | 'fixed' | 'cash' | 'bank'): string;
16
+ export declare function renderGridItem(icon: string, title: string, value: number, subtitle: string, type: "demand" | "fixed" | "cash" | "bank"): string;
22
17
  /**
23
18
  * 信息行
24
19
  */
25
- export declare function renderInfoRow(label: string, value: string, valueClass?: '' | 'success' | 'error'): string;
20
+ export declare function renderInfoRow(label: string, value: string, valueClass?: "" | "success" | "error"): string;
26
21
  /**
27
22
  * 命令按钮网格
28
23
  */
@@ -34,7 +29,7 @@ export declare function renderCommandGrid(commands: Array<{
34
29
  /**
35
30
  * 提示信息框
36
31
  */
37
- export declare function renderPromptBox(title: string, message: string, type?: 'info' | 'warning' | 'success'): string;
32
+ export declare function renderPromptBox(title: string, message: string, type?: "info" | "warning" | "success"): string;
38
33
  /**
39
34
  * 确认对话框样式
40
35
  */
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "koishi-plugin-monetary-bank",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "main": "lib/index.js",
5
5
  "typings": "lib/index.d.ts",
6
6
  "files": [
7
7
  "lib",
8
8
  "dist",
9
- "src"
9
+ "src",
10
+ "assets"
10
11
  ],
11
12
  "koishi": {
12
13
  "description": {
package/readme.md CHANGED
@@ -1,14 +1,24 @@
1
- # koishi-plugin-monetary-bank | 货币银行
1
+ <h1 align="center">koishi-plugin-monetary-bank</h1>
2
2
 
3
- [![npm](https://img.shields.io/npm/v/koishi-plugin-monetary-bank?style=flat-square)](https://www.npmjs.com/package/koishi-plugin-monetary-bank) [![GitHub stars](https://img.shields.io/github/stars/BYWled/koishi-plugin-monetary-bank?style=flat-square&logo=github)](https://github.com/BYWled/koishi-plugin-monetary-bank) [![Gitee](https://img.shields.io/badge/Gitee-Project-c71d23?style=flat-square&logo=gitee&logoColor=white)](https://gitee.com/BYWled/koishi-plugin-monetary-bank)
3
+ <p align="center">
4
+ 为 monetary 插件(或外部项目中的主货币表)提供轻量级银行功能,支持活期/定期存款与利息结算。
5
+ </p>
4
6
 
5
- `Provides banking related services for monetary money`
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/koishi-plugin-monetary-bank"><img src="https://img.shields.io/npm/v/koishi-plugin-monetary-bank?style=for-the-badge&logo=npm" alt="npm" /></a>
9
+ <a href="https://github.com/BYWled/koishi-plugin-monetary-bank"><img src="https://img.shields.io/github/stars/BYWled/koishi-plugin-monetary-bank?style=for-the-badge&logo=github" alt="GitHub Stars" /></a>
10
+ </p>
6
11
 
7
- `为 monetary 插件(或外部项目中的主货币表)提供轻量级银行功能,支持活期/定期存款与利息结算。`
12
+ <p align="center">
13
+ <a href="https://gitee.com/BYWled/koishi-plugin-monetary-bank"><img src="https://img.shields.io/badge/Gitee-代码镜像-C71D23?style=for-the-badge&logo=gitee&logoColor=white" alt="Gitee Mirror" /></a>
14
+ </p>
8
15
 
9
- ---
16
+ <p align="center">
17
+ <a href="https://github.com/BYWled/koishi-plugin-monetary-bank">GitHub</a> ·
18
+ <a href="https://gitee.com/BYWled/koishi-plugin-monetary-bank">Gitee</a>
19
+ </p>
10
20
 
11
- **版本**: v2.1.0
21
+ > 版本:**2.2.0**
12
22
 
13
23
  ## ✨ 特点
14
24
 
@@ -203,7 +213,7 @@ import { renderHeader, renderBalanceCard, renderPromptBox, getBaseTemplate } fro
203
213
 
204
214
  // 构建 HTML 内容
205
215
  const content = `
206
- ${renderHeader('🎯', '自定义页面', username)}
216
+ ${renderHeader('manage', '自定义页面', username)}
207
217
  ${renderBalanceCard('数据展示', 1000, 'coin')}
208
218
  ${renderPromptBox('提示', '这是一个自定义页面', 'info')}
209
219
  `;
@@ -225,3 +235,7 @@ const image = await ctx.puppeteer.render(html);
225
235
  **仓库**: `koishi-plugin-monetary-bank`
226
236
 
227
237
  萌新编写,部分借助了AI的力量,若有纰漏,还望海涵QwQ
238
+
239
+ ## 🙏 第三方资源/致谢
240
+
241
+ - Roboto Mono 字体(SIL OPEN FONT LICENSE Version 1.1):https://fonts.google.com/specimen/Roboto+Mono
package/src/index.ts CHANGED
@@ -1270,24 +1270,24 @@ export async function apply(ctx: Context, config: Config) {
1270
1270
  interestEnabled: boolean
1271
1271
  ) {
1272
1272
  const commands = [
1273
- { icon: '💰', name: 'bank.bal', desc: '查询存款余额' },
1274
- { icon: '📥', name: 'bank.in', desc: '存入现金' },
1275
- { icon: '📤', name: 'bank.out', desc: '取出现金' }
1273
+ { icon: 'balance', name: 'bank.bal', desc: '查询存款余额' },
1274
+ { icon: 'deposit', name: 'bank.in', desc: '存入现金' },
1275
+ { icon: 'withdraw', name: 'bank.out', desc: '取出现金' }
1276
1276
  ]
1277
1277
 
1278
1278
  if (interestEnabled) {
1279
1279
  commands.push(
1280
- { icon: '🔒', name: 'bank.fixed', desc: '申请定期存款' },
1281
- { icon: '⚙️', name: 'bank.fixed.manage', desc: '管理定期存款' }
1280
+ { icon: 'fixed', name: 'bank.fixed', desc: '申请定期存款' },
1281
+ { icon: 'manage', name: 'bank.fixed.manage', desc: '管理定期存款' }
1282
1282
  )
1283
1283
  }
1284
1284
 
1285
1285
  const content = `
1286
- ${renderHeader('🏦', '欢迎使用银行', username)}
1286
+ ${renderHeader('bank', '欢迎使用银行', username)}
1287
1287
 
1288
1288
  <div class="grid">
1289
- ${renderGridItem('💵', '现金余额', cash, '可用于存款', 'cash')}
1290
- ${renderGridItem('🏦', '银行总资产', balance.total, `活期 ${balance.demand} + 定期 ${balance.fixed}`, 'bank')}
1289
+ ${renderGridItem('cash', '现金余额', cash, '可用于存款', 'cash')}
1290
+ ${renderGridItem('bank', '银行总资产', balance.total, `活期 ${balance.demand} + 定期 ${balance.fixed}`, 'bank')}
1291
1291
  </div>
1292
1292
 
1293
1293
  ${renderPromptBox('可用命令', '点击下方命令查看详情或直接输入使用', 'info')}
@@ -1296,7 +1296,7 @@ export async function apply(ctx: Context, config: Config) {
1296
1296
  `
1297
1297
 
1298
1298
  const html = getBaseTemplate(content, 800, getTheme(config))
1299
- const fallback = `🏦 银行服务中心\n\n账户信息:\n现金:${cash} ${currency}\n银行总资产:${balance.total} ${currency}\n - 活期:${balance.demand} ${currency}\n - 定期:${balance.fixed} ${currency}\n\n可用命令:\n${commands.map(c => `${c.icon} ${c.name} - ${c.desc}`).join('\n')}`
1299
+ const fallback = `银行服务中心\n\n账户信息:\n现金:${cash} ${currency}\n银行总资产:${balance.total} ${currency}\n - 活期:${balance.demand} ${currency}\n - 定期:${balance.fixed} ${currency}\n\n可用命令:\n${commands.map(c => `${c.name} - ${c.desc}`).join('\n')}`
1300
1300
 
1301
1301
  return await renderToImage(html, fallback)
1302
1302
  }
@@ -1311,7 +1311,7 @@ export async function apply(ctx: Context, config: Config) {
1311
1311
  cash: number
1312
1312
  ) {
1313
1313
  const content = `
1314
- ${renderHeader('💰', '存款确认', username)}
1314
+ ${renderHeader('deposit', '存款确认', username)}
1315
1315
 
1316
1316
  ${renderConfirmDialog('请确认存款信息', [
1317
1317
  { label: '存款金额', value: `${amount.toLocaleString()} ${currency}` },
@@ -1339,7 +1339,7 @@ export async function apply(ctx: Context, config: Config) {
1339
1339
  balance: number
1340
1340
  ) {
1341
1341
  const content = `
1342
- ${renderHeader('💸', '取款确认', username)}
1342
+ ${renderHeader('withdraw', '取款确认', username)}
1343
1343
 
1344
1344
  ${renderConfirmDialog('请确认取款信息', [
1345
1345
  { label: '取款金额', value: `${amount.toLocaleString()} ${currency}` },
@@ -1370,11 +1370,11 @@ export async function apply(ctx: Context, config: Config) {
1370
1370
  const fixedPercent = balance.total > 0 ? (balance.fixed / balance.total * 100).toFixed(1) : '0'
1371
1371
 
1372
1372
  const content = `
1373
- ${renderHeader('🏦', '银行资产', username)}
1373
+ ${renderHeader('balance', '银行资产', username)}
1374
1374
  ${renderBalanceCard('总资产', balance.total, currency)}
1375
1375
  <div class="grid">
1376
- ${renderGridItem('💵', '可用资产(活期)', balance.demand, `利率 ${demandRate}% | 占比 ${demandPercent}%`, 'demand')}
1377
- ${renderGridItem('🔒', '不可用资产(定期)', balance.fixed, `占比 ${fixedPercent}%`, 'fixed')}
1376
+ ${renderGridItem('demand', '可用资产(活期)', balance.demand, `利率 ${demandRate}% | 占比 ${demandPercent}%`, 'demand')}
1377
+ ${renderGridItem('fixed', '不可用资产(定期)', balance.fixed, `占比 ${fixedPercent}%`, 'fixed')}
1378
1378
  </div>
1379
1379
  `
1380
1380
 
@@ -1395,7 +1395,7 @@ export async function apply(ctx: Context, config: Config) {
1395
1395
  newBalance: { total: number; demand: number; fixed: number }
1396
1396
  ) {
1397
1397
  const content = `
1398
- ${renderHeader('💰', '存款成功', username)}
1398
+ ${renderHeader('success', '存款成功', username)}
1399
1399
  ${renderBalanceCard('存入金额', amount, currency)}
1400
1400
  <div class="card success">
1401
1401
  ${renderInfoRow('存款类型', '活期存款')}
@@ -1403,8 +1403,8 @@ export async function apply(ctx: Context, config: Config) {
1403
1403
  ${renderInfoRow('银行总资产', `${newBalance.total.toLocaleString()} ${currency}`, 'success')}
1404
1404
  </div>
1405
1405
  <div class="grid">
1406
- ${renderGridItem('💵', '活期资产', newBalance.demand, '可随时取出', 'demand')}
1407
- ${renderGridItem('🔒', '定期资产', newBalance.fixed, '到期自动转活期', 'fixed')}
1406
+ ${renderGridItem('demand', '活期资产', newBalance.demand, '可随时取出', 'demand')}
1407
+ ${renderGridItem('fixed', '定期资产', newBalance.fixed, '到期自动转活期', 'fixed')}
1408
1408
  </div>
1409
1409
  `
1410
1410
 
@@ -1425,7 +1425,7 @@ export async function apply(ctx: Context, config: Config) {
1425
1425
  newBalance: { total: number; demand: number; fixed: number }
1426
1426
  ) {
1427
1427
  const content = `
1428
- ${renderHeader('💸', '取款成功', username)}
1428
+ ${renderHeader('success', '取款成功', username)}
1429
1429
  ${renderBalanceCard('取出金额', amount, currency)}
1430
1430
  <div class="card success">
1431
1431
  ${renderInfoRow('取款来源', '活期存款')}
@@ -1433,8 +1433,8 @@ export async function apply(ctx: Context, config: Config) {
1433
1433
  ${renderInfoRow('银行总资产', `${newBalance.total.toLocaleString()} ${currency}`)}
1434
1434
  </div>
1435
1435
  <div class="grid">
1436
- ${renderGridItem('💰', '现金余额', newCash, '可用于消费', 'cash')}
1437
- ${renderGridItem('🏦', '银行余额', newBalance.total, '继续生息', 'bank')}
1436
+ ${renderGridItem('cash', '现金余额', newCash, '可用于消费', 'cash')}
1437
+ ${renderGridItem('bank', '银行余额', newBalance.total, '继续生息', 'bank')}
1438
1438
  </div>
1439
1439
  `
1440
1440
 
@@ -1476,7 +1476,7 @@ export async function apply(ctx: Context, config: Config) {
1476
1476
  const totalAmount = records.reduce((sum, r) => sum + r.amount, 0)
1477
1477
 
1478
1478
  const content = `
1479
- ${renderHeader('📋', '定期存款管理', username)}
1479
+ ${renderHeader('manage', '定期存款管理', username)}
1480
1480
  ${renderBalanceCard('定期总额', totalAmount, currency)}
1481
1481
  ${renderPromptBox('管理说明', '请输入编号选择要管理的定期存款,输入 0 退出', 'info')}
1482
1482
  <div style="margin-bottom: 20px;">
@@ -1518,11 +1518,11 @@ export async function apply(ctx: Context, config: Config) {
1518
1518
  }).join('')
1519
1519
 
1520
1520
  const content = `
1521
- ${renderHeader('🔒', '申请定期存款', username)}
1521
+ ${renderHeader('fixed', '申请定期存款', username)}
1522
1522
 
1523
1523
  <div class="grid">
1524
- ${renderGridItem('💵', '可用现金', cash, '优先扣除', 'cash')}
1525
- ${renderGridItem('🏦', '活期存款', demand, '现金不足时扣除', 'demand')}
1524
+ ${renderGridItem('cash', '可用现金', cash, '优先扣除', 'cash')}
1525
+ ${renderGridItem('demand', '活期存款', demand, '现金不足时扣除', 'demand')}
1526
1526
  </div>
1527
1527
 
1528
1528
  ${renderPromptBox('方案选择', '请输入方案编号,或输入 0 取消', 'info')}
@@ -1560,7 +1560,7 @@ export async function apply(ctx: Context, config: Config) {
1560
1560
  const dueDate = settlementDate.toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' })
1561
1561
 
1562
1562
  const content = `
1563
- ${renderHeader('🔒', '定期存款成功', username)}
1563
+ ${renderHeader('success', '定期存款成功', username)}
1564
1564
  ${renderBalanceCard('存入金额', amount, currency)}
1565
1565
 
1566
1566
  <div class="card success">
@@ -1570,8 +1570,8 @@ export async function apply(ctx: Context, config: Config) {
1570
1570
  </div>
1571
1571
 
1572
1572
  <div class="grid">
1573
- ${renderGridItem('💵', '当前现金', newCash, '可用于消费', 'cash')}
1574
- ${renderGridItem('🏦', '银行总资产', newBalance.total, `活期 ${newBalance.demand} + 定期 ${newBalance.fixed}`, 'bank')}
1573
+ ${renderGridItem('cash', '当前现金', newCash, '可用于消费', 'cash')}
1574
+ ${renderGridItem('bank', '银行总资产', newBalance.total, `活期 ${newBalance.demand} + 定期 ${newBalance.fixed}`, 'bank')}
1575
1575
  </div>
1576
1576
 
1577
1577
  ${renderPromptBox('温馨提示', '定期存款到期后将自动转为活期,或可在管理中申请延期续存', 'info')}
@@ -1608,7 +1608,7 @@ export async function apply(ctx: Context, config: Config) {
1608
1608
  }).join('')
1609
1609
 
1610
1610
  const content = `
1611
- ${renderHeader('⚙️', '申请延期续存', username)}
1611
+ ${renderHeader('clock', '申请延期续存', username)}
1612
1612
  ${renderBalanceCard('当前定期金额', currentAmount, currency)}
1613
1613
  ${renderPromptBox('延期说明', '到期后将按选择的新方案继续存款,本金+利息自动续存', 'info')}
1614
1614
  <div style="margin-bottom: 20px;">
@@ -1635,7 +1635,7 @@ export async function apply(ctx: Context, config: Config) {
1635
1635
  currentPlan: string
1636
1636
  ) {
1637
1637
  const content = `
1638
- ${renderHeader('⚠️', '取消延期申请', username)}
1638
+ ${renderHeader('warning', '取消延期申请', username)}
1639
1639
  ${renderBalanceCard('定期金额', amount, currency)}
1640
1640
 
1641
1641
  ${renderConfirmDialog('请确认取消延期', [
@@ -1667,7 +1667,7 @@ export async function apply(ctx: Context, config: Config) {
1667
1667
  ) {
1668
1668
  if (action === 'cancel') {
1669
1669
  const content = `
1670
- ${renderHeader('✅', '取消成功', username)}
1670
+ ${renderHeader('success', '取消成功', username)}
1671
1671
  ${renderBalanceCard('定期金额', amount, currency)}
1672
1672
 
1673
1673
  <div class="card success">
@@ -1685,7 +1685,7 @@ export async function apply(ctx: Context, config: Config) {
1685
1685
  } else {
1686
1686
  const cycleText = cycle === 'day' ? '日' : cycle === 'week' ? '周' : '月'
1687
1687
  const content = `
1688
- ${renderHeader('✅', '延期申请成功', username)}
1688
+ ${renderHeader('success', '延期申请成功', username)}
1689
1689
  ${renderBalanceCard('定期金额', amount, currency)}
1690
1690
 
1691
1691
  <div class="card success">
package/src/templates.ts CHANGED
@@ -1,13 +1,77 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { pathToFileURL } from "url";
4
+
1
5
  /**
2
6
  * HTML模板工具文件
3
7
  * 提供统一的样式和布局模板
4
8
  * 设计风格:深色玻璃拟态,与 monetary-bourse 保持一致
5
9
  */
6
10
 
11
+ const ASSET_BASE_PATH = path.resolve(__dirname, "..", "assets");
12
+ const ASSET_BASE_URL = pathToFileURL(ASSET_BASE_PATH)
13
+ .toString()
14
+ .replace(/\/$/, "");
15
+
16
+ const ICON_MAP: Record<string, string> = {
17
+ bank: "icons/bank.svg",
18
+ balance: "icons/balance.svg",
19
+ cash: "icons/cash.svg",
20
+ demand: "icons/demand.svg",
21
+ fixed: "icons/fixed.svg",
22
+ deposit: "icons/deposit.svg",
23
+ withdraw: "icons/withdraw.svg",
24
+ manage: "icons/manage.svg",
25
+ success: "icons/success.svg",
26
+ warning: "icons/warning.svg",
27
+ clock: "icons/clock.svg",
28
+ };
29
+
30
+ function getAssetUrl(relativePath: string): string {
31
+ return `${ASSET_BASE_URL}/${relativePath}`;
32
+ }
33
+
34
+ const ICON_DATA_URLS: Record<string, string> = {};
35
+
36
+ for (const [key, file] of Object.entries(ICON_MAP)) {
37
+ try {
38
+ const absolutePath = path.resolve(ASSET_BASE_PATH, file);
39
+ const buffer = fs.readFileSync(absolutePath);
40
+ ICON_DATA_URLS[key] =
41
+ `data:image/svg+xml;base64,${buffer.toString("base64")}`;
42
+ } catch {
43
+ ICON_DATA_URLS[key] = "";
44
+ }
45
+ }
46
+
47
+ function getIconUrl(iconName: string): string {
48
+ const key = String(iconName || "").toLowerCase();
49
+ const dataUrl = ICON_DATA_URLS[key];
50
+ if (dataUrl) return dataUrl;
51
+
52
+ const file = ICON_MAP[key];
53
+ return file ? getAssetUrl(file) : "";
54
+ }
55
+
56
+ function renderIcon(iconName: string, className: string, alt: string): string {
57
+ const src = getIconUrl(iconName);
58
+ if (!src) {
59
+ return `<span class="${className} icon-fallback" aria-hidden="true">?</span>`;
60
+ }
61
+
62
+ return `<img class="${className}" src="${src}" alt="${alt}" />`;
63
+ }
64
+
7
65
  /**
8
66
  * 通用HTML模板基础
9
67
  */
10
- export function getBaseTemplate(content: string, width: number = 520, isDark: boolean = false): string {
68
+ export function getBaseTemplate(
69
+ content: string,
70
+ width: number = 520,
71
+ isDark: boolean = false,
72
+ ): string {
73
+ const fontRegularUrl = getAssetUrl("fonts/RobotoMono-Regular.ttf");
74
+ const fontBoldUrl = getAssetUrl("fonts/RobotoMono-Bold.ttf");
11
75
  // 深色模式变量 (Dark Mode)
12
76
  const darkVars = `
13
77
  /* 统一配色 - 深色玻璃拟态 */
@@ -33,7 +97,7 @@ export function getBaseTemplate(content: string, width: number = 520, isDark: bo
33
97
  --danger-bg: rgba(248, 113, 113, 0.15);
34
98
  --shadow-color: rgba(0, 0, 0, 0.6);
35
99
  --separator-color: rgba(48, 54, 61, 0.5);
36
- `
100
+ `;
37
101
 
38
102
  // 浅色模式变量 (Light Mode)
39
103
  // 调整说明:增强阴影,使用深色微边框替代白色高光边框,显著提升对比度
@@ -61,15 +125,15 @@ export function getBaseTemplate(content: string, width: number = 520, isDark: bo
61
125
  --danger-bg: rgba(239, 68, 68, 0.15);
62
126
  --shadow-color: rgba(100, 116, 139, 0.2);
63
127
  --separator-color: rgba(0, 0, 0, 0.08);
64
- `
128
+ `;
65
129
 
66
- const bgStyle = isDark
130
+ const bgStyle = isDark
67
131
  ? `background: radial-gradient(circle at 0% 0%, #1a2332 0%, transparent 50%),
68
132
  radial-gradient(circle at 100% 100%, #161b22 0%, transparent 50%),
69
133
  var(--bg-color);`
70
134
  : `background: radial-gradient(circle at 0% 0%, #e0f2fe 0%, transparent 50%),
71
135
  radial-gradient(circle at 100% 100%, #f0f9ff 0%, transparent 50%),
72
- var(--bg-color);`
136
+ var(--bg-color);`;
73
137
 
74
138
  return `
75
139
  <!DOCTYPE html>
@@ -77,6 +141,22 @@ export function getBaseTemplate(content: string, width: number = 520, isDark: bo
77
141
  <head>
78
142
  <meta charset="UTF-8">
79
143
  <style>
144
+ @font-face {
145
+ font-family: 'Roboto Mono';
146
+ src: url('${fontRegularUrl}') format('truetype');
147
+ font-weight: 400;
148
+ font-style: normal;
149
+ font-display: swap;
150
+ }
151
+
152
+ @font-face {
153
+ font-family: 'Roboto Mono';
154
+ src: url('${fontBoldUrl}') format('truetype');
155
+ font-weight: 700;
156
+ font-style: normal;
157
+ font-display: swap;
158
+ }
159
+
80
160
  :root {
81
161
  ${isDark ? darkVars : lightVars}
82
162
  }
@@ -87,7 +167,7 @@ export function getBaseTemplate(content: string, width: number = 520, isDark: bo
87
167
  position: relative;
88
168
  margin: 0;
89
169
  padding: 32px;
90
- font-family: 'Roboto Mono', 'Trebuchet MS', 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
170
+ font-family: 'Roboto Mono', 'PingFang SC', 'Microsoft YaHei', sans-serif;
91
171
  ${bgStyle}
92
172
  width: ${width}px;
93
173
  box-sizing: border-box;
@@ -129,6 +209,12 @@ export function getBaseTemplate(content: string, width: number = 520, isDark: bo
129
209
  box-shadow: 0 8px 16px rgba(88, 166, 255, 0.3);
130
210
  flex-shrink: 0;
131
211
  }
212
+
213
+ .avatar-icon {
214
+ width: 24px;
215
+ height: 24px;
216
+ display: block;
217
+ }
132
218
 
133
219
  .header-content {
134
220
  flex: 1;
@@ -272,7 +358,9 @@ export function getBaseTemplate(content: string, width: number = 520, isDark: bo
272
358
  }
273
359
 
274
360
  .item-icon {
275
- font-size: 18px;
361
+ width: 18px;
362
+ height: 18px;
363
+ display: block;
276
364
  }
277
365
 
278
366
  .item-title {
@@ -352,11 +440,14 @@ export function getBaseTemplate(content: string, width: number = 520, isDark: bo
352
440
  .cmd-item {
353
441
  background: var(--item-bg);
354
442
  border-radius: 12px;
355
- padding: 20px 16px;
356
- text-align: center;
443
+ padding: 16px;
444
+ text-align: left;
357
445
  border: 1px solid var(--border-color);
358
446
  transition: all 0.2s ease;
359
447
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
448
+ display: flex;
449
+ align-items: center;
450
+ gap: 14px;
360
451
  }
361
452
 
362
453
  .cmd-item:hover {
@@ -366,20 +457,31 @@ export function getBaseTemplate(content: string, width: number = 520, isDark: bo
366
457
  }
367
458
 
368
459
  .cmd-icon {
369
- font-size: 28px;
370
- margin-bottom: 10px;
460
+ width: 32px;
461
+ height: 32px;
462
+ display: block;
463
+ flex-shrink: 0;
464
+ }
465
+
466
+ .cmd-content {
467
+ flex: 1;
468
+ min-width: 0;
371
469
  }
372
470
 
373
471
  .cmd-name {
374
- font-size: 14px;
375
- font-weight: 600;
472
+ font-size: 15px;
473
+ font-weight: 700;
376
474
  color: var(--text-primary);
377
- margin-bottom: 6px;
475
+ margin-bottom: 4px;
476
+ letter-spacing: -0.2px;
378
477
  }
379
478
 
380
479
  .cmd-desc {
381
480
  font-size: 12px;
382
481
  color: var(--text-secondary);
482
+ white-space: nowrap;
483
+ overflow: hidden;
484
+ text-overflow: ellipsis;
383
485
  }
384
486
 
385
487
  /* Prompt Box */
@@ -527,6 +629,14 @@ export function getBaseTemplate(content: string, width: number = 520, isDark: bo
527
629
  background: rgba(88, 166, 255, 0.15);
528
630
  color: var(--accent-color);
529
631
  }
632
+
633
+ .icon-fallback {
634
+ display: inline-flex;
635
+ align-items: center;
636
+ justify-content: center;
637
+ color: var(--text-secondary);
638
+ font-size: 14px;
639
+ }
530
640
  </style>
531
641
  </head>
532
642
  <body>
@@ -536,35 +646,43 @@ export function getBaseTemplate(content: string, width: number = 520, isDark: bo
536
646
  </div>
537
647
  </body>
538
648
  </html>
539
- `
649
+ `;
540
650
  }
541
651
 
542
652
  /**
543
653
  * 页面头部
544
654
  */
545
- export function renderHeader(icon: string, title: string, username: string): string {
655
+ export function renderHeader(
656
+ icon: string,
657
+ title: string,
658
+ username: string,
659
+ ): string {
546
660
  return `
547
661
  <div class="header">
548
- <div class="avatar">${icon}</div>
662
+ <div class="avatar">${renderIcon(icon, "avatar-icon", `${title} 图标`)}</div>
549
663
  <div class="header-content">
550
664
  <div class="title">${title}</div>
551
665
  </div>
552
666
  <div class="user-info">${username}</div>
553
667
  </div>
554
- `
668
+ `;
555
669
  }
556
670
 
557
671
  /**
558
672
  * 余额卡片(大标题样式)
559
673
  */
560
- export function renderBalanceCard(label: string, value: number, currency: string): string {
674
+ export function renderBalanceCard(
675
+ label: string,
676
+ value: number,
677
+ currency: string,
678
+ ): string {
561
679
  return `
562
680
  <div class="balance-section">
563
681
  <div class="balance-label">${label}</div>
564
682
  <div class="balance-value">${value.toLocaleString()}</div>
565
683
  <div class="balance-currency">${currency}</div>
566
684
  </div>
567
- `
685
+ `;
568
686
  }
569
687
 
570
688
  /**
@@ -575,75 +693,98 @@ export function renderGridItem(
575
693
  title: string,
576
694
  value: number,
577
695
  subtitle: string,
578
- type: 'demand' | 'fixed' | 'cash' | 'bank'
696
+ type: "demand" | "fixed" | "cash" | "bank",
579
697
  ): string {
580
698
  return `
581
699
  <div class="grid-item ${type}">
582
700
  <div class="item-header">
583
- <span class="item-icon">${icon}</span>
701
+ ${renderIcon(icon, "item-icon", `${title} 图标`)}
584
702
  <span class="item-title">${title}</span>
585
703
  </div>
586
704
  <div class="item-value">${value.toLocaleString()}</div>
587
705
  <div class="item-subtitle">${subtitle}</div>
588
706
  </div>
589
- `
707
+ `;
590
708
  }
591
709
 
592
710
  /**
593
711
  * 信息行
594
712
  */
595
- export function renderInfoRow(label: string, value: string, valueClass: '' | 'success' | 'error' = ''): string {
713
+ export function renderInfoRow(
714
+ label: string,
715
+ value: string,
716
+ valueClass: "" | "success" | "error" = "",
717
+ ): string {
596
718
  return `
597
719
  <div class="info-row">
598
720
  <span class="info-label">${label}</span>
599
721
  <span class="info-value ${valueClass}">${value}</span>
600
722
  </div>
601
- `
723
+ `;
602
724
  }
603
725
 
604
726
  /**
605
727
  * 命令按钮网格
606
728
  */
607
- export function renderCommandGrid(commands: Array<{ icon: string; name: string; desc: string }>): string {
608
- const items = commands.map(cmd => `
729
+ export function renderCommandGrid(
730
+ commands: Array<{ icon: string; name: string; desc: string }>,
731
+ ): string {
732
+ const items = commands
733
+ .map(
734
+ (cmd) => `
609
735
  <div class="cmd-item">
610
- <div class="cmd-icon">${cmd.icon}</div>
611
- <div class="cmd-name">${cmd.name}</div>
612
- <div class="cmd-desc">${cmd.desc}</div>
736
+ ${renderIcon(cmd.icon, "cmd-icon", `${cmd.name} 图标`)}
737
+ <div class="cmd-content">
738
+ <div class="cmd-name">${cmd.name}</div>
739
+ <div class="cmd-desc">${cmd.desc}</div>
740
+ </div>
613
741
  </div>
614
- `).join('')
615
-
616
- return `<div class="cmd-grid">${items}</div>`
742
+ `,
743
+ )
744
+ .join("");
745
+
746
+ return `<div class="cmd-grid">${items}</div>`;
617
747
  }
618
748
 
619
749
  /**
620
750
  * 提示信息框
621
751
  */
622
- export function renderPromptBox(title: string, message: string, type: 'info' | 'warning' | 'success' = 'info'): string {
752
+ export function renderPromptBox(
753
+ title: string,
754
+ message: string,
755
+ type: "info" | "warning" | "success" = "info",
756
+ ): string {
623
757
  return `
624
758
  <div class="prompt-box ${type}">
625
759
  <div class="prompt-title">${title}</div>
626
760
  <div class="prompt-message">${message}</div>
627
761
  </div>
628
- `
762
+ `;
629
763
  }
630
764
 
631
765
  /**
632
766
  * 确认对话框样式
633
767
  */
634
- export function renderConfirmDialog(title: string, items: Array<{ label: string; value: string }>): string {
635
- const rows = items.map(item => `
768
+ export function renderConfirmDialog(
769
+ title: string,
770
+ items: Array<{ label: string; value: string }>,
771
+ ): string {
772
+ const rows = items
773
+ .map(
774
+ (item) => `
636
775
  <div class="confirm-row">
637
776
  <span class="confirm-label">${item.label}</span>
638
777
  <span class="confirm-value">${item.value}</span>
639
778
  </div>
640
- `).join('')
641
-
779
+ `,
780
+ )
781
+ .join("");
782
+
642
783
  return `
643
784
  <div class="confirm-dialog">
644
785
  <div class="confirm-title">${title}</div>
645
786
  ${rows}
646
787
  <div class="confirm-hint">请回复 yes 或 y 确认,其他内容取消</div>
647
788
  </div>
648
- `
649
- }
789
+ `;
790
+ }