feat:自动识别逻辑增加
This commit is contained in:
parent
9d8a6dcbfe
commit
ca6dba024f
62
openRenamerBackend/entity/bo/rules/AutoRule.ts
Normal file
62
openRenamerBackend/entity/bo/rules/AutoRule.ts
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import RuleInterface from "./RuleInterface";
|
||||||
|
import FileObj from "../../vo/FileObj";
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
|
||||||
|
let pattern = new RegExp(/s(eason)?(\d+)/);
|
||||||
|
let charSet = new Set([' ', '[', '.', '(', '(']);
|
||||||
|
export default class InsertRule implements RuleInterface {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 识别类型,season:季号,name:剧名/电影名识别
|
||||||
|
*/
|
||||||
|
type: string;
|
||||||
|
/**
|
||||||
|
* 前面追加
|
||||||
|
*/
|
||||||
|
frontAdd: string;
|
||||||
|
/**
|
||||||
|
* 后面追加
|
||||||
|
*/
|
||||||
|
endAdd: string;
|
||||||
|
|
||||||
|
constructor(data: any) {
|
||||||
|
this.type = data.type;
|
||||||
|
this.frontAdd = data.frontAdd;
|
||||||
|
this.endAdd = data.endAdd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
deal(file: FileObj): void {
|
||||||
|
//识别到的内容
|
||||||
|
let getStr = null;
|
||||||
|
let patternRes = path.basename(file.path).replace(/[ ]+/, "").toLocaleLowerCase().match(pattern);
|
||||||
|
if (this.type === 'season') {
|
||||||
|
if (patternRes && patternRes[2]) {
|
||||||
|
getStr = patternRes[2];
|
||||||
|
}
|
||||||
|
} else if (this.type === 'name') {
|
||||||
|
let originName = null;
|
||||||
|
if (patternRes && patternRes[2]) {
|
||||||
|
//说明是剧集,取父文件夹的父文件夹名称
|
||||||
|
originName = path.basename(path.resolve(file.path, '..'));
|
||||||
|
} else {
|
||||||
|
//说明是电影
|
||||||
|
originName = path.basename(file.path);
|
||||||
|
}
|
||||||
|
getStr = '';
|
||||||
|
for (let i = 0; i < originName.length; i++) {
|
||||||
|
let char = originName.charAt(i);
|
||||||
|
if (charSet.has(char)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
getStr += char;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getStr && getStr.length > 0) {
|
||||||
|
file.realName = file.realName + this.frontAdd + getStr + this.endAdd;
|
||||||
|
file.name = file.realName + file.expandName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,92 +1,92 @@
|
|||||||
import RuleInterface from "./RuleInterface";
|
import RuleInterface from "./RuleInterface";
|
||||||
import FileObj from "../FileObj";
|
import FileObj from "../../vo/FileObj";
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
export default class DeleteRule implements RuleInterface {
|
export default class DeleteRule implements RuleInterface {
|
||||||
/**
|
/**
|
||||||
* 类别:deletePart:部分删除,deleteAll:全部删除
|
* 类别:deletePart:部分删除,deleteAll:全部删除
|
||||||
*/
|
*/
|
||||||
type: string;
|
type: string;
|
||||||
/**
|
/**
|
||||||
* 部分删除时的开始信息
|
* 部分删除时的开始信息
|
||||||
*/
|
*/
|
||||||
start: DeleteRuleItem;
|
start: DeleteRuleItem;
|
||||||
/**
|
/**
|
||||||
* 部分删除时的结束信息
|
* 部分删除时的结束信息
|
||||||
|
|
||||||
*/
|
*/
|
||||||
end: DeleteRuleItem;
|
end: DeleteRuleItem;
|
||||||
/**
|
/**
|
||||||
* 忽略拓展名,true:忽略,false:不忽略
|
* 忽略拓展名,true:忽略,false:不忽略
|
||||||
*/
|
*/
|
||||||
ignorePostfix: boolean;
|
ignorePostfix: boolean;
|
||||||
|
|
||||||
constructor(data: any) {
|
constructor(data: any) {
|
||||||
this.type = data.type;
|
this.type = data.type;
|
||||||
this.start = new DeleteRuleItem(data.start);
|
this.start = new DeleteRuleItem(data.start);
|
||||||
this.end = new DeleteRuleItem(data.end);
|
this.end = new DeleteRuleItem(data.end);
|
||||||
this.ignorePostfix = data.ignorePostfix;
|
this.ignorePostfix = data.ignorePostfix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
deal(file: FileObj): void {
|
deal(file: FileObj): void {
|
||||||
if (this.type === 'deleteAll') {
|
if (this.type === 'deleteAll') {
|
||||||
file.realName = "";
|
file.realName = "";
|
||||||
if (!this.ignorePostfix) {
|
if (!this.ignorePostfix) {
|
||||||
file.expandName = "";
|
file.expandName = "";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let str = file.realName + (this.ignorePostfix ? "" : file.expandName);
|
let str = file.realName + (this.ignorePostfix ? "" : file.expandName);
|
||||||
let startIndex = this.start.calIndex(str);
|
let startIndex = this.start.calIndex(str);
|
||||||
let endIndex = this.end.calIndex(str);
|
let endIndex = this.end.calIndex(str);
|
||||||
if (startIndex < 0 || endIndex < 0) {
|
if (startIndex < 0 || endIndex < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
str = str.substring(0, startIndex) + str.substring(endIndex + 1);
|
str = str.substring(0, startIndex) + str.substring(endIndex + 1);
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeleteRuleItem {
|
class DeleteRuleItem {
|
||||||
/**
|
/**
|
||||||
* location:位置,text:文本,end:直到末尾
|
* location:位置,text:文本,end:直到末尾
|
||||||
*/
|
*/
|
||||||
type: string;
|
type: string;
|
||||||
/**
|
/**
|
||||||
* 对应的值
|
* 对应的值
|
||||||
*/
|
*/
|
||||||
value: string;
|
value: string;
|
||||||
|
|
||||||
constructor(data: any) {
|
constructor(data: any) {
|
||||||
this.type = data.type;
|
this.type = data.type;
|
||||||
this.value = data.value;
|
this.value = data.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算位置
|
* 计算位置
|
||||||
*/
|
*/
|
||||||
calIndex(str: string): number {
|
calIndex(str: string): number {
|
||||||
if (this.type === 'location') {
|
if (this.type === 'location') {
|
||||||
return parseInt(this.value) - 1;
|
return parseInt(this.value) - 1;
|
||||||
} else if (this.type === 'text') {
|
} else if (this.type === 'text') {
|
||||||
return str.indexOf(this.value);
|
return str.indexOf(this.value);
|
||||||
} else if (this.type === 'end') {
|
} else if (this.type === 'end') {
|
||||||
return str.length - 1;
|
return str.length - 1;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,83 +1,98 @@
|
|||||||
import RuleInterface from "./RuleInterface";
|
import RuleInterface from "./RuleInterface";
|
||||||
import FileObj from "../FileObj";
|
import FileObj from "../../vo/FileObj";
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
|
|
||||||
let pattern = new RegExp(/s(eason)?(\d+)/);
|
let pattern = new RegExp(/s(eason)?(\d+)/);
|
||||||
export default class InsertRule implements RuleInterface {
|
export default class InsertRule implements RuleInterface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入内容
|
* 插入内容
|
||||||
*/
|
*/
|
||||||
insertContent: string;
|
insertContent: string;
|
||||||
/**
|
/**
|
||||||
* 操作类别,front:前缀,backend:后缀,at:位置,replace:替换当前文件名
|
* 操作类别,front:前缀,backend:后缀,at:位置,replace:替换当前文件名
|
||||||
*/
|
*/
|
||||||
type: string;
|
type: string;
|
||||||
/**
|
/**
|
||||||
* 当type为at,时的位置,从1开始
|
* 当type为at,时的位置,从1开始
|
||||||
*/
|
*/
|
||||||
atInput: number;
|
atInput: number;
|
||||||
/**
|
/**
|
||||||
* 当type为at,时的方向,true:从右到左,false:从左到右
|
* 当type为at,时的方向,true:从右到左,false:从左到右
|
||||||
*/
|
*/
|
||||||
atIsRightToleft: boolean;
|
atIsRightToleft: boolean;
|
||||||
/**
|
/**
|
||||||
* 忽略拓展名,true:忽略,false:不忽略
|
* 忽略拓展名,true:忽略,false:不忽略
|
||||||
*/
|
*/
|
||||||
ignorePostfix: boolean;
|
ignorePostfix: boolean;
|
||||||
/**
|
/**
|
||||||
自动识别季号
|
自动识别季号
|
||||||
*/
|
*/
|
||||||
autoSeason: boolean;
|
autoSeason: boolean;
|
||||||
|
/**
|
||||||
constructor(data: any) {
|
后缀过滤是否开启
|
||||||
this.insertContent = data.insertContent;
|
*/
|
||||||
this.type = data.type;
|
endFilter: boolean;
|
||||||
this.atInput = data.atInput;
|
/**
|
||||||
this.atIsRightToleft = data.atIsRightToleft;
|
有效后缀
|
||||||
this.ignorePostfix = data.ignorePostfix;
|
*/
|
||||||
this.autoSeason = data.autoSeason;
|
validEnd: Array<String>;
|
||||||
}
|
|
||||||
|
constructor(data: any) {
|
||||||
|
this.insertContent = data.insertContent;
|
||||||
deal(file: FileObj): void {
|
this.type = data.type;
|
||||||
let str = this.ignorePostfix ? file.realName : file.name;
|
this.atInput = data.atInput;
|
||||||
let season = '';
|
this.atIsRightToleft = data.atIsRightToleft;
|
||||||
if (this.autoSeason) {
|
this.ignorePostfix = data.ignorePostfix;
|
||||||
let patternRes = path.basename(file.path).replace(/[ ]+/, "").toLocaleLowerCase().match(pattern);
|
this.autoSeason = data.autoSeason;
|
||||||
if (patternRes && patternRes[2]) {
|
this.endFilter = data.endFilter;
|
||||||
season = patternRes[2];
|
this.validEnd = data.validEnd;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
switch (this.type) {
|
|
||||||
case "front":
|
deal(file: FileObj): void {
|
||||||
str = this.insertContent + season + str;
|
if (this.endFilter && file.expandName.length > 0 && this.validEnd.indexOf(file.expandName.substring(1)) == -1) {
|
||||||
break;
|
//拓展名不符,跳过
|
||||||
case "backend":
|
return;
|
||||||
str = str + this.insertContent + season;
|
}
|
||||||
break;
|
let str = this.ignorePostfix ? file.realName : file.name;
|
||||||
case "at":
|
let season = '';
|
||||||
let index = this.atIsRightToleft ? str.length - this.atInput + 1 : this.atInput - 1;
|
|
||||||
str = str.substring(0, index) + this.insertContent + season + str.substring(index);
|
if (this.autoSeason) {
|
||||||
break;
|
let patternRes = path.basename(file.path).replace(/[ ]+/, "").toLocaleLowerCase().match(pattern);
|
||||||
case "replace":
|
if (patternRes && patternRes[2]) {
|
||||||
str = this.insertContent + season;
|
season = patternRes[2];
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
|
switch (this.type) {
|
||||||
|
case "front":
|
||||||
if (this.ignorePostfix) {
|
str = this.insertContent + season + str;
|
||||||
file.realName = str;
|
break;
|
||||||
} else {
|
case "backend":
|
||||||
file.expandName = path.extname(str);
|
str = str + this.insertContent + season;
|
||||||
if (file.expandName.length > 0) {
|
break;
|
||||||
file.realName = str.substring(0, str.lastIndexOf("."));
|
case "at":
|
||||||
} else {
|
let index = this.atIsRightToleft ? str.length - this.atInput + 1 : this.atInput - 1;
|
||||||
file.realName = str;
|
str = str.substring(0, index) + this.insertContent + season + str.substring(index);
|
||||||
}
|
break;
|
||||||
}
|
case "replace":
|
||||||
|
str = this.insertContent + season;
|
||||||
file.name = file.realName + file.expandName;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (this.ignorePostfix) {
|
||||||
|
file.realName = str;
|
||||||
|
} else {
|
||||||
|
file.expandName = path.extname(str);
|
||||||
|
if (file.expandName.length > 0) {
|
||||||
|
file.realName = str.substring(0, str.lastIndexOf("."));
|
||||||
|
} else {
|
||||||
|
file.realName = str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
file.name = file.realName + file.expandName;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
import FileObj from "../FileObj";
|
import FileObj from "../../vo/FileObj";
|
||||||
|
|
||||||
export default interface RuleInterface {
|
export default interface RuleInterface {
|
||||||
|
|
||||||
deal(file: FileObj): void;
|
deal(file: FileObj): void;
|
||||||
}
|
}
|
@ -1,80 +1,80 @@
|
|||||||
import RuleInterface from "./RuleInterface";
|
import RuleInterface from "./RuleInterface";
|
||||||
import FileObj from "../FileObj";
|
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;
|
currentIndex: 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;
|
||||||
|
|
||||||
constructor(data: any) {
|
constructor(data: any) {
|
||||||
this.start = data.start;
|
this.start = data.start;
|
||||||
this.currentIndex = data.start;
|
this.currentIndex = data.start;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
deal(file: FileObj): void {
|
deal(file: FileObj): void {
|
||||||
let length = this.currentIndex.toString().length;
|
let length = this.currentIndex.toString().length;
|
||||||
let numStr = (this.addZero && this.numLength > length ? "0".repeat(this.numLength - length) : "") + this.currentIndex;
|
let numStr = (this.addZero && this.numLength > length ? "0".repeat(this.numLength - length) : "") + this.currentIndex;
|
||||||
let str = this.ignorePostfix ? file.realName : file.name;
|
let str = this.ignorePostfix ? file.realName : file.name;
|
||||||
switch (this.insertType) {
|
switch (this.insertType) {
|
||||||
case "front":
|
case "front":
|
||||||
str = numStr + str;
|
str = numStr + str;
|
||||||
break;
|
break;
|
||||||
case "backend":
|
case "backend":
|
||||||
str = str + numStr;
|
str = str + numStr;
|
||||||
break;
|
break;
|
||||||
case "at":
|
case "at":
|
||||||
str = str.substring(0, this.insertValue - 1) + numStr + str.substring(this.insertValue - 1);
|
str = str.substring(0, this.insertValue - 1) + numStr + str.substring(this.insertValue - 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.currentIndex += this.increment;
|
this.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;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,50 +1,55 @@
|
|||||||
import * as pathUtil from "path";
|
import * as pathUtil from "path";
|
||||||
export default class FileObj {
|
export default class FileObj {
|
||||||
/**
|
/**
|
||||||
* 文件名
|
* 文件名
|
||||||
*/
|
*/
|
||||||
name: string;
|
name: string;
|
||||||
/**
|
/**
|
||||||
* 拓展名
|
原始名字
|
||||||
*/
|
*/
|
||||||
expandName: string;
|
originName: string;
|
||||||
/**
|
/**
|
||||||
* 去掉拓展名后的名字
|
* 拓展名
|
||||||
*/
|
*/
|
||||||
realName: string;
|
expandName: string;
|
||||||
/**
|
/**
|
||||||
* 所属路径
|
* 去掉拓展名后的名字
|
||||||
*/
|
*/
|
||||||
path: string;
|
realName: string;
|
||||||
/**
|
/**
|
||||||
* 是否文件夹
|
* 所属路径
|
||||||
*/
|
*/
|
||||||
isFolder: boolean;
|
path: string;
|
||||||
/**
|
/**
|
||||||
* 重命名错误原因
|
* 是否文件夹
|
||||||
*/
|
*/
|
||||||
errorMessage: string;
|
isFolder: boolean;
|
||||||
/**
|
/**
|
||||||
* 创建时间ms
|
* 重命名错误原因
|
||||||
*/
|
*/
|
||||||
createdTime: number;
|
errorMessage: string;
|
||||||
/**
|
/**
|
||||||
* 更新时间ms
|
* 创建时间ms
|
||||||
*/
|
*/
|
||||||
updatedTime: number;
|
createdTime: number;
|
||||||
|
/**
|
||||||
|
* 更新时间ms
|
||||||
constructor(name: string, path, isFolder, createdTime, updatedTime) {
|
*/
|
||||||
this.name = name;
|
updatedTime: number;
|
||||||
this.expandName = pathUtil.extname(name);
|
|
||||||
if (this.expandName.length > 0) {
|
|
||||||
this.realName = name.substring(0, name.lastIndexOf("."));
|
constructor(name: string, path, isFolder, createdTime, updatedTime) {
|
||||||
} else {
|
this.name = name;
|
||||||
this.realName = name;
|
this.originName = name;
|
||||||
}
|
this.expandName = pathUtil.extname(name);
|
||||||
this.path = path;
|
if (this.expandName.length > 0) {
|
||||||
this.isFolder = isFolder;
|
this.realName = name.substring(0, name.lastIndexOf("."));
|
||||||
this.createdTime = createdTime;
|
} else {
|
||||||
this.updatedTime = updatedTime;
|
this.realName = name;
|
||||||
}
|
}
|
||||||
|
this.path = path;
|
||||||
|
this.isFolder = isFolder;
|
||||||
|
this.createdTime = createdTime;
|
||||||
|
this.updatedTime = updatedTime;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,27 +1,35 @@
|
|||||||
import DeleteRule from "./rules/DeleteRule";
|
import DeleteRule from "../bo/rules/DeleteRule";
|
||||||
import InsertRule from "./rules/InsertRule";
|
import InsertRule from "../bo/rules/InsertRule";
|
||||||
import SerializationRule from "./rules/SerializationRule";
|
import SerializationRule from "../bo/rules/SerializationRule";
|
||||||
|
import AutoRule from "../bo/rules/AutoRule";
|
||||||
export default class RuleObj {
|
|
||||||
type: string;
|
export default class RuleObj {
|
||||||
message: string;
|
type: string;
|
||||||
/**
|
message: string;
|
||||||
* 具体参数
|
/**
|
||||||
*/
|
* 具体参数
|
||||||
data: any;
|
*/
|
||||||
|
data: any;
|
||||||
constructor(data: any) {
|
|
||||||
this.type = data.type;
|
constructor(data: any) {
|
||||||
this.message = data.message;
|
this.type = data.type;
|
||||||
switch (this.type) {
|
this.message = data.message;
|
||||||
case "delete":
|
switch (this.type) {
|
||||||
this.data = new DeleteRule(data.data);
|
case "delete":
|
||||||
break;
|
this.data = new DeleteRule(data.data);
|
||||||
case "insert":
|
break;
|
||||||
this.data = new InsertRule(data.data);
|
case "insert":
|
||||||
break;
|
this.data = new InsertRule(data.data);
|
||||||
default:
|
break;
|
||||||
this.data = new SerializationRule(data.data);
|
case "serialization":
|
||||||
}
|
this.data = new SerializationRule(data.data);
|
||||||
}
|
break;
|
||||||
|
case "auto":
|
||||||
|
this.data = new AutoRule(data.data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error("不支持的规则:" + this.type);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -3,7 +3,7 @@ import * as path from 'path';
|
|||||||
import * as fs from 'fs-extra';
|
import * as fs from 'fs-extra';
|
||||||
|
|
||||||
import ProcessHelper from '../util/ProcesHelper';
|
import ProcessHelper from '../util/ProcesHelper';
|
||||||
import FileObj from '../vo/FileObj';
|
import FileObj from '../entity/vo/FileObj';
|
||||||
import SavePathDao from '../dao/SavePathDao';
|
import SavePathDao from '../dao/SavePathDao';
|
||||||
import SavePath from '../entity/dto/SavePath';
|
import SavePath from '../entity/dto/SavePath';
|
||||||
|
|
||||||
@ -28,6 +28,9 @@ class FileService {
|
|||||||
fileList = await fs.readdir(pathStr);
|
fileList = await fs.readdir(pathStr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (!(fs.pathExists(pathStr))) {
|
||||||
|
throw new Error("路径不存在");
|
||||||
|
}
|
||||||
fileList = await fs.readdir(pathStr);
|
fileList = await fs.readdir(pathStr);
|
||||||
}
|
}
|
||||||
let folderList: Array<FileObj> = new Array();
|
let folderList: Array<FileObj> = new Array();
|
||||||
|
@ -2,9 +2,9 @@ import config from '../config';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as fs from 'fs-extra';
|
import * as fs from 'fs-extra';
|
||||||
|
|
||||||
import FileObj from '../vo/FileObj';
|
import FileObj from '../entity/vo/FileObj';
|
||||||
import RuleObj from '../vo/RuleObj';
|
import RuleObj from '../entity/vo/RuleObj';
|
||||||
import RuleInterface from '../vo/rules/RuleInterface';
|
import RuleInterface from '../entity/bo/rules/RuleInterface';
|
||||||
|
|
||||||
|
|
||||||
class RenamerService {
|
class RenamerService {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
"lint": "vue-cli-service lint"
|
"lint": "vue-cli-service lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@element-plus/icons": "^0.0.11",
|
"@element-plus/icons-vue": "^2.0.10",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"core-js": "^3.6.5",
|
"core-js": "^3.6.5",
|
||||||
"dayjs": "^1.10.7",
|
"dayjs": "^1.10.7",
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="">
|
<html lang="">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
|
||||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
<title>renamer</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<noscript>
|
<noscript>
|
||||||
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
<strong
|
||||||
|
>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to
|
||||||
|
continue.</strong
|
||||||
|
>
|
||||||
</noscript>
|
</noscript>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<!-- built files will be auto injected -->
|
<!-- built files will be auto injected -->
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app">
|
<div class="app">
|
||||||
|
<div class="head">菜单栏</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<router-view />
|
<router-view />
|
||||||
</div>
|
</div>
|
||||||
|
@ -36,8 +36,10 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import HttpUtil from "../utils/HttpUtil";
|
import HttpUtil from "../utils/HttpUtil";
|
||||||
|
import Bus from "../utils/Bus";
|
||||||
export default {
|
export default {
|
||||||
name: "FileChose",
|
name: "FileChose",
|
||||||
|
props: ["curChoosePath"],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isWindows: false,
|
isWindows: false,
|
||||||
@ -61,9 +63,20 @@ export default {
|
|||||||
return targetList.length > 0 ? targetList[0].id : null;
|
return targetList.length > 0 ? targetList[0].id : null;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
async curChoosePath(newVal) {
|
||||||
|
console.log("变更路径:", newVal);
|
||||||
|
this.pathList = newVal;
|
||||||
|
await this.breadcrumbClick(this.pathList.length - 1);
|
||||||
|
},
|
||||||
|
},
|
||||||
async created() {
|
async created() {
|
||||||
|
if (this.curChoosePath && this.curChoosePath.length > 0) {
|
||||||
|
this.pathList = this.curChoosePath;
|
||||||
|
}
|
||||||
await this.breadcrumbClick(this.pathList.length - 1);
|
await this.breadcrumbClick(this.pathList.length - 1);
|
||||||
await this.refreshSavePathList();
|
await this.refreshSavePathList();
|
||||||
|
Bus.$on("refreshSavePathList", this.refreshSavePathList);
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
@ -77,15 +90,18 @@ export default {
|
|||||||
//点击面包蟹
|
//点击面包蟹
|
||||||
async breadcrumbClick(index) {
|
async breadcrumbClick(index) {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
let path = this.createPath(index);
|
try {
|
||||||
let fileList = await HttpUtil.get("/file/query", {
|
let path = this.createPath(index);
|
||||||
path: encodeURIComponent(path),
|
let fileList = await HttpUtil.get("/file/query", {
|
||||||
showHidden: false,
|
path: encodeURIComponent(path),
|
||||||
});
|
showHidden: false,
|
||||||
fileList.forEach((item) => (item.checked = false));
|
});
|
||||||
this.fileList = fileList;
|
fileList.forEach((item) => (item.checked = false));
|
||||||
this.filterText = "";
|
this.fileList = fileList;
|
||||||
this.loading = false;
|
this.filterText = "";
|
||||||
|
} finally {
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
//文件列表点击
|
//文件列表点击
|
||||||
@ -130,9 +146,8 @@ export default {
|
|||||||
},
|
},
|
||||||
//收藏路径
|
//收藏路径
|
||||||
async savePath() {
|
async savePath() {
|
||||||
let res = await HttpUtil.post("/file/path/save", null, { name: this.saveName, content: JSON.stringify(this.pathList) });
|
await HttpUtil.post("/file/path/save", null, { name: this.saveName, content: JSON.stringify(this.pathList) });
|
||||||
this.$emit("refreshSavePathList");
|
Bus.$emit("refreshSavePathList");
|
||||||
this.refreshSavePathList();
|
|
||||||
this.saveName = "";
|
this.saveName = "";
|
||||||
this.showSave = false;
|
this.showSave = false;
|
||||||
this.$message.success("操作成功");
|
this.$message.success("操作成功");
|
||||||
@ -140,15 +155,9 @@ export default {
|
|||||||
//取消收藏路径
|
//取消收藏路径
|
||||||
async cancelSavePath() {
|
async cancelSavePath() {
|
||||||
await HttpUtil.delete("/file/path/delete", { id: this.curSavePathId });
|
await HttpUtil.delete("/file/path/delete", { id: this.curSavePathId });
|
||||||
this.refreshSavePathList();
|
Bus.$emit("refreshSavePathList");
|
||||||
this.$emit("refreshSavePathList");
|
|
||||||
this.$message.success("操作成功");
|
this.$message.success("操作成功");
|
||||||
},
|
},
|
||||||
//变更路径
|
|
||||||
changePath(item) {
|
|
||||||
this.pathList = JSON.parse(item.content);
|
|
||||||
this.breadcrumbClick(this.pathList.length - 1);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -5,11 +5,13 @@
|
|||||||
<el-menu-item :disabled="editRule != null" index="delete">删除</el-menu-item>
|
<el-menu-item :disabled="editRule != null" index="delete">删除</el-menu-item>
|
||||||
<!-- <el-menu-item index="replace">替换</el-menu-item> -->
|
<!-- <el-menu-item index="replace">替换</el-menu-item> -->
|
||||||
<el-menu-item :disabled="editRule != null" index="serialization">序列化</el-menu-item>
|
<el-menu-item :disabled="editRule != null" index="serialization">序列化</el-menu-item>
|
||||||
|
<el-menu-item :disabled="editRule != null" index="auto">自动识别</el-menu-item>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
<div class="rule">
|
<div class="rule">
|
||||||
<insert-rule ref="rule" :editRule="editRule" v-if="currentIndex == 'insert'" />
|
<insert-rule ref="rule" :editRule="editRule" v-if="currentIndex == 'insert'" />
|
||||||
<delete-rule ref="rule" :editRule="editRule" v-else-if="currentIndex == 'delete'" />
|
<delete-rule ref="rule" :editRule="editRule" v-else-if="currentIndex == 'delete'" />
|
||||||
<serialization-rule ref="rule" :editRule="editRule" v-else-if="currentIndex == 'serialization'" />
|
<serialization-rule ref="rule" :editRule="editRule" v-else-if="currentIndex == 'serialization'" />
|
||||||
|
<auto-rule ref="rule" :editRule="editRule" v-else-if="currentIndex == 'auto'" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="text-align: center">
|
<div style="text-align: center">
|
||||||
@ -21,9 +23,11 @@
|
|||||||
import InsertRule from "./rules/InsertRule.vue";
|
import InsertRule from "./rules/InsertRule.vue";
|
||||||
import DeleteRule from "./rules/DeleteRule.vue";
|
import DeleteRule from "./rules/DeleteRule.vue";
|
||||||
import SerializationRule from "./rules/SerializationRule.vue";
|
import SerializationRule from "./rules/SerializationRule.vue";
|
||||||
|
import AutoRule from "./rules/AutoRule";
|
||||||
export default {
|
export default {
|
||||||
components: { InsertRule, DeleteRule, SerializationRule },
|
components: { InsertRule, DeleteRule, SerializationRule, AutoRule },
|
||||||
props: ["editRule"],
|
props: ["editRule"],
|
||||||
|
emits: ["ruleAdd"],
|
||||||
name: "Rule",
|
name: "Rule",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
93
openRenamerFront/src/components/rules/AutoRule.vue
Normal file
93
openRenamerFront/src/components/rules/AutoRule.vue
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
<template>
|
||||||
|
<div class="flex">
|
||||||
|
<span class="left">识别类型:</span>
|
||||||
|
<div class="location">
|
||||||
|
<el-radio v-model="ruleObj.data.type" label="season"
|
||||||
|
>季号识别
|
||||||
|
<el-tooltip effect="dark" :content="message2" placement="top">
|
||||||
|
<el-icon><InfoFilled /></el-icon>
|
||||||
|
</el-tooltip>
|
||||||
|
</el-radio>
|
||||||
|
<el-radio v-model="ruleObj.data.type" label="name"
|
||||||
|
>剧名/电影名识别
|
||||||
|
<el-tooltip effect="dark" :content="message2" placement="top">
|
||||||
|
<el-icon><InfoFilled /></el-icon>
|
||||||
|
</el-tooltip>
|
||||||
|
</el-radio>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<div class="left">前面追加:</div>
|
||||||
|
<el-input v-model="ruleObj.data.frontAdd" placeholder="识别内容前面追加,未识别到不会追加" style="width: 20em" />
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<div class="left">后面追加:</div>
|
||||||
|
<el-input v-model="ruleObj.data.endAdd" placeholder="识别内容后面追加,未识别到不会追加" style="width: 20em" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { InfoFilled } from "@element-plus/icons-vue";
|
||||||
|
export default {
|
||||||
|
name: "AutoRule",
|
||||||
|
props: ["editRule"],
|
||||||
|
components: { InfoFilled },
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
message1: '通过识别文件夹名称获取季号,放在插入文本最后,可识别"s1","s01","season 01","season01"等以s或season开头后接数字的',
|
||||||
|
message2:
|
||||||
|
"如果父文件夹包含season字段,那么会从父文件夹的父文件夹名称中取剧名,否则将从父文件夹名称中取电影名。规则为从开头开始取,直到遇见第一个空格/./[等符号",
|
||||||
|
ruleObj: {
|
||||||
|
type: "auto",
|
||||||
|
message: "",
|
||||||
|
data: {
|
||||||
|
type: "",
|
||||||
|
frontAdd: "",
|
||||||
|
endAdd: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
if (this.editRule) {
|
||||||
|
console.log(this.editRule);
|
||||||
|
this.ruleObj = JSON.parse(JSON.stringify(this.editRule));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
exportObj() {
|
||||||
|
if (this.ruleObj.data.type === "") {
|
||||||
|
this.$message({ message: "请选择识别类型", type: "warning" });
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
this.ruleObj.message = `自动识别:"${this.ruleObj.data.type == "season" ? "季号" : "剧名/电影名识别"}";`;
|
||||||
|
if (this.ruleObj.data.frontAdd.length > 0) {
|
||||||
|
this.ruleObj.message += `前缀添加:${this.ruleObj.data.frontAdd}`;
|
||||||
|
}
|
||||||
|
if (this.ruleObj.data.endAdd.length > 0) {
|
||||||
|
this.ruleObj.message += `后缀添加:${this.ruleObj.data.endAdd}`;
|
||||||
|
}
|
||||||
|
return this.ruleObj;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.flex {
|
||||||
|
display: flex;
|
||||||
|
justify-content: left;
|
||||||
|
align-items: center;
|
||||||
|
padding-top: 1em;
|
||||||
|
|
||||||
|
.left {
|
||||||
|
width: 6em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.location {
|
||||||
|
justify-content: left;
|
||||||
|
flex-direction: column;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@ -23,16 +23,36 @@
|
|||||||
<div class="flex">
|
<div class="flex">
|
||||||
<div class="left">季号识别:</div>
|
<div class="left">季号识别:</div>
|
||||||
<el-switch v-model="ruleObj.data.autoSeason" />
|
<el-switch v-model="ruleObj.data.autoSeason" />
|
||||||
通过识别文件夹名称获取季号,放在插入文本最后,可识别"s1","s01","season 01","season01"等以s或season开头后接数字的
|
<el-tooltip effect="dark" :content="message1" placement="top">
|
||||||
|
<el-icon><InfoFilled /></el-icon>
|
||||||
|
</el-tooltip>
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<div class="left">有效后缀:</div>
|
||||||
|
<el-switch v-model="ruleObj.data.endFilter" />
|
||||||
|
<template v-if="ruleObj.data.endFilter">
|
||||||
|
<el-tag v-for="item in ruleObj.data.validEnd" closable :key="item" @close="deleteEnd(item)" text>{{ item }}</el-tag>
|
||||||
|
<el-input v-if="validEndInputShow" v-model="validEndInput" style="width: 5em" size="small" @keyup.enter="validEndAdd" @blur="validEndAdd" />
|
||||||
|
<el-button v-else class="button-new-tag ml-1" size="small" @click="validEndInputShow = true">+ 新增</el-button>
|
||||||
|
</template>
|
||||||
|
<el-tooltip effect="dark" :content="message2" placement="top">
|
||||||
|
<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: "InsertRule",
|
name: "InsertRule",
|
||||||
props: ["editRule"],
|
props: ["editRule"],
|
||||||
|
components: { InfoFilled },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
message1: '通过识别文件夹名称获取季号,放在插入文本最后,可识别"s1","s01","season 01","season01"等以s或season开头后接数字的',
|
||||||
|
message2: '开启本选项后,本规则只在后缀匹配时才会生效.(输入后缀不包含".")',
|
||||||
|
validEndInputShow: false,
|
||||||
|
validEndInput: "",
|
||||||
ruleObj: {
|
ruleObj: {
|
||||||
type: "insert",
|
type: "insert",
|
||||||
message: "",
|
message: "",
|
||||||
@ -43,6 +63,8 @@ export default {
|
|||||||
atIsRightToleft: false,
|
atIsRightToleft: false,
|
||||||
ignorePostfix: true,
|
ignorePostfix: true,
|
||||||
autoSeason: false,
|
autoSeason: false,
|
||||||
|
endFilter: false,
|
||||||
|
validEnd: ["srt", "ass"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -62,6 +84,14 @@ export default {
|
|||||||
this.ruleObj.message = `插入:"${this.ruleObj.data.insertContent}"`;
|
this.ruleObj.message = `插入:"${this.ruleObj.data.insertContent}"`;
|
||||||
return this.ruleObj;
|
return this.ruleObj;
|
||||||
},
|
},
|
||||||
|
validEndAdd() {
|
||||||
|
this.ruleObj.data.validEnd.push(this.validEndInput);
|
||||||
|
this.validEndInput = "";
|
||||||
|
this.validEndInputShow = false;
|
||||||
|
},
|
||||||
|
deleteEnd(item) {
|
||||||
|
this.ruleObj.data.validEnd.splice(this.ruleObj.data.validEnd.indexOf(item), 1);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
33
openRenamerFront/src/utils/Bus.js
Normal file
33
openRenamerFront/src/utils/Bus.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
class Bus {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
this.list = {
|
||||||
|
}; // 收集订阅
|
||||||
|
}
|
||||||
|
// 订阅
|
||||||
|
$on (name, fn) {
|
||||||
|
|
||||||
|
this.list[name] = this.list[name] || [];
|
||||||
|
this.list[name].push(fn);
|
||||||
|
}
|
||||||
|
// 发布
|
||||||
|
$emit (name, data) {
|
||||||
|
|
||||||
|
if (this.list[name]) {
|
||||||
|
|
||||||
|
this.list[name].forEach((fn) => {
|
||||||
|
fn(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 取消订阅
|
||||||
|
$off (name) {
|
||||||
|
|
||||||
|
if (this.list[name]) {
|
||||||
|
|
||||||
|
delete this.list[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default new Bus;
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-loading="loading" element-loading-text="后台处理中,请稍候">
|
<div v-loading="loading" element-loading-text="后台处理中,请稍候">
|
||||||
<br />
|
<br />
|
||||||
<el-button type="primary" @click="submit" size="default">重命名</el-button>
|
<el-button type="success" @click="submit" size="default">开始重命名</el-button>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
<!-- 规则列表 -->
|
<!-- 规则列表 -->
|
||||||
<rule-block @ruleUpdate="ruleUpdate" />
|
<rule-block @ruleUpdate="ruleUpdate" />
|
||||||
@ -20,7 +20,6 @@
|
|||||||
:key="item.id"
|
:key="item.id"
|
||||||
@click="clickSavePath(item)"
|
@click="clickSavePath(item)"
|
||||||
@close="deleteSavePath(item)"
|
@close="deleteSavePath(item)"
|
||||||
type="primary"
|
|
||||||
text
|
text
|
||||||
>{{ item.name }}</el-tag
|
>{{ item.name }}</el-tag
|
||||||
>
|
>
|
||||||
@ -56,17 +55,18 @@
|
|||||||
<!-- 新增文件弹窗 -->
|
<!-- 新增文件弹窗 -->
|
||||||
|
|
||||||
<el-dialog title="新增文件" v-model="dialogVisible" width="70%">
|
<el-dialog title="新增文件" v-model="dialogVisible" width="70%">
|
||||||
<file-chose ref="fileChose" :curSavePath="curSavePath" @addData="addData" @refreshSavePathList="refreshSavePathList" />
|
<file-chose ref="fileChose" :curChoosePath="curChoosePath" @addData="addData" @refreshSavePathList="refreshSavePathList" />
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// @ is an alias to /src
|
// @ is an alias to /src
|
||||||
import { ArrowDownBold, ArrowUpBold } from "@element-plus/icons";
|
import { ArrowDownBold, ArrowUpBold } 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/RuleBlock.vue";
|
||||||
|
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"]);
|
||||||
|
|
||||||
@ -88,12 +88,13 @@ export default {
|
|||||||
needPreview: false, //需要点击预览
|
needPreview: false, //需要点击预览
|
||||||
applicationRule: null, //当前应用的应用规则模板
|
applicationRule: null, //当前应用的应用规则模板
|
||||||
savePathList: [], //收藏的路径列表
|
savePathList: [], //收藏的路径列表
|
||||||
curSavePath: null, //当前选择的收藏路径
|
curChoosePath: null, //当前选择的收藏路径
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
this.savePathList = await HttpUtil.get("/file/path");
|
this.savePathList = await HttpUtil.get("/file/path");
|
||||||
window.isWindows = await HttpUtil.get("/file/isWindows");
|
window.isWindows = await HttpUtil.get("/file/isWindows");
|
||||||
|
Bus.$on("refreshSavePathList", this.refreshSavePathList);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
//新增文件
|
//新增文件
|
||||||
@ -181,17 +182,14 @@ export default {
|
|||||||
this.dialogVisible = true;
|
this.dialogVisible = true;
|
||||||
},
|
},
|
||||||
//点击收藏路径
|
//点击收藏路径
|
||||||
clickSavePath(item) {
|
async clickSavePath(item) {
|
||||||
|
this.curChoosePath = JSON.parse(item.content);
|
||||||
this.dialogVisible = true;
|
this.dialogVisible = true;
|
||||||
console.log(item);
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.$refs["fileChose"].changePath(item);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
async deleteSavePath(item) {
|
async deleteSavePath(item) {
|
||||||
console.log(item);
|
console.log(item);
|
||||||
await HttpUtil.delete("/file/path/delete", { id: item.id });
|
await HttpUtil.delete("/file/path/delete", { id: item.id });
|
||||||
await this.refreshSavePathList();
|
Bus.$emit("refreshSavePathList");
|
||||||
},
|
},
|
||||||
async refreshSavePathList() {
|
async refreshSavePathList() {
|
||||||
this.savePathList = await HttpUtil.get("/file/path");
|
this.savePathList = await HttpUtil.get("/file/path");
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="ruleBlock">
|
<div class="ruleBlock">
|
||||||
<el-checkbox v-model="item.checked" v-for="(item, index) in ruleList" :key="index">
|
<el-checkbox v-model="item.checked" v-for="(item, index) in ruleList" :key="index" @dblclick="editClick(item)">
|
||||||
<s v-if="item.blocked">{{ item.message }}</s>
|
<s v-if="item.blocked">{{ item.message }}</s>
|
||||||
<span v-else>{{ item.message }}</span>
|
<span v-else>{{ item.message }}</span>
|
||||||
</el-checkbox>
|
</el-checkbox>
|
||||||
@ -21,7 +21,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 弹窗 -->
|
<!-- 弹窗 -->
|
||||||
<el-dialog title="新增规则" v-model="addRuleDialogShow" width="70%">
|
<el-dialog title="新增规则" v-model="addRuleDialogShow" width="70%" @close="ruleDialogClose">
|
||||||
<rule :editRule="editRule" @ruleAdd="ruleAdd" v-if="addRuleDialogShow" />
|
<rule :editRule="editRule" @ruleAdd="ruleAdd" v-if="addRuleDialogShow" />
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<el-dialog title="选择规则模板" v-model="ruleTemplateShow" width="70%">
|
<el-dialog title="选择规则模板" v-model="ruleTemplateShow" width="70%">
|
||||||
@ -142,10 +142,14 @@ export default {
|
|||||||
this.ruleUpdate();
|
this.ruleUpdate();
|
||||||
},
|
},
|
||||||
//编辑规则
|
//编辑规则
|
||||||
editClick() {
|
editClick(rule) {
|
||||||
this.editRule = this.checkedRules[0];
|
this.editRule = rule && rule.data ? rule : this.checkedRules[0];
|
||||||
this.addRuleDialogShow = true;
|
this.addRuleDialogShow = true;
|
||||||
},
|
},
|
||||||
|
ruleDialogClose() {
|
||||||
|
this.editRule = null;
|
||||||
|
this.addRuleDialogShow = false;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user