fix some bug

This commit is contained in:
2026-06-06 15:48:27 +03:30
parent f82a0c3873
commit 4c707849ef
5 changed files with 29 additions and 27 deletions
+5 -13
View File
@@ -9,26 +9,18 @@ export const price = ref<Price>()
export const lastPrice = ref<Price>()
export const olderPrice = ref<number | undefined>(0)
/** buy/sell معامله: اول up (مثل endpoint قدیمی /price/up) سپس fallback */
/** buy/sell نمایش و معامله — همان buy/sell/price_last از /api/price/last */
export function getTradeBuyPrice(p?: Price | null) {
return p?.up?.buy ?? p?.buy ?? 0
return p?.buy ?? p?.price_last ?? p?.up?.buy ?? 0
}
export function getTradeSellPrice(p?: Price | null) {
return p?.up?.sell ?? p?.sell ?? 0
return p?.sell ?? p?.up?.sell ?? 0
}
/** یکسان‌سازی پاسخ last با رفتار قدیمی price/up */
/** up جدا نگه داشته می‌شود؛ buy/sell/price_last از lastPrice سرور دست‌نخورده می‌ماند */
export function normalizePriceResponse(data: Price): Price {
if (!data?.up) {
return data
}
return {
...data,
buy: data.up.buy,
sell: data.up.sell,
}
return data
}
export async function setIntervalGetAllPrice() {