Skip to content

Commit

Permalink
fix(all): 优化浏览器启动以及各种加载逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed May 22, 2023
1 parent 685fcf5 commit b00e72a
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 125 deletions.
27 changes: 23 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
{
"cSpell.words": [
"userscript"
]
}
"cSpell.words": ["ICVE", "userscript", "userscripts"],
"eslint.validate": ["javascript", "javascriptreact", "vue"],
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
/** 样式自动生成 */
"less.compile": {
"compress": false,
"sourceMap": false,
"out": "../css/"
},
/** 鼠标中键代码缩进 */
"editor.mouseWheelZoom": true,
/** 鼠标滚动速度 */
"editor.mouseWheelScrollSensitivity": 2,
/** 不生成 @return 的 jsdoc */
"typescript.suggest.jsdoc.generateReturns": false,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
2 changes: 0 additions & 2 deletions packages/app/src/scripts/automation/index.ts

This file was deleted.

5 changes: 3 additions & 2 deletions packages/app/src/scripts/automation/wk/cx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ function login(
const tryLogin = async () => {
tryCount--;
const area = await page.$('#numVerCode');
if (area !== null) {
const codeInput = await page.$('#vercode');
if (area && codeInput) {
/** 破解验证码 */
if (opts?.ocrApiUrl && opts?.ocrApiImageKey && area) {
await breakVerifyCode(page, area, {
await breakVerifyCode(page, area, codeInput, {
ocrApiUrl: opts.ocrApiUrl,
ocrApiImageKey: opts.ocrApiImageKey
});
Expand Down
2 changes: 0 additions & 2 deletions packages/app/src/scripts/automation/wk/index.ts

This file was deleted.

14 changes: 12 additions & 2 deletions packages/app/src/scripts/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { CXPhoneLoginScript, CXUnitLoginScript } from './automation/wk/cx';
import { ZHSPhoneLoginScript, ZHSUnitLoginScript } from './automation/wk/zhs';
import { NewPageScript } from './automation';
import { ICVELoginScript } from './automation/wk/icve';
import { ZJYLoginScript } from './automation/wk/zjy';
import { NewPageScript } from './automation/common';

export const scripts = [CXPhoneLoginScript, CXUnitLoginScript, ZHSPhoneLoginScript, ZHSUnitLoginScript, NewPageScript];
export const scripts = [
CXPhoneLoginScript,
CXUnitLoginScript,
ZHSPhoneLoginScript,
ZHSUnitLoginScript,
ZJYLoginScript,
ICVELoginScript,
NewPageScript
];
3 changes: 2 additions & 1 deletion packages/app/src/scripts/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function slowType(page: Page, selector: string, text: string) {
export async function breakVerifyCode(
page: Page,
imageElement: ElementHandle<any>,
inputElement: ElementHandle<any>,
options: { ocrApiUrl: string; ocrApiImageKey: string }
) {
const box = await imageElement.boundingBox();
Expand All @@ -24,7 +25,7 @@ export async function breakVerifyCode(
if (canOCR) {
/** 破解验证码 */
if (code) {
await page.fill('#vercode', code);
await inputElement.fill(code);
} else if (error) {
throw new Error(error);
}
Expand Down
Loading

0 comments on commit b00e72a

Please # to comment.