From f497e7eb27bb83cdb87c670bca92b00b85a2532c Mon Sep 17 00:00:00 2001 From: stqfdyr <89149493+stqfdyr@users.noreply.github.com> Date: Fri, 2 Oct 2026 18:19:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?docs:=20=E4=B8=BB=E9=A2=98=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=BB=B7=E6=A0=BC=E6=8C=89=20zh-CN=20=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=EF=BC=8C=E5=85=9C=E4=BD=8F=E6=97=A7=E7=89=88?= =?UTF-8?q?=20hub=20=E5=AD=98=E4=B8=8B=E7=9A=84=E9=9D=9E=E6=B3=95=E8=B4=A7?= =?UTF-8?q?=E5=B8=81=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/content/dev/theme.mdx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/content/dev/theme.mdx b/src/content/dev/theme.mdx index cd04a3d..cf8f611 100644 --- a/src/content/dev/theme.mdx +++ b/src/content/dev/theme.mdx @@ -109,8 +109,23 @@ const days = node.expires_in !== undefined ## 价格与付款周期 -`currency` 是三个大写字母的货币代码,可以直接交给 `Intl.NumberFormat`。hub 只检查格式,不核对代码是否 -真的存在;`Intl` 遇到不认识的代码会把代码本身当作符号显示。 +`currency` 是三个大写字母的货币代码,交给 `Intl.NumberFormat` 显示。hub 只检查格式,不核对代码是否 +真的存在;`Intl` 遇到不认识的代码会把代码本身当作符号显示。hub 1.3.1 之前不检查,那时存下的值可能不是 +三个字母,`Intl` 遇到会抛错,要兜住。 + +```ts +// 地区写死 zh-CN:显示不随访客的浏览器语言变, +// 美元、港币写作 US$、HK$,日元写作 JP¥,不和人民币的 ¥ 混 +function money(amount: number, currency: string): string { + try { + return new Intl.NumberFormat("zh-CN", { style: "currency", currency }) + .format(amount) + } catch { + // hub 1.3.1 之前存下的值,可能不是三个字母 + return `${currency} ${amount.toFixed(2)}` + } +} +``` `billing_cycle` 是付款周期: From 1e57473408ff2a3d5ddf01882b338a218b7ee574 Mon Sep 17 00:00:00 2001 From: stqfdyr <89149493+stqfdyr@users.noreply.github.com> Date: Fri, 2 Oct 2026 18:35:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?docs:=20=E4=BB=B7=E6=A0=BC=E4=B8=80?= =?UTF-8?q?=E8=8A=82=E5=85=88=E5=86=99=E6=98=8E=E7=89=88=E6=9C=AC=E8=BE=B9?= =?UTF-8?q?=E7=95=8C=EF=BC=8C=E7=A4=BA=E4=BE=8B=E5=90=8C=E6=AD=A5=E6=9C=80?= =?UTF-8?q?=E5=A4=9A=E4=B8=A4=E4=BD=8D=E5=B0=8F=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/content/dev/theme.mdx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/content/dev/theme.mdx b/src/content/dev/theme.mdx index cf8f611..5b00028 100644 --- a/src/content/dev/theme.mdx +++ b/src/content/dev/theme.mdx @@ -109,17 +109,21 @@ const days = node.expires_in !== undefined ## 价格与付款周期 -`currency` 是三个大写字母的货币代码,交给 `Intl.NumberFormat` 显示。hub 只检查格式,不核对代码是否 -真的存在;`Intl` 遇到不认识的代码会把代码本身当作符号显示。hub 1.3.1 之前不检查,那时存下的值可能不是 -三个字母,`Intl` 遇到会抛错,要兜住。 +`currency` 是货币代码,交给 `Intl.NumberFormat` 显示。hub 1.3.1 起写入的都是三个大写字母:只检查格式, +不核对代码是否真的存在,`Intl` 遇到不认识的代码会把代码本身当作符号显示。更早的 hub 不检查,那时存下的值 +可能不是三个字母,`Intl` 会抛错,要兜住。 ```ts // 地区写死 zh-CN:显示不随访客的浏览器语言变, // 美元、港币写作 US$、HK$,日元写作 JP¥,不和人民币的 ¥ 混 function money(amount: number, currency: string): string { try { - return new Intl.NumberFormat("zh-CN", { style: "currency", currency }) - .format(amount) + return new Intl.NumberFormat("zh-CN", { + style: "currency", + currency, + // 最多两位小数,与价格的填写精度一致,日元的小数不会被取整 + maximumFractionDigits: 2, + }).format(amount) } catch { // hub 1.3.1 之前存下的值,可能不是三个字母 return `${currency} ${amount.toFixed(2)}`