feat:支持根据拓展名分组
This commit is contained in:
parent
94a90ba359
commit
7d6006d1fd
@ -10,7 +10,7 @@ export default class InsertRule implements RuleInterface {
|
||||
/**
|
||||
* 记录当前的值是多少
|
||||
*/
|
||||
currentIndex: number;
|
||||
currentIndexMap: Map<string, number>;
|
||||
/**
|
||||
* 增量
|
||||
*/
|
||||
@ -35,21 +35,28 @@ export default class InsertRule implements RuleInterface {
|
||||
* 忽略拓展名
|
||||
*/
|
||||
ignorePostfix: boolean;
|
||||
/**
|
||||
* 拓展名分组
|
||||
*/
|
||||
postfixGroup: boolean;
|
||||
|
||||
constructor(data: any) {
|
||||
this.start = data.start;
|
||||
this.currentIndex = data.start;
|
||||
this.currentIndexMap = new Map<string, number>();
|
||||
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 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":
|
||||
@ -62,7 +69,7 @@ export default class InsertRule implements RuleInterface {
|
||||
str = str.substring(0, this.insertValue - 1) + numStr + str.substring(this.insertValue - 1);
|
||||
break;
|
||||
}
|
||||
this.currentIndex += this.increment;
|
||||
this.currentIndexMap.set(expand, currentIndex + this.increment);
|
||||
|
||||
if (this.ignorePostfix) {
|
||||
file.realName = str;
|
||||
|
@ -35,6 +35,6 @@
|
||||
//设置上一节获取到的key
|
||||
window.qieziStatisticKey = "13ec82dd91294ae4a88b0d2cc6cbdf76";
|
||||
</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>
|
||||
</html>
|
||||
|
@ -19,7 +19,7 @@
|
||||
{{ version }}</a>
|
||||
</el-tooltip>
|
||||
|
||||
<template v-if="latestVersion && latestVersion>version">
|
||||
<template v-if="latestVersion && showNewVersion">
|
||||
最新版本:
|
||||
<el-tooltip effect="dark" content="点击查看更新文档" placement="top">
|
||||
<a href="https://blog.fleyx.com/blog/detail/20221130/#%e5%8d%87%e7%ba%a7" target="_blank">
|
||||
@ -40,9 +40,10 @@ export default {
|
||||
name: "Home",
|
||||
data() {
|
||||
return {
|
||||
version: 1.4,
|
||||
version: "1.5",
|
||||
latestVersion: null,
|
||||
activeIndex: location.pathname,
|
||||
showNewVersion: false
|
||||
};
|
||||
},
|
||||
async beforeCreate() {
|
||||
@ -53,12 +54,30 @@ export default {
|
||||
//获取最新版本
|
||||
let config = await httpUtil.get("https://s3.fleyx.com/picbed/openRenamer/config.json");
|
||||
this.latestVersion = config.version;
|
||||
this.showNewVersion = checkVersion(this.version, this.latestVersion);
|
||||
|
||||
},
|
||||
async mounted() {
|
||||
console.log(this.$route);
|
||||
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>
|
||||
|
||||
<style lang="less">
|
||||
|
@ -2,20 +2,20 @@
|
||||
<div class="flex">
|
||||
<span class="left">起始数:</span>
|
||||
<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 class="flex">
|
||||
<span class="left">增量:</span>
|
||||
<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 class="flex">
|
||||
<span class="left">填充0补足:</span>
|
||||
<div class="right">
|
||||
<el-switch v-model="ruleObj.data.addZero" />
|
||||
<el-input-number size="small" :min="1" :disabled="!ruleObj.data.addZero" v-model="ruleObj.data.numLength" />
|
||||
<el-switch v-model="ruleObj.data.addZero"/>
|
||||
<el-input-number size="small" :min="1" :disabled="!ruleObj.data.addZero" v-model="ruleObj.data.numLength"/>
|
||||
</div>
|
||||
</div>
|
||||
<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="backend">后缀</el-radio>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex">
|
||||
<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>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {InfoFilled} from "@element-plus/icons-vue";
|
||||
|
||||
export default {
|
||||
name: "SerializationRule",
|
||||
|
||||
components: {InfoFilled},
|
||||
props: ["editRule"],
|
||||
data() {
|
||||
return {
|
||||
@ -53,6 +66,7 @@ export default {
|
||||
ignorePostfix: true,
|
||||
insertType: "front",
|
||||
insertValue: 1,
|
||||
postfixGroup: true
|
||||
},
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user