qiushang hace 10 meses
padre
commit
0f165c9aee
Se han modificado 3 ficheros con 65 adiciones y 32 borrados
  1. 1 1
      package.json
  2. 60 27
      src/renderer/components/home.vue
  3. 4 4
      yarn.lock

+ 1 - 1
package.json

@@ -40,7 +40,7 @@
     "fast-glob": "^3.3.2",
     "fs-extra": "10.1.0",
     "request": "^2.88.2",
-    "uuid": "^10.0.0",
+    "uuid": "9.0.1",
     "vue": "^2.5.2",
     "vue-electron": "^1.0.6",
     "vue-router": "^3.0.1",

+ 60 - 27
src/renderer/components/home.vue

@@ -51,7 +51,7 @@
 						<div class="table-scroll">
 							<vxe-table ref="xTable" 
 								show-overflow class="img-table" max-height="100%" empty-text="没有更多数据了!" :loading="tabLoading"
-								:loading-config="{icon: 'vxe-icon-indicator roll', text: '文件加载中...'}" :row-config="{isHover: true}"
+								:loading-config="{icon: 'vxe-icon-indicator roll', text: '任务处理中...'}" :row-config="{isHover: true}"
 								:edit-config="{trigger: 'click', mode: 'cell'}" :data="fileList" :scroll-y="{enabled: true}">
 								<vxe-column type="seq" width="60" title="编号"></vxe-column>
 								<vxe-column field="match" title="匹配词" width="150"></vxe-column>
@@ -124,8 +124,6 @@
 							<el-button type="danger" style="position: absolute; top: 40px; right: 10px;" @click="exportFile()" :loading="exportLoading">开始处理</el-button>
 						</div>
 					</div>
-					
-					
 				</div>
 				
 			</el-main>
@@ -166,7 +164,6 @@ export default {
 	},
 	data() {
 	    return {
-			test: 0,
 			imgUrl: this.$api.imgUrl,
 			menuIndex: '1', // 重命名类型 1 or 2
 			fileList: [], // 文件列表
@@ -186,6 +183,7 @@ export default {
 			
 	        dowloadModel: false,
 			finishModel: false,
+			loadingModal: false,
 	    };
 	},
 	mounted() {
@@ -208,6 +206,8 @@ export default {
 	            shell.openExternal(url);
 	        });
 		});
+		
+		this.loadingModal = true;
 	},
 	methods: {
 		// 选择导出目录
@@ -345,7 +345,7 @@ export default {
 						}
 						break;
 				}
-				console.log('----验证规则----', ruleStr);
+				//console.log('----验证规则----', ruleStr);
 				try{
 					const files = await fg(ruleStr, { dot: true });
 					let regExp = new RegExp(paramArr.join('|'));
@@ -397,7 +397,7 @@ export default {
 				
 				let size = 999999999;
 				if(!authority.isAuthority){
-					size = 999999;
+					size = 99999;
 				}
 				
 				if(!fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName)){
@@ -405,42 +405,57 @@ export default {
 				}
 				let newPath = this.downloadDir + separator + pjson.softInfo.softName;
 				
+				if(this.handleData.type == '4' && !this.coverFile){
+					this.$notify.error({
+						title: '提示',
+						message: '请选择覆盖文件后再操作'
+					});
+					return false;
+				}
+				
+				this.tabLoading = true;
+				
 				setTimeout(() => {
 					for(let i = 0; i < this.fileList.length; i++){
 						if(i < size){
 							let item = this.fileList[i];
 							let newFilePath = newPath + separator + item.name;
-							console.log(i, new Date().getTime());
-							// if(fse.existsSync(newFilePath)){
-							// 	newFilePath = newPath + separator + item.title + '重复' + new Date().getTime() + i + item.suffix;
-							// }
 							try {
 								if(this.handleData.type == '1'){ // 复制
-									//fse.copySync(item.path, newFilePath);
-									//item.status = '2';
-									fse.copy(item.path, newFilePath, {overwrite: false, errorOnExist: true}).then(() => {
-										console.log('复制成功!')
+									try{
+										fse.copySync(item.path, newFilePath, { overwrite: false, errorOnExist: true });
 										item.status = '2';
-									}).catch(err => {
-										let str = err.toString();
-										console.error('复制失败', err.toString(), item.path)
+									}catch(e){
+										let str = e.toString();
 										if(str.indexOf('already exists') > -1 && str.indexOf(item.name) > -1){
-											console.log('重新复制')
-											// newFilePath = newPath + separator + item.title + '重复' + uuidv4() + i.toString() + item.suffix;
+											newFilePath = newPath + separator + item.title + '重复文件' + uuidv4().substr(0, 18) + i.toString() + item.suffix;
+											fse.copy(item.path, newFilePath).then(() => {
+												item.status = '2';
+											}).catch(err => {
+												item.status = '6';
+											})
 										}
-										item.status = '6';
-									})
-									
+									}
 								}
 								
 								if(this.handleData.type == '2'){ // 剪切
-									fse.moveSync(item.path, newFilePath);
-									item.status = '3'
+									try{
+										fse.moveSync(item.path, newFilePath);
+										item.status = '3'
+									}catch(e){
+										let str = e.toString();
+										if(str.indexOf('already exists') > -1){
+											newFilePath = newPath + separator + item.title + '重复文件' + uuidv4().substr(0, 18) + i.toString() + item.suffix;
+											fse.move(item.path, newFilePath).then(() => {
+												item.status = '3';
+											}).catch(err => {
+												item.status = '6';
+											})
+										}
+									}
 								}
 								
 								if(this.handleData.type == '3'){ // 删除
-									// fse.removeSync(item.path);
-									// item.status = '4'
 									//异步
 									fse.remove(item.path).then(() => {
 										item.status = '4';
@@ -450,6 +465,16 @@ export default {
 								}
 								
 								if(this.handleData.type == '4'){ // 覆盖
+									let filename = this.coverFile.substr(this.coverFile.lastIndexOf('\\')+1);
+									if(filename == item.name){
+										fse.copy(this.coverFile, item.path).then(() => {
+											item.status = '2';
+										}).catch(err => {
+											item.status = '6';
+										})
+									}else{
+										item.status = '6';
+									}
 									
 								}
 								
@@ -457,11 +482,19 @@ export default {
 								console.error(err);
 								item.status = '6';
 							}
+							
+							this.nums++;
 						}
 					}
 					
-					console.log('end', new Date().getTime());
 				}, 100);
+			
+				// let delay = 500;
+				// this.fileList.length / 500
+			
+				setTimeout(() => {
+					this.tabLoading = false;
+				}, 5000)
 				
 			}
 	    },

+ 4 - 4
yarn.lock

@@ -9430,10 +9430,10 @@ utils-merge@1.0.1:
   resolved "https://registry.npmmirror.com/utils-merge/-/utils-merge-1.0.1.tgz"
   integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==
 
-uuid@^10.0.0:
-  version "10.0.0"
-  resolved "https://registry.npmmirror.com/uuid/-/uuid-10.0.0.tgz#5a95aa454e6e002725c79055fd42aaba30ca6294"
-  integrity sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==
+uuid@9.0.1:
+  version "9.0.1"
+  resolved "https://registry.npmmirror.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30"
+  integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==
 
 uuid@^3.3.2:
   version "3.4.0"