Skip to content

Commit 084b54a

Browse files
committed
feat: 新增歌曲列表紧凑样式 #401
1 parent 1477d26 commit 084b54a

6 files changed

Lines changed: 90 additions & 19 deletions

File tree

‎src/components/list/SongList.vue‎

Lines changed: 62 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,43 @@ const batch = useMultiSelect(sortedItems, {
270270
});
271271
const { deleteConfirmOpen, deleteDialogTitle, deleteDialogContent } = batch;
272272
273+
/** 是否使用紧凑列表样式 */
274+
const isCompactList = computed(() => settings.appearance.songListStyle === "compact");
275+
276+
/**
277+
* 计算歌曲行样式
278+
* @param item - 歌曲数据
279+
* @returns 行容器的 class 列表
280+
*/
281+
const trackRowClass = (item: Track): string[] => {
282+
const selected = batch.active.value && batch.selectedIds.value.has(item.id);
283+
const playing = playingId.value === item.id;
284+
285+
if (isCompactList.value) {
286+
return [
287+
"group flex items-center gap-3 pl-3 pr-4 h-14 rounded-lg cursor-pointer transition-colors duration-150",
288+
batch.active.value
289+
? selected
290+
? "bg-primary/10"
291+
: "hover:bg-on-surface/5"
292+
: playing
293+
? "bg-primary/14"
294+
: "hover:bg-on-surface/6 active:bg-on-surface/10",
295+
];
296+
}
297+
298+
return [
299+
"group flex items-center gap-3 pl-3 pr-6 h-19 rounded-xl cursor-pointer border-2 border-solid transition-[background-color,border-color] duration-200",
300+
batch.active.value
301+
? selected
302+
? "bg-primary/10 border-primary/30"
303+
: "bg-surface-panel border-primary/12 hover:border-primary/20 hover:bg-on-surface/5"
304+
: playing
305+
? "bg-primary/16 border-primary/40"
306+
: "bg-surface-panel border-primary/12 hover:border-primary/30 hover:bg-on-surface/8 active:bg-on-surface/12",
307+
];
308+
};
309+
273310
/** 添加到歌单相关 */
274311
const {
275312
open: pickerOpen,
@@ -381,7 +418,7 @@ defineExpose({
381418
<SVirtualList
382419
ref="virtualListRef"
383420
:items="sortedItems"
384-
:item-height="88"
421+
:item-height="isCompactList ? 56 : 88"
385422
:padding-bottom="isFloatingPlayerBar ? PLAYER_BAR_GAP : 80"
386423
:get-item-key="(item: Track) => item.id"
387424
item-fixed
@@ -504,7 +541,12 @@ defineExpose({
504541
<!-- 普通模式 -->
505542
<div
506543
v-else
507-
class="flex items-center gap-3 pl-3 pr-6 mx-3 h-10 border-2 border-solid border-transparent text-sm text-on-surface-variant/60"
544+
class="flex items-center gap-3 text-sm text-on-surface-variant/60"
545+
:class="
546+
isCompactList
547+
? 'pl-3 pr-4 mx-3 h-9'
548+
: 'pl-3 pr-6 mx-3 h-10 border-2 border-solid border-transparent'
549+
"
508550
>
509551
<div v-if="showIndex" class="w-8 shrink-0 flex items-center justify-center">
510552
<span>#</span>
@@ -576,19 +618,10 @@ defineExpose({
576618
</template>
577619
<!-- 列表项 -->
578620
<template #default="{ item, index }: { item: Track; index: number }">
579-
<div class="px-3 pb-3">
621+
<div :class="isCompactList ? 'px-3' : 'px-3 pb-3'">
580622
<div
581623
data-song-item
582-
class="group flex items-center gap-3 pl-3 pr-6 h-19 rounded-xl cursor-pointer border-2 border-solid transition-[background-color,border-color] duration-200"
583-
:class="
584-
batch.active.value
585-
? batch.selectedIds.value.has(item.id)
586-
? 'bg-primary/10 border-primary/30'
587-
: 'bg-surface-panel border-primary/12 hover:border-primary/20 hover:bg-on-surface/5'
588-
: playingId === item.id
589-
? 'bg-primary/16 border-primary/40'
590-
: 'bg-surface-panel border-primary/12 hover:border-primary/30 hover:bg-on-surface/8 active:bg-on-surface/12'
591-
"
624+
:class="trackRowClass(item)"
592625
@click="batch.active.value ? batch.toggle(item.id) : undefined"
593626
@dblclick="onTrackDblClick(item, index)"
594627
@contextmenu="contextTrack = item"
@@ -618,7 +651,8 @@ defineExpose({
618651
<template v-else>
619652
<span
620653
v-if="playingId !== item.id"
621-
class="text-sm font-bold tabular-nums group-hover:opacity-0 transition-opacity duration-300"
654+
class="font-bold tabular-nums group-hover:opacity-0 transition-opacity duration-300"
655+
:class="isCompactList ? 'text-xs' : 'text-sm'"
622656
>
623657
{{ index + 1 }}
624658
</span>
@@ -639,12 +673,18 @@ defineExpose({
639673
</div>
640674
<!-- 信息 -->
641675
<div class="flex-1 min-w-0 flex items-center gap-3">
642-
<SImg :src="item.cover" class="size-12 rounded-lg shrink-0" />
676+
<SImg
677+
:src="item.cover"
678+
:class="['shrink-0', isCompactList ? 'size-9 rounded-md' : 'size-12 rounded-lg']"
679+
/>
643680
<div class="flex-1 min-w-0">
644681
<div class="flex items-baseline gap-1.5 min-w-0">
645682
<span
646-
class="text-base font-medium truncate"
647-
:class="playingId === item.id ? 'text-primary' : ''"
683+
:class="[
684+
'font-medium truncate',
685+
isCompactList ? 'text-sm' : 'text-base',
686+
playingId === item.id ? 'text-primary' : '',
687+
]"
648688
>
649689
{{ item.title }}
650690
</span>
@@ -666,8 +706,11 @@ defineExpose({
666706
</span>
667707
</div>
668708
<div
669-
class="text-sm mt-1 truncate flex items-center gap-1"
670-
:class="playingId === item.id ? 'text-primary/70' : 'text-on-surface-variant'"
709+
:class="[
710+
'truncate flex items-center gap-1',
711+
isCompactList ? 'text-xs mt-0.5' : 'text-sm mt-1',
712+
playingId === item.id ? 'text-primary/70' : 'text-on-surface-variant',
713+
]"
671714
>
672715
<STag
673716
v-if="downloadStore.isDownloaded(item)"

‎src/i18n/locales/en-US.json‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,12 @@
16361636
"sidebarFull": "Immersive Sidebar",
16371637
"floating": "Dynamic Floating"
16381638
},
1639+
"songListStyle": {
1640+
"label": "Song List Style",
1641+
"description": "Display density of song lists",
1642+
"comfortable": "Comfortable",
1643+
"compact": "Compact"
1644+
},
16391645
"routeTransition": {
16401646
"label": "Page Transition",
16411647
"description": "Animation effect when switching pages",

‎src/i18n/locales/zh-CN.json‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,12 @@
16361636
"sidebarFull": "沉浸侧栏",
16371637
"floating": "灵动悬浮"
16381638
},
1639+
"songListStyle": {
1640+
"label": "歌曲列表样式",
1641+
"description": "配置歌曲列表的展示密度",
1642+
"comfortable": "舒适",
1643+
"compact": "紧凑"
1644+
},
16391645
"routeTransition": {
16401646
"label": "页面切换",
16411647
"description": "切换页面时的过渡动画效果",

‎src/settings/categories/appearance.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ const appearanceCategory: SettingCategory = {
138138
],
139139
defaultValue: "default",
140140
},
141+
{
142+
key: "songListStyle",
143+
type: "select",
144+
binding: { store: "settings", path: "appearance.songListStyle" },
145+
options: [
146+
{ value: "comfortable", labelKey: "settings.songListStyle.comfortable" },
147+
{ value: "compact", labelKey: "settings.songListStyle.compact" },
148+
],
149+
defaultValue: "comfortable",
150+
},
141151
{
142152
key: "sidebarCollapsed",
143153
type: "switch",

‎src/stores/settings.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export const useSettingsStore = defineStore(
106106
/** 外观 */
107107
const appearance = reactive<AppearanceSettings>({
108108
layoutMode: "default",
109+
songListStyle: "comfortable",
109110
routeTransition: "fade",
110111
seamlessTransition: false,
111112
reduceMotion: false,

‎src/types/settings.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ export type LyricSourcePreference = Platform | "auto" | "self";
4040
/** 布局模式 */
4141
export type LayoutMode = "default" | "sidebar-full" | "floating";
4242

43+
/** 歌曲列表样式 */
44+
export type SongListStyle = "comfortable" | "compact";
45+
4346
/** 路由切换动效 */
4447
export type RouteTransition = "none" | "fade" | "slide" | "zoom";
4548

@@ -289,6 +292,8 @@ export interface PlayerSettings {
289292
export interface AppearanceSettings {
290293
/** 布局模式 */
291294
layoutMode: LayoutMode;
295+
/** 歌曲列表样式 */
296+
songListStyle: SongListStyle;
292297
/** 路由切换动效 */
293298
routeTransition: RouteTransition;
294299
/** 页面之间的共享元素过渡 */

0 commit comments

Comments
 (0)