qiushang 11 kuukautta sitten
vanhempi
commit
0377ced57f
2 muutettua tiedostoa jossa 73 lisäystä ja 17 poistoa
  1. 1 1
      src/renderer/assets/css/home.scss
  2. 72 16
      src/renderer/components/home.vue

+ 1 - 1
src/renderer/assets/css/home.scss

@@ -241,7 +241,7 @@ div,p{
 
 .table-scroll {
   overflow-y: auto;
-  height: calc(100% - 41px);
+  height: calc(100% - 101px);
 }
 
 .img-table {

+ 72 - 16
src/renderer/components/home.vue

@@ -57,14 +57,18 @@
 					<el-main v-show="['1', '2', '3', '4', '10'].indexOf(menuIndex) > -1" ref="el-main" style="background-color: #fafafa;">
 						<template>
 							<div class="content-top">
-								<el-button-group>
-									<el-button type="primary" size="mini" icon="el-icon-circle-plus-outline"
-										@click="addVisible = true;">添加链接</el-button>
-									<el-button type="primary" size="mini" icon="el-icon-upload"
-										@click="pickFile()">导入链接</el-button>
-									<el-button type="primary" size="mini" icon="el-icon-delete"
-										@click="clearList()">清空链接</el-button>
-								</el-button-group>
+								<div>
+									<el-button-group>
+										<el-button type="primary" size="mini" icon="el-icon-circle-plus-outline"
+											@click="addVisible = true;">添加链接</el-button>
+										<el-button type="primary" size="mini" icon="el-icon-upload"
+											@click="pickLink()">导入链接</el-button>
+										<el-button type="primary" size="mini" icon="el-icon-delete"
+											@click="clearList()">清空链接</el-button>
+									</el-button-group>
+									
+									<el-link type="info" style="margin-left: 20px; vertical-align:baseline;" @click="downloadExample()">模板下载<i class="el-icon-download"></i></el-link>
+								</div>
 								
 								<el-row type="flex" style="align-items: center;">
 									<div class="set-item">
@@ -79,7 +83,7 @@
 								</el-row>
 							</div>
 							
-							<div style="padding: 20px 20px 0 20px; height: calc(100% - 160px);">
+							<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>
@@ -439,7 +443,7 @@
 					}
 				});
 			},
-			async pickFile() {
+			async pickLink() {
 				const spinLoad = this.$loading();
 				await electronApi.call('pickFile', ['xlsx,xls', true]).then(async (path) => {
 					spinLoad.close();
@@ -453,16 +457,44 @@
 						if(workSheetsFromBuffer && workSheetsFromBuffer.length > 0){
 							let errMsg = "";
 							workSheetsFromBuffer[0].data.map((item, index) => {
-								if(item[0] == undefined){
-									errMsg += "第" + (index+1) + "行格式有误</br>";
-									item[0] = '';
+								if(item.length > 0){
+									if(item[1] == undefined){
+										errMsg += "第" + (index+1) + "行格式有误</br>";
+										item[1] = '';
+									}else if(!/^(http|https):\/\/.+$/.exec(item[1])){
+										errMsg += "第" + (index+1) + "行网址格式有误</br>";
+									}else{
+										let info = {
+											url: item[1],
+											title: item[0].trim(),
+											status: '1',
+											num: 0,
+											newPath: ''
+										}
+										switch(this.menuIndex){
+											case '1':
+												this.alibabaList.push(info);
+												break;
+											case '2':
+												this.jdList.push(info);
+												break;
+											case '3':
+												this.tmallList.push(info);
+												break;
+											case '4':
+												this.tbList.push(info);
+												break;
+											case '10':
+												this.commonList.push(info);
+												break;
+										}
+									}
 								}
-								
-								console.log(item)
 							});
 							if(errMsg){
 								this.$notify({
 									title: '请检查文件以下问题',
+									dangerouslyUseHTMLString: true,
 									message: errMsg,
 									type: 'warning'
 								});
@@ -1478,6 +1510,16 @@
 				await browser.close();
 			},
 			
+			//
+			downloadExample(){
+				let url = 'https://www.xingyousoft.com/soft/XYCapture/example.xlsx';
+				if (!fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName)) {
+					fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName);
+				}
+				let path = this.downloadDir + separator + pjson.softInfo.softName + '\\链接模板下载.xlsx';
+				this.downloadImage(url, path, 'example');
+			},
+			
 			// 下载网址链接的图片
 			async downloadImage(imageUrl, outputPath, urlInfo) {
 				let _this = this;
@@ -1514,7 +1556,21 @@
 						});
 						
 						req.on('end', ()=> {
-							urlInfo.num += 1;
+							if(urlInfo != 'example'){
+								urlInfo.num += 1;
+							}else{
+								this.$msgbox({
+									title: '消息',
+									message: '模板下载成功,保存位置:' + this.downloadDir + separator + pjson.softInfo.softName,
+									showCancelButton: true,
+									confirmButtonText: '去查看',
+									cancelButtonText: '取消',
+								}).then(action => {
+									this.openFolder();
+								}).catch(action => {
+									
+								});
+							}
 							//console.log('下载完成', outputPath)
 							resolve(true);
 						});