mirror of
https://github.com/Kvan7/Exiled-Exchange-2.git
synced 2026-09-24 21:55:41 +00:00
+3
-2
@@ -62,7 +62,7 @@ type WidgetWellKnownFlag =
|
||||
'hide-on-focus'
|
||||
|
||||
export const defaultConfig: Config = {
|
||||
configVersion: 8,
|
||||
configVersion: 9,
|
||||
priceCheckKey: 'D',
|
||||
priceCheckKeyHold: 'Ctrl',
|
||||
priceCheckLocked: 'Ctrl + Alt + D',
|
||||
@@ -138,7 +138,8 @@ export const defaultConfig: Config = {
|
||||
wmFlags: ['hide-on-blur', 'skip-menu'],
|
||||
chaosPriceThreshold: 0.05,
|
||||
showRateLimitState: false,
|
||||
apiLatencySeconds: 2
|
||||
apiLatencySeconds: 2,
|
||||
collapseListings: 'api'
|
||||
} as PriceCheckWidget,
|
||||
{
|
||||
wmId: 3,
|
||||
|
||||
@@ -142,6 +142,13 @@ export const config = (() => {
|
||||
config.configVersion = 8
|
||||
}
|
||||
|
||||
if (config.configVersion < 9) {
|
||||
config.widgets.find(w => w.wmType === 'price-check')!
|
||||
.collapseListings = 'api'
|
||||
|
||||
config.configVersion = 9
|
||||
}
|
||||
|
||||
store.store = config
|
||||
return store
|
||||
})()
|
||||
|
||||
@@ -49,6 +49,7 @@ export interface PriceCheckWidget extends Widget {
|
||||
chaosPriceThreshold: number
|
||||
showRateLimitState: boolean
|
||||
apiLatencySeconds: number
|
||||
collapseListings: 'api' | 'app'
|
||||
}
|
||||
|
||||
export interface ItemCheckWidget extends Widget {
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
<td colspan="100" class="text-transparent">***</td>
|
||||
</tr>
|
||||
<tr v-else :key="result.id">
|
||||
<td class="px-2 whitespace-no-wrap">{{ result.priceAmount }} {{ result.priceCurrency }}</td>
|
||||
<td class="px-2 whitespace-no-wrap">{{ result.priceAmount }} {{ result.priceCurrency }} <span v-if="result.listedTimes > 2" class="rounded px-1 text-gray-800 bg-gray-400 -mr-2"><span class="font-sans">×</span> {{ result.listedTimes }}</span></td>
|
||||
<td v-if="item.stackSize" class="px-2 text-right">{{ result.stackSize }}</td>
|
||||
<td v-if="filters.itemLevel" class="px-2 whitespace-no-wrap text-right">{{ result.itemLevel }}</td>
|
||||
<td v-if="item.rarity === 'Gem'" class="pl-2 whitespace-no-wrap">{{ result.level }}</td>
|
||||
@@ -124,6 +124,9 @@ import { artificialSlowdown } from './artificial-slowdown'
|
||||
const slowdown = artificialSlowdown(900)
|
||||
|
||||
const SHOW_RESULTS = 20
|
||||
const API_FETCH_LIMIT = 100
|
||||
const MIN_NOT_GROUPED = 7
|
||||
const MIN_GROUPED = 10
|
||||
|
||||
function useTradeApi () {
|
||||
let searchId = 0
|
||||
@@ -131,6 +134,38 @@ function useTradeApi () {
|
||||
const searchResult = shallowRef<SearchResult | null>(null)
|
||||
const fetchResults = shallowRef<PricingResult[]>([])
|
||||
|
||||
const groupedResults = computed(() => {
|
||||
const out: Array<PricingResult & { listedTimes: number }> = []
|
||||
for (const result of fetchResults.value) {
|
||||
if (result == null) break
|
||||
if (out.length === 0) {
|
||||
out.push({ listedTimes: 1, ...result })
|
||||
continue
|
||||
}
|
||||
const existingRes = out.find((added, idx) =>
|
||||
(
|
||||
added.accountName === result.accountName &&
|
||||
added.priceCurrency === result.priceCurrency &&
|
||||
added.priceAmount === result.priceAmount
|
||||
) ||
|
||||
(
|
||||
added.accountName === result.accountName &&
|
||||
(out.length - idx) <= 2 // last or prev
|
||||
)
|
||||
)
|
||||
if (existingRes) {
|
||||
if (existingRes.stackSize) {
|
||||
existingRes.stackSize += result.stackSize!
|
||||
} else {
|
||||
existingRes.listedTimes += 1
|
||||
}
|
||||
} else {
|
||||
out.push({ listedTimes: 1, ...result })
|
||||
}
|
||||
}
|
||||
return out
|
||||
})
|
||||
|
||||
async function search (filters: ItemFilters, stats: StatFilter[], item: ParsedItem) {
|
||||
try {
|
||||
searchId += 1
|
||||
@@ -147,6 +182,7 @@ function useTradeApi () {
|
||||
}
|
||||
searchResult.value = _searchResult
|
||||
|
||||
// first two req are parallel, then sequential on demand
|
||||
{
|
||||
const r1 = (_searchResult.result.length > 0)
|
||||
? requestResults(_searchResult.id, _searchResult.result.slice(0, 10))
|
||||
@@ -159,12 +195,31 @@ function useTradeApi () {
|
||||
: Promise.resolve()
|
||||
await Promise.all([r1, r2])
|
||||
}
|
||||
|
||||
let fetched = 20
|
||||
async function fetchMore (): Promise<void> {
|
||||
if (_searchId !== searchId) return
|
||||
const totalGrouped = groupedResults.value.length
|
||||
const totalNotGrouped = groupedResults.value.reduce((len, res) =>
|
||||
res.listedTimes <= 2 ? len + 1 : len, 0)
|
||||
if (
|
||||
(totalNotGrouped < MIN_NOT_GROUPED || totalGrouped < MIN_GROUPED) &&
|
||||
fetched < _searchResult.total &&
|
||||
fetched < API_FETCH_LIMIT
|
||||
) {
|
||||
await requestResults(_searchResult.id, _searchResult.result.slice(fetched, fetched + 10))
|
||||
.then(results => { _fetchResults.push(...results) })
|
||||
fetched += 10
|
||||
return fetchMore()
|
||||
}
|
||||
}
|
||||
return fetchMore()
|
||||
} catch (err) {
|
||||
error.value = err.message
|
||||
}
|
||||
}
|
||||
|
||||
return { error, searchResult, groupedResults: fetchResults, search }
|
||||
return { error, searchResult, groupedResults, search }
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
|
||||
@@ -166,7 +166,7 @@ interface TradeRequest { /* eslint-disable camelcase */
|
||||
heist_trap_disarmament?: FilterRange
|
||||
}
|
||||
}
|
||||
trade_filters: {
|
||||
trade_filters?: {
|
||||
filters: {
|
||||
collapse?: FilterBoolean
|
||||
indexed?: { option?: string }
|
||||
@@ -227,13 +227,7 @@ export function createTradeRequest (filters: ItemFilters, stats: StatFilter[], i
|
||||
stats: [
|
||||
{ type: 'and', filters: [] }
|
||||
],
|
||||
filters: {
|
||||
trade_filters: {
|
||||
filters: {
|
||||
collapse: { option: 'true' }
|
||||
}
|
||||
}
|
||||
}
|
||||
filters: {}
|
||||
},
|
||||
sort: {
|
||||
price: 'asc'
|
||||
@@ -246,6 +240,9 @@ export function createTradeRequest (filters: ItemFilters, stats: StatFilter[], i
|
||||
if (cfg.chaosPriceThreshold !== 0) {
|
||||
prop.set(query.filters, 'trade_filters.filters.price.min', cfg.chaosPriceThreshold)
|
||||
}
|
||||
if (cfg.collapseListings === 'api') {
|
||||
prop.set(query.filters, 'trade_filters.filters.collapse.option', String(true))
|
||||
}
|
||||
}
|
||||
|
||||
if (filters.trade.listed) {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<ui-radio v-model="config.showSeller" value="account" class="mr-4">{{ t('Account name') }}</ui-radio>
|
||||
<ui-radio v-model="config.showSeller" value="ign">{{ t('Last character name') }}</ui-radio>
|
||||
</div>
|
||||
<div class="mb-4 italic text-gray-500">{{ t('Your items will be highlighted even if it is turned off') }}</div>
|
||||
<div class="mb-4 italic text-gray-500">{{ t('Your items will be highlighted even if this setting is off') }}</div>
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<div class="flex-1 mb-1">{{ t('Fill stat values') }}</div>
|
||||
@@ -42,9 +42,17 @@
|
||||
<ui-radio v-model="config.priceCheckShowCursor" :value="false">{{ t('No') }}</ui-radio>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-2 bg-orange-800 p-2">{{ t('Settings below are a compromise between increasing load on PoE website and convenient price checking / more accurate search.') }}</div>
|
||||
<div class="mb-2">
|
||||
<div class="flex-1 mb-1">{{ t('Extra time to prevent spurious Rate limiting') }}</div>
|
||||
<div class="flex-1 mb-1">{{ t('Show indication on collapsed listings') }}</div>
|
||||
<div class="mb-4 flex">
|
||||
<ui-radio v-model="configWidget.collapseListings" value="api" class="mr-4">{{ t('No') }}</ui-radio>
|
||||
<ui-radio v-model="configWidget.collapseListings" value="app">{{ t('Yes') }}</ui-radio>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-2 border p-2 border-gray-600 border-dashed">
|
||||
<div class="flex-1 mb-1">{{ t('Extra time to prevent spurious Rate limiting') }}</div>
|
||||
<div class="flex">
|
||||
<div class="flex mr-6">
|
||||
<input v-model.number="apiLatencySeconds" class="rounded bg-gray-900 px-1 block w-16 mb-1 font-fontin-regular text-center" />
|
||||
<span class="ml-2">{{ t('seconds') }}</span>
|
||||
@@ -71,6 +79,7 @@ export default defineComponent({
|
||||
return {
|
||||
t,
|
||||
config: computed(() => Config.store),
|
||||
configWidget,
|
||||
searchStatRange: computed<number>({
|
||||
get () {
|
||||
return Config.store.searchStatRange
|
||||
@@ -114,14 +123,16 @@ export default defineComponent({
|
||||
"Account name": "Имя учетной записи",
|
||||
"Show seller": "Показывать продавца",
|
||||
"Last character name": "Имя последнего персонажа",
|
||||
"Your items will be highlighted even if it is turned off": "Ваши предметы будут подсвечены, даже если это отключено",
|
||||
"Your items will be highlighted even if this setting is off": "Ваши предметы будут подсвечены, даже если эта настройка выключена",
|
||||
"Fill stat values": "Заполнять значения свойств",
|
||||
"Exact roll": "Точное значение",
|
||||
"Show memorized cursor position": "Показывать запомненную позицию курсора",
|
||||
"Minimum buyout price": "Минимальная цена выкупа",
|
||||
"Chaos Orbs": "Сфер хаоса",
|
||||
"Extra time to prevent spurious Rate limiting": "Добавочное время для предотвращения ложного срабатывания ограничения на запросы",
|
||||
"seconds": "секунды"
|
||||
"seconds": "секунды",
|
||||
"Settings below are a compromise between increasing load on PoE website and convenient price checking / more accurate search.": "Настройки ниже являются компромиссом между увеличенной нагрузкой на сайт PoE и удобством проверки цен / более точным поиском.",
|
||||
"Show indication on collapsed listings": "Показывать индикацию на сгруппированных результатах"
|
||||
}
|
||||
}
|
||||
</i18n>
|
||||
|
||||
Reference in New Issue
Block a user