From 8017cdedc256018477016b54bd5a141293b2982a Mon Sep 17 00:00:00 2001 From: chenhb23 Date: Mon, 21 Aug 2023 14:30:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8F=82=E6=95=B0=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/package.json | 2 +- docs/pages/20230821/ajax-pwd.html | 188 ++++++++++++++++++++++++++++++ docs/pages/20230821/ajax.html | 76 ++++++++++++ package.json | 2 +- src/common/core/matcher.ts | 34 +++--- src/renderer/store/Download.ts | 1 + src/renderer/store/Upload.ts | 1 + 7 files changed, 289 insertions(+), 15 deletions(-) create mode 100644 docs/pages/20230821/ajax-pwd.html create mode 100644 docs/pages/20230821/ajax.html diff --git a/app/package.json b/app/package.json index ab51b0a..6462224 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "lanzouyun-pan", - "version": "3.4.4", + "version": "3.4.5", "private": true, "main": "build/main/index.js", "description": "蓝奏云网盘客户端", diff --git a/docs/pages/20230821/ajax-pwd.html b/docs/pages/20230821/ajax-pwd.html new file mode 100644 index 0000000..d7b79a6 --- /dev/null +++ b/docs/pages/20230821/ajax-pwd.html @@ -0,0 +1,188 @@ + + + + + +舞蹈教师聘用合同.docx + + + + + + + +
+
18**的分享文件
+
+
谨防刷单兼职,网贷,金融,裸聊敲诈,赌博等诈骗,请立即举报
+ +
舞蹈教师聘用合同.docx
+ +
2023-01-28 Win桌面
+
大小:15.8 K
+
+
+
+
手机下载请扫二维码
+
+
+
版权声明:不得利用云存储发布,存储,淫秽,诈骗等违法信息。
或者投诉邮箱:ta@lanzou.com
© 2023 Lanzou
+ + +
+ + \ No newline at end of file diff --git a/docs/pages/20230821/ajax.html b/docs/pages/20230821/ajax.html new file mode 100644 index 0000000..a31158b --- /dev/null +++ b/docs/pages/20230821/ajax.html @@ -0,0 +1,76 @@ + + + + + + + + +
地址超时,请刷新
+ +
电信下载联通下载普通下载
+ + + + diff --git a/package.json b/package.json index bad6b34..730ee86 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lanzouyun-pan", - "version": "3.4.4", + "version": "3.4.5", "private": true, "main": "build/main/index.js", "description": "蓝奏云网盘客户端", diff --git a/src/common/core/matcher.ts b/src/common/core/matcher.ts index 2f4bebd..fa56f40 100644 --- a/src/common/core/matcher.ts +++ b/src/common/core/matcher.ts @@ -30,14 +30,16 @@ export class Matcher { const script = scripts.eq(0).html() if (!script) throw new Error('script 获取失败') - return prettier.format(script, { - plugins: [parserBabel], - parser: 'babel', - semi: true, // 加上分号 - trailingComma: 'none', // 不加尾逗号 - singleQuote: false, // 使用双冒号 - printWidth: 1000, // 为了让代码尽量不换行 - }) + return ( + prettier.format(script, { + plugins: [parserBabel], + parser: 'babel', + semi: true, // 加上分号 + trailingComma: 'none', // 不加尾逗号 + singleQuote: false, // 使用双冒号 + printWidth: 1000, // 为了让代码尽量不换行 + }) + '\n' + ) } /** @@ -57,7 +59,7 @@ export class Matcher { const variable = getVariable(script) const data = getData(script) - const body = eval(`${variable}(${data})`) + const body = eval(`(() => {${variable}return ${data}})()`) if (typeof body.data === 'string') { body.data = queryString.parse(body.data) @@ -88,10 +90,11 @@ export class Matcher { * data 为 object 类型 */ static parseAjax(html: string) { + const cleanReg = /function .+?\(\) {[\s\S]+?}\n/g return this.parseAjaxData( html, - script => script.match(/([\s\S]+)\$\.ajax/)[1], - script => script.match(/\$\.ajax\(([\s\S]+)\)/)[1] + script => script.replace(cleanReg, '').match(/([\s\S]+)\$\.ajax/)[1], + script => script.replace(cleanReg, '').match(/\$\.ajax\(([\s\S]+)\)/)[1] ) } @@ -101,10 +104,15 @@ export class Matcher { * data 由 string 转为 object 类型 */ static parsePwdAjax(html: string, password = '') { + const cleanReg = /function down_p\(\) {([\s\S]+?)\n}\n/ return this.parseAjaxData( html, - _ => `var pwd = "${password}";`, - script => script.match(/\$\.ajax\(({[\s\S]+?})\);/)?.[1] + script => + script + .match(cleanReg)?.[1] + ?.replace(/var pwd.*?\n/, `var pwd = "${password}";\n`) + .match(/([\s\S]+)\$\.ajax/)[1], + script => script.match(cleanReg)?.[1]?.match(/\$\.ajax\(({[\s\S]+?})\);/)?.[1] ) } diff --git a/src/renderer/store/Download.ts b/src/renderer/store/Download.ts index 29fdf46..0c4612b 100644 --- a/src/renderer/store/Download.ts +++ b/src/renderer/store/Download.ts @@ -212,6 +212,7 @@ export class Download extends EventEmitter implements Task { subtask.status = TaskStatus.finish this.emit('finish-task', task, subtask) } catch (e: any) { + console.error(e) if (abort.signal.aborted) { subtask.status = TaskStatus.pause } else { diff --git a/src/renderer/store/Upload.ts b/src/renderer/store/Upload.ts index 269e12b..c82eceb 100644 --- a/src/renderer/store/Upload.ts +++ b/src/renderer/store/Upload.ts @@ -313,6 +313,7 @@ export class Upload extends EventEmitter implements Task { subtask.status = TaskStatus.finish this.emit('finish-task', task, subtask) } catch (e: any) { + console.error(e) if (abort.signal.aborted) { subtask.status = TaskStatus.pause } else {