Split desktop and mobile layouts with shared page data so APIs fetch once per context.
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>
This commit is contained in:
@@ -1,22 +1,54 @@
|
||||
import { ref } from 'vue'
|
||||
import { useFundUserStore } from '@/store/fundStore'
|
||||
|
||||
export function useUserFunds() {
|
||||
const funds = ref([])
|
||||
const loading = ref(false)
|
||||
const fundStore = useFundUserStore()
|
||||
/** 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
|
||||
|
||||
const loadFunds = async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
const result = await fundStore.getMyFund()
|
||||
funds.value = result?.rows || []
|
||||
} catch (error) {
|
||||
console.error('Error loading funds:', error)
|
||||
} finally {
|
||||
loading.value = 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 { funds, loading, loadFunds }
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user