This commit is contained in:
Liwanyi 2023-05-31 18:31:03 +08:00
parent 9b8bab4a92
commit 8d8b78c6a1
5 changed files with 60 additions and 8 deletions

View File

@ -5,6 +5,15 @@
# CHANGE # CHANGE
## 0.9.5
2023年05月31日
### 修改
- 明文密码简单编码处理
- 自动登录前添加确认
## 0.9.4 ## 0.9.4
2023年05月31日 2023年05月31日

View File

@ -1,6 +1,6 @@
{ {
"name": "wuhu-torn-helper", "name": "wuhu-torn-helper",
"version": "0.9.4", "version": "0.9.5",
"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

View File

@ -17,13 +17,40 @@ export default class LocalConfigWrapper {
public get config(): Config { public get config(): Config {
const _this = this; const _this = this;
const str2code = (str: string): number[] => {
let code = [];
for (let i = 0; i < str.length; i++) {
code.push(str.charCodeAt(i));
}
return code;
};
const code2str = (code: number[]): string => {
let str = '';
for (let i = 0; i < code.length; i++) {
str += String.fromCharCode(code[i]);
}
return str;
};
return new Proxy(_this.Local, { return new Proxy(_this.Local, {
get(target: Config, prop: string) { get(target: Config, prop: string) {
return target[prop] ?? defaultConfig[prop]; let value = target[prop] ?? defaultConfig[prop];
if (prop === 'autoLoginPwd') {
let jsonObj;
try {
jsonObj = JSON.parse(window.atob(value));
} catch (e) {
jsonObj = [];
}
value = code2str(jsonObj);
}
return value;
}, },
set(target: Config, prop: string, value: any): boolean { set(target: Config, prop: string, value: any): boolean {
let config = target; let config = target;
let preVal = config[prop]; let preVal = config[prop];
if (prop === 'autoLoginPwd') {
value = window.btoa(JSON.stringify(str2code(value)));
}
if (preVal !== value) { if (preVal !== value) {
config[prop] = value; config[prop] = value;
_this.setLocal(config); _this.setLocal(config);

View File

@ -5,6 +5,8 @@ import { Injectable } from "../../container/Injectable";
import Logger from "../Logger"; import Logger from "../Logger";
import LocalConfigWrapper from "../LocalConfigWrapper"; import LocalConfigWrapper from "../LocalConfigWrapper";
import MsgWrapper from "./MsgWrapper"; import MsgWrapper from "./MsgWrapper";
import { ElMessageBox } from "element-plus";
import { MessageBoxData } from "element-plus/es/components/message-box/src/message-box.type";
@ClassName('InfoUtils') @ClassName('InfoUtils')
@Injectable() @Injectable()
@ -36,6 +38,20 @@ export default class InfoUtils {
const { autoLoginEmail, autoLoginPwd } = this.localConfigWrapper.config; const { autoLoginEmail, autoLoginPwd } = this.localConfigWrapper.config;
if (autoLoginEmail && autoLoginPwd) { if (autoLoginEmail && autoLoginPwd) {
window.setTimeout(async () => { window.setTimeout(async () => {
let alertRs: MessageBoxData = null;
try {
alertRs = await ElMessageBox.confirm(
'可进行自动登录',
'确认',
{
confirmButtonText: '好',
cancelButtonText: '算了',
type: 'info',
}
)
} catch (e) {
}
if (alertRs !== 'confirm') return;
this.msgWrapper.create('正尝试自动登录...', null, 'info'); this.msgWrapper.create('正尝试自动登录...', null, 'info');
await fetch("https://www.torn.com/page.php?sid=Auth", { await fetch("https://www.torn.com/page.php?sid=Auth", {
"headers": { "headers": {