From 8ce7f902af5133d742e1fe1017359af4d162080f Mon Sep 17 00:00:00 2001 From: aaa Date: Mon, 3 Feb 2025 17:23:16 +0800 Subject: [PATCH] feat: transaction framework --- components/DesktopSideBar.vue | 27 +++++---- components/TransactionList.vue | 52 ++++++++++++++++- components/TransactionListItem.vue | 37 +++++++++++++ layouts/desktop.vue | 12 ++-- models/transaction.ts | 28 ++++++++++ package-lock.json | 7 +++ package.json | 1 + pages/desktop/dashboard.vue | 12 ++-- pages/desktop/transaction.vue | 89 ++++++++++++++++++++++++++++-- utils/currency.ts | 17 ++++++ 10 files changed, 252 insertions(+), 30 deletions(-) create mode 100644 components/TransactionListItem.vue create mode 100644 models/transaction.ts create mode 100644 utils/currency.ts diff --git a/components/DesktopSideBar.vue b/components/DesktopSideBar.vue index 0cfc87d..b14e16c 100644 --- a/components/DesktopSideBar.vue +++ b/components/DesktopSideBar.vue @@ -1,17 +1,16 @@ \ No newline at end of file + + + + + + + diff --git a/components/TransactionList.vue b/components/TransactionList.vue index 75ec3e8..e50a96a 100644 --- a/components/TransactionList.vue +++ b/components/TransactionList.vue @@ -1,7 +1,57 @@ diff --git a/layouts/desktop.vue b/layouts/desktop.vue index fd970f9..1f24d3e 100644 --- a/layouts/desktop.vue +++ b/layouts/desktop.vue @@ -1,16 +1,16 @@ diff --git a/models/transaction.ts b/models/transaction.ts new file mode 100644 index 0000000..8fd0998 --- /dev/null +++ b/models/transaction.ts @@ -0,0 +1,28 @@ +export interface Category { + id: string, + name: string, +} + +export interface Tag { + id: string, + name: string, +} + +export interface Amount{ + currency: string, + val: string, +} + +export interface Transaction{ + id: string, + description: string, + time: string, + category?: Category, + tags?: Tag[], + amount?: +} + +export interface TransactionGroup { + group_title: string, + transactions?: Transaction[], +} diff --git a/package-lock.json b/package-lock.json index 6656aeb..b143452 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "hasInstallScript": true, "dependencies": { "@mdi/font": "^7.4.47", + "dayjs": "^1.11.13", "nuxt": "^3.15.4", "vue": "latest", "vue-router": "latest" @@ -4081,6 +4082,12 @@ "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", "license": "MIT" }, + "node_modules/dayjs": { + "version": "1.11.13", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.13.tgz", + "integrity": "sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==", + "license": "MIT" + }, "node_modules/db0": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/db0/-/db0-0.2.3.tgz", diff --git a/package.json b/package.json index a634e94..1e6543a 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ }, "dependencies": { "@mdi/font": "^7.4.47", + "dayjs": "^1.11.13", "nuxt": "^3.15.4", "vue": "latest", "vue-router": "latest" diff --git a/pages/desktop/dashboard.vue b/pages/desktop/dashboard.vue index aa7909c..24c73fe 100644 --- a/pages/desktop/dashboard.vue +++ b/pages/desktop/dashboard.vue @@ -1,10 +1,14 @@ \ No newline at end of file + diff --git a/pages/desktop/transaction.vue b/pages/desktop/transaction.vue index 3914136..ff9368e 100644 --- a/pages/desktop/transaction.vue +++ b/pages/desktop/transaction.vue @@ -1,17 +1,96 @@ diff --git a/utils/currency.ts b/utils/currency.ts new file mode 100644 index 0000000..fc77c28 --- /dev/null +++ b/utils/currency.ts @@ -0,0 +1,17 @@ + +// 定义支持的货币类型 +type Currency = "USD" | "EUR" | "GBP" | "JPY" | "CNY"; + +// 定义货币类型到 HTML 字符的映射 +const currencySymbols: Record = { + USD: "$", // 美元符号 + EUR: "€", // 欧元符号 + GBP: "£", // 英镑符号 + JPY: "¥", // 日元符号 + CNY: "¥", // 人民币符号(与日元相同) +}; + + +export function CurrencyTypeToSymbol(currencyType: string){ + return currencySymbols[currencyType] || ""; +}