2026-06-14 10:08:46 +03:30
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import { computed } from 'vue'
|
2026-06-16 19:47:28 +03:30
|
|
|
|
import { storeToRefs } from 'pinia'
|
2026-06-14 10:08:46 +03:30
|
|
|
|
import { useUserStore } from '@/store/userStore'
|
2026-06-16 19:47:28 +03:30
|
|
|
|
import { getToken } from '@/utils'
|
2026-10-06 13:38:35 +03:30
|
|
|
|
import { isGuestHomeActive } from '@/utils/guestHome'
|
2026-06-14 10:08:46 +03:30
|
|
|
|
import HomeSkeleton from '../components/HomeSkeleton.vue'
|
|
|
|
|
|
import { getHomeLayoutConfig } from './registry'
|
|
|
|
|
|
import { HOME_SECTION_COMPONENTS } from './sections'
|
|
|
|
|
|
import type { HomeLayoutConfig, HomeSectionId } from './types'
|
2026-11-10 11:48:28 +03:30
|
|
|
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
2026-06-14 10:08:46 +03:30
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
|
layoutConfig?: HomeLayoutConfig
|
|
|
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
|
|
const userStore = useUserStore()
|
2026-06-16 19:47:28 +03:30
|
|
|
|
const { userInfo } = storeToRefs(userStore)
|
2026-06-14 10:08:46 +03:30
|
|
|
|
const layoutConfig = computed(() => props.layoutConfig ?? getHomeLayoutConfig())
|
|
|
|
|
|
|
2026-10-06 13:38:35 +03:30
|
|
|
|
const isGuestHome = computed(() => isGuestHomeActive())
|
|
|
|
|
|
|
2026-06-14 10:08:46 +03:30
|
|
|
|
const outerSections = computed(() =>
|
2026-10-06 13:38:35 +03:30
|
|
|
|
(layoutConfig.value.outerSections ?? [])
|
|
|
|
|
|
.filter((section) => section.visible !== false)
|
|
|
|
|
|
.filter((section) => {
|
|
|
|
|
|
if (!isGuestHome.value) return true
|
|
|
|
|
|
return section.id !== 'assets' && section.id !== 'boursecuQuickActions'
|
|
|
|
|
|
}),
|
2026-06-14 10:08:46 +03:30
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const innerSections = computed(() =>
|
|
|
|
|
|
layoutConfig.value.sections.filter((section) => section.visible !== false)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-07-02 17:20:07 +03:30
|
|
|
|
const tailSections = computed(() =>
|
|
|
|
|
|
(layoutConfig.value.tailSections ?? []).filter((section) => section.visible !== false)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-06-16 19:47:28 +03:30
|
|
|
|
/** محتوا با userInfo — دادههای API در پسزمینه لود میشوند */
|
2026-10-06 13:38:35 +03:30
|
|
|
|
const showContent = computed(() => Boolean(userInfo.value) || isGuestHome.value)
|
2026-06-16 19:47:28 +03:30
|
|
|
|
const showSkeleton = computed(() => Boolean(getToken()) && !userInfo.value)
|
|
|
|
|
|
|
2026-06-14 10:08:46 +03:30
|
|
|
|
function resolveSectionComponent(sectionId: HomeSectionId) {
|
|
|
|
|
|
return HOME_SECTION_COMPONENTS[sectionId]
|
|
|
|
|
|
}
|
2026-11-10 11:48:28 +03:30
|
|
|
|
|
|
|
|
|
|
async function retryLoad() {
|
|
|
|
|
|
if (!getToken()) return
|
|
|
|
|
|
await userStore.getMyInfo()
|
|
|
|
|
|
}
|
2026-06-14 10:08:46 +03:30
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-06-16 19:47:28 +03:30
|
|
|
|
<div v-if="showContent">
|
2026-06-14 10:08:46 +03:30
|
|
|
|
<component
|
|
|
|
|
|
:is="resolveSectionComponent(section.id)"
|
|
|
|
|
|
v-for="section in outerSections"
|
|
|
|
|
|
:key="`outer-${section.id}`"
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<div v-if="layoutConfig.wrapperClass" :class="layoutConfig.wrapperClass">
|
|
|
|
|
|
<component
|
|
|
|
|
|
:is="resolveSectionComponent(section.id)"
|
|
|
|
|
|
v-for="section in innerSections"
|
|
|
|
|
|
:key="section.id"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<template v-else>
|
|
|
|
|
|
<component
|
|
|
|
|
|
:is="resolveSectionComponent(section.id)"
|
|
|
|
|
|
v-for="section in innerSections"
|
|
|
|
|
|
:key="section.id"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</template>
|
2026-07-02 17:20:07 +03:30
|
|
|
|
|
|
|
|
|
|
<component
|
|
|
|
|
|
:is="resolveSectionComponent(section.id)"
|
|
|
|
|
|
v-for="section in tailSections"
|
|
|
|
|
|
:key="`tail-${section.id}`"
|
|
|
|
|
|
/>
|
2026-06-14 10:08:46 +03:30
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-06-16 19:47:28 +03:30
|
|
|
|
<HomeSkeleton v-else-if="showSkeleton" class="w-full" />
|
2026-11-10 11:48:28 +03:30
|
|
|
|
|
|
|
|
|
|
<div v-else class="home-layout-fallback flex flex-col items-center justify-center gap-3 p-6 text-center min-h-[50vh]">
|
|
|
|
|
|
<p class="text-sm text-slate-600 leading-7">
|
|
|
|
|
|
در حال آمادهسازی صفحه اصلی هستیم. اگر چیزی نمایش داده نمیشود، یکبار تلاش مجدد کنید.
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<BasicButton type="primary" class="!rounded-xl" @click="retryLoad">
|
|
|
|
|
|
تلاش مجدد
|
|
|
|
|
|
</BasicButton>
|
|
|
|
|
|
</div>
|
2026-06-14 10:08:46 +03:30
|
|
|
|
</template>
|