Make boursecu branch boursecu-only and simplify app loading.
Remove multi-tenant branches and default views, show logo-only boot and splash screens, and polish boursecu transactions tab styling. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,20 +7,16 @@ import { useWalletAssets } from '@/composables/useWalletAssets'
|
||||
import type { WalletMetalTotal } from '@/models/walletAssets'
|
||||
import {
|
||||
formatBoursecuMetalModalText,
|
||||
formatMetalAssetsInfoText,
|
||||
formatRialAssetsInfoText,
|
||||
resolveAssetsRialValue,
|
||||
} from '@/utils/productAssets'
|
||||
import { useConfigStore } from '@/store/configStore'
|
||||
import { useSettingsStore } from '@/store/settingsStore'
|
||||
import { getTradeBuyPrice, lastPrice, stopLastPricePolling } from '@/utils/price'
|
||||
import { getStoreClosedMessage, isStoreClosed } from '@/utils/storeHours'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { getReferralShareText, getReferralShareTitle, shareReferralText } from '@/utils/referralShare'
|
||||
import { useBanners } from './useBanners'
|
||||
import { usePriceChart, type ChartMetalType } from './usePriceChart'
|
||||
import type { HomeActionItem } from '../layouts/types'
|
||||
import { getHomeLayoutId } from '../layouts/registry'
|
||||
import { initHomePageData, resetHomePageData, useHomePageLoading } from './useHomePageData'
|
||||
import { ensureAuthenticatedRoute } from '@/app/setupRouter'
|
||||
import { resetWalletPageData } from '../../wallet/composables/useWalletPageData'
|
||||
@@ -30,7 +26,6 @@ import { resetProductsPageData } from '../../products/composables/useProductsPag
|
||||
|
||||
export interface HomePageContext {
|
||||
homePageLoading: ReturnType<typeof useHomePageLoading>['homePageLoading']
|
||||
isGaroosi: ReturnType<typeof computed<boolean>>
|
||||
bannerEnabled: ReturnType<typeof computed<boolean>>
|
||||
showClosedMessage: ReturnType<typeof computed<boolean>>
|
||||
closedMessage: ReturnType<typeof computed>
|
||||
@@ -41,7 +36,6 @@ export interface HomePageContext {
|
||||
updateChartData: ReturnType<typeof usePriceChart>['updateChartData']
|
||||
selectedChartMetal: ReturnType<typeof usePriceChart>['selectedChartMetal']
|
||||
setChartMetal: (metal: ChartMetalType) => void
|
||||
isBoursecuHomeLayout: ReturnType<typeof computed<boolean>>
|
||||
handleBannerClick: (banner: { typeClick?: string; modalText?: string; link?: string }) => void
|
||||
openGoldModal: (
|
||||
metal: WalletMetalTotal,
|
||||
@@ -57,7 +51,6 @@ export const HOME_PAGE_CONTEXT_KEY: InjectionKey<HomePageContext> = Symbol('home
|
||||
export function useHomePage() {
|
||||
const userStore = useUserStore()
|
||||
const walletStore = useWalletStore()
|
||||
const configStore = useConfigStore()
|
||||
const settingsStore = useSettingsStore()
|
||||
const { assetsSummary, clearWalletAssets } = useWalletAssets()
|
||||
|
||||
@@ -76,9 +69,7 @@ export function useHomePage() {
|
||||
selectedChartMetal,
|
||||
setChartMetal,
|
||||
} = usePriceChart()
|
||||
const isBoursecuHomeLayout = computed(() => getHomeLayoutId() === 'boursecu')
|
||||
|
||||
const isGaroosi = computed(() => configStore.config?.name === 'garoosi')
|
||||
const bannerEnabled = computed(() => settingsStore.isSettingTruthy('banner_enabled'))
|
||||
const closedMessage = computed(() => userStore.getValueByKey('closed_message'))
|
||||
const marketClosedText = computed(() => {
|
||||
@@ -100,7 +91,7 @@ export function useHomePage() {
|
||||
{
|
||||
name: 'deposit',
|
||||
icon: 'vuesax-linear:card-add',
|
||||
label: isGaroosi.value ? 'واریز و برداشت' : 'واریز نقدی',
|
||||
label: 'واریز نقدی',
|
||||
handler: () => router.push({ name: 'wallet', query: { state: 'deposit' } }),
|
||||
},
|
||||
{
|
||||
@@ -114,21 +105,11 @@ export function useHomePage() {
|
||||
{
|
||||
name: 'assets',
|
||||
icon: 'vuesax-linear:cup',
|
||||
label: isGaroosi.value ? 'دعوت از دوستان' : 'دارایی ها',
|
||||
handler: () => (isGaroosi.value ? shareCode() : router.push({ name: 'fund' })),
|
||||
label: 'دارایی ها',
|
||||
handler: () => router.push({ name: 'fund' }),
|
||||
},
|
||||
])
|
||||
|
||||
async function shareCode() {
|
||||
const text = getReferralShareText({
|
||||
userName: userStore.userInfo?.name,
|
||||
projectName: configStore.config.name,
|
||||
referralId: userStore.userInfo?.referral_id,
|
||||
})
|
||||
|
||||
await shareReferralText(text, getReferralShareTitle(configStore.config.name))
|
||||
}
|
||||
|
||||
function copyCode() {
|
||||
const code = userStore.userInfo?.referral_id
|
||||
if (code) {
|
||||
@@ -178,9 +159,7 @@ export function useHomePage() {
|
||||
const title =
|
||||
modalTitle ??
|
||||
modalText ??
|
||||
(isBoursecuHomeLayout.value
|
||||
? formatBoursecuMetalModalText(metal)
|
||||
: formatMetalAssetsInfoText(metal))
|
||||
formatBoursecuMetalModalText(metal)
|
||||
|
||||
Modal.confirm({
|
||||
title,
|
||||
@@ -230,7 +209,6 @@ export function useHomePage() {
|
||||
|
||||
const context: HomePageContext = {
|
||||
homePageLoading,
|
||||
isGaroosi,
|
||||
bannerEnabled,
|
||||
showClosedMessage,
|
||||
closedMessage: marketClosedText,
|
||||
@@ -241,7 +219,6 @@ export function useHomePage() {
|
||||
updateChartData,
|
||||
selectedChartMetal,
|
||||
setChartMetal,
|
||||
isBoursecuHomeLayout,
|
||||
handleBannerClick,
|
||||
openGoldModal,
|
||||
openRialModal,
|
||||
|
||||
@@ -2,7 +2,6 @@ import { ref } from 'vue'
|
||||
import { getLastPrices, startLastPricePolling, stopLastPricePolling } from '@/utils/price'
|
||||
import { useWalletAssets } from '@/composables/useWalletAssets'
|
||||
import { clearProductsCatalog } from '@/composables/useProductsCatalog'
|
||||
import { getHomeLayoutId } from '../layouts/registry'
|
||||
import { fetchHomeChartPrices, loadHomeMaftolOffset, resetHomePriceChart } from './usePriceChart'
|
||||
import { loadHomeBanners, resetHomeBanners } from './useBanners'
|
||||
import { loadHomeFunds, resetHomeFunds } from './useUserFunds'
|
||||
@@ -24,10 +23,7 @@ export function isHomePageDataInitialized() {
|
||||
export async function initHomePageData(force = false) {
|
||||
if (!force && initialized.value) {
|
||||
startLastPricePolling()
|
||||
|
||||
if (getHomeLayoutId() === 'boursecu') {
|
||||
void loadHomeMaftolOffset(false)
|
||||
}
|
||||
void loadHomeMaftolOffset(false)
|
||||
|
||||
return
|
||||
}
|
||||
@@ -49,9 +45,7 @@ export async function initHomePageData(force = false) {
|
||||
loadHomeBanners(force),
|
||||
])
|
||||
|
||||
if (getHomeLayoutId() === 'boursecu') {
|
||||
await loadHomeMaftolOffset(force)
|
||||
}
|
||||
await loadHomeMaftolOffset(force)
|
||||
|
||||
initialized.value = true
|
||||
} catch (error) {
|
||||
|
||||
@@ -2,7 +2,6 @@ import { computed, ref, watch } from 'vue'
|
||||
import { getAllPrices } from '@/api/home'
|
||||
import type { Product } from '@/models/products'
|
||||
import { getProductsCatalog, getProductsCatalogRef } from '@/composables/useProductsCatalog'
|
||||
import { getHomeLayoutId } from '../layouts/registry'
|
||||
import { getProductBuyPrice, resolvePriceOffsetRatio } from '@/utils/productPrice'
|
||||
import { isKatodMesGroup, isMaftolMesGroup, isShamshMesGroup } from '@/utils/productDealMethod'
|
||||
import { getTradeBuyPrice, getTradeSellPrice, lastPrice } from '@/utils/price'
|
||||
@@ -31,10 +30,6 @@ function resolveChartProducts(products: Product[]) {
|
||||
|
||||
/** نسبت مفتول به کاتد — reactive به قیمت لحظهای و کاتالوگ محصولات */
|
||||
const maftolChartRatio = computed(() => {
|
||||
if (getHomeLayoutId() !== 'boursecu') {
|
||||
return 0
|
||||
}
|
||||
|
||||
void lastPrice.value?.price_last
|
||||
|
||||
const { katod, maftol } = resolveChartProducts(catalogProducts.value)
|
||||
@@ -43,10 +38,6 @@ const maftolChartRatio = computed(() => {
|
||||
|
||||
/** نسبت شمش مس به کاتد */
|
||||
const shamshChartRatio = computed(() => {
|
||||
if (getHomeLayoutId() !== 'boursecu') {
|
||||
return 0
|
||||
}
|
||||
|
||||
void lastPrice.value?.price_last
|
||||
|
||||
const { katod, shamsh } = resolveChartProducts(catalogProducts.value)
|
||||
@@ -100,13 +91,12 @@ function applyChartRatio(basePrice: number, ratio: number) {
|
||||
export function resolveMetalDayRangePrices(options: {
|
||||
price: { up?: { buy?: number; sell?: number }; buy?: number; sell?: number; price_last?: number } | null | undefined
|
||||
metal: ChartMetalType
|
||||
isBoursecuLayout: boolean
|
||||
metalRatio: number
|
||||
}) {
|
||||
const baseHigh = options.price?.up?.buy ?? getTradeBuyPrice(options.price as Parameters<typeof getTradeBuyPrice>[0])
|
||||
const baseLow = options.price?.up?.sell ?? getTradeSellPrice(options.price as Parameters<typeof getTradeSellPrice>[0])
|
||||
|
||||
if (!options.isBoursecuLayout || options.metal === 'katod') {
|
||||
if (options.metal === 'katod') {
|
||||
return { high: baseHigh, low: baseLow }
|
||||
}
|
||||
|
||||
@@ -176,7 +166,7 @@ function buildChartPoints(items: Array<{ timestamp: number; value: number }>): C
|
||||
function syncChartSeries() {
|
||||
const ratio = selectedMetalChartRatio.value
|
||||
const data =
|
||||
getHomeLayoutId() === 'boursecu' && selectedChartMetal.value !== 'katod'
|
||||
selectedChartMetal.value !== 'katod'
|
||||
? rawChartPoints.value.map(
|
||||
([timestamp, value]) =>
|
||||
[timestamp, applyChartRatio(value, ratio)] as ChartPoint
|
||||
@@ -221,11 +211,6 @@ async function fetchPrices(force = false) {
|
||||
}
|
||||
|
||||
async function loadMetalChartOffsets(force = false) {
|
||||
if (getHomeLayoutId() !== 'boursecu') {
|
||||
syncChartSeries()
|
||||
return
|
||||
}
|
||||
|
||||
if (!force && metalOffsetLoaded && catalogProducts.value.length > 0) {
|
||||
return
|
||||
}
|
||||
@@ -258,7 +243,7 @@ function updateChartData(timeline: string) {
|
||||
function setChartMetal(metal: ChartMetalType) {
|
||||
selectedChartMetal.value = metal
|
||||
|
||||
if (metal !== 'katod' && getHomeLayoutId() === 'boursecu' && !catalogProducts.value.length) {
|
||||
if (metal !== 'katod' && !catalogProducts.value.length) {
|
||||
void loadMetalChartOffsets(true)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user