Compare commits
3 Commits
fff01ff30f
...
9f2627faf8
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f2627faf8 | |||
| a7b1fb902c | |||
| 6afce2ef58 |
@@ -1,24 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { vOnClickOutside } from '@vueuse/components';
|
import { vOnClickOutside } from '@vueuse/components';
|
||||||
import { useEventListener, useVModel } from '@vueuse/core';
|
import { useEventListener } from '@vueuse/core';
|
||||||
import { watch } from 'vue';
|
import { watch } from 'vue';
|
||||||
|
|
||||||
interface Props {
|
const open = defineModel('open', { default: false });
|
||||||
open: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Emit {
|
watch(open, value => {
|
||||||
(e: 'update:open', value: boolean): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
|
||||||
open: false,
|
|
||||||
});
|
|
||||||
const emit = defineEmits<Emit>();
|
|
||||||
|
|
||||||
const isOpen = useVModel(props, 'open', emit, {passive: true});
|
|
||||||
|
|
||||||
watch(isOpen, value => {
|
|
||||||
if (value) {
|
if (value) {
|
||||||
document.body.classList.add('overflow-hidden');
|
document.body.classList.add('overflow-hidden');
|
||||||
} else {
|
} else {
|
||||||
@@ -27,18 +14,18 @@ watch(isOpen, value => {
|
|||||||
});
|
});
|
||||||
useEventListener('keyup', e => {
|
useEventListener('keyup', e => {
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
isOpen.value = false;
|
open.value = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Transition name="fade">
|
<Transition name="fade">
|
||||||
<template v-if="isOpen">
|
<template v-if="open">
|
||||||
<div class="fixed inset-0 z-10">
|
<div class="fixed inset-0 z-10">
|
||||||
<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" v-on-click-outside="() => isOpen = false">
|
<div class="justify-self-center m-auto" v-on-click-outside="() => open = false">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,24 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useVModel } from '@vueuse/core';
|
|
||||||
|
|
||||||
interface Props {
|
const modelValue = defineModel({ default: false });
|
||||||
modelValue?: boolean;
|
|
||||||
}
|
|
||||||
interface Emits {
|
|
||||||
(e: 'update:modelValue', value: boolean): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
|
||||||
modelValue: false
|
|
||||||
});
|
|
||||||
const emit = defineEmits<Emits>();
|
|
||||||
|
|
||||||
const value = useVModel(props, 'modelValue', emit);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<label class="flex items-center relative w-max cursor-pointer select-none">
|
<label class="flex items-center relative w-max cursor-pointer select-none">
|
||||||
<input type="checkbox" class="appearance-none transition-colors cursor-pointer w-10 h-5 rounded-full checked:bg-emerald-500 peer" v-model="value" />
|
<input type="checkbox" class="appearance-none transition-colors cursor-pointer w-10 h-5 rounded-full checked:bg-emerald-500 peer" v-model="modelValue" />
|
||||||
<span class="w-5 h-5 right-5 absolute rounded-full transform transition-transform bg-slate-100 peer-checked:bg-emerald-200" />
|
<span class="w-5 h-5 right-5 absolute rounded-full transform transition-transform bg-slate-100 peer-checked:bg-emerald-200" />
|
||||||
</label>
|
</label>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,23 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { vElementHover } from '@vueuse/components';
|
import { vElementHover } from '@vueuse/components';
|
||||||
import { useElementBounding, useVModel } from '@vueuse/core';
|
import { useElementBounding } from '@vueuse/core';
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { useSharedWindowSize } from './tooltip';
|
import { useSharedWindowSize } from './tooltip';
|
||||||
|
|
||||||
interface Props {
|
const open = defineModel('open', { default: false });
|
||||||
open: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Emit {
|
|
||||||
(e: 'update:open', value: boolean): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
|
||||||
open: false,
|
|
||||||
});
|
|
||||||
const emit = defineEmits<Emit>();
|
|
||||||
|
|
||||||
const isOpen = useVModel(props, 'open', emit, {passive: true});
|
|
||||||
|
|
||||||
const { width, height } = useSharedWindowSize();
|
const { width, height } = useSharedWindowSize();
|
||||||
const mainDiv = ref<HTMLDivElement | null>(null);
|
const mainDiv = ref<HTMLDivElement | null>(null);
|
||||||
@@ -39,16 +26,16 @@ const positions = computed(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div ref="mainDiv" clas="flex flex-col items-center justify-center" :class="{
|
<div ref="mainDiv" clas="flex flex-col items-center justify-center" :class="{
|
||||||
'open': isOpen,
|
'open': open,
|
||||||
'tooltip-top': positions.includes('top'),
|
'tooltip-top': positions.includes('top'),
|
||||||
'tooltip-bottom': positions.includes('bottom'),
|
'tooltip-bottom': positions.includes('bottom'),
|
||||||
'tooltip-left': positions.includes('left'),
|
'tooltip-left': positions.includes('left'),
|
||||||
'tooltip-right': positions.includes('right')
|
'tooltip-right': positions.includes('right')
|
||||||
}">
|
}">
|
||||||
<div v-element-hover="(h: boolean) => isOpen = h" class="m-auto header">
|
<div v-element-hover="(h: boolean) => open = h" class="m-auto header">
|
||||||
<slot name="header" />
|
<slot name="header" />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="isOpen" class="m-auto">
|
<div v-if="open" class="m-auto">
|
||||||
<div class="z-10 relative">
|
<div class="z-10 relative">
|
||||||
<div class="absolute">
|
<div class="absolute">
|
||||||
<slot />
|
<slot />
|
||||||
|
|||||||
@@ -18,4 +18,10 @@ const timeFormat = new Intl.NumberFormat("en-US", {
|
|||||||
minimumIntegerDigits: 2
|
minimumIntegerDigits: 2
|
||||||
});
|
});
|
||||||
|
|
||||||
export const formatEveDate = (date?: Date | null) => !date ? '' : `${date.getUTCFullYear()}.${timeFormat.format(date.getUTCMonth() + 1)}.${timeFormat.format(date.getUTCDate())} ${timeFormat.format(date.getUTCHours())}:${timeFormat.format(date.getUTCMinutes())}`;
|
export const formatEveDate = (date?: Date | null) => {
|
||||||
|
try {
|
||||||
|
return !date ? '' : `${date.getUTCFullYear()}.${timeFormat.format(date.getUTCMonth() + 1)}.${timeFormat.format(date.getUTCDate())} ${timeFormat.format(date.getUTCHours())}:${timeFormat.format(date.getUTCMinutes())}`;
|
||||||
|
} catch (e) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
};
|
||||||
35
src/market/RegionalMarketCache.spec.ts
Normal file
35
src/market/RegionalMarketCache.spec.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import { describe, expect, it } from 'vitest'
|
||||||
|
import { RegionalMarketCache } from './RegionalMarketCache'
|
||||||
|
|
||||||
|
describe('RegionalMarketCache', () => {
|
||||||
|
it('should cache and retrieve values', async () => {
|
||||||
|
const cache = new RegionalMarketCache<string>(1000)
|
||||||
|
|
||||||
|
cache.set(1, 1, 'test')
|
||||||
|
expect(cache.get(1, 1)).toBe('test')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should remove values', async () => {
|
||||||
|
const cache = new RegionalMarketCache<string>(1000)
|
||||||
|
|
||||||
|
cache.set(1, 1, 'test')
|
||||||
|
cache.remove(1, 1)
|
||||||
|
expect(cache.get(1, 1)).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should compute values if absent', async () => {
|
||||||
|
const cache = new RegionalMarketCache<string>(1000)
|
||||||
|
const value = await cache.computeIfAbsent(1, 1, () => Promise.resolve('test'))
|
||||||
|
|
||||||
|
expect(value).toBe('test')
|
||||||
|
expect(cache.get(1, 1)).toBe('test')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should expire values', async () => {
|
||||||
|
const cache = new RegionalMarketCache<string>(1)
|
||||||
|
|
||||||
|
cache.set(1, 1, 'test')
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 10))
|
||||||
|
expect(cache.get(1, 1)).toBeUndefined()
|
||||||
|
})
|
||||||
|
})
|
||||||
50
src/market/RegionalMarketCache.ts
Normal file
50
src/market/RegionalMarketCache.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
class CacheEntry<T> {
|
||||||
|
public value: T;
|
||||||
|
public expiration: Date;
|
||||||
|
|
||||||
|
constructor(value: T, expiration: Date) {
|
||||||
|
this.value = value;
|
||||||
|
this.expiration = expiration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ExpirationSupplier<T> = (v: T) => Date;
|
||||||
|
|
||||||
|
export class RegionalMarketCache<T> {
|
||||||
|
private cache: Record<number, Record<number, CacheEntry<T>>>;
|
||||||
|
private expirationSupplier: (v: T) => Date;
|
||||||
|
|
||||||
|
constructor(expiration: ExpirationSupplier<T> | number) {
|
||||||
|
this.cache = {};
|
||||||
|
this.expirationSupplier = expiration instanceof Function ? expiration : () => new Date(Date.now() + expiration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get(regionId: number, typeId: number): T | undefined {
|
||||||
|
const entry = this.cache[regionId]?.[typeId];
|
||||||
|
|
||||||
|
if (entry && entry.expiration > new Date()) {
|
||||||
|
return entry.value;
|
||||||
|
}
|
||||||
|
this.remove(regionId, typeId);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
public set(regionId: number, typeId: number, value: T): void {
|
||||||
|
this.cache[regionId] = this.cache[regionId] ?? {};
|
||||||
|
this.cache[regionId][typeId] = new CacheEntry(value, this.expirationSupplier(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public remove(regionId: number, typeId: number): void {
|
||||||
|
delete this.cache[regionId]?.[typeId];
|
||||||
|
}
|
||||||
|
|
||||||
|
public async computeIfAbsent(regionId: number, typeId: number, supplier: () => (Promise<T> | T)): Promise<T> {
|
||||||
|
let value = this.get(regionId, typeId);
|
||||||
|
|
||||||
|
if (!value) {
|
||||||
|
value = await supplier();
|
||||||
|
this.set(regionId, typeId, value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { LoadingSpinner, Tooltip } from '@/components';
|
import { LoadingSpinner, Tooltip } from '@/components';
|
||||||
import { formatIsk } from '@/formaters';
|
import { formatIsk } from '@/formaters';
|
||||||
import { getHistory, getHistoryQuartils, jitaId } from '@/market';
|
import { getHistory, getHistoryQuartils } from '@/market';
|
||||||
import { ArrowTrendingDownIcon, ArrowTrendingUpIcon } from '@heroicons/vue/24/outline';
|
import { ArrowTrendingDownIcon, ArrowTrendingUpIcon } from '@heroicons/vue/24/outline';
|
||||||
import { computedAsync } from '@vueuse/core';
|
import { computedAsync } from '@vueuse/core';
|
||||||
import { ref, watchEffect } from 'vue';
|
import { ref, watchEffect } from 'vue';
|
||||||
@@ -22,7 +22,7 @@ const q1 = ref(0);
|
|||||||
const median = ref(0);
|
const median = ref(0);
|
||||||
const q3 = ref(0);
|
const q3 = ref(0);
|
||||||
const lineColor = ref('');
|
const lineColor = ref('');
|
||||||
const history = computedAsync(() => getHistory(jitaId, props.id), []);
|
const history = computedAsync(() => getHistory(props.id), []);
|
||||||
|
|
||||||
watchEffect(async () => {
|
watchEffect(async () => {
|
||||||
if (!open.value || !props.id) {
|
if (!open.value || !props.id) {
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { ref } from 'vue';
|
import { RegionalMarketCache } from '../RegionalMarketCache';
|
||||||
|
import { jitaId } from '../market';
|
||||||
import { MarketType } from "../type";
|
import { MarketType } from "../type";
|
||||||
import { MarketTypePrice } from './MarketTypePrice';
|
import { MarketTypePrice } from './MarketTypePrice';
|
||||||
import { getEvepraisalPrices } from './evepraisal';
|
import { getEvepraisalPrices } from './evepraisal';
|
||||||
import { getfuzzworkPrices } from './fuzzwork';
|
import { getfuzzworkPrices } from './fuzzwork';
|
||||||
|
|
||||||
type MarketTypePriceCache = {
|
|
||||||
price: MarketTypePrice,
|
|
||||||
date: Date
|
|
||||||
}
|
|
||||||
|
|
||||||
const cacheDuration = 1000 * 60 * 5; // 5 minutes
|
const cacheDuration = 1000 * 60 * 5; // 5 minutes
|
||||||
const priceGetters = {
|
const priceGetters = {
|
||||||
evepraisal: getEvepraisalPrices,
|
evepraisal: getEvepraisalPrices,
|
||||||
@@ -17,21 +13,21 @@ const priceGetters = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const useApraisalStore = defineStore('appraisal', () => {
|
export const useApraisalStore = defineStore('appraisal', () => {
|
||||||
const cache = ref<Record<number, MarketTypePriceCache>>({});
|
const cache: RegionalMarketCache<MarketTypePrice> = new RegionalMarketCache(cacheDuration);
|
||||||
|
|
||||||
const getPricesUncached = priceGetters.fuzzwork;
|
const getPricesUncached = priceGetters.fuzzwork;
|
||||||
|
|
||||||
const getPrice = async (type: MarketType): Promise<MarketTypePrice> => (await getPrices([type]))[0];
|
const getPrice = async (type: MarketType, regionId?: number): Promise<MarketTypePrice> => (await getPrices([type], regionId))[0];
|
||||||
const getPrices = async (types: MarketType[]): Promise<MarketTypePrice[]> => {
|
const getPrices = async (types: MarketType[], regionId?: number): Promise<MarketTypePrice[]> => {
|
||||||
const now = new Date();
|
|
||||||
const cached: MarketTypePrice[] = [];
|
const cached: MarketTypePrice[] = [];
|
||||||
const uncached: MarketType[] = [];
|
const uncached: MarketType[] = [];
|
||||||
|
const rId = regionId ?? jitaId;
|
||||||
|
|
||||||
types.forEach(t => {
|
types.forEach(t => {
|
||||||
const cachedPrice = cache.value[t.id];
|
const cachedPrice = cache.get(rId, t.id);
|
||||||
|
|
||||||
if (cachedPrice && now.getTime() - cachedPrice.date.getTime() < cacheDuration) {
|
if (cachedPrice) {
|
||||||
cached.push(cachedPrice.price);
|
cached.push(cachedPrice);
|
||||||
} else {
|
} else {
|
||||||
uncached.push(t);
|
uncached.push(t);
|
||||||
}
|
}
|
||||||
@@ -40,8 +36,8 @@ export const useApraisalStore = defineStore('appraisal', () => {
|
|||||||
if (uncached.length > 0) {
|
if (uncached.length > 0) {
|
||||||
const prices = await getPricesUncached(uncached);
|
const prices = await getPricesUncached(uncached);
|
||||||
|
|
||||||
prices.forEach(p => cache.value[p.type.id] = { price: p, date: now });
|
prices.forEach(p => cache.set(rId, p.type.id, p));
|
||||||
return [...cached, ...prices];
|
return [ ...cached, ...prices ];
|
||||||
}
|
}
|
||||||
return cached;
|
return cached;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { esiAxiosInstance } from "@/service";
|
import { esiAxiosInstance } from "@/service";
|
||||||
|
import { RegionalMarketCache } from '../RegionalMarketCache';
|
||||||
|
import { jitaId } from "../market";
|
||||||
|
|
||||||
|
|
||||||
export type EsiMarketOrderHistory = {
|
export type EsiMarketOrderHistory = {
|
||||||
@@ -11,16 +13,18 @@ export type EsiMarketOrderHistory = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO use pinia store
|
// TODO use pinia store
|
||||||
const historyCache: { [key: number]: { [key: number]: EsiMarketOrderHistory[] } } = {};
|
const historyCache: RegionalMarketCache<EsiMarketOrderHistory[]> = new RegionalMarketCache(() => {
|
||||||
|
const date = new Date();
|
||||||
|
|
||||||
export const getHistory = async (regionId: number, tyeId: number): Promise<EsiMarketOrderHistory[]> => {
|
if (date.getUTCHours() < 11) {
|
||||||
if (historyCache[regionId]?.[tyeId]) {
|
date.setUTCDate(date.getUTCDate() - 1);
|
||||||
return historyCache[regionId][tyeId];
|
|
||||||
}
|
}
|
||||||
|
date.setUTCHours(11, 0, 0, 0);
|
||||||
|
return date;
|
||||||
|
});
|
||||||
|
|
||||||
const value = (await esiAxiosInstance.get(`/markets/${regionId}/history/`, { params: { type_id: tyeId } })).data;
|
export const getHistory = async (tyeId: number, regionId?: number): Promise<EsiMarketOrderHistory[]> => {
|
||||||
|
const rId = regionId ?? jitaId;
|
||||||
|
|
||||||
historyCache[regionId] = historyCache[regionId] ?? {};
|
return historyCache.computeIfAbsent(rId, tyeId, async () => (await esiAxiosInstance.get(`/markets/${rId}/history/`, { params: { type_id: tyeId } })).data);
|
||||||
historyCache[regionId][tyeId] = value;
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
export * from './RegionalMarketCache';
|
||||||
export * from './history';
|
export * from './history';
|
||||||
export * from './tax';
|
export * from './tax';
|
||||||
export * from './type';
|
export * from './type';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { marbasAxiosInstance, MarbasObject } from "@/marbas";
|
import { marbasAxiosInstance, MarbasObject } from "@/marbas";
|
||||||
import { EsiMarketOrderHistory, getHistory, jitaId, MarketType, MarketTypePrice } from "@/market";
|
import { EsiMarketOrderHistory, getHistory, MarketType, MarketTypePrice } from "@/market";
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { computed, ref } from "vue";
|
import { computed, ref } from "vue";
|
||||||
@@ -47,4 +47,4 @@ export const useMarketTrackingStore = defineStore('marketTracking', () => {
|
|||||||
return { types, addType, removeType };
|
return { types, addType, removeType };
|
||||||
});
|
});
|
||||||
|
|
||||||
export const createResult = async (id: number, price: MarketTypePrice): Promise<TrackingResult> => ({ history: await getHistory(jitaId, id), ...price });
|
export const createResult = async (id: number, price: MarketTypePrice): Promise<TrackingResult> => ({ history: await getHistory(id), ...price });
|
||||||
@@ -1,25 +1,18 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { vOnClickOutside } from '@vueuse/components';
|
import { vOnClickOutside } from '@vueuse/components';
|
||||||
import { useVirtualList, useVModel } from '@vueuse/core';
|
import { useVirtualList } from '@vueuse/core';
|
||||||
import log from 'loglevel';
|
import log from 'loglevel';
|
||||||
import { nextTick, ref, watch, watchEffect } from 'vue';
|
import { nextTick, ref, watch, watchEffect } from 'vue';
|
||||||
import { MarketType, searchMarketTypes } from './MarketType';
|
import { MarketType, searchMarketTypes } from './MarketType';
|
||||||
import MarketTypeLabel from "./MarketTypeLabel.vue";
|
import MarketTypeLabel from "./MarketTypeLabel.vue";
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
modelValue?: MarketType;
|
|
||||||
}
|
|
||||||
interface Emits {
|
interface Emits {
|
||||||
(e: 'update:modelValue', value?: MarketType): void;
|
|
||||||
(e: 'submit'): void;
|
(e: 'submit'): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<Props>();
|
const modelValue = defineModel<MarketType>();
|
||||||
const emit = defineEmits<Emits>();
|
const emit = defineEmits<Emits>();
|
||||||
|
|
||||||
const value = useVModel(props, 'modelValue', emit);
|
|
||||||
|
|
||||||
const isOpen = ref(false);
|
const isOpen = ref(false);
|
||||||
const name = ref('');
|
const name = ref('');
|
||||||
const suggestions = ref<MarketType[]>([]);
|
const suggestions = ref<MarketType[]>([]);
|
||||||
@@ -47,7 +40,7 @@ const moveUp = () => {
|
|||||||
}
|
}
|
||||||
const select = (type?: MarketType) => {
|
const select = (type?: MarketType) => {
|
||||||
log.debug('Select:', type);
|
log.debug('Select:', type);
|
||||||
value.value = type;
|
modelValue.value = type;
|
||||||
currentIndex.value = -1;
|
currentIndex.value = -1;
|
||||||
suggestions.value = [];
|
suggestions.value = [];
|
||||||
isOpen.value = false;
|
isOpen.value = false;
|
||||||
@@ -62,18 +55,18 @@ const submit = async () => {
|
|||||||
|
|
||||||
select(v);
|
select(v);
|
||||||
await nextTick();
|
await nextTick();
|
||||||
} else if (props.modelValue === undefined && suggestions.value.length > 0) {
|
} else if (modelValue.value === undefined && suggestions.value.length > 0) {
|
||||||
select(suggestions.value[0]);
|
select(suggestions.value[0]);
|
||||||
await nextTick();
|
await nextTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.value === undefined) {
|
if (modelValue.value === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
emit('submit');
|
emit('submit');
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => props.modelValue, async v => {
|
watch(() => modelValue.value, async v => {
|
||||||
if (v === undefined) {
|
if (v === undefined) {
|
||||||
name.value = '';
|
name.value = '';
|
||||||
} else {
|
} else {
|
||||||
@@ -96,7 +89,7 @@ watchEffect(async () => {
|
|||||||
<template>
|
<template>
|
||||||
<div @click="() => isOpen = true" v-on-click-outside="() => isOpen = false">
|
<div @click="() => isOpen = true" v-on-click-outside="() => isOpen = false">
|
||||||
<div class="fake-input">
|
<div class="fake-input">
|
||||||
<img v-if="value?.id" :src="`https://images.evetech.net/types/${value.id}/icon?size=32`" alt="" />
|
<img v-if="modelValue?.id" :src="`https://images.evetech.net/types/${modelValue.id}/icon?size=32`" alt="" />
|
||||||
<input type="text" v-model="name" @keyup.enter="submit" @keyup.down="moveDown" @keyup.up="moveUp" />
|
<input type="text" v-model="name" @keyup.enter="submit" @keyup.down="moveDown" @keyup.up="moveUp" />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="suggestions.length > 1" class="z-20 absolute w-96">
|
<div v-if="suggestions.length > 1" class="z-20 absolute w-96">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { MarketType, MarketTypeInput, MarketTypePrice, getHistory, getMarketTypes, jitaId, useApraisalStore } from "@/market";
|
import { MarketType, MarketTypeInput, MarketTypePrice, getHistory, getMarketTypes, useApraisalStore } from "@/market";
|
||||||
import { BuyModal } from '@/market/acquisition';
|
import { BuyModal } from '@/market/acquisition';
|
||||||
import { TrackingResult, TrackingResultTable, createResult, useMarketTrackingStore } from '@/market/tracking';
|
import { TrackingResult, TrackingResultTable, createResult, useMarketTrackingStore } from '@/market/tracking';
|
||||||
import { ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
@@ -15,7 +15,7 @@ const items = ref<TrackingResult[]>([]);
|
|||||||
const addOrRelaod = async (type: MarketType) => {
|
const addOrRelaod = async (type: MarketType) => {
|
||||||
const typeID = type.id;
|
const typeID = type.id;
|
||||||
const [history, price] = await Promise.all([
|
const [history, price] = await Promise.all([
|
||||||
getHistory(jitaId, typeID),
|
getHistory(typeID),
|
||||||
apraisalStore.getPrice(type)
|
apraisalStore.getPrice(type)
|
||||||
]);
|
]);
|
||||||
const itm = {
|
const itm = {
|
||||||
|
|||||||
@@ -1,24 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useVModel } from '@vueuse/core';
|
|
||||||
|
|
||||||
interface Props {
|
const modelValue = defineModel({ default: false });
|
||||||
modelValue?: boolean;
|
|
||||||
}
|
|
||||||
interface Emits {
|
|
||||||
(e: 'update:modelValue', value: boolean): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
|
||||||
modelValue: false
|
|
||||||
});
|
|
||||||
const emit = defineEmits<Emits>();
|
|
||||||
|
|
||||||
const value = useVModel(props, 'modelValue', emit);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<label class="flex items-center relative w-max cursor-pointer select-none">
|
<label class="flex items-center relative w-max cursor-pointer select-none">
|
||||||
<input type="checkbox" class="appearance-none transition-colors cursor-pointer w-14 h-7 rounded-full" v-model="value" />
|
<input type="checkbox" class="appearance-none transition-colors cursor-pointer w-14 h-7 rounded-full" v-model="modelValue" />
|
||||||
<span class="absolute font-medium text-xs right-1"> Buy </span>
|
<span class="absolute font-medium text-xs right-1"> Buy </span>
|
||||||
<span class="absolute font-medium text-xs right-8"> Sell </span>
|
<span class="absolute font-medium text-xs right-8"> Sell </span>
|
||||||
<span class="w-7 h-7 right-7 absolute rounded-full transform transition-transform bg-slate-100" />
|
<span class="w-7 h-7 right-7 absolute rounded-full transform transition-transform bg-slate-100" />
|
||||||
|
|||||||
@@ -1,22 +1,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { evepraisalAxiosInstance } from '@/market/appraisal/evepraisal';
|
import { evepraisalAxiosInstance } from '@/market/appraisal/evepraisal';
|
||||||
import { useVModel } from '@vueuse/core';
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
name: string;
|
name: string;
|
||||||
modelValue?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Emits {
|
const modelValue = defineModel({ default: '' });
|
||||||
(e: 'update:modelValue', value: string): void;
|
defineProps<Props>();
|
||||||
}
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
|
||||||
modelValue: ''
|
|
||||||
});
|
|
||||||
const emit = defineEmits<Emits>();
|
|
||||||
|
|
||||||
const value = useVModel(props, 'modelValue', emit);
|
|
||||||
|
|
||||||
const loadFromId = async (e: Event) => {
|
const loadFromId = async (e: Event) => {
|
||||||
const input = e.target as HTMLInputElement;
|
const input = e.target as HTMLInputElement;
|
||||||
@@ -31,7 +21,7 @@ const loadFromId = async (e: Event) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
value.value = JSON.stringify(response.data);
|
modelValue.value = JSON.stringify(response.data);
|
||||||
input.value = '';
|
input.value = '';
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -39,6 +29,6 @@ const loadFromId = async (e: Event) => {
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex-1 mx-1">
|
<div class="flex-1 mx-1">
|
||||||
<span>{{ name }}</span><input type="text" class="ms-2" @change="loadFromId" placeholder="id evepraisal" />
|
<span>{{ name }}</span><input type="text" class="ms-2" @change="loadFromId" placeholder="id evepraisal" />
|
||||||
<textarea class="mt-1" v-model="value" />
|
<textarea class="mt-1" v-model="modelValue" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
Reference in New Issue
Block a user