Let melted products trade without store inventory, and split TV sell prices with extra tickers.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import { getConfigApp } from '@/utils/config'
|
||||
import { getTvProductBuyPrice, getTvProductSellPrice, isTvProductPriceInactive } from '@/utils/productPrice'
|
||||
import { getLastPrices, getTradeBuyPrice, getTradeSellPrice, lastPrice, startLastPricePolling, stopLastPricePolling } from '@/utils/price'
|
||||
import { getPriceDisplayMessage, getPriceDisplayState, NO_QUOTE_MESSAGE } from '@/utils/storeHours'
|
||||
import { isMeltedTradeGroup } from '@/utils/productCategories'
|
||||
import { isMeltedTradeGroup, isMetalCommodityGroup } from '@/utils/productCategories'
|
||||
import { priceSocketConnected, priceStreamLifecycle } from '@/utils/priceSocketState'
|
||||
import { usePrice } from '@/utils/usePrice'
|
||||
import logoFallback from '@/assets/img/logo_full_.png'
|
||||
@@ -37,10 +37,8 @@ function isParsianCoin(product: Product) {
|
||||
|
||||
function isBankCoin(product: Product) {
|
||||
if (isParsianCoin(product)) return false
|
||||
const text = productText(product)
|
||||
const group = (product.group_type ?? '').trim()
|
||||
if (group === 'سکه' || group === 'سکه بانکی' || group.includes('بانکی')) return true
|
||||
return text.includes('سکه') && /تمام|نیم|ربع/.test(text)
|
||||
return group === 'سکه' || group === 'سکه بانکی' || (group.includes('سکه') && !group.includes('پارسیان'))
|
||||
}
|
||||
|
||||
function bankCoinRank(product: Product) {
|
||||
@@ -51,14 +49,23 @@ function bankCoinRank(product: Product) {
|
||||
return 99
|
||||
}
|
||||
|
||||
function isBankCoinDenomination(product: Product) {
|
||||
return bankCoinRank(product) <= 3
|
||||
}
|
||||
|
||||
function isSimorghBar(product: Product) {
|
||||
return productText(product).includes('سیمرغ')
|
||||
}
|
||||
|
||||
function isGoldBar(product: Product) {
|
||||
if (isMeltedTradeGroup(product.group_type) || isMetalCommodityGroup(product.group_type)) {
|
||||
return false
|
||||
}
|
||||
|
||||
const group = (product.group_type ?? '').trim()
|
||||
if (group.includes('شمش') || isSimorghBar(product)) {
|
||||
return true
|
||||
}
|
||||
|
||||
return (product.title ?? '').includes('شمش')
|
||||
}
|
||||
|
||||
export function useTvMonitorPage() {
|
||||
const rootEl = ref<HTMLElement | null>(null)
|
||||
const { isFullscreen, enter: enterFullscreen, exit: exitFullscreen } = useFullscreen(rootEl)
|
||||
@@ -96,8 +103,7 @@ export function useTvMonitorPage() {
|
||||
const bankCoins = computed(() =>
|
||||
catalogProducts.value
|
||||
.filter(isBankCoin)
|
||||
.filter(isBankCoinDenomination)
|
||||
.sort((a, b) => bankCoinRank(a) - bankCoinRank(b) || Number(b.amount ?? 0) - Number(a.amount ?? 0)),
|
||||
.sort((a, b) => bankCoinRank(a) - bankCoinRank(b) || Number(a.amount ?? 0) - Number(b.amount ?? 0)),
|
||||
)
|
||||
|
||||
const hasCoinBoard = computed(
|
||||
@@ -114,23 +120,31 @@ export function useTvMonitorPage() {
|
||||
.sort((a, b) => Number(a.amount ?? 0) - Number(b.amount ?? 0)),
|
||||
)
|
||||
|
||||
/** تیکر پایین: شمش / آبشده / هر محصول غیرسکه */
|
||||
/** تیکر بالا: فقط شمشهای تابلو */
|
||||
const tickerProducts = computed(() =>
|
||||
catalogProducts.value
|
||||
.filter((p) => !isParsianCoin(p) && !isBankCoin(p))
|
||||
.filter(isGoldBar)
|
||||
.sort((a, b) => Number(a.amount ?? 0) - Number(b.amount ?? 0)),
|
||||
)
|
||||
|
||||
const tickerTitle = computed(() => {
|
||||
const items = tickerProducts.value
|
||||
if (!items.length) return ''
|
||||
if (items.every(isSimorghBar)) return 'شمش سیمرغ'
|
||||
if (items.every((p) => isMeltedTradeGroup(p.group_type))) return 'آبشده'
|
||||
return 'محصولات تابلو'
|
||||
})
|
||||
const tickerTitle = computed(() => (tickerProducts.value.length ? 'مظنه شمشها' : ''))
|
||||
|
||||
/** تیکر پایین: بقیه — نه سکه، نه پارسیان، نه شمش */
|
||||
const extraTickerProducts = computed(() =>
|
||||
catalogProducts.value
|
||||
.filter((product) => !isParsianCoin(product) && !isBankCoin(product) && !isGoldBar(product))
|
||||
.sort((a, b) => (a.title ?? '').localeCompare(b.title ?? '', 'fa')),
|
||||
)
|
||||
|
||||
const extraTickerTitle = computed(() =>
|
||||
extraTickerProducts.value.length ? 'سایر مظنهها' : '',
|
||||
)
|
||||
|
||||
const hasBoardContent = computed(
|
||||
() => hasCoinBoard.value || tickerProducts.value.length > 0,
|
||||
() =>
|
||||
hasCoinBoard.value
|
||||
|| tickerProducts.value.length > 0
|
||||
|| extraTickerProducts.value.length > 0,
|
||||
)
|
||||
|
||||
const statusBanner = computed(() => {
|
||||
@@ -230,22 +244,23 @@ export function useTvMonitorPage() {
|
||||
}
|
||||
|
||||
function tickerItemLabel(product: Product) {
|
||||
if (isSimorghBar(product)) return simorghWeightLabel(product)
|
||||
const amount = Number(product.amount ?? 0)
|
||||
if (isMeltedTradeGroup(product.group_type)) {
|
||||
return amount > 0 ? `${product.title} · ${amount} گرم` : product.title
|
||||
}
|
||||
return amount > 0 ? `${product.title} · ${amount} گرم` : product.title
|
||||
const title = (product.title ?? '').trim()
|
||||
if (title) return title
|
||||
return simorghWeightLabel(product)
|
||||
}
|
||||
|
||||
function isProductTvInactive(product: Product) {
|
||||
return isTvProductPriceInactive(product)
|
||||
}
|
||||
|
||||
function productBuyLabel(product: Product) {
|
||||
if (isTvProductPriceInactive(product)) return NO_QUOTE_MESSAGE
|
||||
if (isProductTvInactive(product)) return NO_QUOTE_MESSAGE
|
||||
const value = getTvProductBuyPrice(product)
|
||||
return value > 0 ? usePrice(value) : '—'
|
||||
}
|
||||
|
||||
function productSellLabel(product: Product) {
|
||||
if (isTvProductPriceInactive(product)) return NO_QUOTE_MESSAGE
|
||||
if (isProductTvInactive(product)) return NO_QUOTE_MESSAGE
|
||||
const value = getTvProductSellPrice(product)
|
||||
return value > 0 ? usePrice(value) : '—'
|
||||
}
|
||||
@@ -298,6 +313,8 @@ export function useTvMonitorPage() {
|
||||
coinRowCount,
|
||||
tickerProducts,
|
||||
tickerTitle,
|
||||
extraTickerProducts,
|
||||
extraTickerTitle,
|
||||
statusBanner,
|
||||
liveBuy,
|
||||
liveSell,
|
||||
@@ -307,6 +324,7 @@ export function useTvMonitorPage() {
|
||||
loading,
|
||||
productWeightLabel,
|
||||
tickerItemLabel,
|
||||
isProductTvInactive,
|
||||
productBuyLabel,
|
||||
productSellLabel,
|
||||
liveQuoteLabel,
|
||||
|
||||
Reference in New Issue
Block a user