feat: 添加钱包功能,创建钱包状态管理,更新个人资料页面,优化样式和交互
This commit is contained in:
25
src/store/wallet.ts
Normal file
25
src/store/wallet.ts
Normal 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,
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user