|
@@ -9,7 +9,7 @@
|
|
|
<div class="content-top">
|
|
|
<el-button-group>
|
|
|
<el-button type="primary" size="mini" icon="el-icon-document" v-if="['1','3','5'].indexOf(menuIndex) > -1" @click="pickFile()">添加文件</el-button>
|
|
|
- <el-button type="primary" size="mini" icon="el-icon-document" v-if="['1','3','5'].indexOf(menuIndex) > -1" @click="pickDir()">添加目录</el-button>
|
|
|
+ <el-button type="primary" size="mini" icon="el-icon-document" v-if="['1','3','5'].indexOf(menuIndex) > -1" @click="pickDir()">打开文件夹</el-button>
|
|
|
<el-button type="primary" size="mini" icon="el-icon-folder" v-if="['2','4','6'].indexOf(menuIndex) > -1" @click="addDir()">添加文件夹</el-button>
|
|
|
<el-button type="primary" size="mini" icon="el-icon-delete" @click="clearList()">清空列表</el-button>
|
|
|
<el-popover v-if="['1','3','5'].indexOf(menuIndex) > -1" popper-class="popper-open" placement="bottom" trigger="hover" content="添加目录会导入目录以及子目录下所有文件">
|
|
@@ -17,37 +17,41 @@
|
|
|
</el-popover>
|
|
|
</el-button-group>
|
|
|
|
|
|
- <div style="width: 366px; display: flex; justify-content: space-between;align-items: flex-end;">
|
|
|
- <el-popover v-if="(menuIndex == '1' && fileList.length > 0) || (menuIndex == '2' && dirList.length > 0)" placement="bottom" popper-class="popper-open" trigger="hover" content="命名撤回一次">
|
|
|
- <el-button slot="reference" type="info" size="mini" @click="back()" :disabled="(menuIndex == '1' && backFileList.length == 0) || (menuIndex == '2' && backDirList.length == 0)" >撤回</el-button>
|
|
|
- </el-popover>
|
|
|
- <div v-else></div>
|
|
|
+ <el-row type="flex" style="align-items: center;">
|
|
|
+ <div>
|
|
|
+ <span class="set-title">存放目录:</span>
|
|
|
+ <el-input :title="downloadDir" ref="upload-input" size="mini" @focus="pickPath" placeholder="请选择输出目录" v-model="downloadDir" readonly style="width:200px;" prefix-icon="el-icon-folder"></el-input>
|
|
|
+ <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>
|
|
|
+ </el-popover>
|
|
|
+ </div>
|
|
|
<el-button type="danger" style="margin-left: 20px;" @click="exportFile()" :loading="exportLoading">开始处理</el-button>
|
|
|
- </div>
|
|
|
+ </el-row>
|
|
|
</div>
|
|
|
|
|
|
<div class="soft-content">
|
|
|
<div class="content-left">
|
|
|
+ <div class="handle-item">
|
|
|
+ <label class="handle-label">搜索目录:</label>
|
|
|
+ <el-input readonly ref="search-input" size="mini" placeholder="请选择搜索目录" v-model="searchDir" style="width:300px;" prefix-icon="el-icon-folder"></el-input>
|
|
|
+ <el-button type="primary" size="mini" @click="pickDir()">选择目录</el-button>
|
|
|
+ </div>
|
|
|
+ <div class="handle-item">
|
|
|
+ <label class="handle-label">操作方式:</label>
|
|
|
+ <el-radio-group v-model="handleData.type" size="mini">
|
|
|
+ <el-radio label="1" border>复制</el-radio>
|
|
|
+ <el-radio label="2" border>剪切</el-radio>
|
|
|
+ <el-radio label="3" border>删除</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </div>
|
|
|
|
|
|
- <div>
|
|
|
- <div class="handle-item">
|
|
|
- <label class="handle-label">操作方式:</label>
|
|
|
- <el-radio-group v-model="handleData.type">
|
|
|
- <el-radio label="1" border>复制</el-radio>
|
|
|
- <el-radio label="2" border>剪切</el-radio>
|
|
|
- <el-radio label="3" border>删除</el-radio>
|
|
|
- </el-radio-group>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="handle-item">
|
|
|
- <label class="handle-label">查找规则:</label>
|
|
|
- <el-radio-group v-model="handleData.rule">
|
|
|
- <el-radio label="1" border>相同文件名</el-radio>
|
|
|
- <el-radio label="2" border>包含文件名</el-radio>
|
|
|
- <el-radio label="3" border>文件名且格式相同</el-radio>
|
|
|
- </el-radio-group>
|
|
|
- </div>
|
|
|
-
|
|
|
+ <div class="handle-item">
|
|
|
+ <label class="handle-label">查找规则:</label>
|
|
|
+ <el-radio-group v-model="handleData.rule" size="mini">
|
|
|
+ <el-radio label="1" border>相同文件名</el-radio>
|
|
|
+ <el-radio label="2" border>包含文件名</el-radio>
|
|
|
+ <el-radio label="3" border>文件名且格式相同</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
</div>
|
|
|
|
|
|
<div class="table-scroll">
|
|
@@ -106,7 +110,10 @@
|
|
|
|
|
|
<!-- 设置区域 -->
|
|
|
<div class="content-right">
|
|
|
- <el-input type="textarea" :rows="20" placeholder="请输入内容" v-model="handleData.findText"></el-input>
|
|
|
+ <el-input type="textarea" :rows="20" placeholder="查找文件名清单,多个请换行显示:
|
|
|
+ 名称1
|
|
|
+ 名称2
|
|
|
+ 名称3" v-model="handleData.findText"></el-input>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
@@ -151,8 +158,10 @@ export default {
|
|
|
return {
|
|
|
imgUrl: this.$api.imgUrl,
|
|
|
menuIndex: '1', // 重命名类型 1 or 2
|
|
|
- fileList: [], // 文件列表
|
|
|
- handleData: {
|
|
|
+ fileList: [], // 文件列表
|
|
|
+ downloadDir: os.userInfo().homedir + separator + "Downloads",
|
|
|
+ searchDir: '',
|
|
|
+ handleData: {
|
|
|
type: '1',
|
|
|
rule: '1',
|
|
|
findText: '',
|
|
@@ -169,12 +178,10 @@ export default {
|
|
|
|
|
|
let __dirname = os.userInfo().homedir;
|
|
|
if(fs.existsSync(__dirname + separator + "Desktop")){
|
|
|
- this.downloadFoundDir = this.downloadDir = __dirname + separator + "Desktop"
|
|
|
+ this.downloadDir = __dirname + separator + "Desktop";
|
|
|
} else{
|
|
|
- this.downloadFoundDir = this.downloadDir = __dirname + separator + "Downloads"
|
|
|
+ this.downloadDir = __dirname + separator + "Downloads";
|
|
|
}
|
|
|
- this.extractData.newPath = this.downloadDir;
|
|
|
- this.foundData.newPath = this.downloadFoundDir;
|
|
|
|
|
|
// 打开浏览器
|
|
|
const { shell } = require('electron');
|
|
@@ -185,60 +192,30 @@ export default {
|
|
|
e.preventDefault();
|
|
|
shell.openExternal(url);
|
|
|
});
|
|
|
- });
|
|
|
-
|
|
|
- (async () => {
|
|
|
- const files = await fg(['D:/桌面/测试文件/**/[1].{jpeg,png,gif}']);
|
|
|
- console.log(files);
|
|
|
- })();
|
|
|
+ });
|
|
|
},
|
|
|
methods: {
|
|
|
// 选择导出目录 1、提取和文件生成
|
|
|
- pickPath(str, input) {
|
|
|
- this.$refs[input].blur();
|
|
|
+ pickPath() {
|
|
|
+ this.$refs['upload-input'].blur();
|
|
|
electronApi.call('pickDir', []).then((path) => {
|
|
|
if (path) {
|
|
|
- this[str].newPath = path;
|
|
|
- if(str == 'foundData'){
|
|
|
- this.downloadFoundDir = path;
|
|
|
- }else{
|
|
|
- this.downloadDir = path;
|
|
|
- }
|
|
|
-
|
|
|
+ this.downloadDir = path;
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
// 打开自定义目录
|
|
|
openFolder(str){
|
|
|
- let path = str == 'foundData' ? this.downloadFoundDir : this.downloadDir;
|
|
|
- if(str == 'extractData'){
|
|
|
- if(fs.existsSync(path + separator + pjson.softInfo.softName)){
|
|
|
- path = path + separator + pjson.softInfo.softName;
|
|
|
- } else {
|
|
|
- fs.mkdirSync(path + separator + pjson.softInfo.softName);
|
|
|
- path = path + separator + pjson.softInfo.softName;
|
|
|
- }
|
|
|
+ let path = this.downloadDir;
|
|
|
+ if(!fs.existsSync(path + separator + pjson.softInfo.softName)){
|
|
|
+ fs.mkdirSync(path + separator + pjson.softInfo.softName);
|
|
|
}
|
|
|
+ path = path + separator + pjson.softInfo.softName;
|
|
|
electronApi.call('showItemInfolder',[path+'\\tty.tty'])
|
|
|
},
|
|
|
// 清除列表
|
|
|
clearList() {
|
|
|
- if(['1', '3', '5'].indexOf(this.menuIndex) > -1){
|
|
|
- this.backFileList = [];
|
|
|
- this.fileList = [];
|
|
|
- this.fileTimeList = [];
|
|
|
- this.filexlsxPath = "";
|
|
|
- this.filexlsxData = [];
|
|
|
- }else if(['2', '4', '6'].indexOf(this.menuIndex) > -1){
|
|
|
- this.backDirList = [];
|
|
|
- this.dirList = [];
|
|
|
- this.dirTimeList = [];
|
|
|
- this.dirxlsxPath = "";
|
|
|
- this.dirxlsxData = [];
|
|
|
- }else{
|
|
|
- this.foundList = [];
|
|
|
- this.foundList2 = [];
|
|
|
- }
|
|
|
+
|
|
|
},
|
|
|
async pickFile(){
|
|
|
const spinLoad = this.$loading();
|
|
@@ -251,11 +228,13 @@ export default {
|
|
|
spinLoad.close();
|
|
|
});
|
|
|
},
|
|
|
- // 添加目录导入文件
|
|
|
+ // 选择搜索目录
|
|
|
async pickDir(){
|
|
|
const spinLoad = this.$loading();
|
|
|
- await electronApi.call('pickDir', [os.userInfo().homedir]).then((path) =>{
|
|
|
- this.dealDir(path);
|
|
|
+ await electronApi.call('pickDir', []).then((path) =>{
|
|
|
+ if(path){
|
|
|
+ this.searchDir = path;
|
|
|
+ }
|
|
|
spinLoad.close();
|
|
|
}).catch(err => {
|
|
|
spinLoad.close();
|
|
@@ -457,7 +436,6 @@ export default {
|
|
|
// 导出
|
|
|
exportFile(flag) {
|
|
|
let authority = this.$refs.headerRef.authority;
|
|
|
- console.log(this.handleData.findText.split('\n'));
|
|
|
if (this.handleData.findText) {
|
|
|
if (!authority.isAuthority && !flag) { // 非会员点击转换弹出提示框
|
|
|
this.$refs.headerRef.memberModel = true;
|
|
@@ -465,7 +443,34 @@ export default {
|
|
|
return false;
|
|
|
} else {
|
|
|
this.$refs.headerRef.memberModel = false;
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ (async () => {
|
|
|
+ let findText = this.handleData.findText.split('\n');
|
|
|
+ let searchDir = this.searchDir.replace(/\\/g, '/');
|
|
|
+ let paramArr = [];
|
|
|
+ for(let i=0; i< findText.length; i++){
|
|
|
+ if(findText[i].trim()){
|
|
|
+ paramArr.push(findText[i].trim());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let params = paramArr.join('|');
|
|
|
+ let ruleStr = '';
|
|
|
+ switch(this.handleData.rule){
|
|
|
+ case '1': //相同文件名
|
|
|
+ ruleStr = searchDir + '/**/('+params+').*';
|
|
|
+ break;
|
|
|
+ case '2': //包含文件名
|
|
|
+ ruleStr = searchDir + '/**/*('+params+')*.*';
|
|
|
+ break;
|
|
|
+ case '3': //文件名格式相同
|
|
|
+ ruleStr = searchDir + '/**/('+params+')';
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ console.log(ruleStr);
|
|
|
+ const files = await fg([ruleStr], { dot: true });
|
|
|
+ console.log(files);
|
|
|
+ })();
|
|
|
|
|
|
this.exportLoading = true;
|
|
|
setTimeout(() => {
|