qiushang 11 mēneši atpakaļ
vecāks
revīzija
e93599c6a8
2 mainītis faili ar 100 papildinājumiem un 29 dzēšanām
  1. 1 1
      package.json
  2. 99 28
      src/renderer/components/home.vue

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 	"name": "XYCapture",
-	"version": "2.0.2.3",
+	"version": "2.0.2.5",
 	"author": "苏州星优办公软件有限公司",
 	"description": "An electron-vue project",
 	"license": "capture",

+ 99 - 28
src/renderer/components/home.vue

@@ -12,18 +12,18 @@
 					<el-menu :default-openeds="['a', 'b']" :default-active="menuIndex" @select="setMenuIndex" active-text-color="#409EFF" background-color="#333744" text-color="#fff" style="margin-top: 10px;">
 						<el-submenu index="a">
 							<template slot="title"><img src="../assets/image/m-download.png" class="m-image"/>图片下载</template>
-							<el-menu-item index="1">
-								<img src="../assets/image/m-alibaba.png" class="m-image"/><span slot="title">阿里巴巴</span>
+							<el-menu-item index="3">
+								<img src="../assets/image/m-tmall.png" class="m-image"/><span slot="title">天猫</span>
 							</el-menu-item>
 							<el-menu-item index="2">
 								<img src="../assets/image/m-jd.png" class="m-image"/><span slot="title">京东</span>
 							</el-menu-item>
-							<el-menu-item index="3">
-								<img src="../assets/image/m-tmall.png" class="m-image"/><span slot="title">天猫</span>
-							</el-menu-item>
 							<el-menu-item index="4">
 								<img src="../assets/image/m-taobao.png" class="m-image"/><span slot="title">淘宝</span>
 							</el-menu-item>
+							<el-menu-item index="1">
+								<img src="../assets/image/m-alibaba.png" class="m-image"/><span slot="title">阿里巴巴</span>
+							</el-menu-item>
 							<el-menu-item index="10">
 								<img src="../assets/image/m-chrome.png" class="m-image"/><span slot="title">其他网址</span>
 							</el-menu-item>
@@ -85,16 +85,21 @@
 							
 							<div style="padding: 20px 20px 0 20px; height: calc(100% - 62px);">
 								<el-row type="flex" justify="space-between">
-									<h3>
-										<span v-if="menuIndex == '1'">阿里巴巴 - </span>
-										<span v-if="menuIndex == '2'">京东 - </span>
-										<span v-if="menuIndex == '3'">天猫 - </span>
-										<span v-if="menuIndex == '4'">淘宝 - </span>
-										<span v-if="menuIndex == '10'">网页 - </span>
-										图片下载
-									</h3>
+									<div>
+										<h3 style="display: inline-block;">
+											<span v-if="menuIndex == '1'">阿里巴巴 - </span>
+											<span v-if="menuIndex == '2'">京东 - </span>
+											<span v-if="menuIndex == '3'">天猫 - </span>
+											<span v-if="menuIndex == '4'">淘宝 - </span>
+											<span v-if="menuIndex == '10'">网页 - </span>
+											图片下载
+										</h3>
+										<el-link v-if="menuIndex == '3' || menuIndex == '4'" :underline="false" type="danger" style="text-align: center; font-size: 12px;">
+											(需登录{{menuIndex == '3' ? '天猫' : '淘宝'}}账号后才能下载)
+										</el-link>
+									</div>
 									
-									<el-link v-if="tbStatus == 3" :underline="false" type="danger" style="text-align: center; font-size: 13px;">登录完成后请关闭浏览器</el-link>
+									<el-link v-if="tbStatus == 3" :underline="false" type="danger" style="text-align: center; font-size: 12px;">登录完成后请关闭浏览器</el-link>
 								</el-row>
 								
 								<div style="padding: 15px 0 20px;">
@@ -119,7 +124,7 @@
 												<div>
 													<el-tag type="info" size="mini" v-if="tbStatus == 1">未检测</el-tag>
 													<el-tag type="success" size="mini" v-if="tbStatus == 2">账号已登录</el-tag>
