From 40b363c3e50e8fba70f8153b274146fe67dd8d0f Mon Sep 17 00:00:00 2001 From: fanxb Date: Thu, 12 Jan 2023 22:55:40 +0800 Subject: [PATCH] temp --- openRenamerBackend/api/AutoPlanApi.ts | 49 +++++++++++++++ .../entity/dto/AutoPlanConfigDto.ts | 9 +++ openRenamerBackend/service/AutoPlanService.ts | 34 ++++++++++ openRenamerFront/src/components/Rule.vue | 12 ++-- .../src/components/rules/RuleBlock.vue | 4 +- .../src/views/auto/components/editForm.vue | 62 +++++++++++++------ 6 files changed, 142 insertions(+), 28 deletions(-) create mode 100644 openRenamerBackend/api/AutoPlanApi.ts create mode 100644 openRenamerBackend/entity/dto/AutoPlanConfigDto.ts create mode 100644 openRenamerBackend/service/AutoPlanService.ts diff --git a/openRenamerBackend/api/AutoPlanApi.ts b/openRenamerBackend/api/AutoPlanApi.ts new file mode 100644 index 0000000..355eece --- /dev/null +++ b/openRenamerBackend/api/AutoPlanApi.ts @@ -0,0 +1,49 @@ +import { Context } from "koa"; +import FileService from "../service/FileService"; +import config from "../config"; + +const router = {}; + +/** + * 获取目录下的文件列表 + */ +router["GET /file/query"] = async function (ctx: Context) { + ctx.body = await FileService.readPath(ctx.query.path as string, ctx.query.showHidden === '1'); +}; + +/** + *是否windows + */ +router['GET /file/isWindows'] = async function (ctx: Context) { + ctx.body = config.isWindows; +} + +/** + * 检查路径是否存在 + */ +router["GET /file/path/exist"] = async function (ctx: Context) { + ctx.body = await FileService.checkExist(ctx.query.path as string); +}; + +/** + * 收藏路径 + */ +router["POST /file/path/save"] = async function (ctx: Context) { + ctx.body = await FileService.savePath(ctx.request.body); +}; + +/** + * 获取收藏路径 + */ +router["GET /file/path"] = async function (ctx: Context) { + ctx.body = await FileService.getSaveList(); +}; + +/** + * 获取收藏路径 + */ +router["DELETE /file/path/delete"] = async function (ctx: Context) { + ctx.body = await FileService.deleteOne(ctx.query.id); +}; + +export default router; diff --git a/openRenamerBackend/entity/dto/AutoPlanConfigDto.ts b/openRenamerBackend/entity/dto/AutoPlanConfigDto.ts new file mode 100644 index 0000000..19e5054 --- /dev/null +++ b/openRenamerBackend/entity/dto/AutoPlanConfigDto.ts @@ -0,0 +1,9 @@ +export default interface AutoPlanConfigDto { + paths: Array, + version: Number, + ignoreSeason0: Boolean, + ignorePaths: Array, + deleteSmallVideo: boolean, + rules: Array, + start: boolean +} \ No newline at end of file diff --git a/openRenamerBackend/service/AutoPlanService.ts b/openRenamerBackend/service/AutoPlanService.ts new file mode 100644 index 0000000..f03a00b --- /dev/null +++ b/openRenamerBackend/service/AutoPlanService.ts @@ -0,0 +1,34 @@ +import config from '../config'; +import * as path from 'path'; +import * as fs from 'fs-extra'; + +import ProcessHelper from '../util/ProcesHelper'; +import FileObj from '../entity/vo/FileObj'; +import SavePathDao from '../dao/SavePathDao'; +import SavePath from '../entity/po/SavePath'; +import AutoPlanConfigDto from '../entity/dto/AutoPlanConfigDto'; +import GlobalConfig from 'entity/po/GlobalConfig'; +import GlobalConfigService from './GlobalConfigService'; + +const autoConfigCode = "autoConfig"; + +class AutoPlanService { + /** + * 保存配置 + */ + static async saveAutoConfig(body: AutoPlanConfigDto): Promise { + let configBody: GlobalConfig = { + code: autoConfigCode, + val: JSON.stringify(body), + description: "自动化计划配置" + }; + await GlobalConfigService.insertOrReplace(configBody); + if (!body.start) { + return; + } + let old = await GlobalConfigService.getVal(autoConfigCode); + if (old && old.length) + } +} + +export default AutoPlanService; diff --git a/openRenamerFront/src/components/Rule.vue b/openRenamerFront/src/components/Rule.vue index 1efce60..6382d5f 100644 --- a/openRenamerFront/src/components/Rule.vue +++ b/openRenamerFront/src/components/Rule.vue @@ -4,7 +4,7 @@ 插入 删除 - 序列化 + 序列化 自动识别
@@ -26,25 +26,25 @@ import SerializationRule from "./rules/SerializationRule.vue"; import AutoRule from "./rules/AutoRule"; export default { components: { InsertRule, DeleteRule, SerializationRule, AutoRule }, - props: ["editRule"], + props: ["editRule", "isAutoPlan"], emits: ["ruleAdd"], name: "Rule", - data() { + data () { return { currentIndex: "insert", options: [{ label: "插入", value: "insert" }], }; }, - created() { + created () { if (this.editRule) { this.currentIndex = this.editRule.type; } }, methods: { - menuChange(index) { + menuChange (index) { this.currentIndex = index; }, - submit() { + submit () { let data = this.$refs["rule"].exportObj(); if (data != null) { this.$emit("ruleAdd", data); diff --git a/openRenamerFront/src/components/rules/RuleBlock.vue b/openRenamerFront/src/components/rules/RuleBlock.vue index c725c14..eed73de 100644 --- a/openRenamerFront/src/components/rules/RuleBlock.vue +++ b/openRenamerFront/src/components/rules/RuleBlock.vue @@ -38,8 +38,8 @@ + 新增规则
- - + + diff --git a/openRenamerFront/src/views/auto/components/editForm.vue b/openRenamerFront/src/views/auto/components/editForm.vue index a567297..6eb5060 100644 --- a/openRenamerFront/src/views/auto/components/editForm.vue +++ b/openRenamerFront/src/views/auto/components/editForm.vue @@ -1,14 +1,15 @@