|
@@ -137,8 +137,8 @@
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="set-item">
|
|
<div class="set-item">
|
|
- <span>保存目录:</span>
|
|
|
|
- <el-input :title="handleData.newPath" ref="upload-input" @focus="pickPath" placeholder="请选择输出目录" size="mini" v-model="handleData.newPath" readonly style="width:180px;" prefix-icon="el-icon-folder"></el-input>
|
|
|
|
|
|
+ <span class="set-title">保存目录:</span>
|
|
|
|
+ <el-input :title="handleData.newPath" ref="upload-input" @focus="pickPath" placeholder="请选择输出目录" size="small" v-model="handleData.newPath" readonly style="width:180px;" prefix-icon="el-icon-folder"></el-input>
|
|
<el-popover placement="bottom" popper-class="popper-open" trigger="hover" content="打开保存目录">
|
|
<el-popover placement="bottom" popper-class="popper-open" trigger="hover" content="打开保存目录">
|
|
<i class="el-icon-folder-opened" slot="reference" style="padding-left: 5px; cursor: pointer; font-size: 22px; vertical-align: middle;" @click="openFolder()"></i>
|
|
<i class="el-icon-folder-opened" slot="reference" style="padding-left: 5px; cursor: pointer; font-size: 22px; vertical-align: middle;" @click="openFolder()"></i>
|
|
</el-popover>
|
|
</el-popover>
|
|
@@ -379,12 +379,12 @@
|
|
let size = fs.statSync(file).size;
|
|
let size = fs.statSync(file).size;
|
|
|
|
|
|
if (!this.$refs.headerRef.authority.isAuthority) {
|
|
if (!this.$refs.headerRef.authority.isAuthority) {
|
|
- if (size > 1024 * 200) {
|
|
|
|
- this.$notify.error({
|
|
|
|
- title: '免费版,文件最大不能超过200KB!'
|
|
|
|
- });
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
|
|
+ // if (size > 1024 * 200) {
|
|
|
|
+ // this.$notify.error({
|
|
|
|
+ // title: '免费版,文件最大不能超过200KB!'
|
|
|
|
+ // });
|
|
|
|
+ // return false;
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
|
|
|
|
let fileInfo = {
|
|
let fileInfo = {
|
|
@@ -490,70 +490,64 @@
|
|
this.loading = false;
|
|
this.loading = false;
|
|
return false;
|
|
return false;
|
|
}else{
|
|
}else{
|
|
-
|
|
|
|
let fileList = this.fileList;
|
|
let fileList = this.fileList;
|
|
let authority = this.$refs.headerRef.authority;
|
|
let authority = this.$refs.headerRef.authority;
|
|
- if (fileList.length > 0) {
|
|
|
|
- if (!authority.isAuthority && !flag) {
|
|
|
|
- this.$refs.headerRef.memberModel = true;
|
|
|
|
- this.$refs.headerRef.isClick = true;
|
|
|
|
- return false;
|
|
|
|
- } else {
|
|
|
|
- this.$refs.headerRef.memberModel = false;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- this.loading = true;
|
|
|
|
- setTimeout(() => {
|
|
|
|
- this.loading = false;
|
|
|
|
- }, 3000)
|
|
|
|
|
|
+ if (!authority.isAuthority && !flag) {
|
|
|
|
+ this.$refs.headerRef.memberModel = true;
|
|
|
|
+ this.$refs.headerRef.isClick = true;
|
|
|
|
+ return false;
|
|
|
|
+ } else {
|
|
|
|
+ this.$refs.headerRef.memberModel = false;
|
|
}
|
|
}
|
|
|
|
|
|
//percent
|
|
//percent
|
|
let taskArr = [];
|
|
let taskArr = [];
|
|
let newPath = '';
|
|
let newPath = '';
|
|
- for (let i = 0; i < fileList.length; i++) {
|
|
|
|
- let item = fileList[i];
|
|
|
|
- let lastIndex = item.path.lastIndexOf('.');
|
|
|
|
- let suffix = this.exportFormat;
|
|
|
|
|
|
+ setTimeout(async() => {
|
|
|
|
+ for (let i = 0; i < fileList.length; i++) {
|
|
|
|
+ let item = fileList[i];
|
|
|
|
+ let lastIndex = item.path.lastIndexOf('.');
|
|
|
|
+ let suffix = this.exportFormat;
|
|
|
|
+
|
|
|
|
+ if (fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName)) {
|
|
|
|
+ this.handleData.newPath = this.downloadDir + separator + pjson.softInfo.softName;
|
|
|
|
+ } else {
|
|
|
|
+ fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName);
|
|
|
|
+ this.handleData.newPath = this.downloadDir + separator + pjson.softInfo.softName;
|
|
|
|
+ }
|
|
|
|
|
|
- if (fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName)) {
|
|
|
|
- this.handleData.newPath = this.downloadDir + separator + pjson.softInfo.softName;
|
|
|
|
- } else {
|
|
|
|
- fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName);
|
|
|
|
- this.handleData.newPath = this.downloadDir + separator + pjson.softInfo.softName;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- newPath = this.handleData.newPath + separator + item.name.slice(0, item.name.lastIndexOf('.')) + '.' + suffix;
|
|
|
|
|
|
+ newPath = this.handleData.newPath + separator + item.name.slice(0, item.name.lastIndexOf('.')) + '.' + suffix;
|
|
|
|
+ // 处理文件
|
|
|
|
+ let task = this.dealFile(i, item, newPath);
|
|
|
|
+ if (task) {
|
|
|
|
+ taskArr.push(task);
|
|
|
|
+ }
|
|
|
|
|
|
- // 处理文件
|
|
|
|
- let task = this.dealFile(i, item, newPath);
|
|
|
|
- if (task) {
|
|
|
|
- taskArr.push(task);
|
|
|
|
|
|
+ if ((i + 1) % this.execLimit == 0) {
|
|
|
|
+ await Promise.all(taskArr).then(result => {
|
|
|
|
+ taskArr = [];
|
|
|
|
+ }).catch(err => {
|
|
|
|
+ console.log('err' + i, err)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
- if ((i + 1) % this.execLimit == 0) {
|
|
|
|
|
|
+
|
|
|
|
+ if (taskArr.length > 0) {
|
|
await Promise.all(taskArr).then(result => {
|
|
await Promise.all(taskArr).then(result => {
|
|
taskArr = [];
|
|
taskArr = [];
|
|
}).catch(err => {
|
|
}).catch(err => {
|
|
- console.log('err' + i, err)
|
|
|
|
|
|
+ // 错误文件添加到服务中
|
|
|
|
+ console.log('err', err)
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- if (taskArr.length > 0) {
|
|
|
|
- await Promise.all(taskArr).then(result => {
|
|
|
|
- taskArr = [];
|
|
|
|
- }).catch(err => {
|
|
|
|
- // 错误文件添加到服务中
|
|
|
|
- console.log('err', err)
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 打开文件夹
|
|
|
|
- if (fileList.length > 0) {
|
|
|
|
- this.$message({message: "恭喜你,任务已完成!", type: 'success'});
|
|
|
|
- electronApi.call('showItemInfolder', [newPath])
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ // 打开文件夹
|
|
|
|
+ if (fileList.length > 0) {
|
|
|
|
+ this.$message({message: "恭喜你,任务已完成!", type: 'success'});
|
|
|
|
+ electronApi.call('showItemInfolder', [this.handleData.newPath + '\\xy.txt'])
|
|
|
|
+ }
|
|
|
|
+ }, 300)
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -561,22 +555,17 @@
|
|
this.loading = false;
|
|
this.loading = false;
|
|
}, 3000)
|
|
}, 3000)
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ },
|
|
|
|
+ showPercent(num, index, item){
|
|
|
|
+ item.percent = num;
|
|
|
|
+ this.fileList.splice(index, 1, item);
|
|
},
|
|
},
|
|
// 处理文件
|
|
// 处理文件
|
|
dealFile(index, item, newPath) {
|
|
dealFile(index, item, newPath) {
|
|
- return new Promise(async (resolve, reject) => {
|
|
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
let path = item.path;
|
|
let path = item.path;
|
|
|
|
|
|
- item.percent = 5;
|
|
|
|
- this.fileList[index].setInt = setInterval(() => {
|
|
|
|
- if(item.percent < 70){
|
|
|
|
- item.percent += 2;
|
|
|
|
- }else if(item.percent < 99){
|
|
|
|
- item.percent += 1;
|
|
|
|
- }
|
|
|
|
- this.fileList.splice(index, 1, item);
|
|
|
|
- }, 600);
|
|
|
|
|
|
+ this.showPercent(5, index, item);
|
|
|
|
|
|
fs.readFile(path, 'utf8', async(err, data) => {
|
|
fs.readFile(path, 'utf8', async(err, data) => {
|
|
if (err) {
|
|
if (err) {
|
|
@@ -585,12 +574,8 @@
|
|
title: '错误',
|
|
title: '错误',
|
|
message: "出现错误,请重试!" + filePath
|
|
message: "出现错误,请重试!" + filePath
|
|
});
|
|
});
|
|
- clearInterval(this.fileList[index].setInt);
|
|
|
|
reject(false);
|
|
reject(false);
|
|
- return;
|
|
|
|
}
|
|
}
|
|
- let startTime = new Date().getTime();
|
|
|
|
- console.log("文件内字符长度", data.length);
|
|
|
|
|
|
|
|
let outContent = '';
|
|
let outContent = '';
|
|
this.pinSetting.separator = this.separator == '' ? ' ' : this.separator;
|
|
this.pinSetting.separator = this.separator == '' ? ' ' : this.separator;
|
|
@@ -607,6 +592,8 @@
|
|
outContent = pinyin(data, this.pinSetting);
|
|
outContent = pinyin(data, this.pinSetting);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ this.showPercent(50, index, item);
|
|
|
|
+
|
|
let buffer;
|
|
let buffer;
|
|
if(this.pinBuild == 1){ // 上下结构
|
|
if(this.pinBuild == 1){ // 上下结构
|
|
let blob = htmlDocx.asBlob(outContent);
|
|
let blob = htmlDocx.asBlob(outContent);
|
|
@@ -614,7 +601,8 @@
|
|
}else{
|
|
}else{
|
|
buffer = outContent;
|
|
buffer = outContent;
|
|
}
|
|
}
|
|
- console.log('--out内容长度---',outContent.length,'--buffer的长度---',buffer.length);
|
|
|
|
|
|
+
|
|
|
|
+ this.showPercent(70, index, item);
|
|
|
|
|
|
let filePath = newPath;
|
|
let filePath = newPath;
|
|
fs.writeFile(filePath, buffer, (err) => {
|
|
fs.writeFile(filePath, buffer, (err) => {
|
|
@@ -624,32 +612,13 @@
|
|
title: '错误',
|
|
title: '错误',
|
|
message: "出现错误,请重试!" + filePath
|
|
message: "出现错误,请重试!" + filePath
|
|
});
|
|
});
|
|
- clearInterval(this.fileList[index].setInt);
|
|
|
|
reject(false);
|
|
reject(false);
|
|
throw err;
|
|
throw err;
|
|
}
|
|
}
|
|
- item.percent = 100;
|
|
|
|
- let endTime = new Date().getTime();
|
|
|
|
- console.log('耗时:', endTime - startTime);
|
|
|
|
- clearInterval(this.fileList[index].setInt);
|
|
|
|
|
|
+ this.showPercent(100, index, item);
|
|
|
|
+ resolve(true);
|
|
});
|
|
});
|
|
-
|
|
|
|
-
|
|
|
|
- // let writerStream = fs.createWriteStream(filePath);
|
|
|
|
- // writerStream.write(buffer, 'utf8');
|
|
|
|
- // writerStream.on('finish', () => {
|
|
|
|
- // item.percent = 100;
|
|
|
|
- // let endTime = new Date().getTime();
|
|
|
|
- // clearInterval(this.fileList[index].setInt);
|
|
|
|
- // console.log('耗时:', endTime - startTime);
|
|
|
|
- // console.log('All writes are now complete.');
|
|
|
|
- // });
|
|
|
|
- // writerStream.on('error', (err) => {
|
|
|
|
- // console.error('An error occurred:', err);
|
|
|
|
- // });
|
|
|
|
- // writerStream.end();
|
|
|
|
});
|
|
});
|
|
- resolve(true);
|
|
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|