Skip to content

Commit

Permalink
fix: console some issues and add some optimizes . (#498)
Browse files Browse the repository at this point in the history
* optimize: add folder type attachment in Attachments.vue

* build: upgrade version to 0.11.3

* fix: can not display all dir in AttachmentDirectoryTreeSelect.vue

* fix: attachment select component search issue

* optimize: subject list in Subjects.vue
  • Loading branch information
chivehao authored Oct 27, 2023
1 parent 0b421e0 commit 007bede
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 34 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

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

# 0.11.3

## 新特性

- 附件选择输入查询名称时,支持添加空格加多个关键词

## 优化

- 点击创建目录按钮时,自动聚焦到输入框

## 问题修复

- 当单个目录内目录页数超过10的时候,目录选择组件无法展示第二页的目录
- 条目管理页条件查询问题
- 附件选择组件当查询条件更新时,没有自动将当前页设置成第一页
- 条目管理页列表卡片展示优化
- 新增条目后跳转条目管理页的查询问题

# 0.11.2

## 新功能
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const props = withDefaults(
const emit = defineEmits<{
// eslint-disable-next-line no-unused-vars
(event: 'update:targetDirid', targetDirid: number): void;
(event: 'update:targetDirid', targetDirid: number | undefined): void;
}>();
const targetDirectoryId = computed({
Expand Down Expand Up @@ -47,6 +47,8 @@ const loadDirectoryNodes = async (node, resolve) => {
const { data } = await apiClient.attachment.listAttachmentsByCondition({
type: 'Directory',
parentId: parentId as any as string,
page: 1,
size: 999999,
});
const attachments: Attachment[] = data.items;
const dirNodes: DirNode[] = attachments.map((attachment) => {
Expand All @@ -60,7 +62,7 @@ const loadDirectoryNodes = async (node, resolve) => {
};
const onClear = () => {
emit('update:targetDirid', 0);
emit('update:targetDirid', undefined);
};
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,13 @@ const onConfirm = () => {
const onParentDirSelected = async (val) => {
console.log('val', val);
if (!val || val === '') {
val = 0;
attachmentCondition.value.parentId = undefined;
}
attachmentCondition.value.page = 1;
await fetchAttachments();
};
const onSearchNameChange = async () => {
attachmentCondition.value.page = 1;
await fetchAttachments();
};
Expand Down Expand Up @@ -173,7 +177,7 @@ onMounted(fetchAttachments);
v-model="attachmentCondition.name"
placeholder="搜索附件,模糊匹配,回车搜查"
clearable
@change="fetchAttachments"
@change="onSearchNameChange"
>
<template #append>
<el-button :icon="Search" @click="fetchAttachments" />
Expand All @@ -184,7 +188,9 @@ onMounted(fetchAttachments);

<br />

<el-row v-if="attachmentCondition.total > 10">
<el-row
v-if="attachmentCondition.total > 10 || attachmentCondition.page > 1"
>
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
<el-pagination
v-model:page-size="attachmentCondition.size"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,13 @@ const onConfirm = () => {
const onParentDirSelected = async (val) => {
console.log('val', val);
if (!val || val === '') {
val = 0;
attachmentCondition.value.parentId = undefined;
}
attachmentCondition.value.page = 1;
await fetchAttachments();
};
const onSearchNameChange = async () => {
attachmentCondition.value.page = 1;
await fetchAttachments();
};
Expand Down Expand Up @@ -173,7 +177,7 @@ onMounted(fetchAttachments);
v-model="attachmentCondition.name"
placeholder="搜索附件,模糊匹配,回车搜查"
clearable
@change="fetchAttachments"
@change="onSearchNameChange"
>
<template #append>
<el-button :icon="Search" @click="fetchAttachments" />
Expand All @@ -184,7 +188,9 @@ onMounted(fetchAttachments);

<br />

<el-row v-if="attachmentCondition.total > 10">
<el-row
v-if="attachmentCondition.total > 10 || attachmentCondition.page > 1"
>
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
<el-pagination
v-model:page-size="attachmentCondition.size"
Expand Down
19 changes: 15 additions & 4 deletions console/src/modules/content/attachment/Attachments.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, watch, onMounted, h } from 'vue';
import { ref, watch, onMounted, h, nextTick } from 'vue';
import { useI18n } from 'vue-i18n';
import { Attachment } from '@runikaros/api-client';
import { isImage, isVideo, isVoice } from '@/utils/file';
Expand Down Expand Up @@ -168,6 +168,7 @@ onMounted(fetchAttachments);
const dialogFolderVisible = ref(false);
const createFolderName = ref('');
const createFolderInputRef = ref();
const onCreateFolderButtonClick = async () => {
await apiClient.attachment.createDirectory({
parentId: attachmentCondition.value.parentId as any as string,
Expand All @@ -178,6 +179,11 @@ const onCreateFolderButtonClick = async () => {
await fetchAttachments();
dialogFolderVisible.value = false;
};
const onCreateFolderDialogOpen = () => {
nextTick(() => {
createFolderInputRef.value.focus();
});
};
const currentSelectionAttachment = ref<Attachment>();
const onCurrentChange = (val: Attachment | undefined) => {
Expand Down Expand Up @@ -417,8 +423,13 @@ watch(attachmentCondition.value, () => {
@delete="fetchAttachments"
/>

<el-dialog v-model="dialogFolderVisible" title="新建目录">
<el-dialog
v-model="dialogFolderVisible"
title="新建目录"
@open="onCreateFolderDialogOpen"
>
<el-input
ref="createFolderInputRef"
v-model="createFolderName"
autocomplete="off"
size="large"
Expand Down Expand Up @@ -476,7 +487,7 @@ watch(attachmentCondition.value, () => {
<el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
<el-input
v-model="attachmentCondition.name"
placeholder="搜索附件,模糊匹配,回车搜查"
placeholder="搜索当前目录下的所有附件,模糊匹配,空格多个关键词,回车搜查"
clearable
@change="fetchAttachments"
>
Expand All @@ -489,7 +500,7 @@ watch(attachmentCondition.value, () => {

<br />

<el-row v-if="attachmentCondition.total > 10">
<el-row v-if="attachmentCondition.total > 10 || attachmentCondition.page > 1">
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
<el-pagination
v-model:page-size="attachmentCondition.size"
Expand Down
16 changes: 9 additions & 7 deletions console/src/modules/content/subject/Subjects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ interface SubjectsCondition {
total: number;
name: string;
nameCn: string;
nsfw: boolean;
nsfw: boolean | undefined;
type?: 'ANIME' | 'COMIC' | 'GAME' | 'MUSIC' | 'NOVEL' | 'REAL' | 'OTHER';
}
const findSubjectsCondition = ref<SubjectsCondition>({
page: 1,
size: 10,
total: 10,
size: 12,
total: 0,
name: '',
nameCn: '',
nsfw: false,
nsfw: undefined,
type: undefined,
});
Expand Down Expand Up @@ -230,16 +230,18 @@ onMounted(fetchSubjectByRouterQuery);
<br />

<el-row>
<el-col
><el-pagination
<el-col>
<el-pagination
v-model:page-size="findSubjectsCondition.size"
v-model:current-page="findSubjectsCondition.page"
background
:total="findSubjectsCondition.total"
layout="total, sizes, prev, pager, next, jumper"
:page-sizes="[6, 12, 24, 48, 96, 192]"
@current-change="fetchSubjects"
@size-change="fetchSubjects"
/></el-col>
/>
</el-col>
</el-row>
</template>

Expand Down
2 changes: 2 additions & 0 deletions console/src/modules/user/Collection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ onMounted(fetchCollections);
background
:total="findSubjectCollection.total"
layout="total, sizes, prev, pager, next, jumper"
:page-sizes="[6, 12, 24, 48, 96, 192]"
@current-change="fetchCollections"
@size-change="fetchCollections"
/>
Expand Down Expand Up @@ -124,6 +125,7 @@ onMounted(fetchCollections);
background
:total="findSubjectCollection.total"
layout="total, sizes, prev, pager, next, jumper"
:page-sizes="[6, 12, 24, 48, 96, 192]"
@current-change="fetchCollections"
@size-change="fetchCollections"
/>
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.11.2
version=0.11.3
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ public Mono<PagingWrap<AttachmentEntity>> listEntitiesByCondition(
final int page = Optional.ofNullable(searchCondition.getPage()).orElse(1);
final int size = Optional.ofNullable(searchCondition.getSize()).orElse(10);

final String name = StringUtils.hasText(searchCondition.getName())
? searchCondition.getName() : "";
final String nameLike = "%" + name + "%";
String[] nameKeyWords = StringUtils.hasText(searchCondition.getName())
? searchCondition.getName().split(" ")
: new String[] {};
final AttachmentType type = searchCondition.getType();
final Long parentId = searchCondition.getParentId();
final PageRequest pageRequest = PageRequest.of(page - 1, size);
Expand All @@ -129,8 +129,12 @@ public Mono<PagingWrap<AttachmentEntity>> listEntitiesByCondition(
criteria = criteria.and("type").is(type);
}

if (StringUtils.hasText(name)) {
criteria = criteria.and("name").like(nameLike);
for (String nameKeyWord : nameKeyWords) {
if (!StringUtils.hasText(nameKeyWord)) {
continue;
}
String nameKeyWordLike = "%" + nameKeyWord + "%";
criteria = criteria.and("name").like(nameKeyWordLike);
}

Query query = Query.query(criteria)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,17 @@ public Mono<PagingWrap<SubjectMeta>> listEntitiesByCondition(FindSubjectConditio
String nameCn = condition.getNameCn();
String nameCnLike = "%" + nameCn + "%";
Boolean nsfw = condition.getNsfw();
SubjectType type = condition.getType();
final SubjectType type = condition.getType();
final Boolean airTimeDesc = condition.getAirTimeDesc();

final PageRequest pageRequest = PageRequest.of(page - 1, size);

Criteria criteria =
Criteria.where("nsfw").is(nsfw);
Criteria criteria = Criteria.empty();

if (Objects.nonNull(nsfw)) {
criteria =
Criteria.where("nsfw").is(nsfw);
}

if (StringUtils.isNotBlank(name)) {
criteria = criteria.and("name").like(nameLike);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public class FindSubjectCondition {
private Integer size;
private String name;
private String nameCn;
/**
* default is false.
*/
private Boolean nsfw;
private SubjectType type;
private Integer year;
Expand All @@ -46,9 +43,6 @@ public void initDefaultIfNull() {
if (Objects.isNull(size)) {
page = 10;
}
if (Objects.isNull(nsfw)) {
nsfw = false;
}
if (Objects.isNull(airTimeDesc)) {
airTimeDesc = true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package run.ikaros.server.core.subject.vo;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;

class FindSubjectConditionTest {

@Test
void getNsfw() {
Boolean nsfw = null;
FindSubjectCondition condition = FindSubjectCondition.builder().nsfw(nsfw).build();
Assertions.assertThat(condition.getNsfw()).isNull();
}
}

0 comments on commit 007bede

Please sign in to comment.