This commit is contained in:
2023-10-01 11:49:02 +02:00
parent c3205a3e74
commit 0ce205a4a0
3 changed files with 17 additions and 8 deletions

View File

@@ -34,10 +34,10 @@ useEventListener('keyup', e => {
<template> <template>
<Transition name="fade"> <Transition name="fade">
<template v-if="isOpen"> <template v-if="isOpen">
<div class="fixed inset-0" @click="isOpen = false"> <div class="fixed inset-0">
<div class="absolute bg-black opacity-80 inset-0 z-0" /> <div class="absolute bg-black opacity-80 inset-0 z-0" />
<div class="absolute grid inset-0"> <div class="absolute grid inset-0">
<div class="justify-self-center m-auto" @click.stop> <div class="justify-self-center m-auto">
<slot /> <slot />
</div> </div>
</div> </div>

View File

@@ -19,11 +19,20 @@ const cacheDuration = 1000 * 60 * 5; // 5 minutes
export const useApraisalStore = defineStore('appraisal', () => { export const useApraisalStore = defineStore('appraisal', () => {
const cache = ref<Record<number, MarketTypePriceCache>>({}); const cache = ref<Record<number, MarketTypePriceCache>>({});
const getPricesUncached = async (types: MarketType[]): Promise<MarketTypePrice[]> => (await evepraisalAxiosInstance.post(`/appraisal.json?market=jita&persist=no&raw_textarea=${types.map(t => t.name).join("%0A")}`)).data.appraisal.items.map((item: any) => ({ const getPricesUncached = async (types: MarketType[]): Promise<MarketTypePrice[]> => {
type: types.find(t => t.name === item.typeName), const batches = [];
buy: item.prices.buy.max,
sell: item.prices.sell.min for (let i = 0; i < types.length; i += 100) {
})); batches.push(evepraisalAxiosInstance.post(`/appraisal.json?market=jita&persist=no&raw_textarea=${types.slice(i, i + 100).map(t => t.name).join("%0A")}`));
}
return (await Promise.all(batches))
.flatMap(b => b.data.appraisal.items)
.map((item: any) => ({
type: types.find(t => t.name === item.typeName) as MarketType,
buy: item.prices.buy.max,
sell: item.prices.sell.min
}));
}
const getPrice = async (type: MarketType): Promise<MarketTypePrice> => (await getPrices([type]))[0]; const getPrice = async (type: MarketType): Promise<MarketTypePrice> => (await getPrices([type]))[0];
const getPrices = async (types: MarketType[]): Promise<MarketTypePrice[]> => { const getPrices = async (types: MarketType[]): Promise<MarketTypePrice[]> => {

View File

@@ -30,7 +30,7 @@ const open = (t: MarketType, s?: Record<string, number> | number) => {
} }
modalOpen.value = true; modalOpen.value = true;
} }
const add = () => { const add = () => {
const id = type.value?.id; const id = type.value?.id;
if (!id) { if (!id) {