Skip to content

Commit

Permalink
opmtimize: console subject and attachment operate (#499)
Browse files Browse the repository at this point in the history
* build: upgrade version to 0.11.4

* feat: add some subject collect and unCollect and episode collection mark finish events, in order to support publish this events to plugin.

* optimize: console attachment and subject operate.

* docs: update CHANGELOG.MD
  • Loading branch information
chivehao authored Oct 28, 2023
1 parent 007bede commit 1719095
Showing 13 changed files with 304 additions and 32 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -2,6 +2,21 @@

更新日志文档,版本顺序从新到旧,最新版本在最前(上)面。

# 0.11.4

## 新特性

- 当收藏条目时,发布条目收藏更新事件,同时广播给插件,该事件有两个动作,收藏和取消收藏
- 当剧集收藏是否完成更新事件发生时,发布剧集收藏进度更新事件,同时广播给插件

## 控制台优化

- 文件详情添加逻辑路径
- 附件管理页单行右键添加 复制简单名称、复制完整名称、复制URL、下载功能
- 附件表格新增逻辑路径属性,用以区别相同文件名称的不同位置文件
- 附件管理页默认的查询条件`nsfw`修改为`false`
- 修复条目同步后的查询条件不匹配问题

# 0.11.3

## 新特性
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package run.ikaros.api.core.collection.event;

import lombok.Getter;
import lombok.Setter;
import run.ikaros.api.plugin.event.PluginAwareEvent;

@Getter
public class EpisodeCollectionFinishChangeEvent extends PluginAwareEvent {
private final long userId;
private final long episodeId;
private final boolean finish;
@Setter
private long subjectId;

/**
* Construct.
*/
public EpisodeCollectionFinishChangeEvent(Object source, long userId, long episodeId,
boolean finish) {
super(source);
this.userId = userId;
this.episodeId = episodeId;
this.finish = finish;
}

/**
* Construct.
*/
public EpisodeCollectionFinishChangeEvent(Object source, String pluginId, long userId,
long episodeId,
boolean finish) {
super(source, pluginId);
this.userId = userId;
this.episodeId = episodeId;
this.finish = finish;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package run.ikaros.api.core.collection.event;

import lombok.Getter;
import run.ikaros.api.core.collection.SubjectCollection;

@Getter
public class SubjectCollectEvent extends SubjectCollectionUpdateEvent {
/**
* Construct.
*/
public SubjectCollectEvent(Object source,
SubjectCollection subjectCollection) {
super(source, subjectCollection, true);
}

/**
* Construct.
*/
public SubjectCollectEvent(Object source, String pluginId,
SubjectCollection subjectCollection, boolean collect) {
super(source, pluginId, subjectCollection, collect);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package run.ikaros.api.core.collection.event;

import lombok.Getter;
import run.ikaros.api.core.collection.SubjectCollection;
import run.ikaros.api.plugin.event.PluginAwareEvent;

@Getter
public class SubjectCollectionUpdateEvent extends PluginAwareEvent {
private final SubjectCollection subjectCollection;
/**
* <ul>
* <li>true - collect action</li>
* <li>false - uncollect action</li>
* </ul>
* .
*/
private final boolean collect;

/**
* Construct.
*/
public SubjectCollectionUpdateEvent(Object source, SubjectCollection subjectCollection,
boolean collect) {
super(source);
this.subjectCollection = subjectCollection;
this.collect = collect;
}

/**
* Construct.
*/
public SubjectCollectionUpdateEvent(Object source, String pluginId,
SubjectCollection subjectCollection, boolean collect) {
super(source, pluginId);
this.subjectCollection = subjectCollection;
this.collect = collect;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package run.ikaros.api.core.collection.event;

import lombok.Getter;
import run.ikaros.api.core.collection.SubjectCollection;

@Getter
public class SubjectUnCollectEvent extends SubjectCollectionUpdateEvent {
/**
* Construct.
*/
public SubjectUnCollectEvent(Object source,
SubjectCollection subjectCollection) {
super(source, subjectCollection, false);
}

/**
* Construct.
*/
public SubjectUnCollectEvent(Object source, String pluginId,
SubjectCollection subjectCollection,
boolean collect) {
super(source, pluginId, subjectCollection, collect);
}
}
Original file line number Diff line number Diff line change
@@ -215,6 +215,9 @@ const handleClose = (done: () => void) => {
>
{{ file.updateTime }}
</el-descriptions-item>
<el-descriptions-item v-if="file.path" label="路径">
{{ file.path }}
</el-descriptions-item>
<el-descriptions-item v-if="file.url" label="URL">
<a :href="file.url" target="_blank">{{ file.url }}</a>
</el-descriptions-item>
79 changes: 69 additions & 10 deletions console/src/modules/content/attachment/Attachments.vue
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ import {
Delete,
Position,
CopyDocument,
Download,
} from '@element-plus/icons-vue';
import {
ElRow,
@@ -260,7 +261,7 @@ const onDeleteButtonClick = async () => {
if (hasDir) {
ElMessageBox.confirm(
'您当前删除的附件包括目录类型,系统默认会删除目录里的所有内容,您确定要删除吗?',
'伊卡洛斯检测到您当前待删除的附件(选中的)包含目录类型,系统默认会删除目录里的所有内容,您确定要删除吗?',
'警告',
{
confirmButtonText: '确认',
@@ -309,21 +310,55 @@ const onRowContextmenu = (row, column, event) => {
minWidth: 320,
items: [
{
label: '详情',
// divided: 'down',
label:
currentSelectionAttachment.value?.type === 'Directory'
? '进入'
: '详情',
divided: 'down',
icon: h(Pointer, { style: 'height: 14px' }),
onClick: () => {
entryAttachment(currentSelectionAttachment.value);
},
},
{
label: '复制名称',
divided: 'down',
label: '复制简短名称',
icon: h(CopyDocument, { style: 'height: 14px' }),
onClick: async () => {
const name = currentSelectionAttachment.value?.name as string;
var simpleName = name.replace(/\[.*?\]/g, '');
simpleName = simpleName.substring(0, simpleName.lastIndexOf('.'));
await copyValue(simpleName);
ElMessage.success('已复制附件【' + name + '】的简短名称到剪贴板');
},
},
{
label: '复制完整名称',
icon: h(CopyDocument, { style: 'height: 14px' }),
onClick: async () => {
const name = currentSelectionAttachment.value?.name as string;
await copyValue(name);
ElMessage.success('已复制复制名称【' + name + '】到剪贴板');
ElMessage.success('已复制附件【' + name + '】的完整名称到剪贴板');
},
},
{
label: '复制URL',
divided: 'down',
disabled: currentSelectionAttachment.value?.type !== 'File',
icon: h(CopyDocument, { style: 'height: 14px' }),
onClick: async () => {
const name = currentSelectionAttachment.value?.name as string;
const url = currentSelectionAttachment.value?.url as string;
await copyValue(url);
ElMessage.success('已复制附件【' + name + '】的URL到剪贴板');
},
},
{
label: '下载',
disabled: currentSelectionAttachment.value?.type !== 'File',
icon: h(Download, { style: 'height: 14px' }),
onClick: async () => {
const url = currentSelectionAttachment.value?.url as string;
window.open(url);
},
},
{
@@ -332,7 +367,9 @@ const onRowContextmenu = (row, column, event) => {
onClick: async () => {
if (currentSelectionAttachment.value?.type === 'Directory') {
await ElMessageBox.confirm(
'您当前删除的附件为目录类型,系统默认会删除目录里的所有内容,您确定要删除吗?',
'您当前删除的附件【' +
currentSelectionAttachment.value.name +
'】为目录类型,系统默认会删除目录里的所有内容,您确定要删除吗?',
'警告',
{
confirmButtonText: '确认',
@@ -352,9 +389,31 @@ const onRowContextmenu = (row, column, event) => {
});
});
} else {
await deleteAttachment(
currentSelectionAttachment.value as Attachment
);
await ElMessageBox.confirm(
'您当前待删除的附件为【' +
currentSelectionAttachment.value?.name +
'】您确定要删除吗?',
'警告',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(async () => {
await deleteAttachment(
currentSelectionAttachment.value as Attachment
);
})
.catch(() => {
ElMessage({
type: 'info',
message:
'删除目录【' +
currentSelectionAttachment.value?.name +
'】取消',
});
});
}
await fetchAttachments();
},
5 changes: 3 additions & 2 deletions console/src/modules/content/subject/SubjectSyncDialog.vue
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
import { usePluginModuleStore } from '@/stores/plugin';
import { apiClient } from '@/utils/api-client';
import { PluginModule } from '@runikaros/shared';
import { Subject } from '@runikaros/api-client';
import { ElMessage, FormInstance, FormRules } from 'element-plus';
import { computed, onMounted, reactive, ref } from 'vue';
import {
@@ -35,7 +36,7 @@ const emit = defineEmits<{
// eslint-disable-next-line no-unused-vars
(event: 'close'): void;
// eslint-disable-next-line no-unused-vars
(event: 'closeWithSubjectName', subjectName: string): void;
(event: 'closeWithSubjectName', subject: Subject): void;
}>();
const dialogVisible = computed({
@@ -91,7 +92,7 @@ const onConfirm = async (formEl: FormInstance | undefined) => {
syncButtonLoading.value = false;
});
dialogVisible.value = false;
emit('closeWithSubjectName', data.name);
emit('closeWithSubjectName', data);
} else {
console.log('error submit!', fields);
ElMessage.error('请检查所填内容是否有必要项缺失。');
9 changes: 6 additions & 3 deletions console/src/modules/content/subject/Subjects.vue
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ const findSubjectsCondition = ref<SubjectsCondition>({
total: 0,
name: '',
nameCn: '',
nsfw: undefined,
nsfw: false,
type: undefined,
});
@@ -101,8 +101,11 @@ const fetchSubjects = async () => {
};
const subjectSyncDialogVisible = ref(false);
const onSubjectSyncDialogCloseWithSubjectName = (subjectName: string) => {
findSubjectsCondition.value.name = subjectName;
const onSubjectSyncDialogCloseWithSubjectName = (subject: Subject) => {
findSubjectsCondition.value.name = subject.name;
findSubjectsCondition.value.nsfw = subject.nsfw;
findSubjectsCondition.value.nameCn = subject.name_cn as string;
findSubjectsCondition.value.type = subject.type;
fetchSubjects();
};
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.11.3
version=0.11.4
Loading

0 comments on commit 1719095

Please sign in to comment.