更新
This commit is contained in:
parent
d788227ae4
commit
d30e4f0d96
@ -5,6 +5,14 @@
|
|||||||
|
|
||||||
# CHANGE
|
# CHANGE
|
||||||
|
|
||||||
|
## 1.0.1
|
||||||
|
|
||||||
|
2023年06月14日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- 公司存取钱
|
||||||
|
|
||||||
## 1.0.0
|
## 1.0.0
|
||||||
|
|
||||||
2023年06月12日
|
2023年06月12日
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wuhu-torn-helper",
|
"name": "wuhu-torn-helper",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"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
@ -7,7 +7,6 @@ import SidebarHelper from "./action/SidebarHelper";
|
|||||||
import CommonUtils from "./utils/CommonUtils";
|
import CommonUtils from "./utils/CommonUtils";
|
||||||
import FetchUtils from "./utils/FetchUtils";
|
import FetchUtils from "./utils/FetchUtils";
|
||||||
import ZhongIcon from "./ZhongIcon";
|
import ZhongIcon from "./ZhongIcon";
|
||||||
import Alert from "./utils/Alert";
|
|
||||||
import FetchEventCallback from "./action/FetchEventCallback";
|
import FetchEventCallback from "./action/FetchEventCallback";
|
||||||
import globVars from "../globVars";
|
import globVars from "../globVars";
|
||||||
import TranslateNew from "./action/TranslateNew";
|
import TranslateNew from "./action/TranslateNew";
|
||||||
@ -20,6 +19,7 @@ import ModuleLoader from "./ModuleLoader";
|
|||||||
import TornPDAUtils from "./utils/TornPDAUtils";
|
import TornPDAUtils from "./utils/TornPDAUtils";
|
||||||
import TravelItem from "./action/TravelItem";
|
import TravelItem from "./action/TravelItem";
|
||||||
import IconHelper from "./IconHelper";
|
import IconHelper from "./IconHelper";
|
||||||
|
import MsgWrapper from "./utils/MsgWrapper";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 脚本不区分页面的通用功能入口
|
* 脚本不区分页面的通用功能入口
|
||||||
@ -38,7 +38,7 @@ export class Common {
|
|||||||
private readonly icon: ZhongIcon,
|
private readonly icon: ZhongIcon,
|
||||||
private readonly fetchUtils: FetchUtils,
|
private readonly fetchUtils: FetchUtils,
|
||||||
private readonly moduleLoader: ModuleLoader,
|
private readonly moduleLoader: ModuleLoader,
|
||||||
// private readonly msgWrapper: MsgWrapper,
|
private readonly msgWrapper: MsgWrapper,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,15 +126,15 @@ export class Common {
|
|||||||
new MutationObserver((mutations, observer) => {
|
new MutationObserver((mutations, observer) => {
|
||||||
if (!this.localConfigWrapper.config.CashChangeAlert) {
|
if (!this.localConfigWrapper.config.CashChangeAlert) {
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
new Alert('现金变动提醒已关闭', { sysNotify: true });
|
this.msgWrapper.create('现金变动提醒已关闭', { sysNotify: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.logger.info("现金变动提醒", mutations);
|
this.logger.info("现金变动提醒", mutations);
|
||||||
mutations.forEach(item => {
|
mutations.forEach(item => {
|
||||||
if (item.attributeName === 'data-money') {
|
if (item.attributeName === 'data-money') {
|
||||||
this.icon.updateCashView(userMoney.innerText);
|
this.icon.updateCashView(userMoney.innerText);
|
||||||
new Alert(
|
this.msgWrapper.create(
|
||||||
'提醒: 现金变动 ' + item.oldValue + ' -> ' + userMoney.innerText,
|
'现金变动 ' + item.oldValue + ' ➡️ ' + userMoney.innerText,
|
||||||
{ sysNotify: true }
|
{ sysNotify: true }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import adHelper from "../func/module/adHelper";
|
|||||||
import safeKeeper from "../func/module/safeKeeper";
|
import safeKeeper from "../func/module/safeKeeper";
|
||||||
import initMiniProf from "../func/utils/initMiniProf";
|
import initMiniProf from "../func/utils/initMiniProf";
|
||||||
import CommonUtils from "./utils/CommonUtils";
|
import CommonUtils from "./utils/CommonUtils";
|
||||||
import Alert from "./utils/Alert";
|
|
||||||
import * as EVENTS from "../../static/json/event.json";
|
import * as EVENTS from "../../static/json/event.json";
|
||||||
import * as FEST from "../../static/json/fest.json";
|
import * as FEST from "../../static/json/fest.json";
|
||||||
import Popup from "./utils/Popup";
|
import Popup from "./utils/Popup";
|
||||||
@ -28,6 +27,7 @@ import { Container } from "../container/Container";
|
|||||||
import TornPDAUtils from "./utils/TornPDAUtils";
|
import TornPDAUtils from "./utils/TornPDAUtils";
|
||||||
import InfoUtils from "./utils/InfoUtils";
|
import InfoUtils from "./utils/InfoUtils";
|
||||||
import globVars from "../globVars";
|
import globVars from "../globVars";
|
||||||
|
import MsgWrapper from "./utils/MsgWrapper";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('ZhongIcon')
|
@ClassName('ZhongIcon')
|
||||||
@ -44,6 +44,7 @@ export default class ZhongIcon {
|
|||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
private readonly tornPDAUtils: TornPDAUtils,
|
private readonly tornPDAUtils: TornPDAUtils,
|
||||||
private readonly infoUtils: InfoUtils,
|
private readonly infoUtils: InfoUtils,
|
||||||
|
private readonly msgWrapper: MsgWrapper,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +134,7 @@ export default class ZhongIcon {
|
|||||||
textarea_node.remove();
|
textarea_node.remove();
|
||||||
target.innerHTML = '已复制';
|
target.innerHTML = '已复制';
|
||||||
target.onclick = null;
|
target.onclick = null;
|
||||||
new Alert('脚本已复制,请前往粘贴');
|
this.msgWrapper.create('脚本已复制,请前往粘贴');
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import InfoUtils from "../utils/InfoUtils";
|
import InfoUtils from "../utils/InfoUtils";
|
||||||
import Alert from "../utils/Alert";
|
|
||||||
import MathUtils from "../utils/MathUtils";
|
import MathUtils from "../utils/MathUtils";
|
||||||
import NOTIFY_HTML from "../../../static/html/buyBeer/notify.html";
|
import NOTIFY_HTML from "../../../static/html/buyBeer/notify.html";
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
@ -9,6 +8,7 @@ import LocalConfigWrapper from "../LocalConfigWrapper";
|
|||||||
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 MsgWrapper from "../utils/MsgWrapper";
|
||||||
|
|
||||||
@ClassName('BuyBeerHelper')
|
@ClassName('BuyBeerHelper')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -25,6 +25,7 @@ export default class BuyBeerHelper implements BeerMonitorLoop, ResponseInject {
|
|||||||
private readonly infoUtils: InfoUtils,
|
private readonly infoUtils: InfoUtils,
|
||||||
private readonly mathUtils: MathUtils,
|
private readonly mathUtils: MathUtils,
|
||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
|
private readonly msgWrapper: MsgWrapper,
|
||||||
) {
|
) {
|
||||||
this.time = this.localConfigWrapper.config._15AlarmTime || 30;
|
this.time = this.localConfigWrapper.config._15AlarmTime || 30;
|
||||||
}
|
}
|
||||||
@ -60,16 +61,18 @@ export default class BuyBeerHelper implements BeerMonitorLoop, ResponseInject {
|
|||||||
if (this.isNotifying) return;
|
if (this.isNotifying) return;
|
||||||
this.isNotifying = true;
|
this.isNotifying = true;
|
||||||
// 发送通知
|
// 发送通知
|
||||||
const notify = new Alert(this.notifyHtml, {
|
const rNum = this.mathUtils.getRandomInt(0, 99);
|
||||||
|
// const notify =
|
||||||
|
this.msgWrapper.create(NOTIFY_HTML.replace('{{}}', rNum.toString()), {
|
||||||
timeout: 30,
|
timeout: 30,
|
||||||
sysNotify: true,
|
sysNotify: true,
|
||||||
});
|
});
|
||||||
notify.getElement().querySelector('.wh-notify-msg button').addEventListener('click', () => this.skip_today());
|
document.querySelector('button#wh-rd-btn-' + rNum).addEventListener('click', () => this.skip_today());
|
||||||
notify.getElement().addEventListener('click', ev => {
|
// notify.getElement().addEventListener('click', ev => {
|
||||||
if ((ev.target as HTMLElement).tagName.toLowerCase() === 'a') {
|
// if ((ev.target as HTMLElement).tagName.toLowerCase() === 'a') {
|
||||||
notify.close();
|
// notify.close();
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
// 声音提醒
|
// 声音提醒
|
||||||
{
|
{
|
||||||
let loop = 3;
|
let loop = 3;
|
||||||
@ -110,9 +113,10 @@ export default class BuyBeerHelper implements BeerMonitorLoop, ResponseInject {
|
|||||||
this.localConfigWrapper.config._15_alarm_ignore = [date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()];
|
this.localConfigWrapper.config._15_alarm_ignore = [date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()];
|
||||||
// WuhuConfig.set('_15_alarm_ignore', [date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()], false);
|
// WuhuConfig.set('_15_alarm_ignore', [date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()], false);
|
||||||
// 通知
|
// 通知
|
||||||
const notify = new Alert(`明早8点前将不再提醒 <button id="wh-rd-btn-${ this.mathUtils.getRandomInt(0, 100) }">取消</button>`);
|
const rNumber = this.mathUtils.getRandomInt(0, 100);
|
||||||
|
const notify = this.msgWrapper.create(`明早8点前将不再提醒 <button id="wh-rd-btn-${ rNumber }">取消</button>`);
|
||||||
// 通知中的取消按钮
|
// 通知中的取消按钮
|
||||||
notify.getElement().querySelector('.wh-notify-msg button')
|
document.querySelector('#wh-rd-btn-' + rNumber)
|
||||||
.addEventListener(
|
.addEventListener(
|
||||||
'click',
|
'click',
|
||||||
() => this.localConfigWrapper.config._15_alarm_ignore.length = 0
|
() => this.localConfigWrapper.config._15_alarm_ignore.length = 0
|
||||||
@ -139,11 +143,14 @@ export default class BuyBeerHelper implements BeerMonitorLoop, ResponseInject {
|
|||||||
popup.element.appendChild(confirm);
|
popup.element.appendChild(confirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public responseHandler(url: string, body: { json: unknown; text: string; isModified: boolean }, opt: { method: "GET" | "POST"; requestBody: string }) {
|
public responseHandler(url: string, body: { json: unknown; text: string; isModified: boolean }, opt: {
|
||||||
|
method: "GET" | "POST";
|
||||||
|
requestBody: string
|
||||||
|
}) {
|
||||||
if (url.includes('shops.php') && opt?.method === 'POST') {
|
if (url.includes('shops.php') && opt?.method === 'POST') {
|
||||||
let req = opt.requestBody;
|
let req = opt.requestBody;
|
||||||
if (req && req.includes('step=buyShopItem') && req.includes('ID=180') && body.json && body.json['success']) {
|
if (req && req.includes('step=buyShopItem') && req.includes('ID=180') && body.json && body.json['success']) {
|
||||||
new Alert('检测到已成功购买啤酒');
|
this.msgWrapper.create('检测到已成功购买啤酒');
|
||||||
this.skip_today();
|
this.skip_today();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import FetchUtils from "../utils/FetchUtils";
|
import FetchUtils from "../utils/FetchUtils";
|
||||||
import InfoUtils from "../utils/InfoUtils";
|
import InfoUtils from "../utils/InfoUtils";
|
||||||
import Alert from "../utils/Alert";
|
|
||||||
import TRAVEL_STATE from "../../enum/TravelState";
|
import TRAVEL_STATE from "../../enum/TravelState";
|
||||||
import LocalConfigWrapper from "../LocalConfigWrapper";
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import Logger from "../Logger";
|
import Logger from "../Logger";
|
||||||
|
import MsgWrapper from "../utils/MsgWrapper";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公司助手
|
* 公司助手
|
||||||
@ -22,6 +22,7 @@ export default class CompanyHelper {
|
|||||||
private readonly fetchUtils: FetchUtils,
|
private readonly fetchUtils: FetchUtils,
|
||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
private readonly infoUtils: InfoUtils,
|
private readonly infoUtils: InfoUtils,
|
||||||
|
private readonly msgWrapper: MsgWrapper,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +77,7 @@ export default class CompanyHelper {
|
|||||||
this.logger.info('火车检测: 火车/星级: ' + trains + '/' + stars);
|
this.logger.info('火车检测: 火车/星级: ' + trains + '/' + stars);
|
||||||
this.logger.info({ tmp });
|
this.logger.info({ tmp });
|
||||||
if (trains + stars > 20) {
|
if (trains + stars > 20) {
|
||||||
new Alert(`公司助手<br/><br/>火车检测:火车明日将溢出!${ trains }/20火车`, {
|
this.msgWrapper.create(`【公司助手】火车检测:火车明日将溢出!${ trains }/20火车`, {
|
||||||
timeout: 15,
|
timeout: 15,
|
||||||
force: true,
|
force: true,
|
||||||
sysNotify: true
|
sysNotify: true
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import titleTrans from "../translate/titleTrans";
|
import titleTrans from "../translate/titleTrans";
|
||||||
import contentTitleLinksTrans from "../translate/contentTitleLinksTrans";
|
import contentTitleLinksTrans from "../translate/contentTitleLinksTrans";
|
||||||
import Device from "../../enum/Device";
|
import Device from "../../enum/Device";
|
||||||
import Alert from "../../class/utils/Alert";
|
|
||||||
import ActionButtonUtils from "../../class/utils/ActionButtonUtils";
|
import ActionButtonUtils from "../../class/utils/ActionButtonUtils";
|
||||||
import CommonUtils from "../../class/utils/CommonUtils";
|
import CommonUtils from "../../class/utils/CommonUtils";
|
||||||
import TRAVEL_ALARM_CSS from "../../../static/css/travel_alarm.module.css";
|
import TRAVEL_ALARM_CSS from "../../../static/css/travel_alarm.module.css";
|
||||||
@ -13,37 +12,7 @@ import Global from "../../class/Global";
|
|||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
import LocalConfigWrapper from "../../class/LocalConfigWrapper";
|
import LocalConfigWrapper from "../../class/LocalConfigWrapper";
|
||||||
|
import MsgWrapper from "../../class/utils/MsgWrapper";
|
||||||
// async function travelHelper(): Promise<void> {
|
|
||||||
// let global = Container.factory(Global);
|
|
||||||
// let commonUtils = Container.factory(CommonUtils);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// async function travelBack(): Promise<null> {
|
|
||||||
// if (typeof window['getAction'] !== 'function') return;
|
|
||||||
// let backHomeAction = function (): Promise<string> {
|
|
||||||
// return new Promise(resolve => {
|
|
||||||
// window.getAction({
|
|
||||||
// type: "post",
|
|
||||||
// action: 'travelagency.php',
|
|
||||||
// data: {
|
|
||||||
// step: 'backHomeAction'
|
|
||||||
// },
|
|
||||||
// success: function (msg) {
|
|
||||||
// resolve(msg);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
// let res = await backHomeAction();
|
|
||||||
// new Alert(res);
|
|
||||||
// if (!res.includes('error')) {
|
|
||||||
// new Alert('成功,即将刷新');
|
|
||||||
// window.setTimeout(() => location.reload(), 3000);
|
|
||||||
// } else {
|
|
||||||
// new Alert('出错了');
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 飞行助手
|
* 飞行助手
|
||||||
@ -61,6 +30,7 @@ export default class TravelHelper {
|
|||||||
private readonly commonUtils: CommonUtils,
|
private readonly commonUtils: CommonUtils,
|
||||||
private readonly actionButtonUtils: ActionButtonUtils,
|
private readonly actionButtonUtils: ActionButtonUtils,
|
||||||
private readonly localConfigWrapper: LocalConfigWrapper,
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly msgWrapper: MsgWrapper,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,10 +103,6 @@ export default class TravelHelper {
|
|||||||
const set_node = wh_trv_alarm_node.querySelectorAll('#wh-trv-alarm-cont button')[0] as HTMLButtonElement;
|
const set_node = wh_trv_alarm_node.querySelectorAll('#wh-trv-alarm-cont button')[0] as HTMLButtonElement;
|
||||||
// 落地前响铃时长
|
// 落地前响铃时长
|
||||||
const cd_time = wh_trv_alarm_node.querySelector('input[type="number"]') as HTMLInputElement;
|
const cd_time = wh_trv_alarm_node.querySelector('input[type="number"]') as HTMLInputElement;
|
||||||
let count_down_notify: MyHTMLElement | { close: Function } = {
|
|
||||||
close: () => {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
set_node.onclick = () => {
|
set_node.onclick = () => {
|
||||||
try {
|
try {
|
||||||
wh_trv_alarm.alert_time = parseInt(cd_time.value);
|
wh_trv_alarm.alert_time = parseInt(cd_time.value);
|
||||||
@ -145,8 +111,7 @@ export default class TravelHelper {
|
|||||||
}
|
}
|
||||||
save_trv_settings();
|
save_trv_settings();
|
||||||
set_node.value = wh_trv_alarm.alert_time;
|
set_node.value = wh_trv_alarm.alert_time;
|
||||||
count_down_notify.close();
|
this.msgWrapper.create('设置已更新');
|
||||||
count_down_notify = new Alert('设置已更新');
|
|
||||||
};
|
};
|
||||||
// 停止响铃按钮
|
// 停止响铃按钮
|
||||||
const stop_node = wh_trv_alarm_node.querySelectorAll('#wh-trv-alarm-cont button')[1] as HTMLButtonElement;
|
const stop_node = wh_trv_alarm_node.querySelectorAll('#wh-trv-alarm-cont button')[1] as HTMLButtonElement;
|
||||||
@ -157,15 +122,10 @@ export default class TravelHelper {
|
|||||||
}
|
}
|
||||||
// 开启闹钟勾选
|
// 开启闹钟勾选
|
||||||
const enable_node = wh_trv_alarm_node.querySelector('#wh-trv-alarm-cont input[type="checkbox"]') as HTMLInputElement;
|
const enable_node = wh_trv_alarm_node.querySelector('#wh-trv-alarm-cont input[type="checkbox"]') as HTMLInputElement;
|
||||||
let on_off_notify: MyHTMLElement | { close: Function } = {
|
|
||||||
close: () => {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
enable_node.onchange = ev => {
|
enable_node.onchange = ev => {
|
||||||
wh_trv_alarm.enable = (<HTMLInputElement>ev.target).checked;
|
wh_trv_alarm.enable = (<HTMLInputElement>ev.target).checked;
|
||||||
save_trv_settings();
|
save_trv_settings();
|
||||||
on_off_notify.close();
|
this.msgWrapper.create(wh_trv_alarm.enable ? '闹钟已开启' : '闹钟已关闭');
|
||||||
on_off_notify = new Alert(wh_trv_alarm.enable ? '闹钟已开启' : '闹钟已关闭');
|
|
||||||
};
|
};
|
||||||
// 剩余时间 秒
|
// 剩余时间 秒
|
||||||
const remaining_sec = parseInt(remaining_arr);
|
const remaining_sec = parseInt(remaining_arr);
|
||||||
@ -260,7 +220,7 @@ export default class TravelHelper {
|
|||||||
// 海外警告
|
// 海外警告
|
||||||
if (this.localConfigWrapper.config.abroadWarning) {
|
if (this.localConfigWrapper.config.abroadWarning) {
|
||||||
let c = 1;
|
let c = 1;
|
||||||
setInterval(() => new Alert(`警告:您已海外落地${ c++ * 30 }秒`, {
|
setInterval(() => this.msgWrapper.create(`警告:您已海外落地${ c++ * 30 }秒`, {
|
||||||
timeout: 30,
|
timeout: 30,
|
||||||
sysNotify: true
|
sysNotify: true
|
||||||
}), 30000);
|
}), 30000);
|
||||||
@ -365,12 +325,12 @@ export default class TravelHelper {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
let res = await backHomeAction();
|
let res = await backHomeAction();
|
||||||
new Alert(res);
|
this.msgWrapper.create(res);
|
||||||
if (!res.includes('error')) {
|
if (!res.includes('error')) {
|
||||||
new Alert('成功,即将刷新');
|
this.msgWrapper.create('成功,即将刷新');
|
||||||
window.setTimeout(() => location.reload(), 3000);
|
window.setTimeout(() => location.reload(), 3000);
|
||||||
} else {
|
} else {
|
||||||
new Alert('出错了');
|
this.msgWrapper.create('出错了');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
24
src/ts/func/utils/fetchCurrentMoney.ts
Normal file
24
src/ts/func/utils/fetchCurrentMoney.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
const init: RequestInit = {
|
||||||
|
"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/companies.php",
|
||||||
|
"referrerPolicy": "strict-origin-when-cross-origin",
|
||||||
|
"body": null,
|
||||||
|
"method": "GET",
|
||||||
|
"mode": "cors",
|
||||||
|
"credentials": "include"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const fetchCurrentMoney = async (action?: string): Promise<number> => {
|
||||||
|
return Number(await (await fetch(window.addRFC("/inputMoneyAction.php?step=" + (action ? action : "generalAction")), init)).text());
|
||||||
|
};
|
||||||
|
|
||||||
|
export const fetchCurrentCompanyAvailableMoney = () => {
|
||||||
|
return fetchCurrentMoney("companyAction");
|
||||||
|
};
|
||||||
@ -1,21 +0,0 @@
|
|||||||
import { isRef, onMounted, onUnmounted, Ref } from 'vue'
|
|
||||||
|
|
||||||
// https://cn.vuejs.org/guide/reusability/composables.html#mouse-tracker-example
|
|
||||||
export function useEventListener(target: HTMLElement | Ref<HTMLElement>, event: string, callback: (ev: Event) => void) {
|
|
||||||
// 如果你想的话,
|
|
||||||
// 也可以用字符串形式的 CSS 选择器来寻找目标 DOM 元素
|
|
||||||
onMounted(() => {
|
|
||||||
if (isRef(target)) {
|
|
||||||
target.value.addEventListener(event, callback)
|
|
||||||
} else {
|
|
||||||
target.addEventListener(event, callback)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
onUnmounted(() => {
|
|
||||||
if (isRef(target)) {
|
|
||||||
target.value.removeEventListener(event, callback)
|
|
||||||
} else {
|
|
||||||
target.removeEventListener(event, callback)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
107
src/vue/CompanyWithdraw.vue
Normal file
107
src/vue/CompanyWithdraw.vue
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
|
||||||
|
import { inject, onMounted, ref } from "vue";
|
||||||
|
import toThousands from "../ts/func/utils/toThousands";
|
||||||
|
import { fetchCurrentCompanyAvailableMoney, fetchCurrentMoney } from "../ts/func/utils/fetchCurrentMoney";
|
||||||
|
import { ElMessage } from "element-plus";
|
||||||
|
import { LoggerKey } from "../ts/class/Logger";
|
||||||
|
|
||||||
|
const logger = inject(LoggerKey);
|
||||||
|
|
||||||
|
const inputMoney = ref('');
|
||||||
|
const inputWithdrawMoney = ref('');
|
||||||
|
const formModel = ref({
|
||||||
|
cash: 0, company: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
const updateCash = async () => {
|
||||||
|
formModel.value.cash = await fetchCurrentMoney();
|
||||||
|
return formModel.value.cash;
|
||||||
|
};
|
||||||
|
const updateCompany = async () => {
|
||||||
|
formModel.value.company = await fetchCurrentCompanyAvailableMoney();
|
||||||
|
return formModel.value.company;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存取钱通用
|
||||||
|
* @param amount
|
||||||
|
* @param action {'deposit' | 'withdraw'}
|
||||||
|
*/
|
||||||
|
const deposit = async (amount: number, action: 'deposit' | 'withdraw' = 'deposit') => {
|
||||||
|
if (amount < 1) {
|
||||||
|
ElMessage.error('数额不能小于1');
|
||||||
|
logger.error('数额不能小于1');
|
||||||
|
throw new Error('数额不能小于1');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await fetch(window.addRFC("https://www.torn.com/companies.php?step=funds"), {
|
||||||
|
"headers": {
|
||||||
|
"accept": "*/*",
|
||||||
|
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||||
|
"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/companies.php",
|
||||||
|
"referrerPolicy": "strict-origin-when-cross-origin",
|
||||||
|
"body": action + "=" + amount,
|
||||||
|
"method": "POST",
|
||||||
|
"mode": "cors",
|
||||||
|
"credentials": "include"
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
ElMessage.error('请求出错 ' + e.message);
|
||||||
|
logger.error(e.stack);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
ElMessage.success('$' + toThousands(amount) + ' 存取请求完成');
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
updateCompany();
|
||||||
|
updateCash();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<el-form
|
||||||
|
:model="formModel"
|
||||||
|
label-position="top"
|
||||||
|
>
|
||||||
|
<el-form-item :label="'现金 $' + toThousands(formModel.cash)">
|
||||||
|
<el-input
|
||||||
|
v-model="inputWithdrawMoney"
|
||||||
|
:formatter="toThousands"
|
||||||
|
:parser="(value) => value.replaceAll(',', '')"
|
||||||
|
>
|
||||||
|
<template #prepend>
|
||||||
|
<el-button @click="async () => inputWithdrawMoney = toThousands(await updateCash())">$</el-button>
|
||||||
|
</template>
|
||||||
|
<template #append>
|
||||||
|
<el-button @click="deposit(Number(inputWithdrawMoney.replaceAll(',', '')), 'withdraw')">取出</el-button>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="'公司可用余额 $' + toThousands(formModel.company)">
|
||||||
|
<el-input
|
||||||
|
v-model="inputMoney"
|
||||||
|
:formatter="toThousands"
|
||||||
|
:parser="(value) => value.replaceAll(',', '')"
|
||||||
|
>
|
||||||
|
<template #prepend>
|
||||||
|
<el-button @click="async () => inputMoney = toThousands(await updateCompany())">$</el-button>
|
||||||
|
</template>
|
||||||
|
<template #append>
|
||||||
|
<el-button @click="deposit(Number(inputMoney.replaceAll(',', '')))">存入</el-button>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
@ -1,16 +1,20 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-config-provider :size="'default'" :z-index="1000000">
|
<el-config-provider :size="'default'" :z-index="1000000">
|
||||||
<el-dropdown :hide-on-click="false" size="small" style="z-index: 1000000;user-select: none" trigger="click">
|
<el-dropdown
|
||||||
<el-button circle class="wh-menu-button">
|
:hide-on-click="false"
|
||||||
<el-icon>
|
:max-height="(documentHeight * 0.8 | 0) + 'px'" size="small" style="z-index: 1000000;user-select: none"
|
||||||
<MoonNight/>
|
trigger="click"
|
||||||
</el-icon>
|
>
|
||||||
</el-button>
|
<el-button circle class="wh-menu-button">
|
||||||
<template #dropdown>
|
<el-icon>
|
||||||
<el-dropdown-menu>
|
<MoonNight/>
|
||||||
<el-dropdown-item>芜湖助手</el-dropdown-item>
|
</el-icon>
|
||||||
<el-dropdown-item divided>
|
</el-button>
|
||||||
<el-dropdown placement="bottom-end" size="small" style="width: 100%" trigger="click">
|
<template #dropdown>
|
||||||
|
<el-dropdown-menu>
|
||||||
|
<el-dropdown-item>芜湖助手</el-dropdown-item>
|
||||||
|
<el-dropdown-item divided>
|
||||||
|
<el-dropdown placement="bottom-end" size="small" style="width: 100%" trigger="click">
|
||||||
<el-button link size="small" style="width: 100%;text-align: left;">💪 快速锻炼 ></el-button>
|
<el-button link size="small" style="width: 100%;text-align: left;">💪 快速锻炼 ></el-button>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-item @click="quickGymTrain.doTrain(BATTLE_STAT.STR)">力量
|
<el-dropdown-item @click="quickGymTrain.doTrain(BATTLE_STAT.STR)">力量
|
||||||
@ -91,6 +95,7 @@ import MarketHelper from "./MarketHelper.vue";
|
|||||||
import PTMarketView from "./PTMarketView.vue";
|
import PTMarketView from "./PTMarketView.vue";
|
||||||
import QuickCrime from "./QuickCrime.vue";
|
import QuickCrime from "./QuickCrime.vue";
|
||||||
import VirusProgramming from "./VirusProgramming.vue";
|
import VirusProgramming from "./VirusProgramming.vue";
|
||||||
|
import CompanyWithdraw from "./CompanyWithdraw.vue";
|
||||||
|
|
||||||
const logger = inject(LoggerKey);
|
const logger = inject(LoggerKey);
|
||||||
const quickGymTrain = inject(QuickGymTrainKey);
|
const quickGymTrain = inject(QuickGymTrainKey);
|
||||||
@ -196,6 +201,10 @@ const menuItemList = [
|
|||||||
title: '🅿️ PT购买',
|
title: '🅿️ PT购买',
|
||||||
template: PTMarketView,
|
template: PTMarketView,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '💰 公司存钱',
|
||||||
|
template: CompanyWithdraw,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '⚙️ 插件配置',
|
title: '⚙️ 插件配置',
|
||||||
template: Config,
|
template: Config,
|
||||||
@ -205,6 +214,7 @@ const drawer = ref(false);
|
|||||||
const drawerTitle = ref('');
|
const drawerTitle = ref('');
|
||||||
const drawerContent = shallowRef(null);
|
const drawerContent = shallowRef(null);
|
||||||
const isMobilePhone = ref(false);
|
const isMobilePhone = ref(false);
|
||||||
|
const documentHeight = ref(0);
|
||||||
|
|
||||||
// fast travel
|
// fast travel
|
||||||
const travelData = [
|
const travelData = [
|
||||||
@ -311,15 +321,10 @@ onMounted(() => {
|
|||||||
if (document.documentElement.scrollWidth < 800) {
|
if (document.documentElement.scrollWidth < 800) {
|
||||||
isMobilePhone.value = true;
|
isMobilePhone.value = true;
|
||||||
}
|
}
|
||||||
|
documentHeight.value = document.documentElement.scrollHeight;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
export default {
|
|
||||||
name: 'FloatMenu',
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.wh-menu-button {
|
.wh-menu-button {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user