From 059806a3570450d7262b5a862b37f2955403478b Mon Sep 17 00:00:00 2001 From: fanxb Date: Thu, 28 Apr 2022 15:06:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=8F=92=E5=85=A5=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=AD=A3=E5=8F=B7=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- openRenamerBackend/service/RenamerService.ts | 1 - openRenamerBackend/vo/rules/InsertRule.ts | 15 ++++ openRenamerFront/src/App.vue | 36 +++++++--- openRenamerFront/src/components/FileChose.vue | 5 +- .../src/components/rules/DeleteRule.vue | 69 ++++--------------- .../src/components/rules/InsertRule.vue | 41 ++++------- .../components/rules/SerializationRule.vue | 35 ++-------- openRenamerFront/src/router/index.js | 10 +-- openRenamerFront/src/views/About.vue | 5 -- 9 files changed, 76 insertions(+), 141 deletions(-) delete mode 100644 openRenamerFront/src/views/About.vue diff --git a/openRenamerBackend/service/RenamerService.ts b/openRenamerBackend/service/RenamerService.ts index 13893ff..d9d534a 100644 --- a/openRenamerBackend/service/RenamerService.ts +++ b/openRenamerBackend/service/RenamerService.ts @@ -4,7 +4,6 @@ import * as fs from 'fs-extra'; import FileObj from '../vo/FileObj'; import RuleObj from '../vo/RuleObj'; -import DeleteRule from '../vo/rules/DeleteRule'; import RuleInterface from '../vo/rules/RuleInterface'; diff --git a/openRenamerBackend/vo/rules/InsertRule.ts b/openRenamerBackend/vo/rules/InsertRule.ts index f6670e6..16ac837 100644 --- a/openRenamerBackend/vo/rules/InsertRule.ts +++ b/openRenamerBackend/vo/rules/InsertRule.ts @@ -2,6 +2,8 @@ import RuleInterface from "./RuleInterface"; import FileObj from "../FileObj"; import path from 'path'; + +let pattern = new RegExp(/s(eason)?(\d+)/); export default class InsertRule implements RuleInterface { /** @@ -24,6 +26,10 @@ export default class InsertRule implements RuleInterface { * 忽略拓展名,true:忽略,false:不忽略 */ ignorePostfix: boolean; + /** + 自动识别季号 + */ + autoSeason: boolean; constructor(data: any) { this.insertContent = data.insertContent; @@ -31,6 +37,7 @@ export default class InsertRule implements RuleInterface { this.atInput = data.atInput; this.atIsRightToleft = data.atIsRightToleft; this.ignorePostfix = data.ignorePostfix; + this.autoSeason = data.autoSeason; } @@ -51,6 +58,13 @@ export default class InsertRule implements RuleInterface { str = this.insertContent; break; } + if (this.autoSeason) { + let patternRes = path.basename(file.path).replace(/[ ]+/, "").toLocaleLowerCase().match(pattern); + if (patternRes[2]) { + str += patternRes[2]; + } + } + if (this.ignorePostfix) { file.realName = str; } else { @@ -61,6 +75,7 @@ export default class InsertRule implements RuleInterface { file.realName = str; } } + file.name = file.realName + file.expandName; } } \ No newline at end of file diff --git a/openRenamerFront/src/App.vue b/openRenamerFront/src/App.vue index e379c18..2149e70 100644 --- a/openRenamerFront/src/App.vue +++ b/openRenamerFront/src/App.vue @@ -1,14 +1,13 @@