commit
f643044fb5
@ -3,78 +3,85 @@ import FileObj from "../../vo/FileObj";
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
export default class InsertRule implements RuleInterface {
|
export default class InsertRule implements RuleInterface {
|
||||||
/**
|
/**
|
||||||
* 开始位置
|
* 开始位置
|
||||||
*/
|
*/
|
||||||
start: number;
|
start: number;
|
||||||
/**
|
/**
|
||||||
* 记录当前的值是多少
|
* 记录当前的值是多少
|
||||||
*/
|
*/
|
||||||
currentIndex: number;
|
currentIndexMap: Map<string, number>;
|
||||||
/**
|
/**
|
||||||
* 增量
|
* 增量
|
||||||
*/
|
*/
|
||||||
increment: number;
|
increment: number;
|
||||||
/**
|
/**
|
||||||
* 是否填充0
|
* 是否填充0
|
||||||
*/
|
*/
|
||||||
addZero: boolean;
|
addZero: boolean;
|
||||||
/**
|
/**
|
||||||
* 填充后长度
|
* 填充后长度
|
||||||
*/
|
*/
|
||||||
numLength: number;
|
numLength: number;
|
||||||
/**
|
/**
|
||||||
* 插入位置,front:前缀,backend:后缀,at:位置
|
* 插入位置,front:前缀,backend:后缀,at:位置
|
||||||
*/
|
*/
|
||||||
insertType: string;
|
insertType: string;
|
||||||
/**
|
/**
|
||||||
* 插入的位置
|
* 插入的位置
|
||||||
*/
|
*/
|
||||||
insertValue: number;
|
insertValue: number;
|
||||||
/**
|
/**
|
||||||
* 忽略拓展名
|
* 忽略拓展名
|
||||||
*/
|
*/
|
||||||
ignorePostfix: boolean;
|
ignorePostfix: boolean;
|
||||||
|
/**
|
||||||
|
* 拓展名分组
|
||||||
|
*/
|
||||||
|
postfixGroup: boolean;
|
||||||
|
|
||||||
constructor(data: any) {
|
constructor(data: any) {
|
||||||
this.start = data.start;
|
this.start = data.start;
|
||||||
this.currentIndex = data.start;
|
this.currentIndexMap = new Map<string, number>();
|
||||||
this.increment = data.increment;
|
this.increment = data.increment;
|
||||||
this.addZero = data.addZero;
|
this.addZero = data.addZero;
|
||||||
this.numLength = data.numLength;
|
this.numLength = data.numLength;
|
||||||
this.insertType = data.insertType;
|
this.insertType = data.insertType;
|
||||||
this.insertValue = data.insertValue;
|
this.insertValue = data.insertValue;
|
||||||
this.ignorePostfix = data.ignorePostfix;
|
this.ignorePostfix = data.ignorePostfix;
|
||||||
}
|
this.postfixGroup = data.postfixGroup;
|
||||||
|
}
|
||||||
|
|
||||||
deal(file: FileObj): void {
|
deal(file: FileObj): void {
|
||||||
let length = this.currentIndex.toString().length;
|
let expand = this.postfixGroup ? file.expandName : "";
|
||||||
let numStr = (this.addZero && this.numLength > length ? "0".repeat(this.numLength - length) : "") + this.currentIndex;
|
let currentIndex = this.currentIndexMap.has(expand) ? this.currentIndexMap.get(expand) : this.start;
|
||||||
let str = this.ignorePostfix ? file.realName : file.name;
|
let length = currentIndex.toString().length;
|
||||||
switch (this.insertType) {
|
let numStr = (this.addZero && this.numLength > length ? "0".repeat(this.numLength - length) : "") + currentIndex;
|
||||||
case "front":
|
let str = this.ignorePostfix ? file.realName : file.name;
|
||||||
str = numStr + str;
|
switch (this.insertType) {
|
||||||
break;
|
case "front":
|
||||||
case "backend":
|
str = numStr + str;
|
||||||
str = str + numStr;
|
break;
|
||||||
break;
|
case "backend":
|
||||||
case "at":
|
str = str + numStr;
|
||||||
str = str.substring(0, this.insertValue - 1) + numStr + str.substring(this.insertValue - 1);
|
break;
|
||||||
break;
|
case "at":
|
||||||
}
|
str = str.substring(0, this.insertValue - 1) + numStr + str.substring(this.insertValue - 1);
|
||||||
this.currentIndex += this.increment;
|
break;
|
||||||
|
}
|
||||||
|
this.currentIndexMap.set(expand, currentIndex + this.increment);
|
||||||
|
|
||||||
if (this.ignorePostfix) {
|
if (this.ignorePostfix) {
|
||||||
file.realName = str;
|
file.realName = str;
|
||||||
} else {
|
} else {
|
||||||
file.expandName = path.extname(str);
|
file.expandName = path.extname(str);
|
||||||
if (file.expandName.length > 0) {
|
if (file.expandName.length > 0) {
|
||||||
file.realName = str.substring(0, str.lastIndexOf("."));
|
file.realName = str.substring(0, str.lastIndexOf("."));
|
||||||
} else {
|
} else {
|
||||||
file.realName = str;
|
file.realName = str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file.name = file.realName + file.expandName;
|
file.name = file.realName + file.expandName;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -38,12 +38,26 @@ export function isNfo(str: string) {
|
|||||||
|
|
||||||
let pattern1 = new RegExp(/s(eason)?\.?(\d+)/);
|
let pattern1 = new RegExp(/s(eason)?\.?(\d+)/);
|
||||||
let pattern2 = new RegExp(/(\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();
|
name = name.replace(/[ ]+/, "").toLocaleLowerCase();
|
||||||
let patternRes = name.match(pattern1);
|
let patternRes = name.match(pattern1);
|
||||||
if (patternRes && patternRes[2]) {
|
if (patternRes && patternRes[2]) {
|
||||||
@ -53,5 +67,18 @@ export function getSeason(name: string) {
|
|||||||
if (patternRes && patternRes[1]) {
|
if (patternRes && patternRes[1]) {
|
||||||
return 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 "";
|
return "";
|
||||||
}
|
}
|
@ -35,6 +35,6 @@
|
|||||||
//设置上一节获取到的key
|
//设置上一节获取到的key
|
||||||
window.qieziStatisticKey = "13ec82dd91294ae4a88b0d2cc6cbdf76";
|
window.qieziStatisticKey = "13ec82dd91294ae4a88b0d2cc6cbdf76";
|
||||||
</script>
|
</script>
|
||||||
<script src="https://qiezi.fleyx.com/qiezijs/1.0/qiezi_statistic.min.js" type="text/javascript"></script>
|
<script src="https://qiezi.fleyx.com/qiezijs/1.0/qiezi_statistic.min.js" type="text/javascript" defer></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -14,15 +14,17 @@
|
|||||||
<router-view/>
|
<router-view/>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">版本:
|
<div class="footer">版本:
|
||||||
<el-tooltip effect="dark" content="点击查看更新内容" placement="top">
|
<el-tooltip effect="dark" content="点击查看更新记录" placement="top">
|
||||||
<a href="https://blog.fleyx.com/blog/detail/20221130/#13" target="_blank">
|
<a href="https://blog.fleyx.com/blog/detail/20221130/#%E7%89%88%E6%9C%AC%E6%9B%B4%E6%96%B0%E8%AE%B0%E5%BD%95"
|
||||||
|
target="_blank">
|
||||||
{{ version }}</a>
|
{{ version }}</a>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
|
||||||
<template v-if="latestVersion && latestVersion>version">
|
<template v-if="latestVersion && showNewVersion">
|
||||||
最新版本:
|
最新版本:
|
||||||
<el-tooltip effect="dark" content="点击查看更新文档" placement="top">
|
<el-tooltip effect="dark" content="点击查看更新文档" placement="top">
|
||||||
<a href="https://blog.fleyx.com/blog/detail/20221130/#%e5%8d%87%e7%ba%a7" target="_blank">
|
<a href="https://blog.fleyx.com/blog/detail/20221130/#%E7%89%88%E6%9C%AC%E6%9B%B4%E6%96%B0%E8%AE%B0%E5%BD%95"
|
||||||
|
target="_blank">
|
||||||
{{ latestVersion }}</a>
|
{{ latestVersion }}</a>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
|
||||||
@ -40,9 +42,10 @@ export default {
|
|||||||
name: "Home",
|
name: "Home",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
version: 1.4,
|
version: "1.5",
|
||||||
latestVersion: null,
|
latestVersion: null,
|
||||||
activeIndex: location.pathname,
|
activeIndex: location.pathname,
|
||||||
|
showNewVersion: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
async beforeCreate() {
|
async beforeCreate() {
|
||||||
@ -53,12 +56,30 @@ export default {
|
|||||||
//获取最新版本
|
//获取最新版本
|
||||||
let config = await httpUtil.get("https://s3.fleyx.com/picbed/openRenamer/config.json");
|
let config = await httpUtil.get("https://s3.fleyx.com/picbed/openRenamer/config.json");
|
||||||
this.latestVersion = config.version;
|
this.latestVersion = config.version;
|
||||||
|
this.showNewVersion = checkVersion(this.version, this.latestVersion);
|
||||||
|
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
console.log(this.$route);
|
console.log(this.$route);
|
||||||
console.log(location);
|
console.log(location);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function checkVersion(version, latestVersion) {
|
||||||
|
let versions = version.split(".");
|
||||||
|
let latestVersions = latestVersion.split('.');
|
||||||
|
for (let i = 0; i < versions.length; i++) {
|
||||||
|
if (i >= latestVersions.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let versionNum = parseInt(versions[i]);
|
||||||
|
let latestVersionNum = parseInt(latestVersions[i]);
|
||||||
|
if (versionNum !== latestVersionNum) {
|
||||||
|
return versionNum < latestVersionNum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
|
@ -11,21 +11,25 @@
|
|||||||
<el-button type="primary" size="small" @click="editClick">
|
<el-button type="primary" size="small" @click="editClick">
|
||||||
<el-tooltip effect="dark" content="编辑规则" placement="top">
|
<el-tooltip effect="dark" content="编辑规则" placement="top">
|
||||||
<el-icon>
|
<el-icon>
|
||||||
<edit />
|
<edit/>
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" size="small" @click="move('top')">
|
<el-button type="primary" size="small" @click="move('top')">
|
||||||
<el-tooltip effect="dark" content="上移规则" placement="top">
|
<el-tooltip effect="dark" content="上移规则" placement="top">
|
||||||
<el-icon>
|
<el-icon>
|
||||||
<top />
|
<top/>
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" size="small" @click="move('bottom')">
|
<el-button type="primary" size="small" @click="move('bottom')">
|
||||||
<el-tooltip effect="dark" content="下移规则" placement="top"
|
<el-tooltip effect="dark" content="下移规则" placement="top"
|
||||||
><el-icon> <bottom /> </el-icon
|
>
|
||||||
></el-tooltip>
|
<el-icon>
|
||||||
|
<bottom/>
|
||||||
|
</el-icon
|
||||||
|
>
|
||||||
|
</el-tooltip>
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@ -38,11 +42,12 @@
|
|||||||
<el-button type="primary" size="small" text @click="addRuleDialogShow = true">+ 新增规则</el-button>
|
<el-button type="primary" size="small" text @click="addRuleDialogShow = true">+ 新增规则</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<el-dialog :title="editRule ? '编辑规则' : '新增规则'" v-model="addRuleDialogShow" width="70%" @close="ruleDialogClose">
|
<el-dialog :title="editRule ? '编辑规则' : '新增规则'" v-model="addRuleDialogShow" width="70%"
|
||||||
<rule :editRule="editRule" @ruleAdd="ruleAdd" v-if="addRuleDialogShow" :isAutoPlan="rules != undefined" />
|
@close="ruleDialogClose">
|
||||||
|
<rule :editRule="editRule" @ruleAdd="ruleAdd" v-if="addRuleDialogShow" :isAutoPlan="rules != undefined"/>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<el-dialog title="模板管理" v-model="ruleTemplateShow" width="70%">
|
<el-dialog title="模板管理" v-model="ruleTemplateShow" width="70%">
|
||||||
<application-rule-list v-if="ruleTemplateShow" :curId="chosedTemplate.id" @templateUpdate="templateUpdate" />
|
<application-rule-list v-if="ruleTemplateShow" :curId="chosedTemplate.id" @templateUpdate="templateUpdate"/>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -51,7 +56,8 @@
|
|||||||
import Rule from "@/components/Rule";
|
import Rule from "@/components/Rule";
|
||||||
import ApplicationRuleList from "./ApplicationRuleList";
|
import ApplicationRuleList from "./ApplicationRuleList";
|
||||||
import HttpUtil from "@/utils/HttpUtil";
|
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 {
|
export default {
|
||||||
name: "RuleBlock",
|
name: "RuleBlock",
|
||||||
props: ["rules"],
|
props: ["rules"],
|
||||||
@ -79,7 +85,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
//如果外部传入了规则
|
//如果外部传入了规则
|
||||||
if (this.rules != undefined) {
|
if (this.rules !== undefined) {
|
||||||
this.ruleList = JSON.parse(JSON.stringify(this.rules));
|
this.ruleList = JSON.parse(JSON.stringify(this.rules));
|
||||||
} else {
|
} else {
|
||||||
this.chosedTemplate = await HttpUtil.get("/applicationRule/default");
|
this.chosedTemplate = await HttpUtil.get("/applicationRule/default");
|
||||||
@ -107,7 +113,9 @@ export default {
|
|||||||
},
|
},
|
||||||
//切换模板
|
//切换模板
|
||||||
async templateUpdate(newVal) {
|
async templateUpdate(newVal) {
|
||||||
|
console.debug("新的模板:", newVal);
|
||||||
this.ruleList = JSON.parse(newVal.content);
|
this.ruleList = JSON.parse(newVal.content);
|
||||||
|
this.chosedTemplate = newVal;
|
||||||
this.ruleUpdate();
|
this.ruleUpdate();
|
||||||
this.ruleTemplateShow = false;
|
this.ruleTemplateShow = false;
|
||||||
},
|
},
|
||||||
@ -127,11 +135,11 @@ export default {
|
|||||||
//禁用/启用
|
//禁用/启用
|
||||||
async block() {
|
async block() {
|
||||||
this.ruleList
|
this.ruleList
|
||||||
.filter((item) => item.checked)
|
.filter((item) => item.checked)
|
||||||
.forEach((item) => {
|
.forEach((item) => {
|
||||||
item.blocked = !item.blocked;
|
item.blocked = !item.blocked;
|
||||||
item.checked = false;
|
item.checked = false;
|
||||||
});
|
});
|
||||||
await this.ruleUpdate();
|
await this.ruleUpdate();
|
||||||
},
|
},
|
||||||
//删除规则
|
//删除规则
|
||||||
|
@ -2,20 +2,20 @@
|
|||||||
<div class="flex">
|
<div class="flex">
|
||||||
<span class="left">起始数:</span>
|
<span class="left">起始数:</span>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<el-input-number :min="1" size="small" v-model="ruleObj.data.start" />
|
<el-input-number :min="1" size="small" v-model="ruleObj.data.start"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<span class="left">增量:</span>
|
<span class="left">增量:</span>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<el-input-number :min="1" size="small" v-model="ruleObj.data.increment" />
|
<el-input-number :min="1" size="small" v-model="ruleObj.data.increment"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<span class="left">填充0补足:</span>
|
<span class="left">填充0补足:</span>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<el-switch v-model="ruleObj.data.addZero" />
|
<el-switch v-model="ruleObj.data.addZero"/>
|
||||||
<el-input-number size="small" :min="1" :disabled="!ruleObj.data.addZero" v-model="ruleObj.data.numLength" />
|
<el-input-number size="small" :min="1" :disabled="!ruleObj.data.addZero" v-model="ruleObj.data.numLength"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
@ -24,21 +24,34 @@
|
|||||||
<el-radio style="margin-top: 1em" v-model="ruleObj.data.insertType" label="front">前缀</el-radio>
|
<el-radio style="margin-top: 1em" v-model="ruleObj.data.insertType" label="front">前缀</el-radio>
|
||||||
<el-radio style="margin-top: 1em" v-model="ruleObj.data.insertType" label="backend">后缀</el-radio>
|
<el-radio style="margin-top: 1em" v-model="ruleObj.data.insertType" label="backend">后缀</el-radio>
|
||||||
<el-radio style="margin-top: 1em" v-model="ruleObj.data.insertType" label="at"
|
<el-radio style="margin-top: 1em" v-model="ruleObj.data.insertType" label="at"
|
||||||
>位置:<el-input-number size="small" :min="1" :disabled="ruleObj.data.insertType !== 'at'" v-model="ruleObj.data.insertValue" />
|
>位置:
|
||||||
|
<el-input-number size="small" :min="1" :disabled="ruleObj.data.insertType !== 'at'"
|
||||||
|
v-model="ruleObj.data.insertValue"/>
|
||||||
</el-radio>
|
</el-radio>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<div class="left">忽略拓展名:</div>
|
<div class="left">忽略拓展名:</div>
|
||||||
<el-switch v-model="ruleObj.data.ignorePostfix" />
|
<el-switch v-model="ruleObj.data.ignorePostfix"/>
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<div class="left">拓展名分组:</div>
|
||||||
|
<el-switch v-model="ruleObj.data.postfixGroup"/>
|
||||||
|
<el-tooltip effect="dark" content="按照文件拓展名分别计数,方便多种类型文件同时生成序列" placement="right">
|
||||||
|
<el-icon>
|
||||||
|
<InfoFilled/>
|
||||||
|
</el-icon>
|
||||||
|
</el-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {InfoFilled} from "@element-plus/icons-vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "SerializationRule",
|
name: "SerializationRule",
|
||||||
|
components: {InfoFilled},
|
||||||
props: ["editRule"],
|
props: ["editRule"],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -53,6 +66,7 @@ export default {
|
|||||||
ignorePostfix: true,
|
ignorePostfix: true,
|
||||||
insertType: "front",
|
insertType: "front",
|
||||||
insertValue: 1,
|
insertValue: 1,
|
||||||
|
postfixGroup: true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user