更新
This commit is contained in:
parent
9b8bab4a92
commit
8d8b78c6a1
@ -5,6 +5,15 @@
|
||||
|
||||
# CHANGE
|
||||
|
||||
## 0.9.5
|
||||
|
||||
2023年05月31日
|
||||
|
||||
### 修改
|
||||
|
||||
- 明文密码简单编码处理
|
||||
- 自动登录前添加确认
|
||||
|
||||
## 0.9.4
|
||||
|
||||
2023年05月31日
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "wuhu-torn-helper",
|
||||
"version": "0.9.4",
|
||||
"version": "0.9.5",
|
||||
"description": "芜湖助手",
|
||||
"scripts": {
|
||||
"release": "cross-env NODE_ENV=production rollup -c && node build.mjs",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -17,13 +17,40 @@ export default class LocalConfigWrapper {
|
||||
|
||||
public get config(): Config {
|
||||
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, {
|
||||
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 {
|
||||
let config = target;
|
||||
let preVal = config[prop];
|
||||
if (prop === 'autoLoginPwd') {
|
||||
value = window.btoa(JSON.stringify(str2code(value)));
|
||||
}
|
||||
if (preVal !== value) {
|
||||
config[prop] = value;
|
||||
_this.setLocal(config);
|
||||
|
||||
@ -5,6 +5,8 @@ import { Injectable } from "../../container/Injectable";
|
||||
import Logger from "../Logger";
|
||||
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||
import MsgWrapper from "./MsgWrapper";
|
||||
import { ElMessageBox } from "element-plus";
|
||||
import { MessageBoxData } from "element-plus/es/components/message-box/src/message-box.type";
|
||||
|
||||
@ClassName('InfoUtils')
|
||||
@Injectable()
|
||||
@ -36,6 +38,20 @@ export default class InfoUtils {
|
||||
const { autoLoginEmail, autoLoginPwd } = this.localConfigWrapper.config;
|
||||
if (autoLoginEmail && autoLoginPwd) {
|
||||
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');
|
||||
await fetch("https://www.torn.com/page.php?sid=Auth", {
|
||||
"headers": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user