Add layout shells, desktop views, module-level page caches, and UI fixes for auth, home, wallet, transactions, address, and related pages. Co-authored-by: Cursor <cursoragent@cursor.com>
55 lines
1.1 KiB
TypeScript
55 lines
1.1 KiB
TypeScript
import { ref } from 'vue'
|
|
import { useFundUserStore } from '@/store/fundStore'
|
|
|
|
/** Module-level fund list — shared across home layout variants. */
|
|
const funds = ref<unknown[]>([])
|
|
const fundsLoading = ref(false)
|
|
let fundsPromise: Promise<void> | null = null
|
|
let fundsLoaded = false
|
|
|
|
async function fetchFunds(force = false) {
|
|
if (!force && fundsLoaded) {
|
|
return
|
|
}
|
|
|
|
if (!force && fundsPromise) {
|
|
return fundsPromise
|
|
}
|
|
|
|
const fundStore = useFundUserStore()
|
|
|
|
fundsPromise = (async () => {
|
|
try {
|
|
fundsLoading.value = true
|
|
const result = await fundStore.getMyFund()
|
|
funds.value = result?.rows || []
|
|
fundsLoaded = true
|
|
} catch (error) {
|
|
console.error('Error loading funds:', error)
|
|
} finally {
|
|
fundsLoading.value = false
|
|
fundsPromise = null
|
|
}
|
|
})()
|
|
|
|
return fundsPromise
|
|
}
|
|
|
|
export function useUserFunds() {
|
|
return {
|
|
funds,
|
|
loading: fundsLoading,
|
|
loadFunds: fetchFunds,
|
|
}
|
|
}
|
|
|
|
export function loadHomeFunds(force = false) {
|
|
return fetchFunds(force)
|
|
}
|
|
|
|
export function resetHomeFunds() {
|
|
funds.value = []
|
|
fundsLoaded = false
|
|
fundsPromise = null
|
|
}
|