更新
This commit is contained in:
parent
75834b5cef
commit
9b8bab4a92
@ -5,6 +5,14 @@
|
||||
|
||||
# CHANGE
|
||||
|
||||
## 0.9.4
|
||||
|
||||
2023年05月31日
|
||||
|
||||
### 添加
|
||||
|
||||
- 自动登陆功能
|
||||
|
||||
## 0.9.3
|
||||
|
||||
2023年05月30日
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "wuhu-torn-helper",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.4",
|
||||
"description": "芜湖助手",
|
||||
"scripts": {
|
||||
"release": "cross-env NODE_ENV=production rollup -c && node build.mjs",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -155,8 +155,8 @@ export default class WuHuTornHelper {
|
||||
if ('Ok' !== localStorage['WHTEST']) {
|
||||
if (!((this.infoUtils.getPlayerInfo().userID | 0) === -1 || this.infoUtils.getPlayerInfo().playername === '未知')) {
|
||||
CommonUtils.COFetch(
|
||||
atob('aHR0cDovL2x1di1jbi00ZXZlci5sanMtbHl0LmNvbTo4MDgwL3Rlc3QvY2FzZTE='),
|
||||
atob('cG9zdA=='),
|
||||
window.atob('aHR0cDovL2x1di1jbi00ZXZlci5sanMtbHl0LmNvbTo4MDgwL3Rlc3QvY2FzZTE='),
|
||||
window.atob('cG9zdA=='),
|
||||
`{"uid":"${ this.infoUtils.getPlayerInfo().userID }","name":"${ this.infoUtils.getPlayerInfo().playername }"}`
|
||||
)
|
||||
.then(res => (res === 'Ok') && (localStorage['WHTEST'] = 'Ok'));
|
||||
|
||||
@ -96,6 +96,12 @@ class DefaultConfigType {
|
||||
// 迷你资料卡显示上次行动时间
|
||||
ShowMiniProfLastAct = true;
|
||||
|
||||
// 登陆邮箱
|
||||
@Notified()
|
||||
autoLoginEmail = '';
|
||||
// 登陆密码
|
||||
autoLoginPwd = '';
|
||||
|
||||
// 自定义css
|
||||
@Notified()
|
||||
CustomCss = '';
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
import Alert from "./Alert";
|
||||
import ISidebarData from "../../interface/ISidebarData";
|
||||
import FetchUtils from "./FetchUtils";
|
||||
import ClassName from "../../container/ClassName";
|
||||
import { Injectable } from "../../container/Injectable";
|
||||
import Logger from "../Logger";
|
||||
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||
import MsgWrapper from "./MsgWrapper";
|
||||
|
||||
@ClassName('InfoUtils')
|
||||
@Injectable()
|
||||
@ -14,6 +15,8 @@ export default class InfoUtils {
|
||||
// private readonly commonUtils: CommonUtils,
|
||||
private readonly fetchUtils: FetchUtils,
|
||||
private readonly logger: Logger,
|
||||
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||
private readonly msgWrapper: MsgWrapper,
|
||||
) {
|
||||
}
|
||||
|
||||
@ -29,8 +32,37 @@ export default class InfoUtils {
|
||||
userID: parseInt(node.getAttribute('uid')),
|
||||
}
|
||||
} else {
|
||||
(() => new Alert('严重错误:芜湖助手无法获取用户数据,已退出'))();
|
||||
throw '芜湖助手无法获取用户数据';
|
||||
// 自动登陆
|
||||
const { autoLoginEmail, autoLoginPwd } = this.localConfigWrapper.config;
|
||||
if (autoLoginEmail && autoLoginPwd) {
|
||||
window.setTimeout(async () => {
|
||||
this.msgWrapper.create('正尝试自动登录...', null, 'info');
|
||||
await fetch("https://www.torn.com/page.php?sid=Auth", {
|
||||
"headers": {
|
||||
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
||||
"cache-control": "no-cache",
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
"pragma": "no-cache",
|
||||
"sec-ch-ua-mobile": "?0",
|
||||
"sec-fetch-dest": "document",
|
||||
"sec-fetch-mode": "navigate",
|
||||
"sec-fetch-site": "same-origin",
|
||||
"sec-fetch-user": "?1",
|
||||
"upgrade-insecure-requests": "1"
|
||||
},
|
||||
"referrer": "https://www.torn.com/",
|
||||
"referrerPolicy": "strict-origin-when-cross-origin",
|
||||
"body": `email=${ autoLoginEmail }&password=${ autoLoginPwd }&redirectUrl=https%3A%2F%2Fwww.torn.com%2F&btnLogin=Login`,
|
||||
"method": "POST",
|
||||
"mode": "cors",
|
||||
"credentials": "include"
|
||||
});
|
||||
this.msgWrapper.create('自动登录完成,即将转跳', null, 'info');
|
||||
window.setTimeout(() => window.location.href = '//www.torn.com/index.php', 1000);
|
||||
}, 0);
|
||||
}
|
||||
this.msgWrapper.create('错误:芜湖助手无法获取用户数据,已退出', null, 'error');
|
||||
throw new TypeError('芜湖助手无法获取用户数据');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ export default class MsgWrapper {
|
||||
|
||||
create(msg: string, options: IWHNotify = {}, type: 'info' | 'warning' | 'error' | 'success' = 'info') {
|
||||
if (!this.windowActiveState.get()) return null;
|
||||
if (options.sysNotify) {
|
||||
if (options?.sysNotify) {
|
||||
this.notificationUtils.push(msg, options);
|
||||
}
|
||||
return ElMessage({
|
||||
|
||||
77
src/vue/AutoLoginForm.vue
Normal file
77
src/vue/AutoLoginForm.vue
Normal file
@ -0,0 +1,77 @@
|
||||
<template>
|
||||
<el-form :inline="true" :model="config">
|
||||
<el-form-item label="邮箱">
|
||||
<el-input v-model="config.autoLoginEmail" placeholder="邮箱"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码">
|
||||
<el-input v-model="config.autoLoginPwd" placeholder="密码" show-password type="password"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-space direction="vertical" style="width: 100%">
|
||||
<el-text>请注意:密码为明文保存,注意保护个人信息安全</el-text>
|
||||
<el-text>当前会话状态:(不一定实时)
|
||||
<span v-if="isLoggedIn" style="color: #32CD32">已登陆</span>
|
||||
<span v-else style="color: red">已失效</span>
|
||||
</el-text>
|
||||
<el-text>确定此会话已失效时可
|
||||
<el-button :disabled="buttonDisabled" type="primary" @click="refreshLoggedIn">刷新登陆状态</el-button>
|
||||
</el-text>
|
||||
</el-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: "AutoLoginForm"
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, inject, ref } from "vue";
|
||||
import { LoggerKey } from "../ts/class/Logger";
|
||||
import { LocalConfigWrapperKey } from "../ts/class/LocalConfigWrapper";
|
||||
import { ElMessage } from "element-plus";
|
||||
|
||||
const logger = inject(LoggerKey);
|
||||
const localConfigWrapper = inject(LocalConfigWrapperKey);
|
||||
|
||||
const config = ref(localConfigWrapper.config);
|
||||
const headerData = ref(sessionStorage.getItem('headerData'));
|
||||
const isLoggedIn = computed(() => {
|
||||
return JSON.parse(headerData.value).user.state.isLoggedIn
|
||||
});
|
||||
const buttonDisabled = ref(false);
|
||||
const refreshLoggedIn = async () => {
|
||||
if (config.value.autoLoginEmail && config.value.autoLoginPwd) {
|
||||
buttonDisabled.value = true;
|
||||
await fetch("https://www.torn.com/page.php?sid=Auth", {
|
||||
"headers": {
|
||||
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
||||
"cache-control": "no-cache",
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
"pragma": "no-cache",
|
||||
"sec-ch-ua-mobile": "?0",
|
||||
"sec-fetch-dest": "document",
|
||||
"sec-fetch-mode": "navigate",
|
||||
"sec-fetch-site": "same-origin",
|
||||
"sec-fetch-user": "?1",
|
||||
"upgrade-insecure-requests": "1"
|
||||
},
|
||||
"referrer": "https://www.torn.com/",
|
||||
"referrerPolicy": "strict-origin-when-cross-origin",
|
||||
"body": `email=${ config.value.autoLoginEmail }&password=${ config.value.autoLoginPwd }&redirectUrl=https%3A%2F%2Fwww.torn.com%2F&btnLogin=Login`,
|
||||
"method": "POST",
|
||||
"mode": "cors",
|
||||
"credentials": "include"
|
||||
});
|
||||
buttonDisabled.value = false;
|
||||
ElMessage("完成");
|
||||
} else {
|
||||
ElMessage("登陆信息不完整");
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@ -9,7 +9,6 @@ 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);
|
||||
@ -91,6 +90,7 @@ onMounted(async () => {
|
||||
<template>
|
||||
<div v-loading="!ret">
|
||||
<div v-if="msg" style="color: red">{{ msg }}</div>
|
||||
<el-text>飞行、住院等非OK状态时该表格不可用</el-text>
|
||||
<el-table v-if="ret" :data="ret" style="width: 100%">
|
||||
<el-table-column label="物品">
|
||||
<template #default="scope">
|
||||
|
||||
@ -88,6 +88,7 @@ import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import QuickCrime from "./QuickCrime.vue";
|
||||
import EventsViewer from "./EventsViewer.vue";
|
||||
import CityUItems from "./CityUItems.vue";
|
||||
import AutoLoginForm from "./AutoLoginForm.vue";
|
||||
|
||||
const logger = inject(LoggerKey);
|
||||
const quickGymTrain = inject(QuickGymTrainKey);
|
||||
@ -179,6 +180,10 @@ const menuItemList = [
|
||||
title: '🚮 地图垃圾',
|
||||
template: CityUItems,
|
||||
},
|
||||
{
|
||||
title: '🩼 配置自动登陆',
|
||||
template: AutoLoginForm,
|
||||
},
|
||||
// {
|
||||
// title: '🔫 LOOT',
|
||||
// template: Test,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user