feat:自动化配置完成

This commit is contained in:
fanxb 2023-01-10 23:15:39 +08:00
parent 977da05608
commit f9a546cb97
9 changed files with 575 additions and 372 deletions

View File

@ -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); 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; export default router;

View File

@ -1,9 +1,10 @@
<template> <template>
<div class="app"> <div class="app">
<el-menu :default-active="activeIndex" mode="horizontal" background-color="#545c64" text-color="#fff" active-text-color="#ffd04b" router> <el-menu :default-active="activeIndex" mode="horizontal" background-color="#545c64" text-color="#fff"
active-text-color="#ffd04b" router>
<el-menu-item index="/">重命名</el-menu-item> <el-menu-item index="/">重命名</el-menu-item>
<!-- <el-menu-item index="/auto">自动化</el-menu-item> <el-menu-item index="/auto">自动化</el-menu-item>
<el-sub-menu index="/download"> <!-- <el-sub-menu index="/download">
<template #title>bt下载</template> <template #title>bt下载</template>
<el-menu-item index="/download/center">下载中心</el-menu-item> <el-menu-item index="/download/center">下载中心</el-menu-item>
<el-menu-item index="/download/config">配置</el-menu-item> <el-menu-item index="/download/config">配置</el-menu-item>
@ -12,7 +13,8 @@
<div class="content"> <div class="content">
<router-view /> <router-view />
</div> </div>
<div class="footer">版本{{ version }}&nbsp;&nbsp;开源地址:<a href="https://github.com/FleyX/open-renamer">open-renamer</a></div> <div class="footer">版本{{ version }}&nbsp;&nbsp;开源地址:<a
href="https://github.com/FleyX/open-renamer">open-renamer</a></div>
</div> </div>
</template> </template>
@ -29,7 +31,7 @@ export default {
async created () { async created () {
let token = localStorage.getItem("token"); let token = localStorage.getItem("token");
window.token = token; window.token = token;
await httpUtil.get("/file/isWindows"); window.isWindows = await httpUtil.get("/file/isWindows");
console.log(this.$route); console.log(this.$route);
console.log(this.activeIndex); console.log(this.activeIndex);
}, },
@ -48,6 +50,7 @@ body {
margin: 0; margin: 0;
background-color: #e8e8e5; background-color: #e8e8e5;
} }
#app { #app {
font-family: Avenir, Helvetica, Arial, sans-serif; font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;

View File