-													<el-link type="danger" v-if="tbStatus == 3" @click="loginUrl('https://login.taobao.com')">未登录,点我去登录</el-link>
+													<el-link type="danger" style="text-decoration: underline;" v-if="tbStatus == 3" :underline="false" @click="loginUrl('https://login.taobao.com')">未登录,点击登录<span>{{menuIndex == '3' ? '天猫' : '淘宝'}}</span>账号</el-link>
 													<el-button size="mini" type="warning" :loading="checkLoading" style="margin-left: 10px;" :disabled='tbStatus == 2' @click="checkLogin">检测登录状态</el-button>
 												</div>
 											</div>
@@ -166,12 +171,11 @@
 										</vxe-column>
 										<vxe-column title="操作" width="80">
 											<template #default="{ row, rowIndex }">
-												<i class="el-icon-delete cur-pointer" style="font-size: 20px;" @click="delFile(rowIndex, 'alibaba')"></i>
+												<i class="el-icon-delete cur-pointer" style="font-size: 20px;" @click="delFile(rowIndex)"></i>
 											</template>
 										</vxe-column>
 									</vxe-table>
 								</div>
-								
 							</div>
 				
 						</template>
@@ -193,6 +197,16 @@
 								<el-button type="primary" @click="onSubmit">确 定</el-button>
 							</span>
 						</el-dialog>
+						
+						<el-dialog title="提示" :visible.sync="loginVisible" width="400px" :close-on-click-modal="false" :close-on-press-escape="false">
+							<div style="text-align: center; color: #999; font-size: 14px;">
+								<p>天猫/淘宝渠道需要登录后才能下载</p>
+								<p style="font-size: 18px; color: #f73131; font-weight: 600; padding: 30px 40px 0;">目前检测还未登录天猫/淘宝账号,需立即登录</p>
+							</div>
+							<div slot="footer" class="dialog-footer-center">
+								<el-button @click="loginVisible = false; loginUrl('https://login.taobao.com')">点击登录天猫/淘宝账号</el-button>
+							</div>
+						</el-dialog>
 				
 					</el-main>
 					
