feat: 银行端
This commit is contained in:
33
src/store/bank.ts
Normal file
33
src/store/bank.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { getBankStats } from '@/pagesBank/api'
|
||||
import type { BankStats } from '@/typings/bank'
|
||||
|
||||
export const useBankStore = defineStore('bank', () => {
|
||||
const stats = ref<BankStats | null>(null)
|
||||
const loading = ref(false)
|
||||
|
||||
/** 获取银行统计数据 */
|
||||
async function fetchStats() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getBankStats()
|
||||
stats.value = res
|
||||
} catch (error) {
|
||||
console.error('Fetch bank stats failed:', error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置状态 */
|
||||
function reset() {
|
||||
stats.value = null
|
||||
}
|
||||
|
||||
return {
|
||||
stats,
|
||||
loading,
|
||||
fetchStats,
|
||||
reset
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user