🎨 Add some currency formatting support to database numeric fields https://github.com/siyuan-note/siyuan/issues/15232

This commit is contained in:
Daniel 2025-07-07 11:35:24 +08:00
parent 9a9f1229b4
commit 64e4ff0d4a
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
15 changed files with 176 additions and 208 deletions

View file

@ -73,7 +73,7 @@ export const formatNumber = (options: {
protyle: options.protyle,
colId: options.colId,
avID: options.avID,
format: "usDollar",
format: "USD",
oldFormat: options.oldFormat,
avPanelElement: options.avPanelElement,
});
@ -82,7 +82,7 @@ export const formatNumber = (options: {
protyle: options.protyle,
colId: options.colId,
avID: options.avID,
format: "yuan",
format: "CNY",
oldFormat: options.oldFormat,
avPanelElement: options.avPanelElement,
});
@ -91,7 +91,7 @@ export const formatNumber = (options: {
protyle: options.protyle,
colId: options.colId,
avID: options.avID,
format: "euro",
format: "EUR",
oldFormat: options.oldFormat,
avPanelElement: options.avPanelElement,
});
@ -100,7 +100,7 @@ export const formatNumber = (options: {
protyle: options.protyle,
colId: options.colId,
avID: options.avID,
format: "pound",
format: "GBP",
oldFormat: options.oldFormat,
avPanelElement: options.avPanelElement,
});
@ -109,7 +109,7 @@ export const formatNumber = (options: {
protyle: options.protyle,
colId: options.colId,
avID: options.avID,
format: "yen",
format: "JPY",
oldFormat: options.oldFormat,
avPanelElement: options.avPanelElement,
});
@ -118,7 +118,7 @@ export const formatNumber = (options: {
protyle: options.protyle,
colId: options.colId,
avID: options.avID,
format: "ruble",
format: "RUB",
oldFormat: options.oldFormat,
avPanelElement: options.avPanelElement,
});
@ -127,7 +127,7 @@ export const formatNumber = (options: {
protyle: options.protyle,
colId: options.colId,
avID: options.avID,
format: "rupee",
format: "INR",
oldFormat: options.oldFormat,
avPanelElement: options.avPanelElement,
});
@ -136,7 +136,7 @@ export const formatNumber = (options: {
protyle: options.protyle,
colId: options.colId,
avID: options.avID,
format: "won",
format: "KRW",
oldFormat: options.oldFormat,
avPanelElement: options.avPanelElement,
});
@ -145,7 +145,7 @@ export const formatNumber = (options: {
protyle: options.protyle,
colId: options.colId,
avID: options.avID,
format: "canadianDollar",
format: "CAD",
oldFormat: options.oldFormat,
avPanelElement: options.avPanelElement,
});
@ -154,7 +154,7 @@ export const formatNumber = (options: {
protyle: options.protyle,
colId: options.colId,
avID: options.avID,
format: "franc",
format: "CHF",
oldFormat: options.oldFormat,
avPanelElement: options.avPanelElement,
});
@ -232,46 +232,14 @@ export const formatNumber = (options: {
};
export const getLabelByNumberFormat = (format: string) => {
switch (format) {
case "":
return window.siyuan.languages.numberFormatNone;
case "commas":
return window.siyuan.languages.numberFormatCommas;
case "percent":
return window.siyuan.languages.numberFormatPercent;
case "usDollar":
return window.siyuan.languages.numberFormatUSDollar;
case "yuan":
return window.siyuan.languages.numberFormatYuan;
case "euro":
return window.siyuan.languages.numberFormatEuro;
case "pound":
return window.siyuan.languages.numberFormatPound;
case "yen":
return window.siyuan.languages.numberFormatYen;
case "ruble":
return window.siyuan.languages.numberFormatRuble;
case "rupee":
return window.siyuan.languages.numberFormatRupee;
case "won":
return window.siyuan.languages.numberFormatWon;
case "canadianDollar":
return window.siyuan.languages.numberFormatCanadianDollar;
case "franc":
return window.siyuan.languages.numberFormatFranc;
case "THB":
return window.siyuan.languages.numberFormatTHB;
case "AUD":
return window.siyuan.languages.numberFormatAUD;
case "HKD":
return window.siyuan.languages.numberFormatHKD;
case "TWD":
return window.siyuan.languages.numberFormatTWD;
case "MOP":
return window.siyuan.languages.numberFormatMOP;
case "SGD":
return window.siyuan.languages.numberFormatSGD;
case "NZD":
return window.siyuan.languages.numberFormatNZD;
if ("" === format) {
return window.siyuan.languages.numberFormatNone;
} else if ("commas" === format) {
return window.siyuan.languages.numberFormatCommas;
} else if ("percent" === format) {
return window.siyuan.languages.numberFormatPercent;
}
let key = "numberFormat" + format;
return window.siyuan.languages[key]
};