mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-12 15:20:44 +08:00
优化任务配置继承逻辑,支持按视图类型继承对应任务配置
- 新增 getLastTaskByCurrentFilter() 方法,根据当前视图筛选条件获取对应类型中编号最大的任务 - 修改 addTask() 方法,使用新的筛选逻辑继承任务配置 - 修改 openCreateTaskModal() 方法,使用新的筛选逻辑继承任务配置 - 现在在剧集视图下新建任务会继承剧集类型中编号最大的任务配置,动画视图下会继承动画类型中编号最大的任务配置,以此类推 - 提升了用户在特定类型视图下新建同类任务时的操作体验
This commit is contained in:
parent
454abc0f3a
commit
46b07fcdac
@ -4100,11 +4100,52 @@
|
||||
if (!this.tasklist || !this.tasklist.selectedType || this.tasklist.selectedType === 'all') return true;
|
||||
const name = task.taskname || task.task_name || '';
|
||||
let contentType = '';
|
||||
|
||||
// 优先从任务配置中读取内容类型
|
||||
if (task.content_type) {
|
||||
contentType = task.content_type;
|
||||
} else if (task.calendar_info && task.calendar_info.extracted && task.calendar_info.extracted.content_type) {
|
||||
contentType = task.calendar_info.extracted.content_type;
|
||||
} else {
|
||||
// 如果任务配置中没有,则从 calendar.tasks 中查找
|
||||
const t = (this.calendar.tasks || []).find(x => (x.task_name || x.taskname) === name);
|
||||
contentType = (t && t.content_type) || 'other';
|
||||
}
|
||||
|
||||
return contentType === this.tasklist.selectedType;
|
||||
} catch (e) { return true; }
|
||||
},
|
||||
// 获取根据当前视图筛选条件过滤后的任务中编号最大的任务
|
||||
getLastTaskByCurrentFilter() {
|
||||
try {
|
||||
if (!this.formData.tasklist || this.formData.tasklist.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 如果当前视图是"全部",返回所有任务中编号最大的任务
|
||||
if (!this.tasklist || !this.tasklist.selectedType || this.tasklist.selectedType === 'all') {
|
||||
return this.formData.tasklist[this.formData.tasklist.length - 1];
|
||||
}
|
||||
|
||||
// 根据当前筛选条件过滤任务
|
||||
const filteredTasks = this.formData.tasklist.filter(task => {
|
||||
return this.tasklistFilterByType(task);
|
||||
});
|
||||
|
||||
// 如果没有匹配的任务,返回所有任务中编号最大的任务
|
||||
if (filteredTasks.length === 0) {
|
||||
return this.formData.tasklist[this.formData.tasklist.length - 1];
|
||||
}
|
||||
|
||||
// 返回过滤后任务中编号最大的任务(最后一个)
|
||||
return filteredTasks[filteredTasks.length - 1];
|
||||
} catch (e) {
|
||||
// 出错时返回所有任务中编号最大的任务
|
||||
return this.formData.tasklist && this.formData.tasklist.length > 0
|
||||
? this.formData.tasklist[this.formData.tasklist.length - 1]
|
||||
: null;
|
||||
}
|
||||
},
|
||||
// 计算转存进度(已转存/已播出 的百分比,取整),优先使用实时映射
|
||||
getTransferProgress(task) {
|
||||
try {
|
||||
@ -6781,7 +6822,9 @@
|
||||
|
||||
// 如果有上一个任务,继承保存路径和命名规则
|
||||
if (this.formData.tasklist.length > 0) {
|
||||
const lastTask = this.formData.tasklist[this.formData.tasklist.length - 1];
|
||||
// 使用新的筛选逻辑:根据当前视图筛选条件获取对应类型中编号最大的任务
|
||||
const lastTask = this.getLastTaskByCurrentFilter();
|
||||
if (lastTask) {
|
||||
newTask.savepath = lastTask.savepath || "";
|
||||
newTask.pattern = lastTask.pattern || "";
|
||||
|
||||
@ -6792,6 +6835,21 @@
|
||||
newTask.episode_naming = lastTask.episode_naming || "";
|
||||
newTask.replace = lastTask.replace || "";
|
||||
}
|
||||
}
|
||||
|
||||
// 根据当前视图筛选条件设置新任务的内容类型
|
||||
if (this.tasklist && this.tasklist.selectedType && this.tasklist.selectedType !== 'all') {
|
||||
// 确保 calendar_info 结构存在
|
||||
if (!newTask.calendar_info) {
|
||||
newTask.calendar_info = {};
|
||||
}
|
||||
if (!newTask.calendar_info.extracted) {
|
||||
newTask.calendar_info.extracted = {};
|
||||
}
|
||||
// 设置内容类型
|
||||
newTask.calendar_info.extracted.content_type = this.tasklist.selectedType;
|
||||
newTask.content_type = this.tasklist.selectedType;
|
||||
}
|
||||
|
||||
// 应用全局插件配置到新任务
|
||||
this.applyGlobalPluginConfig(newTask);
|
||||
@ -11514,7 +11572,9 @@
|
||||
|
||||
// 如果有上一个任务,继承保存路径和命名规则
|
||||
if (this.formData.tasklist && this.formData.tasklist.length > 0) {
|
||||
const lastTask = this.formData.tasklist[this.formData.tasklist.length - 1];
|
||||
// 使用新的筛选逻辑:根据当前视图筛选条件获取对应类型中编号最大的任务
|
||||
const lastTask = this.getLastTaskByCurrentFilter();
|
||||
if (lastTask) {
|
||||
this.createTask.taskData.savepath = lastTask.savepath || "";
|
||||
this.createTask.taskData.pattern = lastTask.pattern || "";
|
||||
this.createTask.taskData.replace = lastTask.replace || "";
|
||||
@ -11525,6 +11585,7 @@
|
||||
this.createTask.taskData.sequence_naming = lastTask.sequence_naming || "";
|
||||
this.createTask.taskData.episode_naming = lastTask.episode_naming || "";
|
||||
}
|
||||
}
|
||||
|
||||
// 应用全局插件配置
|
||||
this.applyGlobalPluginConfig(this.createTask.taskData);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user