fix bug of main-page for guest

This commit is contained in:
2026-10-17 14:12:18 +03:30
parent 9487490981
commit 5e181fdae9
7 changed files with 39 additions and 30 deletions
@@ -1,6 +1,7 @@
import { computed, ref, watch } from 'vue'
import { getAllPrices } from '@/api/home'
import { getAllPrices, getPublicChartPrices } from '@/api/home'
import { getProductsCatalog, getProductsCatalogRef } from '@/composables/useProductsCatalog'
import { getToken } from '@/utils'
import { getTradeBuyPrice, getTradeSellPrice } from '@/utils/price'
export type ChartMetalType = 'katod' | 'maftol' | 'shamsh'
@@ -132,7 +133,7 @@ async function fetchPrices(force = false) {
chartFetchPromise = (async () => {
try {
chartLoading.value = true
const response = await getAllPrices()
const response = await (getToken() ? getAllPrices() : getPublicChartPrices())
const data = resolvePricesMap(response)
cachedPrices.value = data
applyTimelineFromCache()
@@ -149,6 +150,14 @@ async function fetchPrices(force = false) {
}
async function loadMetalChartOffsets(force = false) {
if (!getToken()) {
if (!metalOffsetLoaded) {
syncChartSeries()
metalOffsetLoaded = true
}
return
}
if (!force && metalOffsetLoaded && catalogProducts.value.length > 0) {
return
}