更新
This commit is contained in:
parent
0e5e3180c9
commit
75834b5cef
@ -5,6 +5,14 @@
|
|||||||
|
|
||||||
# CHANGE
|
# CHANGE
|
||||||
|
|
||||||
|
## 0.9.3
|
||||||
|
|
||||||
|
2023年05月30日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- 快速查看地图垃圾
|
||||||
|
|
||||||
## 0.9.2
|
## 0.9.2
|
||||||
|
|
||||||
2023年05月26日
|
2023年05月26日
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wuhu-torn-helper",
|
"name": "wuhu-torn-helper",
|
||||||
"version": "0.9.2",
|
"version": "0.9.3",
|
||||||
"description": "芜湖助手",
|
"description": "芜湖助手",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"release": "cross-env NODE_ENV=production rollup -c && node build.mjs",
|
"release": "cross-env NODE_ENV=production rollup -c && node build.mjs",
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -12,6 +12,7 @@ import InfoUtils from "./utils/InfoUtils";
|
|||||||
import TravelItem, { TravelItemKey } from "./action/TravelItem";
|
import TravelItem, { TravelItemKey } from "./action/TravelItem";
|
||||||
import QuickGymTrain, { QuickGymTrainKey } from "./action/QuickGymTrain";
|
import QuickGymTrain, { QuickGymTrainKey } from "./action/QuickGymTrain";
|
||||||
import QuickFlyBtnHandler, { QuickFlyBtnHandlerKey } from "./handler/QuickFlyBtnHandler";
|
import QuickFlyBtnHandler, { QuickFlyBtnHandlerKey } from "./handler/QuickFlyBtnHandler";
|
||||||
|
import ItemHelper, { ItemHelperKey } from "./utils/ItemHelper";
|
||||||
|
|
||||||
@ClassName("IconHelper")
|
@ClassName("IconHelper")
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -20,7 +21,6 @@ export default class IconHelper {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
// private readonly global: Global,
|
|
||||||
private readonly commonUtils: CommonUtils,
|
private readonly commonUtils: CommonUtils,
|
||||||
private readonly localConfigWrapper: LocalConfigWrapper,
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
private readonly nnb: NNB,
|
private readonly nnb: NNB,
|
||||||
@ -30,6 +30,7 @@ export default class IconHelper {
|
|||||||
private readonly travelItem: TravelItem,
|
private readonly travelItem: TravelItem,
|
||||||
private readonly quickGymTrain: QuickGymTrain,
|
private readonly quickGymTrain: QuickGymTrain,
|
||||||
private readonly quickFlyBtnHandler: QuickFlyBtnHandler,
|
private readonly quickFlyBtnHandler: QuickFlyBtnHandler,
|
||||||
|
private readonly itemHelper: ItemHelper,
|
||||||
) {
|
) {
|
||||||
this._element = document.createElement('div');
|
this._element = document.createElement('div');
|
||||||
}
|
}
|
||||||
@ -51,6 +52,7 @@ export default class IconHelper {
|
|||||||
app.provide(LocalConfigWrapperKey, this.localConfigWrapper);
|
app.provide(LocalConfigWrapperKey, this.localConfigWrapper);
|
||||||
app.provide(QuickGymTrainKey, this.quickGymTrain);
|
app.provide(QuickGymTrainKey, this.quickGymTrain);
|
||||||
app.provide(QuickFlyBtnHandlerKey, this.quickFlyBtnHandler);
|
app.provide(QuickFlyBtnHandlerKey, this.quickFlyBtnHandler);
|
||||||
|
app.provide(ItemHelperKey, this.itemHelper);
|
||||||
app.mount(this._element);
|
app.mount(this._element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -212,6 +212,10 @@ export default class CommonUtils {
|
|||||||
return CommonUtils.elementReady(selectors, content, timeout);
|
return CommonUtils.elementReady(selectors, content, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public querySelector(selectors: string, content: Document = document, timeout: number = 30000): Promise<HTMLElement> {
|
||||||
|
return CommonUtils.elementReady(selectors, content, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
public static addStyle(rules: string): void {
|
public static addStyle(rules: string): void {
|
||||||
const logger = Container.factory(Logger);
|
const logger = Container.factory(Logger);
|
||||||
let element = document.querySelector('style#wh-trans-gStyle');
|
let element = document.querySelector('style#wh-trans-gStyle');
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import Asyncable from "../../interface/Asyncable";
|
|||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
import Logger from "../Logger";
|
import Logger from "../Logger";
|
||||||
|
import { InjectionKey } from "vue";
|
||||||
|
|
||||||
@ClassName('ItemHelper')
|
@ClassName('ItemHelper')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -82,7 +83,7 @@ export default class ItemHelper {
|
|||||||
* 物品查价值
|
* 物品查价值
|
||||||
*/
|
*/
|
||||||
public async getItemValue(idOrName) {
|
public async getItemValue(idOrName) {
|
||||||
return (await this.getItemData(idOrName)).itemValue.replaceAll(/[,$]/, '');
|
return (await this.getItemData(idOrName)).itemValue.replaceAll(/[,$]/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 返回本地物品价格数据,id对应物品名和价格 */
|
/** 返回本地物品价格数据,id对应物品名和价格 */
|
||||||
@ -174,3 +175,5 @@ export default class ItemHelper {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const ItemHelperKey = Symbol('ItemHelperKey') as InjectionKey<ItemHelper>;
|
||||||
|
|||||||
@ -10,7 +10,9 @@ import { Container } from "../../container/Container";
|
|||||||
* @param _base
|
* @param _base
|
||||||
*/
|
*/
|
||||||
export default function cityFinder(_base: TornStyleBlock): void {
|
export default function cityFinder(_base: TornStyleBlock): void {
|
||||||
Container.factory(CommonUtils).styleInject(CITY_FINDER_CSS);
|
let commonUtils: CommonUtils = Container.factory(CommonUtils);
|
||||||
|
commonUtils.styleInject(CITY_FINDER_CSS);
|
||||||
|
let itemHelper: ItemHelper = Container.factory(ItemHelper);
|
||||||
// 物品名与价格
|
// 物品名与价格
|
||||||
let items: {
|
let items: {
|
||||||
[k: number]: {
|
[k: number]: {
|
||||||
@ -28,8 +30,7 @@ export default function cityFinder(_base: TornStyleBlock): void {
|
|||||||
_base.append(header, info);
|
_base.append(header, info);
|
||||||
document.body.classList.add('wh-city-finds');
|
document.body.classList.add('wh-city-finds');
|
||||||
|
|
||||||
let itemHelper = Container.factory(ItemHelper);
|
commonUtils.querySelector('div.leaflet-marker-pane').then(elem => {
|
||||||
CommonUtils.elementReady('div.leaflet-marker-pane').then(elem => {
|
|
||||||
|
|
||||||
// 发现的物品id与map img node
|
// 发现的物品id与map img node
|
||||||
const founds = [];
|
const founds = [];
|
||||||
|
|||||||
116
src/vue/CityUItems.vue
Normal file
116
src/vue/CityUItems.vue
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
name: "CityUItems"
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { inject, onMounted, Ref, ref } from "vue";
|
||||||
|
import { LoggerKey } from "../ts/class/Logger";
|
||||||
|
import { ItemHelperKey } from "../ts/class/utils/ItemHelper";
|
||||||
|
import { itemNameDict } from "../ts/dictionary/translation";
|
||||||
|
import type { TableColumnCtx } from 'element-plus';
|
||||||
|
import toThousands from "../ts/func/utils/toThousands";
|
||||||
|
|
||||||
|
const logger = inject(LoggerKey);
|
||||||
|
const itemHelper = inject(ItemHelperKey);
|
||||||
|
|
||||||
|
const doFetch = () => fetch(window.addRFC("https://www.torn.com/city.php?step=mapData"), {
|
||||||
|
"headers": {
|
||||||
|
"accept": "*/*",
|
||||||
|
"sec-ch-ua-mobile": "?0",
|
||||||
|
"sec-fetch-dest": "empty",
|
||||||
|
"sec-fetch-mode": "cors",
|
||||||
|
"sec-fetch-site": "same-origin",
|
||||||
|
"x-requested-with": "XMLHttpRequest"
|
||||||
|
},
|
||||||
|
"referrer": "https://www.torn.com/city.php",
|
||||||
|
"referrerPolicy": "strict-origin-when-cross-origin",
|
||||||
|
"body": null,
|
||||||
|
"method": "GET",
|
||||||
|
"mode": "cors",
|
||||||
|
"credentials": "include"
|
||||||
|
});
|
||||||
|
const ret: Ref<{ title: string, price: number, id: number }[]> = ref(null);
|
||||||
|
const msg = ref("");
|
||||||
|
const total = ref(0);
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
let _ret: { territoryUserItems?: string, error?: string } = {};
|
||||||
|
try {
|
||||||
|
_ret = await (await doFetch()).json();
|
||||||
|
if (_ret.territoryUserItems) {
|
||||||
|
// 地图垃圾列表
|
||||||
|
let itemList: { title: string }[] = JSON.parse(window.atob(_ret.territoryUserItems));
|
||||||
|
// 加入id和价格信息
|
||||||
|
// 物品id map
|
||||||
|
let itemNameMap = itemHelper.getItemNameMap();
|
||||||
|
// 物品价格
|
||||||
|
let itemPrice = itemHelper.getLocalPriceData();
|
||||||
|
let tmp = [];
|
||||||
|
for (const item of itemList) {
|
||||||
|
let itemInfo: { title: string, price: number, id: number } = {
|
||||||
|
title: item.title,
|
||||||
|
price: null,
|
||||||
|
id: null,
|
||||||
|
};
|
||||||
|
// 加入译名
|
||||||
|
if (itemNameDict[item.title]) {
|
||||||
|
itemInfo.title += `(${ itemNameDict[item.title] })`;
|
||||||
|
}
|
||||||
|
// 物品转id
|
||||||
|
if (itemNameMap.data) {
|
||||||
|
itemInfo.id = itemNameMap.data[item.title];
|
||||||
|
} else {
|
||||||
|
itemInfo.id = (await itemNameMap.promise)[item.title];
|
||||||
|
}
|
||||||
|
// 价格
|
||||||
|
if (itemPrice.data) {
|
||||||
|
itemInfo.price = itemPrice.data[itemInfo.id].price;
|
||||||
|
} else {
|
||||||
|
itemInfo.price = (await itemPrice.promise)[itemInfo.id].price;
|
||||||
|
}
|
||||||
|
total.value += itemInfo.price;
|
||||||
|
tmp.push(itemInfo);
|
||||||
|
}
|
||||||
|
ret.value = tmp;
|
||||||
|
} else {
|
||||||
|
ret.value = [];
|
||||||
|
}
|
||||||
|
if (_ret.error) {
|
||||||
|
msg.value = _ret.error;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
logger.error(e.stack);
|
||||||
|
ret.value = [];
|
||||||
|
ret.value.push({ title: '错误' + e.message, price: -1, id: 0 });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div v-loading="!ret">
|
||||||
|
<div v-if="msg" style="color: red">{{ msg }}</div>
|
||||||
|
<el-table v-if="ret" :data="ret" style="width: 100%">
|
||||||
|
<el-table-column label="物品">
|
||||||
|
<template #default="scope">
|
||||||
|
<div>
|
||||||
|
<span :style="{backgroundImage: 'url(/images/items/'+scope.row.id+'/small.png)'}"
|
||||||
|
style="display:inline-block;width:38px;height:19px;"/>
|
||||||
|
<span v-text="scope.row.title"/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="价值(缓)">
|
||||||
|
<template #default="scope">
|
||||||
|
<div v-text="'$'+toThousands(scope.row.price)"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<div>总计 ${{ toThousands(total) }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
@ -87,6 +87,7 @@ import { QuickFlyBtnHandlerKey } from "../ts/class/handler/QuickFlyBtnHandler";
|
|||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
import QuickCrime from "./QuickCrime.vue";
|
import QuickCrime from "./QuickCrime.vue";
|
||||||
import EventsViewer from "./EventsViewer.vue";
|
import EventsViewer from "./EventsViewer.vue";
|
||||||
|
import CityUItems from "./CityUItems.vue";
|
||||||
|
|
||||||
const logger = inject(LoggerKey);
|
const logger = inject(LoggerKey);
|
||||||
const quickGymTrain = inject(QuickGymTrainKey);
|
const quickGymTrain = inject(QuickGymTrainKey);
|
||||||
@ -174,6 +175,10 @@ const menuItemList = [
|
|||||||
title: '📢 浏览通知',
|
title: '📢 浏览通知',
|
||||||
template: EventsViewer,
|
template: EventsViewer,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '🚮 地图垃圾',
|
||||||
|
template: CityUItems,
|
||||||
|
},
|
||||||
// {
|
// {
|
||||||
// title: '🔫 LOOT',
|
// title: '🔫 LOOT',
|
||||||
// template: Test,
|
// template: Test,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user