diff --git a/.gitignore b/.gitignore index 1936d3c..d6dd4f5 100644 --- a/.gitignore +++ b/.gitignore @@ -101,6 +101,4 @@ dist .dynamodb/ # TernJS port file -.tern-port -openRenamerBackend/database.db -openRenamerBackend/database.db +.tern-port \ No newline at end of file diff --git a/openRenamerBackend/.gitignore b/openRenamerBackend/.gitignore index e3c7e25..46c45b4 100644 --- a/openRenamerBackend/.gitignore +++ b/openRenamerBackend/.gitignore @@ -1,15 +1,16 @@ -.DS_Store -/.vscode/ -.vscode -node_modules/ -/dist/ -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# Editor directories and files -yarn.lock -log -sqls/history.json -static/* -!static/.gitkeep \ No newline at end of file +.DS_Store +/.vscode/ +.vscode +node_modules/ +/dist/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Editor directories and files +yarn.lock +log +sqls/history.json +static/* +!static/.gitkeep +database.db \ No newline at end of file diff --git a/openRenamerBackend/service/FileService.ts b/openRenamerBackend/service/FileService.ts index 45a7ca2..d38fea9 100644 --- a/openRenamerBackend/service/FileService.ts +++ b/openRenamerBackend/service/FileService.ts @@ -6,53 +6,53 @@ import ProcessHelper from '../util/ProcesHelper'; import FileObj from '../vo/FileObj'; class FileService { - static async readPath(pathStr: string, showHidden: boolean): Promise> { - pathStr = decodeURIComponent(pathStr); - let fileList = new Array(); - if (pathStr.trim().length == 0) { - //获取根目录路径 - if (config.isWindows) { - //windows下 - let std: string = ((await ProcessHelper.exec('wmic logicaldisk get caption')) as Object)['stdout'].replace('Caption', ''); - fileList = std - .split('\r\n') - .filter((item) => item.trim().length > 0) - .map((item) => item.trim()); - } else { - //linux下 - pathStr = '/'; - fileList = await fs.readdir(pathStr); - } - } else { - fileList = await fs.readdir(pathStr); - } - let folderList: Array = new Array(); - let files: Array = new Array(); - for (let index in fileList) { - try { - let stat = await fs.stat(path.join(pathStr, fileList[index])); - if (fileList[index].startsWith('.')) { - if (showHidden) { - (stat.isDirectory() ? folderList : files).push( - new FileObj(fileList[index], pathStr, stat.isDirectory(), stat.birthtime.getTime(), stat.mtime.getTime()), - ); - } - } else { - (stat.isDirectory() ? folderList : files).push( - new FileObj(fileList[index], pathStr, stat.isDirectory(), stat.birthtime.getTime(), stat.mtime.getTime()), - ); - } - } catch (e) { - console.error(e); - } - } - folderList.sort((a, b) => a.name.localeCompare(b.name)).push(...files.sort((a, b) => a.name.localeCompare(b.name))); - return folderList; - } + static async readPath(pathStr: string, showHidden: boolean): Promise> { + pathStr = decodeURIComponent(pathStr); + let fileList = new Array(); + if (pathStr.trim().length == 0) { + //获取根目录路径 + if (config.isWindows) { + //windows下 + let std: string = (await ProcessHelper.exec('wmic logicaldisk get caption')).replace('Caption', ''); + fileList = std + .split('\r\n') + .filter((item) => item.trim().length > 0) + .map((item) => item.trim()); + } else { + //linux下 + pathStr = '/'; + fileList = await fs.readdir(pathStr); + } + } else { + fileList = await fs.readdir(pathStr); + } + let folderList: Array = new Array(); + let files: Array = new Array(); + for (let index in fileList) { + try { + let stat = await fs.stat(path.join(pathStr, fileList[index])); + if (fileList[index].startsWith('.')) { + if (showHidden) { + (stat.isDirectory() ? folderList : files).push( + new FileObj(fileList[index], pathStr, stat.isDirectory(), stat.birthtime.getTime(), stat.mtime.getTime()), + ); + } + } else { + (stat.isDirectory() ? folderList : files).push( + new FileObj(fileList[index], pathStr, stat.isDirectory(), stat.birthtime.getTime(), stat.mtime.getTime()), + ); + } + } catch (e) { + console.error(e); + } + } + folderList.sort((a, b) => a.name.localeCompare(b.name)).push(...files.sort((a, b) => a.name.localeCompare(b.name))); + return folderList; + } - static async checkExist(pathStr: string) { - return await fs.pathExists(pathStr); - } + static async checkExist(pathStr: string) { + return await fs.pathExists(pathStr); + } } export default FileService; diff --git a/openRenamerFront/package.json b/openRenamerFront/package.json index d845177..63f91e8 100644 --- a/openRenamerFront/package.json +++ b/openRenamerFront/package.json @@ -11,13 +11,13 @@ "@element-plus/icons": "^0.0.11", "axios": "^0.21.1", "core-js": "^3.6.5", - "element-plus": "^1.0.2-beta.48", + "dayjs": "^1.10.7", + "element-plus": "^1.2.0-beta.5", "vue": "^3.0.0", "vue-router": "^4.0.0-0" }, "devDependencies": { "@vue/cli-plugin-babel": "~4.5.0", - "@vue/cli-plugin-eslint": "~4.5.0", "@vue/cli-plugin-router": "~4.5.0", "@vue/cli-service": "~4.5.0", "@vue/compiler-sfc": "^3.0.0", diff --git a/openRenamerFront/src/App.vue b/openRenamerFront/src/App.vue index 1181246..e379c18 100644 --- a/openRenamerFront/src/App.vue +++ b/openRenamerFront/src/App.vue @@ -1,46 +1,46 @@ - - - - - + + + + + diff --git a/openRenamerFront/src/components/FileChose.vue b/openRenamerFront/src/components/FileChose.vue index b2068dd..97b1e0b 100644 --- a/openRenamerFront/src/components/FileChose.vue +++ b/openRenamerFront/src/components/FileChose.vue @@ -1,145 +1,124 @@ - - - - - + + + + + diff --git a/openRenamerFront/src/components/Rule.vue b/openRenamerFront/src/components/Rule.vue index 3afa9f8..e7e7b29 100644 --- a/openRenamerFront/src/components/Rule.vue +++ b/openRenamerFront/src/components/Rule.vue @@ -1,82 +1,64 @@ - - - - - + + + + + diff --git a/openRenamerFront/src/main.js b/openRenamerFront/src/main.js index 6968460..98b7e58 100644 --- a/openRenamerFront/src/main.js +++ b/openRenamerFront/src/main.js @@ -1,10 +1,10 @@ -import { createApp } from 'vue'; -import App from './App.vue'; -import router from './router'; -import ElementPlus, { ElMessage } from 'element-plus'; -import 'element-plus/lib/theme-chalk/index.css'; - -const vueInstance = createApp(App); -vueInstance.use(router).use(ElementPlus).mount('#app'); -vueInstance.config.globalProperties.$message = ElMessage; -window.vueInstance = vueInstance; +import { createApp } from "vue"; +import App from "./App.vue"; +import router from "./router"; +import ElementPlus, { ElMessage } from "element-plus"; +import "element-plus/dist/index.css"; + +const vueInstance = createApp(App); +vueInstance.use(router).use(ElementPlus).mount("#app"); +vueInstance.config.globalProperties.$message = ElMessage; +window.vueInstance = vueInstance; diff --git a/openRenamerFront/src/views/home/Home.vue b/openRenamerFront/src/views/home/Home.vue index 60090a5..a1ccbfa 100644 --- a/openRenamerFront/src/views/home/Home.vue +++ b/openRenamerFront/src/views/home/Home.vue @@ -1,65 +1,44 @@ @@ -68,80 +47,41 @@ import { ArrowDownBold, ArrowUpBold } from "@element-plus/icons"; import HttpUtil from "../../utils/HttpUtil"; import FileChose from "@/components/FileChose"; -import ApplicationRuleList from "./components/ApplicationRuleList"; -import Rule from "@/components/Rule"; +import RuleBlock from "./components/RuleBlock.vue"; export default { name: "Home", components: { FileChose, - Rule, ArrowDownBold, ArrowUpBold, - ApplicationRuleList, + RuleBlock, }, data() { return { loading: false, //遮罩 dialogVisible: false, //新增文件弹窗 - ruleDialogShow: false, //规则弹窗 - ruleTemplateShow: false, //选择规则模板弹窗是否展示 + ruleList: [], //当前生效的规则 fileList: [], changedFileList: [], - ruleList: [], - editRule: null, //当前编辑的规则 needPreview: false, //需要点击预览 applicationRule: null, //当前应用的应用规则模板 }; }, - computed: { - //选中的规则 - checkedRules() { - return this.ruleList.filter((item) => item.checked); - }, - }, + methods: { //新增文件 async addData(data) { data.forEach((item) => (item.checked = false)); this.fileList.push(...data); this.dialogVisible = false; - console.log("asdffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); this.needPreview = true; await this.showResult(); }, - //新增规则 - async ruleAdd(data) { - data.checked = false; - data.blocked = false; - if (this.editRule != null) { - let index = this.ruleList.indexOf(this.editRule); - this.ruleList.splice(index, 1, data); - this.editRule = null; - } else { - this.ruleList.push(data); - } - this.ruleDialogShow = false; - + async ruleUpdate(rules) { + this.ruleList = rules; this.needPreview = true; await this.showResult(); }, - //禁用/启用 - async block() { - this.ruleList.filter((item) => item.checked).forEach((item) => (item.blocked = !item.blocked)); - this.needPreview = true; - await this.showResult(); - }, - //删除规则 - async deleteRule() { - this.ruleList = this.ruleList.filter((item) => !item.checked); - this.needPreview = true; - await this.showResult(); - }, - //编辑规则 - editClick() { - this.editRule = this.checkedRules[0]; - this.ruleDialogShow = true; - }, //预览结果 async showResult() { if (!this.checkRuleAndFile()) { @@ -153,9 +93,11 @@ export default { ruleList: this.ruleList.filter((item) => !item.blocked), }; this.changedFileList = await HttpUtil.post("/renamer/preview", null, body); + this.fileList = [...this.fileList]; this.needPreview = false; this.loading = false; }, + //提交 async submit() { if (!this.checkRuleAndFile()) { return; @@ -212,30 +154,24 @@ export default { \ No newline at end of file + + + + + diff --git a/openRenamerFront/src/views/home/components/RuleBlock.vue b/openRenamerFront/src/views/home/components/RuleBlock.vue new file mode 100644 index 0000000..3b7298f --- /dev/null +++ b/openRenamerFront/src/views/home/components/RuleBlock.vue @@ -0,0 +1,171 @@ + + + + +