wechat-mp-controller 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +9 -2
- package/dist/index.js +29 -1
- package/package.json +17 -15
package/dist/index.d.ts
CHANGED
|
@@ -13,12 +13,19 @@ export declare class Controller {
|
|
|
13
13
|
isLogin(): boolean;
|
|
14
14
|
close(): Promise<void>;
|
|
15
15
|
login(options?: {
|
|
16
|
-
onQrCode?: (qrcode: string) =>
|
|
17
|
-
onScanSuccess?: () => void;
|
|
16
|
+
onQrCode?: (qrcode: string) => void;
|
|
17
|
+
onScanSuccess?: (qrcode: string) => void;
|
|
18
18
|
}): Promise<void>;
|
|
19
19
|
getOnlineVersion(): Promise<{
|
|
20
20
|
version: string;
|
|
21
21
|
message: string;
|
|
22
22
|
}>;
|
|
23
23
|
getDevVersionInfos(): Promise<UploadVersionInfo[]>;
|
|
24
|
+
submitAudit(options: {
|
|
25
|
+
message: string;
|
|
26
|
+
uploaderOfTargetVersion: {
|
|
27
|
+
name: string;
|
|
28
|
+
openid: string;
|
|
29
|
+
};
|
|
30
|
+
}): Promise<void>;
|
|
24
31
|
}
|
package/dist/index.js
CHANGED
|
@@ -47,16 +47,18 @@ export class Controller {
|
|
|
47
47
|
const imgResponse = await this.page.waitForResponse(src);
|
|
48
48
|
const buffer = await imgResponse.buffer();
|
|
49
49
|
const loginLink = await analyzeQrCodeImgBuffer(buffer);
|
|
50
|
+
let _qrcode = '';
|
|
50
51
|
await new Promise(resolve => {
|
|
51
52
|
qrcodeUtil.generate(loginLink, {
|
|
52
53
|
small: true
|
|
53
54
|
}, function (qrcode) {
|
|
54
55
|
options?.onQrCode?.(qrcode);
|
|
56
|
+
_qrcode = qrcode;
|
|
55
57
|
resolve();
|
|
56
58
|
});
|
|
57
59
|
});
|
|
58
60
|
await this.page.waitForSelector('.weui-desktop-icon__success');
|
|
59
|
-
options?.onScanSuccess?.();
|
|
61
|
+
options?.onScanSuccess?.(_qrcode);
|
|
60
62
|
|
|
61
63
|
// 检查到菜单,认为登录成功
|
|
62
64
|
await this.page.waitForSelector('#menuBar .menu');
|
|
@@ -102,4 +104,30 @@ export class Controller {
|
|
|
102
104
|
}
|
|
103
105
|
return versionInfos;
|
|
104
106
|
}
|
|
107
|
+
async submitAudit(options) {
|
|
108
|
+
if (!this.page) {
|
|
109
|
+
throw new Error('请先进行初始化');
|
|
110
|
+
}
|
|
111
|
+
const versionManageLink = await this.page.$eval('#menuBar a[title="版本管理"]', node => node.href);
|
|
112
|
+
await this.page.goto(versionManageLink);
|
|
113
|
+
await this.page.waitForSelector('.main_bd .code_version_dev .mod_default_bd:nth-child(2) .code_version_logs .code_version_log');
|
|
114
|
+
const url = new URL(this.page.url());
|
|
115
|
+
const urlToken = url.searchParams.get('token');
|
|
116
|
+
if (!urlToken) {
|
|
117
|
+
throw new Error('获取token失败');
|
|
118
|
+
}
|
|
119
|
+
const searchParams = new URLSearchParams({
|
|
120
|
+
action: 'get_class',
|
|
121
|
+
token: urlToken,
|
|
122
|
+
lang: 'zh-CN',
|
|
123
|
+
openid: options.uploaderOfTargetVersion.openid,
|
|
124
|
+
user_name: encodeURIComponent(options.uploaderOfTargetVersion.name)
|
|
125
|
+
});
|
|
126
|
+
await this.page.goto(`https://mp.weixin.qq.com/wxamp/wadevelopcode/get_class?${searchParams.toString()}`);
|
|
127
|
+
await this.page.waitForSelector('.weui-desktop-form__control-group textarea');
|
|
128
|
+
await this.page.locator('.weui-desktop-form__control-group textarea').fill(options.message);
|
|
129
|
+
await this.page.locator('.btn.btn_primary[data-msgid="提交审核"]').click();
|
|
130
|
+
await this.page.waitForSelector('div[data-component="sumbitPage"] .main_bd *[data-msgid="已提交审核"]');
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
105
133
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wechat-mp-controller",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build:clean": "rm -rf ./dist",
|
|
11
|
+
"build:gulp": "gulp",
|
|
12
|
+
"build": "pnpm build:clean && pnpm build:gulp",
|
|
13
|
+
"start": "watch 'pnpm build' src",
|
|
14
|
+
"commitlint": "commitlint --edit",
|
|
15
|
+
"lint": "eslint --ext .js,.ts --max-warnings 0 \"./\" ",
|
|
16
|
+
"tsc": "tsc -p ./tsconfig.json --noEmit",
|
|
17
|
+
"commit": "git-cz",
|
|
18
|
+
"lint-staged": "lint-staged",
|
|
19
|
+
"prepare": "husky",
|
|
20
|
+
"exec:ts-node": "node --disable-warning=ExperimentalWarning --es-module-specifier-resolution=node --loader ts-node/esm",
|
|
21
|
+
"release": "pnpm exec:ts-node \"./scripts/release.ts\"",
|
|
22
|
+
"prepublishOnly": "pnpm build && pnpm exec:ts-node \"./scripts/publish.ts\""
|
|
23
|
+
},
|
|
9
24
|
"files": [
|
|
10
25
|
"dist",
|
|
11
26
|
"package.json",
|
|
@@ -57,18 +72,5 @@
|
|
|
57
72
|
"commitizen": {
|
|
58
73
|
"path": "node_modules/cz-git"
|
|
59
74
|
}
|
|
60
|
-
},
|
|
61
|
-
"scripts": {
|
|
62
|
-
"build:clean": "rm -rf ./dist",
|
|
63
|
-
"build:gulp": "gulp",
|
|
64
|
-
"build": "pnpm build:clean && pnpm build:gulp",
|
|
65
|
-
"start": "watch 'pnpm build' src",
|
|
66
|
-
"commitlint": "commitlint --edit",
|
|
67
|
-
"lint": "eslint --ext .js,.ts --max-warnings 0 \"./\" ",
|
|
68
|
-
"tsc": "tsc -p ./tsconfig.json --noEmit",
|
|
69
|
-
"commit": "git-cz",
|
|
70
|
-
"lint-staged": "lint-staged",
|
|
71
|
-
"exec:ts-node": "node --disable-warning=ExperimentalWarning --es-module-specifier-resolution=node --loader ts-node/esm",
|
|
72
|
-
"release": "pnpm exec:ts-node \"./scripts/release.ts\""
|
|
73
75
|
}
|
|
74
|
-
}
|
|
76
|
+
}
|