feat: 添加钱包功能,创建钱包状态管理,更新个人资料页面,优化样式和交互

This commit is contained in:
2026-01-18 02:19:37 +07:00
parent 1bdaad1434
commit 967b87fc83
4 changed files with 140 additions and 116 deletions

25
src/store/wallet.ts Normal file
View File

@@ -0,0 +1,25 @@
import type { Treaty } from "@elysiajs/eden";
import { client, safeClient } from "@/api";
export type Wallet = Treaty.Data<typeof client.api.wallet.wallets.get>[number];
export const useWalletStore = defineStore("wallet", () => {
const wallets = ref<Wallet[]>([]);
const balanceWallet = ref<Wallet | null>(null);
async function syncWallets() {
const { data } = await safeClient(client.api.wallet.wallets.get(), { silent: true });
wallets.value = data.value || [];
}
async function syncBalanceWallet() {
const { data } = await safeClient(client.api.wallet.wallet_by_code({ walletTypeCode: "balance" }).get(), { silent: true });
balanceWallet.value = data.value || null;
}
return {
wallets,
balanceWallet,
syncWallets,
syncBalanceWallet,
};
});