new UI and handle cashing

This commit is contained in:
2026-06-16 19:47:28 +03:30
parent e174ae28c5
commit 6e5ea0319f
41 changed files with 2936 additions and 641 deletions
+20 -10
View File
@@ -1,6 +1,6 @@
import { computed, h, inject, onMounted, onUnmounted, provide, ref, type InjectionKey } from 'vue'
import { computed, h, inject, onUnmounted, provide, ref, type InjectionKey } from 'vue'
import router from '@/router'
import { loading, removeToken } from '@/utils'
import { getToken, removeToken } from '@/utils'
import { useUserStore } from '@/store/userStore'
import { useWalletStore } from '@/store/walletStore'
import { useWalletAssets } from '@/composables/useWalletAssets'
@@ -20,14 +20,14 @@ import { useBanners } from './useBanners'
import { usePriceChart, type ChartMetalType } from './usePriceChart'
import type { HomeActionItem } from '../layouts/types'
import { getHomeLayoutId } from '../layouts/registry'
import { initHomePageData, resetHomePageData } from './useHomePageData'
import { initHomePageData, resetHomePageData, useHomePageLoading } from './useHomePageData'
import { resetWalletPageData } from '../../wallet/composables/useWalletPageData'
import { resetAddressPageData } from '../../address/composables/useAddressPageData'
import { resetTransactionsPageData } from '../../transactions/composables/useTransactionsPageData'
import { resetProductsPageData } from '../../products/composables/useProductsPageData'
export interface HomePageContext {
loading: typeof loading
homePageLoading: ReturnType<typeof useHomePageLoading>['homePageLoading']
isGaroosi: ReturnType<typeof computed<boolean>>
limitedPrice: ReturnType<typeof computed>
showClosedMessage: ReturnType<typeof computed<boolean>>
@@ -65,6 +65,7 @@ export function useHomePage() {
const TextBanner = ref('')
const { banners } = useBanners()
const { homePageLoading } = useHomePageLoading()
const {
updateChartData,
priceChartSeries,
@@ -230,7 +231,7 @@ export function useHomePage() {
}
const context: HomePageContext = {
loading,
homePageLoading,
isGaroosi,
limitedPrice,
showClosedMessage,
@@ -250,15 +251,12 @@ export function useHomePage() {
provide(HOME_PAGE_CONTEXT_KEY, context)
void ensureHomeUserAndData()
onUnmounted(() => {
stopLastPricePolling()
})
onMounted(() => {
// Single shared fetch for mobile + desktop — safe to call on remount (deduped in useHomePageData)
void initHomePageData()
})
return {
userStore,
walletStore,
@@ -279,3 +277,15 @@ export function useHomePageContext() {
}
return context
}
async function ensureHomeUserAndData() {
const userStore = useUserStore()
if (getToken() && !userStore.userInfo) {
await userStore.getMyInfo()
}
if (getToken()) {
await initHomePageData()
}
}