|
@@ -11,20 +11,38 @@
|
|
|
|
|
|
<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"><i class="el-icon-picture"></i>图片下载</template>
|
|
|
- <el-menu-item index="1">阿里巴巴</el-menu-item>
|
|
|
- <el-menu-item index="2">京东</el-menu-item>
|
|
|
- <el-menu-item index="3">天猫</el-menu-item>
|
|
|
- <el-menu-item index="4">淘宝</el-menu-item>
|
|
|
- <el-menu-item index="10">其他网址</el-menu-item>
|
|
|
+ <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>
|
|
|
+ <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="10">
|
|
|
+ <img src="../assets/image/m-chrome.png" class="m-image"/><span slot="title">其他网址</span>
|
|
|
+ </el-menu-item>
|
|
|
</el-submenu>
|
|
|
|
|
|
<el-submenu index="b">
|
|
|
- <template slot="title"><i class="el-icon-picture-outline-round"></i>图片处理</template>
|
|
|
- <el-menu-item index="2-1">格式转换</el-menu-item>
|
|
|
- <el-menu-item index="2-2">图片压缩</el-menu-item>
|
|
|
- <el-menu-item index="2-3">修改尺寸</el-menu-item>
|
|
|
- <el-menu-item index="2-5">添加水印</el-menu-item>
|
|
|
+ <template slot="title"><img src="../assets/image/m-edit.png" class="m-image"/>图片处理</template>
|
|
|
+ <el-menu-item index="2-1">
|
|
|
+ <img src="../assets/image/m-geshi.png" class="m-image"/><span slot="title">格式转换</span>
|
|
|
+ </el-menu-item>
|
|
|
+ <el-menu-item index="2-2">
|
|
|
+ <img src="../assets/image/m-yasuo.png" class="m-image"/><span slot="title">图片压缩</span>
|
|
|
+ </el-menu-item>
|
|
|
+ <el-menu-item index="2-3">
|
|
|
+ <img src="../assets/image/m-chicun.png" class="m-image"/><span slot="title">修改尺寸</span>
|
|
|
+ </el-menu-item>
|
|
|
+ <el-menu-item index="2-5">
|
|
|
+ <img src="../assets/image/m-shuiyin.png" class="m-image"/><span slot="title">添加水印</span>
|
|
|
+ </el-menu-item>
|
|
|
</el-submenu>
|
|
|
</el-menu>
|
|
|
</el-aside>
|
|
@@ -572,10 +590,10 @@
|
|
|
|
|
|
// 10-普通网址下载
|
|
|
async normalDownload(urlInfo){
|
|
|
- let authority = this.$refs.headerRef.authority.isAuthority;
|
|
|
let task = await new Promise((resolve,reject) =>{
|
|
|
(async () => {
|
|
|
try{
|
|
|
+ let authority = this.$refs.headerRef.authority.isAuthority;
|
|
|
let number = 0;
|
|
|
urlInfo.status = '2';
|
|
|
urlInfo.num = 0;
|
|
@@ -696,6 +714,7 @@
|
|
|
let task = await new Promise((resolve,reject) =>{
|
|
|
(async () => {
|
|
|
try{
|
|
|
+ let authority = this.$refs.headerRef.authority.isAuthority;
|
|
|
urlInfo.status = '2';
|
|
|
urlInfo.num = 0;
|
|
|
const browser = await puppeteer.launch({
|
|
@@ -739,7 +758,7 @@
|
|
|
}, start);
|
|
|
if(start > num || start > 200){ // 防止页面过长,滚动200次自动停止
|
|
|
clearInterval(scrollInt);
|
|
|
- await this.alibabaScanImg(browser, page, urlInfo);
|
|
|
+ await this.alibabaScanImg(browser, page, urlInfo, authority);
|
|
|
this.loading = false;
|
|
|
urlInfo.status = '4';
|
|
|
resolve(true);
|
|
@@ -759,10 +778,10 @@
|
|
|
|
|
|
// 京东下载
|
|
|
async jdDownload(urlInfo){
|
|
|
- let authority = this.$refs.headerRef.authority.isAuthority;
|
|
|
let task = await new Promise((resolve,reject) =>{
|
|
|
(async () => {
|
|
|
try{
|
|
|
+ let authority = this.$refs.headerRef.authority.isAuthority;
|
|
|
urlInfo.status = '2';
|
|
|
urlInfo.num = 0;
|
|
|
const jdBrowser = await puppeteer.launch({
|
|
@@ -1002,7 +1021,7 @@
|
|
|
//淘宝\天猫下载
|
|
|
async tbDownload(urlInfo){
|
|
|
let task = null;
|
|
|
- if(this.tbStatus == 1){ // 未检测登录状态,开始检测
|
|
|
+ if(this.tbStatus == 1 || this.tbStatus == 3){ // 未检测登录状态/或提示未登录状态,开始检测
|
|
|
await this.checkLogin().then((data) => {
|
|
|
if(data == 2){ // 已经登录,处理下载
|
|
|
task = this.tbScanImg(urlInfo);
|
|
@@ -1019,11 +1038,6 @@
|
|
|
});
|
|
|
}else if(this.tbStatus == 2){ // 已经登录
|
|
|
task = this.tbScanImg(urlInfo);
|
|
|
- }else if(this.tbStatus == 3){ // 未登录
|
|
|
- task = 'notLogin';
|
|
|
- this.$notify.error({
|
|
|
- title: '请先登录淘宝/天猫账号后使用!'
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
return task;
|
|
@@ -1031,10 +1045,10 @@
|
|
|
|
|
|
// 淘宝天猫扫描下载图片
|
|
|
async tbScanImg(urlInfo){
|
|
|
- let authority = this.$refs.headerRef.authority.isAuthority;
|
|
|
let task = await new Promise((resolve,reject) =>{
|
|
|
(async () => {
|
|
|
try{
|
|
|
+ let authority = this.$refs.headerRef.authority.isAuthority;
|
|
|
urlInfo.status = '2';
|
|
|
urlInfo.num = 0;
|
|
|
const tbBrowser = await puppeteer.launch({
|
|
@@ -1079,7 +1093,7 @@
|
|
|
clearInterval(scrollInt);
|
|
|
|
|
|
//detailImg:详情图;skuImg:sku图片;commentImg: 评论图;video: 视频
|
|
|
- const imgInfo = await page.evaluate(() => {
|
|
|
+ const imgInfo = await page.evaluate((authority, execNum) => {
|
|
|
let outObj = {
|
|
|
mainImg: [],
|
|
|
detailImg: [],
|
|
@@ -1102,7 +1116,7 @@
|
|
|
if(result){
|
|
|
mainImgUrl = mainImgUrl.replace(result[0], '.'+result[1]);
|
|
|
}
|
|
|
- if(!authority && i < this.execNum){
|
|
|
+ if(!authority && i < execNum){
|
|
|
outObj.mainImg.push(mainImgUrl);
|
|
|
}
|
|
|
if(authority){
|
|
@@ -1120,7 +1134,7 @@
|
|
|
if(result){
|
|
|
skuImgUrl = skuImgUrl.replace(result[0], '.'+result[1]);
|
|
|
}
|
|
|
- if(!authority && i < this.execNum){
|
|
|
+ if(!authority && i < execNum){
|
|
|
outObj.skuImg.push(skuImgUrl);
|
|
|
}
|
|
|
if(authority){
|
|
@@ -1135,7 +1149,7 @@
|
|
|
if(result){
|
|
|
detailImgUrl = detailImgUrl.replace(result[0], '.'+result[1]);
|
|
|
}
|
|
|
- if(!authority && i < this.execNum){
|
|
|
+ if(!authority && i < execNum){
|
|
|
outObj.detailImg.push(detailImgUrl);
|
|
|
}
|
|
|
if(authority){
|
|
@@ -1149,7 +1163,7 @@
|
|
|
}
|
|
|
for(let i=0; i< arr4.length; i++){
|
|
|
if(arr4[i].src.indexOf('/avatar/sns/user/flag/sns_logo') == -1){ //过滤淘宝用户头像
|
|
|
- if(!authority && i < this.execNum){
|
|
|
+ if(!authority && i < execNum){
|
|
|
outObj.commentImg.push(arr4[i].src);
|
|
|
}
|
|
|
if(authority){
|
|
@@ -1161,7 +1175,7 @@
|
|
|
let arr5 = document.querySelectorAll('video.lib-video');
|
|
|
for(let i=0; i< arr5.length; i++){
|
|
|
if(outObj.video.indexOf(arr5[i].src) == -1){
|
|
|
- if(!authority && i < this.execNum){
|
|
|
+ if(!authority && i < execNum){
|
|
|
outObj.video.push(arr5[i].src);
|
|
|
}
|
|
|
if(authority){
|
|
@@ -1170,7 +1184,7 @@
|
|
|
}
|
|
|
}
|
|
|
return outObj;
|
|
|
- });
|
|
|
+ }, authority, this.execNum);
|
|
|
|
|
|
// 主图下载
|
|
|
for(let j = 0; j < imgInfo.mainImg.length; j++){
|
|
@@ -1285,10 +1299,9 @@
|
|
|
},
|
|
|
|
|
|
// 阿里巴巴 - 扫描并下载图片
|
|
|
- async alibabaScanImg(browser, page, urlInfo){
|
|
|
- let authority = this.$refs.headerRef.authority.isAuthority;
|
|
|
+ async alibabaScanImg(browser, page, urlInfo, authority){
|
|
|
//detailImg:详情图;skuImg:sku图片;commentImg: 评论图;video: 视频
|
|
|
- const imgInfo = await page.evaluate(() => {
|
|
|
+ const imgInfo = await page.evaluate((authority, execNum) => {
|
|
|
let outObj = {
|
|
|
mainImg: [],
|
|
|
detailImg: [],
|
|
@@ -1300,7 +1313,7 @@
|
|
|
//主图
|
|
|
let arr1 = document.querySelectorAll('img.detail-gallery-img');
|
|
|
for(let i=0; i< arr1.length; i++){
|
|
|
- if(!authority && i < this.execNum){
|
|
|
+ if(!authority && i < execNum){
|
|
|
outObj.mainImg.push(arr1[i].src);
|
|
|
}
|
|
|
if(authority){
|
|
@@ -1311,7 +1324,7 @@
|
|
|
let arr2 = document.querySelectorAll('.prop-img');
|
|
|
for(let i=0; i< arr2.length; i++){
|
|
|
let src = window.getComputedStyle(arr2[i]).backgroundImage.replace(/url\(["']?(.+?)["']?\)/i, '$1');
|
|
|
- if(!authority && i < this.execNum){
|
|
|
+ if(!authority && i < execNum){
|
|
|
outObj.skuImg.push(src);
|
|
|
}
|
|
|
if(authority){
|
|
@@ -1321,7 +1334,7 @@
|
|
|
//详情图片
|
|
|
let arr3 = document.querySelectorAll('img.desc-img-loaded');
|
|
|
for(let i=0; i< arr3.length; i++){
|
|
|
- if(!authority && i < this.execNum){
|
|
|
+ if(!authority && i < execNum){
|
|
|
outObj.detailImg.push(arr3[i].src);
|
|
|
}
|
|
|
if(authority){
|
|
@@ -1331,7 +1344,7 @@
|
|
|
//评论图片 -- 需要点击切换
|
|
|
// let arr4 = document.querySelectorAll('img.image-box');
|
|
|
// for(let i=0; i< arr4.length; i++){
|
|
|
- // if(!authority && i < this.execNum){
|
|
|
+ // if(!authority && i < execNum){
|
|
|
// outObj.commentImg.push(arr4[i].src);
|
|
|
// }
|
|
|
// if(authority){
|
|
@@ -1342,7 +1355,7 @@
|
|
|
let arr5 = document.querySelectorAll('video.lib-video');
|
|
|
for(let i=0; i< arr5.length; i++){
|
|
|
if(outObj.video.indexOf(arr5[i].src) == -1){
|
|
|
- if(!authority && i < this.execNum){
|
|
|
+ if(!authority && i < execNum){
|
|
|
outObj.video.push(arr5[i].src);
|
|
|
}
|
|
|
if(authority){
|
|
@@ -1351,7 +1364,7 @@
|
|
|
}
|
|
|
}
|
|
|
return outObj;
|
|
|
- });
|
|
|
+ }, authority, this.execNum);
|
|
|
|
|
|
// 主图下载
|
|
|
for(let j = 0; j < imgInfo.mainImg.length; j++){
|
|
@@ -1765,4 +1778,9 @@
|
|
|
h3{
|
|
|
margin: 0;
|
|
|
}
|
|
|
+
|
|
|
+ .m-image{
|
|
|
+ width: 20px;
|
|
|
+ margin-right: 5px;
|
|
|
+ }
|
|
|
</style>
|