change condition of display banner

This commit is contained in:
2026-06-21 14:42:27 +02:00
parent 7545b77a25
commit 6dd2cc7d96
6 changed files with 18 additions and 3 deletions
+9
View File
@@ -24,6 +24,14 @@ export const useSettingsStore = defineStore('settings', () => {
return item?.value ?? null return item?.value ?? null
} }
function isSettingTruthy(key: string) {
const value = getSettingByKey(key)
if (value == null) {
return false
}
return value === true || String(value).toLowerCase() === 'true'
}
function mergeSettings(items?: AppSetting[] | null) { function mergeSettings(items?: AppSetting[] | null) {
if (!items?.length) { if (!items?.length) {
return return
@@ -73,6 +81,7 @@ export const useSettingsStore = defineStore('settings', () => {
fetchSettings, fetchSettings,
mergeSettings, mergeSettings,
getSettingByKey, getSettingByKey,
isSettingTruthy,
metalTypeSettingValue, metalTypeSettingValue,
metalTypeLabel, metalTypeLabel,
meltedGoldLabel, meltedGoldLabel,
@@ -12,6 +12,7 @@ import {
resolveAssetsRialValue, resolveAssetsRialValue,
} from '@/utils/productAssets' } from '@/utils/productAssets'
import { useConfigStore } from '@/store/configStore' import { useConfigStore } from '@/store/configStore'
import { useSettingsStore } from '@/store/settingsStore'
import { getTradeBuyPrice, lastPrice, stopLastPricePolling } from '@/utils/price' import { getTradeBuyPrice, lastPrice, stopLastPricePolling } from '@/utils/price'
import { getStoreClosedMessage, isStoreClosed } from '@/utils/storeHours' import { getStoreClosedMessage, isStoreClosed } from '@/utils/storeHours'
import { message, Modal } from 'ant-design-vue' import { message, Modal } from 'ant-design-vue'
@@ -30,6 +31,7 @@ import { resetProductsPageData } from '../../products/composables/useProductsPag
export interface HomePageContext { export interface HomePageContext {
homePageLoading: ReturnType<typeof useHomePageLoading>['homePageLoading'] homePageLoading: ReturnType<typeof useHomePageLoading>['homePageLoading']
isGaroosi: ReturnType<typeof computed<boolean>> isGaroosi: ReturnType<typeof computed<boolean>>
bannerEnabled: ReturnType<typeof computed<boolean>>
limitedPrice: ReturnType<typeof computed> limitedPrice: ReturnType<typeof computed>
showClosedMessage: ReturnType<typeof computed<boolean>> showClosedMessage: ReturnType<typeof computed<boolean>>
closedMessage: ReturnType<typeof computed> closedMessage: ReturnType<typeof computed>
@@ -57,6 +59,7 @@ export function useHomePage() {
const userStore = useUserStore() const userStore = useUserStore()
const walletStore = useWalletStore() const walletStore = useWalletStore()
const configStore = useConfigStore() const configStore = useConfigStore()
const settingsStore = useSettingsStore()
const { assetsSummary, clearWalletAssets } = useWalletAssets() const { assetsSummary, clearWalletAssets } = useWalletAssets()
const showLogoutConfirm = ref(false) const showLogoutConfirm = ref(false)
@@ -77,6 +80,7 @@ export function useHomePage() {
const isBoursecuHomeLayout = computed(() => getHomeLayoutId() === 'boursecu') const isBoursecuHomeLayout = computed(() => getHomeLayoutId() === 'boursecu')
const isGaroosi = computed(() => configStore.config?.name === 'garoosi') const isGaroosi = computed(() => configStore.config?.name === 'garoosi')
const bannerEnabled = computed(() => settingsStore.isSettingTruthy('banner_enabled'))
const closedMessage = computed(() => userStore.getValueByKey('closed_message')) const closedMessage = computed(() => userStore.getValueByKey('closed_message'))
const marketClosedText = computed(() => { const marketClosedText = computed(() => {
if (!isStoreClosed()) return '' if (!isStoreClosed()) return ''
@@ -227,6 +231,7 @@ export function useHomePage() {
const context: HomePageContext = { const context: HomePageContext = {
homePageLoading, homePageLoading,
isGaroosi, isGaroosi,
bannerEnabled,
limitedPrice, limitedPrice,
showClosedMessage, showClosedMessage,
closedMessage: marketClosedText, closedMessage: marketClosedText,
@@ -9,7 +9,7 @@ const ctx = inject(HOME_PAGE_CONTEXT_KEY)!
<template> <template>
<DesktopHomeSection <DesktopHomeSection
v-if="ctx.isGaroosi.value && ctx.banners.value?.length" v-if="ctx.bannerEnabled.value && ctx.banners.value?.length"
title="بنرها" title="بنرها"
> >
<BannerSlider <BannerSlider
@@ -17,6 +17,7 @@
<Vue3Odometer <Vue3Odometer
:value="displayGoldVal" :value="displayGoldVal"
class="dhome-hero-price__odometer o-text" class="dhome-hero-price__odometer o-text"
style="font-family: iran-sans"
/> />
<span class="dhome-hero-price__unit">ریال</span> <span class="dhome-hero-price__unit">ریال</span>
</div> </div>
+1 -1
View File
@@ -632,7 +632,7 @@ import BasicButton from "@/components/BasicPacks/BasicButton.vue";
const bannerSwiperModules = [Autoplay, Pagination] const bannerSwiperModules = [Autoplay, Pagination]
const nameProject = useConfigStore().config.name const nameProject = useConfigStore().config.name
const settingsStore = useSettingsStore() const settingsStore = useSettingsStore()
const bannerEnabled = computed(() => settingsStore.getSettingByKey('banner_enabled') === 'true') const bannerEnabled = computed(() => settingsStore.isSettingTruthy('banner_enabled'))
const userStore = useUserStore() const userStore = useUserStore()
const walletStore = useWalletStore() const walletStore = useWalletStore()
const wholeBalanceVisible = ref<boolean>(false) const wholeBalanceVisible = ref<boolean>(false)
@@ -8,7 +8,7 @@ const ctx = inject(HOME_PAGE_CONTEXT_KEY)!
<template> <template>
<BannerSlider <BannerSlider
v-if="ctx.isGaroosi.value && ctx.banners.value?.length" v-if="ctx.bannerEnabled.value && ctx.banners.value?.length"
:banners="ctx.banners.value" :banners="ctx.banners.value"
@bannerClick="ctx.handleBannerClick" @bannerClick="ctx.handleBannerClick"
/> />