tracking
This commit is contained in:
@@ -5,7 +5,7 @@ import { RouterLink, RouterView } from 'vue-router';
|
||||
|
||||
<template>
|
||||
<div class="mt-4">
|
||||
<div class="flex border-b-2">
|
||||
<div class="flex border-b-2 border-emerald-500">
|
||||
<RouterLink to="/market/scan" class="tab">
|
||||
<span>Scan</span>
|
||||
</RouterLink>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { MarketOrderHistory, MarketType, getHistory, getMarketType, getMarketTypes, jitaId } from "@/market";
|
||||
import { ScanResult, ScanResultTable } from '@/market/scan';
|
||||
import { evepraisalAxiosInstance } from '@/service';
|
||||
import { MarketOrderHistory, MarketType, MarketTypePrice, getHistory, getMarketType, getMarketTypes, getPrice, getPrices, jitaId } from "@/market";
|
||||
import { BuyModal, ScanResult, ScanResultTable } from '@/market/scan';
|
||||
import { useStorage } from '@vueuse/core';
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
|
||||
@@ -10,6 +9,8 @@ type MarketItemStorage = {
|
||||
history: MarketOrderHistory[];
|
||||
}
|
||||
|
||||
const buyModal = ref<typeof BuyModal>();
|
||||
|
||||
const item = ref("");
|
||||
/**
|
||||
* @deprecated use itemsStorage instead
|
||||
@@ -23,13 +24,13 @@ const addOrRelaod = async (type: MarketType) => {
|
||||
const typeID = type.id;
|
||||
const [history, price] = await Promise.all([
|
||||
getHistory(jitaId, typeID),
|
||||
evepraisalAxiosInstance.post(`/appraisal.json?market=jita&persist=no&raw_textarea=${type.name}`)
|
||||
getPrice(type)
|
||||
]);
|
||||
const item = {
|
||||
type,
|
||||
history,
|
||||
buy: price.data.appraisal.items[0].prices.buy.max,
|
||||
sell: price.data.appraisal.items[0].prices.sell.min
|
||||
buy: price.buy,
|
||||
sell: price.sell
|
||||
};
|
||||
|
||||
if (items.value.some(i => i.type.id === typeID)) {
|
||||
@@ -61,21 +62,15 @@ onMounted(async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const types = await getMarketTypes(itemsStorage.value.map(i => i.typeID));
|
||||
const prices: any = (await evepraisalAxiosInstance.post(`/appraisal.json?market=jita&persist=no&raw_textarea=${types.map(t => t.name).join("%0A")}`)).data;
|
||||
const prices = await getPrices(await getMarketTypes(itemsStorage.value.map(i => i.typeID)));
|
||||
|
||||
items.value = itemsStorage.value.map(i => {
|
||||
const type = types.find(t => t.id === i.typeID) as MarketType;
|
||||
const price = prices.appraisal.items.find((p: any) => p.typeID === i.typeID);
|
||||
const price = prices.find(p => p.type.id === i.typeID) as MarketTypePrice;
|
||||
|
||||
return {
|
||||
...i,
|
||||
type: type,
|
||||
buy: price.prices.buy.max,
|
||||
sell: price.prices.sell.min
|
||||
};
|
||||
return { ...i, ...price };
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -88,6 +83,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
<template v-if="items.length > 0">
|
||||
<hr />
|
||||
<ScanResultTable :items="items" @relaod="type => addOrRelaod(type)" @relaodAll="reloadAll" />
|
||||
<ScanResultTable :items="items" @relaod="type => addOrRelaod(type)" @relaodAll="reloadAll" @buy="(type, buy, sell) => buyModal?.open(type, { 'Buy': buy, 'Sell': sell })" />
|
||||
<BuyModal ref="buyModal" />
|
||||
</template>
|
||||
</template>
|
||||
@@ -1,6 +1,41 @@
|
||||
<script setup lang="ts">
|
||||
import { MarketTypePrice, getMarketTypes, getPrices } from "@/market";
|
||||
import { BuyModal } from '@/market/scan';
|
||||
import { SellModal, TrackResultTable, TrackedItem, useTrackedItemsStorage } from '@/market/track';
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
|
||||
const buyModal = ref<typeof BuyModal>();
|
||||
const sellModal = ref<typeof SellModal>();
|
||||
|
||||
const itemsStorage = useTrackedItemsStorage();
|
||||
const items = ref<TrackedItem[]>([]);
|
||||
|
||||
const relaod = async () => {
|
||||
if (itemsStorage.value.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const prices = await getPrices(await getMarketTypes(itemsStorage.value.map(i => i.typeID)));
|
||||
|
||||
items.value = itemsStorage.value.map(i => {
|
||||
const price = prices.find(p => p.type.id === i.typeID) as MarketTypePrice;
|
||||
|
||||
return { ...i, ...price };
|
||||
});
|
||||
};
|
||||
|
||||
watch(items, itms => itemsStorage.value = itms.map(i => ({ typeID: i.type.id, count: i.count, averagePrice: i.averagePrice })));
|
||||
onMounted(relaod);
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div></div>
|
||||
<div class="mt-4">
|
||||
<template v-if="items.length > 0">
|
||||
<hr />
|
||||
<TrackResultTable :items="items" @buy="(type, price, buy, sell) => buyModal?.open(type, { 'Price': price, 'Buy': buy, 'Sell': sell })" @sell="type => sellModal?.open(type)" />
|
||||
<BuyModal ref="buyModal" @added="relaod" />
|
||||
<SellModal ref="sellModal" @removed="relaod" />
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user