|
@@ -49,7 +49,7 @@
|
|
|
|
|
|
<el-container>
|
|
|
<el-header height="45px" style="background-color: #fafafa; padding: 0 10px;">
|
|
|
- <soft-header ref="headerRef" @update-soft="updateSoft()" @export-file="exportFile" @login-url="loginUrl"></soft-header>
|
|
|
+ <soft-header ref="headerRef" @update-soft="updateSoft()" @export-file="exportFile" @login-url="loginUrl" @clear-cache="clearCache"></soft-header>
|
|
|
</el-header>
|
|
|
|
|
|
<soft-img ref="imgRef" v-show="['2-1', '2-2', '2-3', '2-5'].indexOf(menuIndex) > -1" @open-vip="openVip" @check-authority="checkAuthority"></soft-img>
|
|
@@ -101,8 +101,9 @@
|
|
|
(需登录京东账号后才能下载)
|
|
|
</el-link>
|
|
|
</div>
|
|
|
-
|
|
|
- <el-link v-if="tbStatus == 3 || jdStatus == 3" :underline="false" type="danger" style="text-align: center; font-size: 12px;">登录完成后请关闭浏览器</el-link>
|
|
|
+ <template v-if="menuIndex == '2' || menuIndex == '3' || menuIndex == '4'">
|
|
|
+ <el-link v-if="tbStatus == 3 || jdStatus == 3" :underline="false" type="danger" style="text-align: center; font-size: 12px;">登录完成后请关闭浏览器</el-link>
|
|
|
+ </template>
|
|
|
</el-row>
|
|
|
|
|
|
<div style="padding: 15px 0 20px;">
|
|
@@ -236,6 +237,7 @@
|
|
|
import os from 'os'
|
|
|
import fs from 'fs'
|
|
|
import request from 'request'
|
|
|
+ import path from 'path';
|
|
|
import xlsx from 'node-xlsx';
|
|
|
import softUpdate from './update.vue';
|
|
|
import softHeader from './header.vue';
|
|
@@ -355,6 +357,11 @@
|
|
|
if (!fs.existsSync(os.tmpdir() + separator + 'chrome-data-capture-jd')) {
|
|
|
fs.mkdirSync(os.tmpdir() + separator + 'chrome-data-capture-jd');
|
|
|
}
|
|
|
+
|
|
|
+ let path = os.tmpdir() + separator + 'chrome-data-capture';
|
|
|
+ let path2 = os.tmpdir() + separator + 'chrome-data-capture-jd';
|
|
|
+ this.deleteAll(path, false);
|
|
|
+ this.deleteAll(path2, false);
|
|
|
|
|
|
// 打开浏览器
|
|
|
const {
|
|
@@ -371,6 +378,22 @@
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 删除文件夹内容
|
|
|
+ deleteAll(folderPath, flag) {
|
|
|
+ if (fs.existsSync(folderPath)) {
|
|
|
+ fs.readdirSync(folderPath).forEach((file, index) => {
|
|
|
+ var curPath = path.join(folderPath, file);
|
|
|
+ if (fs.lstatSync(curPath).isDirectory()) {
|
|
|
+ this.deleteAll(curPath, true);
|
|
|
+ } else {
|
|
|
+ fs.unlinkSync(curPath);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if(flag){
|
|
|
+ fs.rmdirSync(folderPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
checkAuthority(){
|
|
|
let authority = this.$refs.headerRef.authority;
|
|
|
this.$refs.imgRef.authority = authority;
|
|
@@ -576,6 +599,12 @@
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ // 清除缓存
|
|
|
+ clearCache(){
|
|
|
+ this.jdStatus = 3;
|
|
|
+ this.tbStatus = 3;
|
|
|
+ },
|
|
|
+
|
|
|
// 去登录
|
|
|
loginUrl(url){
|
|
|
(async () => {
|
|
@@ -656,6 +685,40 @@
|
|
|
fs.mkdirSync(os.tmpdir() + separator + 'chrome-data-capture');
|
|
|
}
|
|
|
|
|
|
+ if(this.menuIndex == '2'){ // 京东
|
|
|
+ if(this.jdStatus == 1 || this.jdStatus == 3){ // 未检测登录状态/或提示未登录状态,开始检测
|
|
|
+ await this.checkJdLogin().then((data) => {
|
|
|
+ if(data != 2){ // 未登录
|
|
|
+ this.jdStatus = 3;
|
|
|
+ this.loginVisible = true;
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ this.jdStatus = 3;
|
|
|
+ });
|
|
|
+ if(this.jdStatus == 3){
|
|
|
+ this.loading = false;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(this.menuIndex == '3' || this.menuIndex == '4'){ // 天猫/淘宝
|
|
|
+ if(this.tbStatus == 1 || this.tbStatus == 3){ // 未检测登录状态/或提示未登录状态,开始检测
|
|
|
+ await this.checkLogin().then((data) => {
|
|
|
+ if(data != 2){ // 未登录
|
|
|
+ this.tbStatus = 3;
|
|
|
+ this.loginVisible = true;
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ this.tbStatus = 3;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(this.tbStatus == 3){
|
|
|
+ this.loading = false;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
let taskArr = [];
|
|
|
let task = "";
|
|
|
for(let i = 0; i < fileList.length; i++){
|
|
@@ -666,11 +729,11 @@
|
|
|
task = this.alibabaDownload(item);
|
|
|
break;
|
|
|
case '2': // 京东
|
|
|
- task = this.jdDownload(item);
|
|
|
+ task = this.jdScanImg(item);
|
|
|
break;
|
|
|
case '3': // 天猫
|
|
|
case '4': // 淘宝
|
|
|
- task = this.tbDownload(item);
|
|
|
+ task = this.tbScanImg(item);
|
|
|
break;
|
|
|
case '10': // 普通网址
|
|
|
task = this.normalDownload(item);
|
|
@@ -953,29 +1016,6 @@
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- //京东下载
|
|
|
- async jdDownload(urlInfo){
|
|
|
- let task = null;
|
|
|
- if(this.jdStatus == 1 || this.jdStatus == 3){ // 未检测登录状态/或提示未登录状态,开始检测
|
|
|
- await this.checkJdLogin().then((data) => {
|
|
|
- if(data == 2){ // 已经登录,处理下载
|
|
|
- task = this.jdScanImg(urlInfo);
|
|
|
- }else{ // 未登录
|
|
|
- task = 'notLogin';
|
|
|
- this.jdStatus = 3;
|
|
|
- this.loginVisible = true;
|
|
|
- }
|
|
|
- }).catch(err => {
|
|
|
- task = 'notLogin';
|
|
|
- this.jdStatus = 3;
|
|
|
- });
|
|
|
- }else if(this.jdStatus == 2){ // 已经登录
|
|
|
- task = this.jdScanImg(urlInfo);
|
|
|
- }
|
|
|
-
|
|
|
- return task;
|
|
|
- },
|
|
|
-
|
|
|
// 京东下载
|
|
|
async jdScanImg(urlInfo){
|
|
|
let task = await new Promise((resolve,reject) =>{
|
|
@@ -1247,32 +1287,6 @@
|
|
|
});
|
|
|
|
|
|
},
|
|
|
-
|
|
|
- //淘宝\天猫下载
|
|
|
- async tbDownload(urlInfo){
|
|
|
- let task = null;
|
|
|
- if(this.tbStatus == 1 || this.tbStatus == 3){ // 未检测登录状态/或提示未登录状态,开始检测
|
|
|
- await this.checkLogin().then((data) => {
|
|
|
- if(data == 2){ // 已经登录,处理下载
|
|
|
- task = this.tbScanImg(urlInfo);
|
|
|
- }else{ // 未登录
|
|
|
- task = 'notLogin';
|
|
|
- this.tbStatus = 3;
|
|
|
- this.loginVisible = true;
|
|
|
- // this.$notify.error({
|
|
|
- // title: '淘宝/天猫账号未登录,下载失败! - error'
|
|
|
- // });
|
|
|
- }
|
|
|
- }).catch(err => {
|
|
|
- task = 'notLogin';
|
|
|
- this.tbStatus = 3;
|
|
|
- });
|
|
|
- }else if(this.tbStatus == 2){ // 已经登录
|
|
|
- task = this.tbScanImg(urlInfo);
|
|
|
- }
|
|
|
-
|
|
|
- return task;
|
|
|
- },
|
|
|
|
|
|
// 淘宝天猫扫描下载图片
|
|
|
async tbScanImg(urlInfo){
|