feat: 添加歌曲列表分页功能和键盘快捷键支持

- 在 SongList 组件中实现分页功能,支持上一页和下一页操作
- 添加键盘快捷键,允许用户通过方向键进行翻页
- 优化组件结构,增强可读性和用户体验
This commit is contained in:
2025-04-28 04:04:21 +08:00
parent 00ce0fc7e1
commit 8b908f5ac9
13 changed files with 1712 additions and 913 deletions

View File

@@ -87,6 +87,33 @@ const batchUpdate_Option = ref<SongRequestOption | undefined>() // 批量编辑
const columns = ref<DataTableColumns<SongsInfo>>() // 表格列定义
const selectedColumn = ref<DataTableRowKey[]>([]) // 表格选中行的 Key 数组
// 分页相关
const currentPage = ref(1) // 当前页码
const handlePageChange = (page: number) => {
currentPage.value = page
}
// 暴露分页方法
const nextPage = () => {
const pagination = songsComputed.value.length > 0 ? Math.ceil(songsComputed.value.length / pageSize.value) : 1
if (currentPage.value < pagination) {
currentPage.value++
}
}
const prevPage = () => {
if (currentPage.value > 1) {
currentPage.value--
}
}
// 暴露给父组件
defineExpose({
nextPage,
prevPage,
currentPage
})
// --- 计算属性 ---
// 筛选后的歌曲列表
@@ -163,8 +190,6 @@ const authorsOptions = computed(() => {
}))
})
// --- 表格列定义 ---
// 作者列定义 (包含筛选逻辑)
const authorColumn = ref<DataTableBaseColumn<SongsInfo>>({
title: '作者',
@@ -751,7 +776,8 @@ onMounted(() => {
pageSizes: [10, 25, 50, 100, 200],
showSizePicker: true,
showQuickJumper: true,
page: currentPage,
onUpdatePage: handlePageChange
}"
:loading="isLoading && songsComputed.length === 0"
striped

File diff suppressed because it is too large Load Diff