@ -10,16 +10,20 @@
<div class="fileList"> <div class="fileList">
<div> <div>
<el-input style="display: inline-block; width: 150px" type="text" size="small" placeholder="关键词过滤" v-model="filterText" clearable /> <el-input style="display: inline-block; width: 150px" type="text" size="small" placeholder="关键词过滤"
v-model="filterText" clearable />
<template v-if="type == 'file'">
<el-button type="primary" @click="selectAll(true)" size="small">全选</el-button> <el-button type="primary" @click="selectAll(true)" size="small">全选</el-button>
<el-button type="primary" @click="selectAll(false)" size="small">全不选</el-button> <el-button type="primary" @click="selectAll(false)" size="small">全不选</el-button>
<el-button type="primary" @click="refresh" size="small">刷新</el-button> <el-button type="primary" @click="refresh" size="small">刷新</el-button>
<el-button v-if="curSavePathId" type="warning" @click="cancelSavePath" size="small">取消收藏</el-button> <el-button v-if="curSavePathId" type="warning" @click="cancelSavePath" size="small">取消收藏</el-button>
<el-button v-else type="primary" @click="showSave = true" size="small">收藏路径</el-button> <el-button v-else type="primary" @click="showSave = true" size="small">收藏路径</el-button>
</template>
</div> </div>
<div v-for="(item, index) in filterFileList" :key="index"> <div v-for="(item, index) in filterFileList" :key="index">
<span class="folder" v-if="item.isFolder" @click="fileClick(item)">{{ item.name }}</span> <span class="folder" v-if="item.isFolder" @click="fileClick(item)">{{ item.name }}</span>
<el-checkbox style="height: 1.4em" v-model="item.checked" v-else>{{ item.name }}</el-checkbox> <el-checkbox style="height: 1.4em" v-model="item.checked" v-else-if="type == 'file'">{{ item.name
}}</el-checkbox>
</div> </div>
</div> </div>
@ -39,7 +43,7 @@ import HttpUtil from "../utils/HttpUtil";
import Bus from "../utils/Bus"; import Bus from "../utils/Bus";
export default { export default {
name: "FileChose", name: "FileChose",
props: ["curChoosePath"], props: ["curChoosePath", "type"],
data () { data () {
return { return {
isWindows: false, isWindows: false,
@ -134,6 +138,7 @@ export default {
}, },
// //
submit () { submit () {
if (this.type === 'file') {
let chosedFiles = this.fileList.filter((item) => item.checked); let chosedFiles = this.fileList.filter((item) => item.checked);
if (chosedFiles.length == 0) { if (chosedFiles.length == 0) {
this.$message({ message: "未选择文件", type: "warning" }); this.$message({ message: "未选择文件", type: "warning" });
@ -142,7 +147,12 @@ export default {
this.$emit("addData", JSON.parse(JSON.stringify(chosedFiles))); this.$emit("addData", JSON.parse(JSON.stringify(chosedFiles)));
this.fileList.forEach((item) => (item.checked = false)); this.fileList.forEach((item) => (item.checked = false));
this.fileList = [...this.fileList]; this.fileList = [...this.fileList];
} else if (this.type === 'folder') {
//
this.$emit("folderChose", this.createPath(this.pathList.length - 1));
}
this.filterText = ""; this.filterText = "";
}, },
// //
async savePath () { async savePath () {
@ -166,6 +176,7 @@ export default {
.main { .main {
height: 65vh; height: 65vh;
} }
.fileList { .fileList {
padding: 1em; padding: 1em;
text-align: left; text-align: left;

View File

@ -0,0 +1,22 @@
<template>
<el-tooltip effect="dark" :content="message" :placement="placement ? placement : 'top'">
<el-icon>
<InfoFilled />
</el-icon>
</el-tooltip>
</template>
<script setup>
import { InfoFilled } from "@element-plus/icons-vue";
import { ref, reactive, onMounted, computed, defineProps } from "vue";
defineProps({
message: String,
placement: String
})
</script>
<style lang="less" scoped>
</style>

View File

@ -10,17 +10,20 @@
<el-table-column prop="comment" label="备注" /> <el-table-column prop="comment" label="备注" />
<el-table-column label="操作" width="250"> <el-table-column label="操作" width="250">
<template #default="scope"> <template #default="scope">
<el-button text type="primary" style="margin-left: 0" size="small" @click="ruleTemplateAction('chose', scope.row)">选择</el-button> <el-button text type="primary" style="margin-left: 0" size="small"
<el-button text type="primary" style="margin-left: 0" size="small" @click="ruleTemplateAction('edit', scope.row)">编辑</el-button> @click="ruleTemplateAction('chose', scope.row)">选择</el-button>
<el-button text type="warning" style="margin-left: 0" size="small" @click="ruleTemplateAction('delete', scope.row)">删除</el-button> <el-button text type="primary" style="margin-left: 0" size="small"
<el-button v-if="defaultTemplateId != scope.row.id" text type="primary" size="small" @click="ruleTemplateAction('default', scope.row)" @click="ruleTemplateAction('edit', scope.row)">编辑</el-button>
>设为默认</el-button <el-button text type="warning" style="margin-left: 0" size="small"
> @click="ruleTemplateAction('delete', scope.row)">删除</el-button>
<el-button v-if="defaultTemplateId != scope.row.id" text type="primary" size="small"
@click="ruleTemplateAction('default', scope.row)">设为默认</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<el-dialog :title="curEdit != null ? '修改' : '新增模板'" v-model="showEditAddModal" width="40em" @close="closeAddEdit" append-to-body> <el-dialog :title="curEdit != null ? '修改' : '新增模板'" v-model="showEditAddModal" width="40em" @close="closeAddEdit"
append-to-body>
<el-form-item label="名称"> <el-form-item label="名称">
<el-input v-model="templateForm.name"></el-input> <el-input v-model="templateForm.name"></el-input>
</el-form-item> </el-form-item>
@ -37,7 +40,7 @@
</template> </template>
<script> <script>
import HttpUtil from "../../../utils/HttpUtil"; import HttpUtil from "@/utils/HttpUtil";
import dayjs from "dayjs"; import dayjs from "dayjs";
export default { export default {
name: "ApplicationRuleList", name: "ApplicationRuleList",
@ -113,4 +116,6 @@ export default {
}; };
</script> </script>
<style></style> <style>
</style>

View File

@ -1,25 +1,31 @@
<template> <template>
<div class="main"> <div class="main">
<div class="menu"> <div class="menu">
<el-button type="warning" size="small" @click="block">禁用/启用</el-button> <el-button v-if="rules == undefined" type="warning" size="small" @click="block">禁用/启用</el-button>
<el-button type="danger" size="small" @click="deleteRule">删除</el-button> <el-button type="danger" size="small" @click="deleteRule">删除</el-button>
<template v-if="rules == undefined">
<el-button type="primary" size="small" @click="templateSubmit">保存</el-button> <el-button type="primary" size="small" @click="templateSubmit">保存</el-button>
<el-button type="primary" size="small" @click="ruleTemplateShow = true">选择模板</el-button> <el-button type="primary" size="small" @click="ruleTemplateShow = true">选择模板</el-button>
</template>
<template v-if="checkedRules.length == 1"> <template v-if="checkedRules.length == 1">
<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><edit /></el-icon> <el-icon>
<edit />
</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><top /></el-icon> <el-icon>
<top />
</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>
><el-icon><bottom /></el-icon <bottom />
></el-tooltip> </el-icon></el-tooltip>
</el-button> </el-button>
</template> </template>
</div> </div>
@ -42,12 +48,13 @@
</template> </template>
<script> <script>
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"],
components: { components: {
Rule, Rule,
ApplicationRuleList, ApplicationRuleList,
@ -71,9 +78,14 @@ export default {
}, },
}, },
async created () { async created () {
//
if (this.rules != undefined) {
this.ruleList = JSON.parse(JSON.stringify(this.rules));
} else {
this.chosedTemplate = await HttpUtil.get("/applicationRule/default"); this.chosedTemplate = await HttpUtil.get("/applicationRule/default");
this.ruleList = JSON.parse(this.chosedTemplate.content); this.ruleList = JSON.parse(this.chosedTemplate.content);
await this.ruleUpdate(); await this.ruleUpdate();
}
}, },
methods: { methods: {
// //
@ -160,17 +172,20 @@ export default {
.main { .main {
text-align: left; text-align: left;
padding: 5px; padding: 5px;
.menu { .menu {
display: flex; display: flex;
justify-content: left; justify-content: left;
align-items: center; align-items: center;
} }
.ruleBlock { .ruleBlock {
text-align: left; text-align: left;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: baseline; align-items: baseline;
} }
.choseTemplate { .choseTemplate {
text-align: center; text-align: center;
padding-top: 2em; padding-top: 2em;

View File

@ -0,0 +1,138 @@
<template>
<div>
<el-form label-width="100px">
<el-form-item label="剧集目录">
<div style="text-align:left">
<template v-for="(item, index) in body.paths" :key="item">
<el-tag closable @close="closePath(index, 'folder')">{{ item }}</el-tag> <br />
</template>
<div style="display:flex;align-items:center">
<el-button type="primary" link @click="showFolderDialog = true">+新增目录</el-button>
<tips message="添加剧集的上级目录,比如'/美剧'目录下就是美剧的剧集文件夹" />
</div>
</div>
</el-form-item>
<el-form-item label="忽略文件">
<div style="text-align:left;display:flex;align-items:center">
<template v-for="(item, index) in body.ignorePaths" :key="item">
<el-tag closable @close="closePath(index, 'ignore')">{{ item }}</el-tag> <br />
</template>
<el-input v-if="ignoreInputVisible" v-model="ignoreInput" class="ml-1 w-20" size="small"
@keyup.enter="addIngoreFile" @blur="addIngoreFile" />
<el-button v-else class="button-new-tag ml-1" size="small" @click="ignoreInputVisible = true">
+ 忽略
</el-button>
<tips message="名字匹配的文件/文件夹将会忽略处理" />
</div>
</el-form-item>
<el-form-item label="忽略特典">
<el-switch v-model="body.ignoreSeason0" class="ml-2"
style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949" />
<tips message="season 0/特典通常命名不规范,建议手动处理" />
</el-form-item>
<el-form-item label="删除小文件">
<el-switch v-model="body.deleteSmallVideo" class="ml-2"
style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949" />
<tips message="删除小于2M的视频文件此类文件通常为广告" />
</el-form-item>
<el-form-item label="规则">
<RuleBlock :rules="body.rules" @ruleUpdate="ruleUpdate" />
</el-form-item>
</el-form>
<el-button type="primary" @click="submit"> 保存自动化配置 </el-button>
<el-dialog title="选择目录" v-model="showFolderDialog" width="70%">
<file-chose ref="fileChose" type="folder" @folderChose="folderChose" />
</el-dialog>
</div>
</template>
<script setup>
import FileChose from "@/components/FileChose.vue";
import RuleBlock from "@/components/rules/RuleBlock.vue";
import Tips from '@/components/Tips.vue';
import { ElMessage, ElMessageBox } from 'element-plus'
import { ref, reactive, onMounted, computed, defineProps } from "vue";
import http from "@/utils/HttpUtil";
//
let body = reactive({
paths: [],
version: 1,
ignoreSeason0: true,
ignorePaths: [],
deleteSmallVideo: true,
rules: []
});
let showFolderDialog = ref(false);
let ignoreInputVisible = ref(false);
let ignoreInput = ref("");
onMounted(async () => {
let res = await http.post("/config/multCode", null, ['autoConfig', 'firstUse']);
if (res.autoConfig == undefined && res.firstUse == undefined) {
await http.post("/config/insertOrUpdate", null, { code: "firstUse", val: "1" });
await ElMessageBox.alert("似乎是首次使用自动化,是否需要查看使用文档?", "提示", {
confirmButtonText: "是",
cancelButtonText: "否",
showCancelButton: true
});
alert("跳转到自动化使用文档");
return;
}
if (res.autoConfig != undefined) {
body = reactive(JSON.parse(res.autoConfig));
}
});
//
async function folderChose (data) {
if (body.paths.indexOf(data) > -1) {
ElMessage({ type: 'warning', message: "路径已存在" });
return;
}
body.paths.push(data);
showFolderDialog.value = false;
}
//
async function addIngoreFile () {
if (body.ignorePaths.indexOf(ignoreInput) > -1) {
ElMessage({ type: 'warning', message: "名称已存在" });
return;
}
body.ignorePaths.push(ignoreInput.value);
ignoreInput.value = "";
ignoreInputVisible.value = false;
}
//
async function closePath (index, type) {
(type === 'folder' ? body.paths : body.ignorePaths).splice(index, 1);
}
//
function ruleUpdate (rules) {
body.rules = rules;
}
//
async function submit () {
await http.post("/config/insertOrUpdate", null, { code: "autoConfig", val: JSON.stringify(body), description: "自动化配置" });
ElMessage({ type: 'success', message: "保存成功" });
}
</script>
<style lang="less" scoped>
.item {
display: flex;
text-align: left;
padding-bottom: 0.5em;
.left {
width: 6em;
font-weight: 600;
}
.right {
flex: 1;
}
}
</style>

View File

@ -1,12 +1,12 @@
<template> <template>
<div>自动化</div>
<div> <div>
<el-button type="primary" @click="submit"> 保存自动化配置 </el-button> <edit-form />
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, reactive, onMounted, computed } from "vue"; import { ref, reactive, onMounted, computed } from "vue";
import editForm from "./components/editForm.vue";
import http from "@/utils/HttpUtil"; import http from "@/utils/HttpUtil";
// //
const qbBody = reactive({ const qbBody = reactive({
@ -42,10 +42,12 @@ async function submit() {
display: flex; display: flex;
text-align: left; text-align: left;
padding-bottom: 0.5em; padding-bottom: 0.5em;
.left { .left {
width: 6em; width: 6em;
font-weight: 600; font-weight: 600;
} }
.right { .right {
flex: 1; flex: 1;
} }

View File

@ -2,38 +2,35 @@
<div v-loading="loading" element-loading-text="后台处理中,请稍候"> <div v-loading="loading" element-loading-text="后台处理中,请稍候">
<br /> <br />
<el-button type="success" @click="submit" size="default">开始重命名</el-button> <el-button type="success" @click="submit" size="default">开始重命名</el-button>
<el-divider content-position="left"><div class="head-text">规则设置</div></el-divider> <el-divider content-position="left">
<div class="head-text">规则设置</div>
</el-divider>
<!-- 规则列表 --> <!-- 规则列表 -->
<rule-block @ruleUpdate="ruleUpdate" /> <rule-block @ruleUpdate="ruleUpdate" />
<el-divider content-position="left"><div class="head-text">文件预览</div></el-divider> <el-divider content-position="left">
<div class="head-text">文件预览</div>
</el-divider>
<!-- 文件预览列表 --> <!-- 文件预览列表 -->
<div class="fileList"> <div class="fileList">
<div> <div>
<el-button type="primary" @click="showFileAdd" size="small">新增</el-button> <el-button type="primary" @click="showFileAdd" size="small">新增</el-button>
收藏路径:<el-tag 收藏路径:<el-tag v-for="item in savePathList" :round="true" class="savePath" closable :key="item.id"
v-for="item in savePathList" @click="clickSavePath(item)" @close="deleteSavePath(item)" text>{{ item.name }}</el-tag>
:round="true"
class="savePath"
closable
:key="item.id"
@click="clickSavePath(item)"
@close="deleteSavePath(item)"
text
>{{ item.name }}</el-tag
>
</div> </div>
<div> <div>
<el-button type="primary" size="small" @click="selectAllFiles">反选</el-button> <el-button type="primary" size="small" @click="selectAllFiles">反选</el-button>
<el-button type="danger" size="small" @click="deleteCheckedFiles">删除</el-button> <el-button type="danger" size="small" @click="deleteCheckedFiles">删除</el-button>
<el-button type="primary" size="small" @click="moveIndex('top')"> <el-button type="primary" size="small" @click="moveIndex('top')">
<el-tooltip effect="dark" content="上移规则" placement="top"> <el-tooltip effect="dark" content="上移规则" placement="top">
<el-icon><top /></el-icon> <el-icon>
<top />
</el-icon>
</el-tooltip> </el-tooltip>
</el-button> </el-button>
<el-button type="primary" size="small" @click="moveIndex('bottom')"> <el-button type="primary" size="small" @click="moveIndex('bottom')">
<el-tooltip effect="dark" content="下移规则" placement="top" <el-tooltip effect="dark" content="下移规则" placement="top"><el-icon>
><el-icon><bottom /></el-icon <bottom />
></el-tooltip> </el-icon></el-tooltip>
</el-button> </el-button>
</div> </div>
<div class="fileBlock"> <div class="fileBlock">
@ -55,7 +52,8 @@
<!-- 新增文件弹窗 --> <!-- 新增文件弹窗 -->
<el-dialog title="新增文件" v-model="dialogVisible" width="70%"> <el-dialog title="新增文件" v-model="dialogVisible" width="70%">
<file-chose ref="fileChose" :curChoosePath="curChoosePath" @addData="addData" @refreshSavePathList="refreshSavePathList" /> <file-chose ref="fileChose" type="file" :curChoosePath="curChoosePath" @addData="addData"
@refreshSavePathList="refreshSavePathList" />
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
@ -65,7 +63,7 @@
import { Top, Bottom } from "@element-plus/icons-vue"; import { Top, Bottom } from "@element-plus/icons-vue";
import HttpUtil from "../../utils/HttpUtil"; import HttpUtil from "../../utils/HttpUtil";
import FileChose from "@/components/FileChose"; import FileChose from "@/components/FileChose";
import RuleBlock from "./components/RuleBlock.vue"; import RuleBlock from "@/components/rules/RuleBlock.vue";
import Bus from "../../utils/Bus"; import Bus from "../../utils/Bus";
let numberSet = new Set(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]); let numberSet = new Set(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]);
@ -282,6 +280,7 @@ function readChar(a, i, n) {
cursor: pointer; cursor: pointer;
margin-right: 0.5em; margin-right: 0.5em;
} }
.fileList { .fileList {
margin-top: 20px; margin-top: 20px;
text-align: left; text-align: left;
@ -289,6 +288,7 @@ function readChar(a, i, n) {
.fileBlock { .fileBlock {
margin-top: 20px; margin-top: 20px;
display: flex; display: flex;
.oneLine { .oneLine {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;