From ea0d68036b8415a0248dc7bb1f02873539c2cdb9 Mon Sep 17 00:00:00 2001 From: fanxb Date: Thu, 13 Apr 2023 19:18:54 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/rules/RuleBlock.vue | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/openRenamerFront/src/components/rules/RuleBlock.vue b/openRenamerFront/src/components/rules/RuleBlock.vue index 4dadcd8..5bee5ed 100644 --- a/openRenamerFront/src/components/rules/RuleBlock.vue +++ b/openRenamerFront/src/components/rules/RuleBlock.vue @@ -11,21 +11,25 @@ - + - + + > + + + + @@ -38,11 +42,12 @@ + 新增规则 - - + + - + @@ -51,7 +56,8 @@ import Rule from "@/components/Rule"; import ApplicationRuleList from "./ApplicationRuleList"; import HttpUtil from "@/utils/HttpUtil"; -import { Top, Bottom, Edit } from "@element-plus/icons-vue"; +import {Top, Bottom, Edit} from "@element-plus/icons-vue"; + export default { name: "RuleBlock", props: ["rules"], @@ -107,7 +113,9 @@ export default { }, //切换模板 async templateUpdate(newVal) { + console.debug("新的模板:", newVal); this.ruleList = JSON.parse(newVal.content); + this.chosedTemplate = newVal; this.ruleUpdate(); this.ruleTemplateShow = false; }, @@ -127,11 +135,11 @@ export default { //禁用/启用 async block() { this.ruleList - .filter((item) => item.checked) - .forEach((item) => { - item.blocked = !item.blocked; - item.checked = false; - }); + .filter((item) => item.checked) + .forEach((item) => { + item.blocked = !item.blocked; + item.checked = false; + }); await this.ruleUpdate(); }, //删除规则 From 94a90ba3599892e50ea215d22ef1e0b7610d2ff7 Mon Sep 17 00:00:00 2001 From: fanxb Date: Thu, 13 Apr 2023 19:55:02 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=E6=94=AF=E6=8C=81=E4=B8=AD=E6=96=87?= =?UTF-8?q?=E6=95=B0=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- openRenamerBackend/util/MediaUtil.ts | 31 +++++++++++++++++-- .../src/components/rules/RuleBlock.vue | 2 +- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/openRenamerBackend/util/MediaUtil.ts b/openRenamerBackend/util/MediaUtil.ts index addaf96..ead7056 100644 --- a/openRenamerBackend/util/MediaUtil.ts +++ b/openRenamerBackend/util/MediaUtil.ts @@ -38,12 +38,26 @@ export function isNfo(str: string) { let pattern1 = new RegExp(/s(eason)?\.?(\d+)/); let pattern2 = new RegExp(/(\d+)/); +let pattern3 = new RegExp(/([一二三四五六七八九十]+)/); +let chineseNumMap = { + "一": "1", + "二": "2", + "三": "3", + "四": "4", + "五": "5", + "六": "6", + "七": "7", + "八": "8", + "九": "9", + "十": "1" + +} /** * 识别季号 - * @param str + * @param name */ -export function getSeason(name: string) { +export function getSeason(name: string): string { name = name.replace(/[ ]+/, "").toLocaleLowerCase(); let patternRes = name.match(pattern1); if (patternRes && patternRes[2]) { @@ -53,5 +67,18 @@ export function getSeason(name: string) { if (patternRes && patternRes[1]) { return patternRes[1]; } + //中文支持 + patternRes = name.match(pattern3); + if (patternRes && patternRes[1]) { + let str = patternRes[1]; + let strs = str.split(""); + if (strs.length == 1) { + return str == '十' ? "10" : chineseNumMap[str]; + } else if (strs.length == 2) { + return strs[0] == '十' ? ("1" + chineseNumMap[strs[1]]) : chineseNumMap[strs[0]] + "0"; + } else if (strs.length == 3) { + return chineseNumMap[strs[0]] + chineseNumMap[strs[2]]; + } + } return ""; } \ No newline at end of file diff --git a/openRenamerFront/src/components/rules/RuleBlock.vue b/openRenamerFront/src/components/rules/RuleBlock.vue index 5bee5ed..bd67d31 100644 --- a/openRenamerFront/src/components/rules/RuleBlock.vue +++ b/openRenamerFront/src/components/rules/RuleBlock.vue @@ -85,7 +85,7 @@ export default { }, async created() { //如果外部传入了规则 - if (this.rules != undefined) { + if (this.rules !== undefined) { this.ruleList = JSON.parse(JSON.stringify(this.rules)); } else { this.chosedTemplate = await HttpUtil.get("/applicationRule/default"); From 7d6006d1fd4b8a9d51830eec51173ffe391f1946 Mon Sep 17 00:00:00 2001 From: fanxb Date: Thu, 13 Apr 2023 20:42:50 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat:=E6=94=AF=E6=8C=81=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E6=8B=93=E5=B1=95=E5=90=8D=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/bo/rules/SerializationRule.ts | 147 +++++++++--------- openRenamerFront/public/index.html | 2 +- openRenamerFront/src/App.vue | 23 ++- .../components/rules/SerializationRule.vue | 28 +++- 4 files changed, 120 insertions(+), 80 deletions(-) diff --git a/openRenamerBackend/entity/bo/rules/SerializationRule.ts b/openRenamerBackend/entity/bo/rules/SerializationRule.ts index e99f116..e8dbf68 100644 --- a/openRenamerBackend/entity/bo/rules/SerializationRule.ts +++ b/openRenamerBackend/entity/bo/rules/SerializationRule.ts @@ -3,78 +3,85 @@ import FileObj from "../../vo/FileObj"; import path from 'path'; export default class InsertRule implements RuleInterface { - /** - * 开始位置 - */ - start: number; - /** - * 记录当前的值是多少 - */ - currentIndex: number; - /** - * 增量 - */ - increment: number; - /** - * 是否填充0 - */ - addZero: boolean; - /** - * 填充后长度 - */ - numLength: number; - /** - * 插入位置,front:前缀,backend:后缀,at:位置 - */ - insertType: string; - /** - * 插入的位置 - */ - insertValue: number; - /** - * 忽略拓展名 - */ - ignorePostfix: boolean; + /** + * 开始位置 + */ + start: number; + /** + * 记录当前的值是多少 + */ + currentIndexMap: Map; + /** + * 增量 + */ + increment: number; + /** + * 是否填充0 + */ + addZero: boolean; + /** + * 填充后长度 + */ + numLength: number; + /** + * 插入位置,front:前缀,backend:后缀,at:位置 + */ + insertType: string; + /** + * 插入的位置 + */ + insertValue: number; + /** + * 忽略拓展名 + */ + ignorePostfix: boolean; + /** + * 拓展名分组 + */ + postfixGroup: boolean; - constructor(data: any) { - this.start = data.start; - this.currentIndex = data.start; - this.increment = data.increment; - this.addZero = data.addZero; - this.numLength = data.numLength; - this.insertType = data.insertType; - this.insertValue = data.insertValue; - this.ignorePostfix = data.ignorePostfix; - } + constructor(data: any) { + this.start = data.start; + this.currentIndexMap = new Map(); + this.increment = data.increment; + this.addZero = data.addZero; + this.numLength = data.numLength; + this.insertType = data.insertType; + this.insertValue = data.insertValue; + this.ignorePostfix = data.ignorePostfix; + this.postfixGroup = data.postfixGroup; + } - deal(file: FileObj): void { - let length = this.currentIndex.toString().length; - let numStr = (this.addZero && this.numLength > length ? "0".repeat(this.numLength - length) : "") + this.currentIndex; - let str = this.ignorePostfix ? file.realName : file.name; - switch (this.insertType) { - case "front": - str = numStr + str; - break; - case "backend": - str = str + numStr; - break; - case "at": - str = str.substring(0, this.insertValue - 1) + numStr + str.substring(this.insertValue - 1); - break; - } - this.currentIndex += this.increment; + deal(file: FileObj): void { + let expand = this.postfixGroup ? file.expandName : ""; + let currentIndex = this.currentIndexMap.has(expand) ? this.currentIndexMap.get(expand) : this.start; + let length = currentIndex.toString().length; + let numStr = (this.addZero && this.numLength > length ? "0".repeat(this.numLength - length) : "") + currentIndex; + let str = this.ignorePostfix ? file.realName : file.name; + switch (this.insertType) { + case "front": + str = numStr + str; + break; + case "backend": + str = str + numStr; + break; + case "at": + str = str.substring(0, this.insertValue - 1) + numStr + str.substring(this.insertValue - 1); + break; + } + this.currentIndexMap.set(expand, currentIndex + this.increment); - if (this.ignorePostfix) { - file.realName = str; - } else { - file.expandName = path.extname(str); - if (file.expandName.length > 0) { - file.realName = str.substring(0, str.lastIndexOf(".")); - } else { - file.realName = str; - } - } + if (this.ignorePostfix) { + file.realName = str; + } else { + file.expandName = path.extname(str); + if (file.expandName.length > 0) { + file.realName = str.substring(0, str.lastIndexOf(".")); + } else { + file.realName = str; + } + } - file.name = file.realName + file.expandName; - } + file.name = file.realName + file.expandName; + } } \ No newline at end of file diff --git a/openRenamerFront/public/index.html b/openRenamerFront/public/index.html index 42153b5..e46fff9 100644 --- a/openRenamerFront/public/index.html +++ b/openRenamerFront/public/index.html @@ -35,6 +35,6 @@ //设置上一节获取到的key window.qieziStatisticKey = "13ec82dd91294ae4a88b0d2cc6cbdf76"; - + diff --git a/openRenamerFront/src/App.vue b/openRenamerFront/src/App.vue index 819a446..c36b911 100644 --- a/openRenamerFront/src/App.vue +++ b/openRenamerFront/src/App.vue @@ -19,7 +19,7 @@ {{ version }}    -