@@ -238,6 +252,7 @@
 		},
 		data() {
 			return {
+				loginVisible: false,
 				addVisible: false,
 				formData: {
 					title: '',
@@ -262,13 +277,13 @@
 				productName: pjson.softInfo.softName,
 				imgUrl: this.$api.imgUrl,
 				imgSrc: '',
-				menuIndex: '1',
+				menuIndex: '3',
 				jdBrowser: '', // 打开京东的浏览器
 				settingData: {
 					detailImg: true,
 					skuImg: true,
-					commentImg: true,
-					video: true,
+					commentImg: false,
+					video: false,
 				},
 				exampleUrl: ['https://www.1688.com', 'https://www.jd.com', 'https://www.tmall.com', 'https://www.taobao.com'],
 
@@ -377,7 +392,25 @@
 				this.$refs.updateRef.updateSoft();
 			},
 			// 删除文件
-			delFile(rowIndex, type){
+			delFile(rowIndex){
+				let type = 'alibaba';
+				switch(this.menuIndex){
+					case '1':
+						type = 'alibaba';
+						break;
+					case '2':
+						type = 'jd';
+						break;
+					case '3':
+						type = 'tmall';
+						break;
+					case '4':
+						type = 'tb';
+						break;
+					case '10':
+						type = 'common';
+						break;
+				}
 				this.$confirm('确认删除此行数据吗?', '提示', {
 					confirmButtonText: '确定',
 					cancelButtonText: '取消',
@@ -1088,9 +1121,10 @@
 						}else{ // 未登录
 							task = 'notLogin';
 							this.tbStatus = 3;
-							this.$notify.error({
-								title: '淘宝/天猫账号未登录,下载失败!'
-							});
+							this.loginVisible = true;
+							// this.$notify.error({
+							// 	title: '淘宝/天猫账号未登录,下载失败! - error'
+							// });
 						}
 					}).catch(err => {
 						task = 'notLogin';
@@ -1116,7 +1150,7 @@
 								userDataDir: os.tmpdir() + separator + 'chrome-data-capture', 
 							});
 							const page = await tbBrowser.newPage();
-							await page.goto(urlInfo.url, {waitUntil : 'networkidle2'});
+							await page.goto(urlInfo.url, {waitUntil : 'networkidle0'});
 							
 							if(urlInfo.title){
 								if (fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title)) {
@@ -1129,12 +1163,30 @@
 								await this.getTitle(page, urlInfo); // 生成页面标题对应的文件夹
 							}
 							
+							let responseVideo = [];
+							page.on('response', async(response) => {
+								// 检查响应的 MIME 类型是否以 'image/' 开头
+								if (response.headers()['content-type'] && response.headers()['content-type'].startsWith('video/')) {
+									responseVideo.push(response.url());
+								}
+							});
+							
 							let pageInfo = await page.evaluate(() => {
 								let cHeight = document.documentElement.clientHeight;
 								let scrollHeight = document.body.scrollHeight;
 								return {'scrollHeight': scrollHeight, 'cHeight': cHeight}
 							});
 							
+							//鼠标放在主图第一张,生成视频
+							const elementHandle = await page.$('li[class*=thumbnail--]');
+							const classListProperty = await elementHandle.getProperty('classList');
+							const classList = await classListProperty.jsonValue();
+							const classesArray = Object.values(classList);
+							const allClasses = classesArray.join(' ');
+							if(allClasses){
+								await page.hover('li.'+allClasses);
+							}
+							
 							let scrollHeight = pageInfo.scrollHeight;
 							let cHeight = pageInfo.cHeight;
 							
@@ -1203,9 +1255,16 @@
 											}
 										}
 										//详情图片 
-										let arr3 = document.querySelectorAll('#content img')
+										let arr3 = document.querySelectorAll('#content img');
 										for(let i=0; i< arr3.length; i++){
 											let detailImgUrl = arr3[i].src;
+											let lazyUrl = arr3[i].getAttribute('data-src');
+											if(arr3[i].src.indexOf('/s.gif') > -1 && lazyUrl){
+												detailImgUrl = lazyUrl;
+												if(!/^http/.exec(lazyUrl)){
+													detailImgUrl = 'https:' + lazyUrl;
+												}
+											}
 											let result = regex.exec(detailImgUrl);
 											if(result){
 												detailImgUrl = detailImgUrl.replace(result[0], '.'+result[1]); 
@@ -1246,6 +1305,10 @@
 										}
 										return outObj;
 									}, authority, this.execNum);
+				
+									if(imgInfo.video.length == 0 && responseVideo.length > 0){
+										imgInfo.video = responseVideo;
+									}
 									
 									// 主图下载
 									for(let j = 0; j < imgInfo.mainImg.length; j++){
@@ -1350,7 +1413,7 @@
 									resolve(true);
 									this.loading = false;
 								}
-							}, 500);
+							}, 300);
 						}catch(e){
 							reject(e);
 							this.showError(e);
@@ -1646,9 +1709,13 @@
 					str = '链接请求超时,请查看网络状态!-3';
 				}else if(e.toString().indexOf('TimeoutError') > -1){
 					str = '链接请求超时,请查看网络状态!-4';
+				}else if(e.toString().indexOf('operation not permitted') > -1){
+					str = '权限受限,请以管理员权限运行软件!-5';
+				}else if(e.toString().indexOf('browser has disconnected') > -1){
+					str = '浏览器断开链接!-6';
 				}else{
 					str = e.toString();
-					console.log(e);
+					//console.log(e);
 				}
 				this.loading = false;
 				this.$notify.error({
@@ -1868,4 +1935,8 @@
 		width: 20px;
 		margin-right: 5px;
 	}
+	
+	.dialog-footer-center{
+		text-align: center;
+	}
 </style>