From f9a546cb978c95ae669c9b5f5919e71540d84242 Mon Sep 17 00:00:00 2001 From: fanxb Date: Tue, 10 Jan 2023 23:15:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E8=87=AA=E5=8A=A8=E5=8C=96=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- openRenamerBackend/api/GlobalConfigApi.ts | 7 + openRenamerFront/src/App.vue | 19 +- openRenamerFront/src/components/FileChose.vue | 69 ++-- openRenamerFront/src/components/Tips.vue | 22 + .../rules}/ApplicationRuleList.vue | 237 +++++------ .../rules}/RuleBlock.vue | 375 +++++++++--------- .../src/views/auto/components/editForm.vue | 138 +++++++ openRenamerFront/src/views/auto/index.vue | 8 +- openRenamerFront/src/views/home/Home.vue | 72 ++-- 9 files changed, 575 insertions(+), 372 deletions(-) create mode 100644 openRenamerFront/src/components/Tips.vue rename openRenamerFront/src/{views/home/components => components/rules}/ApplicationRuleList.vue (81%) rename openRenamerFront/src/{views/home/components => components/rules}/RuleBlock.vue (78%) create mode 100644 openRenamerFront/src/views/auto/components/editForm.vue diff --git a/openRenamerBackend/api/GlobalConfigApi.ts b/openRenamerBackend/api/GlobalConfigApi.ts index 8691d29..732ef5d 100644 --- a/openRenamerBackend/api/GlobalConfigApi.ts +++ b/openRenamerBackend/api/GlobalConfigApi.ts @@ -24,6 +24,13 @@ router["POST /config/update"] = async function (ctx: Context) { ctx.body = await service.updateVal(ctx.request.body.code, ctx.request.body.val); }; +/** + * 提交修改 + */ +router["POST /config/insertOrUpdate"] = async function (ctx: Context) { + ctx.body = await service.insertOrReplace(ctx.request.body); +}; + export default router; diff --git a/openRenamerFront/src/App.vue b/openRenamerFront/src/App.vue index 7935038..2416362 100644 --- a/openRenamerFront/src/App.vue +++ b/openRenamerFront/src/App.vue @@ -1,9 +1,10 @@ @@ -65,7 +63,7 @@ import { Top, Bottom } from "@element-plus/icons-vue"; import HttpUtil from "../../utils/HttpUtil"; import FileChose from "@/components/FileChose"; -import RuleBlock from "./components/RuleBlock.vue"; +import RuleBlock from "@/components/rules/RuleBlock.vue"; import Bus from "../../utils/Bus"; let numberSet = new Set(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]); @@ -78,7 +76,7 @@ export default { Top, Bottom, }, - data() { + data () { return { loading: false, //遮罩 dialogVisible: false, //新增文件弹窗 @@ -93,14 +91,14 @@ export default { }; }, computed: {}, - async created() { + async created () { this.savePathList = await HttpUtil.get("/file/path"); window.isWindows = await HttpUtil.get("/file/isWindows"); Bus.$on("refreshSavePathList", this.refreshSavePathList); }, methods: { //新增文件 - async addData(data) { + async addData (data) { data.forEach((item) => (item.checked = false)); this.fileList.push(...data); this.fileList = [...this.fileList.sort((a, b) => compareStr(a.name, b.name))]; @@ -108,13 +106,13 @@ export default { this.needPreview = true; await this.showResult(); }, - async ruleUpdate(rules) { + async ruleUpdate (rules) { this.ruleList = rules; this.needPreview = true; await this.showResult(); }, //预览结果 - async showResult() { + async showResult () { this.changedFileList = []; if (!this.checkRuleAndFile()) { return; @@ -130,7 +128,7 @@ export default { this.loading = false; }, //提交 - async submit() { + async submit () { if (!this.checkRuleAndFile()) { return; } @@ -151,17 +149,17 @@ export default { } }, //删除选中的文件名 - async deleteCheckedFiles() { + async deleteCheckedFiles () { this.fileList = this.fileList.filter((item) => !item.checked); this.needPreview = true; await this.showResult(); }, //反选 - selectAllFiles() { + selectAllFiles () { this.fileList.forEach((item) => (item.checked = !item.checked)); }, //检查规则和文件 - checkRuleAndFile() { + checkRuleAndFile () { if (this.fileList.length == 0) { this.$message({ message: "请选择文件", type: "warning" }); return false; @@ -173,7 +171,7 @@ export default { return true; }, //移动文件顺序 - async moveIndex(type) { + async moveIndex (type) { let temps = this.fileList.filter((item) => item.checked == true); if (temps.length == 0) { this.$message({ type: "warning", message: "未选中文件,无法移动" }); @@ -208,20 +206,20 @@ export default { this.timer = null; }, 1000); }, - showFileAdd() { + showFileAdd () { this.dialogVisible = true; }, //点击收藏路径 - async clickSavePath(item) { + async clickSavePath (item) { this.curChoosePath = JSON.parse(item.content); this.dialogVisible = true; }, - async deleteSavePath(item) { + async deleteSavePath (item) { console.log(item); await HttpUtil.delete("/file/path/delete", { id: item.id }); Bus.$emit("refreshSavePathList"); }, - async refreshSavePathList() { + async refreshSavePathList () { this.savePathList = await HttpUtil.get("/file/path"); }, }, @@ -232,10 +230,10 @@ export default { * @param a str * @param b str */ -function compareStr(a, b) { +function compareStr (a, b) { let an = a.length; let bn = b.length; - for (let i = 0; i < an; ) { + for (let i = 0; i < an;) { let charA = readChar(a, i, an); let charB = readChar(b, i, bn); if (charB.length == 0) { @@ -257,7 +255,7 @@ function compareStr(a, b) { * @param a a * @param n 数字长度 */ -function readChar(a, i, n) { +function readChar (a, i, n) { let res = ""; for (; i < n; i++) { let char = a.charAt(i); @@ -282,6 +280,7 @@ function readChar(a, i, n) { cursor: pointer; margin-right: 0.5em; } + .fileList { margin-top: 20px; text-align: left; @@ -289,6 +288,7 @@ function readChar(a, i, n) { .fileBlock { margin-top: 20px; display: flex; + .oneLine { display: flex; justify-content: space-between;