qiushang преди 10 месеца
родител
ревизия
6fc00c5a5e
променени са 3 файла, в които са добавени 265 реда и са изтрити 322 реда
  1. 1 1
      package.json
  2. 32 22
      src/renderer/components/home.vue
  3. 232 299
      yarn.lock

+ 1 - 1
package.json

@@ -38,7 +38,7 @@
     "axios": "^0.18.0",
     "element-ui": "^2.15.14",
     "fast-glob": "^3.3.2",
-    "fs-extra": "^11.2.0",
+    "fs-extra": "10.1.0",
     "request": "^2.88.2",
     "vue": "^2.5.2",
     "vue-electron": "^1.0.6",

+ 32 - 22
src/renderer/components/home.vue

@@ -45,9 +45,7 @@
 						<div class="handle-item" style="margin-bottom: 5px;">
 							<p>
 								<b>文件名检索结果:</b>
-								<span style="color: #F56C6C; font-size: 12px;" >共有 {{fileList.length}} 个文件</span>
-								<span style="color: #F56C6C; font-size: 12px;" >,耗时 {{times / 1000}} 秒</span>
-								{{test}}
+								<span style="color: #F56C6C; font-size: 12px;" >共有 {{fileList.length}} 个文件,搜索耗时 {{times / 1000}} 秒</span>
 							</p>
 						</div>
 						<div class="table-scroll">
@@ -354,9 +352,15 @@ export default {
 					files.map(item => {
 						let filename = item.substr(item.lastIndexOf('/')+1);
 						let title = filename.substr(0, filename.lastIndexOf('.'));
+						let suffix = filename.substr(filename.lastIndexOf('.'));
+						if(filename.indexOf('.') < 0){
+							title = filename;
+							suffix = '';
+						}
 						let res = regExp.exec(filename);
 						this.fileList.push({
 							title: title,
+							suffix: suffix, // 带.
 							name: filename,
 							match: res,
 							path: item,
@@ -402,29 +406,29 @@ export default {
 				
 				setTimeout(() => {
 					for(let i = 0; i < this.fileList.length; i++){
-						console.log(i, new Date().getTime());
 						if(i < size){
 							let item = this.fileList[i];
 							let newFilePath = newPath + separator + item.name;
-							if(fse.existsSync(newFilePath)){
-								
-							}
+							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.copySync(item.path, newFilePath);
-									item.status = '2';
-									
-									
-									// fse.copy(item.path, newFilePath).then(() => {
-									// 	console.log('复制成功!')
-									// 	item.status = '2';
-									// }).catch(err => {
-									// 	console.error('复制失败', err)
-									// 	item.status = '6';
-									// });
+									fse.copy(item.path, newFilePath, {overwrite: false, errorOnExist: true}).then(() => {
+										console.log('复制成功!')
+										item.status = '2';
+									}).catch(err => {
+										let str = err.toString();
+										console.error('复制失败', err.toString(), item.path)
+										if(str.indexOf('already exists') > -1 && str.indexOf(item.name) > -1){
+											console.log('重新复制')
+										}
+										item.status = '6';
+									})
 									
 								}
 								
@@ -434,8 +438,14 @@ export default {
 								}
 								
 								if(this.handleData.type == '3'){ // 删除
-									fse.removeSync(item.path);
-									item.status = '4'
+									// fse.removeSync(item.path);
+									// item.status = '4'
+									//异步
+									fse.remove(item.path).then(() => {
+										item.status = '4';
+									}).catch(err => {
+										item.status = '6';
+									})
 								}
 								
 								if(this.handleData.type == '4'){ // 覆盖

Файловите разлики са ограничени, защото са твърде много
+ 232 - 299
yarn.lock


Някои файлове не бяха показани, защото твърде много файлове са промени