1404/10/28-base

This commit is contained in:
2026-01-18 13:01:46 +03:30
parent f95b0cef95
commit 9d96ae106b
455 changed files with 58164 additions and 0 deletions
+87
View File
@@ -0,0 +1,87 @@
import {loading} from '@/utils/index'
import {getLastPrice, getPrice} from '@/api/home'
import {ref} from 'vue'
import type {Price} from '@/models/home'
let interval: any
export const price = ref<Price>()
export const lastPrice = ref<Price>()
export const olderPrice = ref<number| undefined>(0)
export async function setIntervalGetAllPrice() {
// console.log('salam')
try {
interval = setInterval(async () => {
await getLastPrices()
await getUpPrice()
}, 10000)
} catch (e) {
console.log(e)
} finally {
loading.value = false
}
}
export async function setIntervalGetLastPrice() {
// console.log('salam')
try {
interval = setInterval(async () => {
await getLastPrices()
// await getUpPrice()
}, 10000)
} catch (e) {
console.log(e)
} finally {
loading.value = false
}
}
export async function getUpPrice() {
try {
// loading.value = true
const data = await getPrice()
// const dataLast = await getLastPrice()
// if (lastPrice.value?.price_last != dataLast.price_last) {
// olderPrice.value = lastPrice.value?.price_last
// }
price.value = data
// lastPrice.value = dataLast
} catch (e) {
console.log(e)
} finally {
// loading.value = false
}
}
export async function getLastPrices() {
try {
// loading.value = true
// const data = await getPrice()
const dataLast = await getLastPrice()
if (lastPrice.value?.price_last != dataLast.price_last) {
olderPrice.value = lastPrice.value?.price_last
}
// price.value = data
lastPrice.value = dataLast
} catch (e) {
console.log(e)
} finally {
// loading.value = false
}
}
export function stopPriceInterval() {
// console.log('stop')
clearInterval(interval);
}
export function percentPriceChanged() {
// console.log(olderPrice.value)
// console.log(lastPrice.value?.price_last)
if (!olderPrice.value)
return 0
return ((lastPrice.value?.price_last-olderPrice.value) *100)/olderPrice.value
}