From 089de84396a53f025d618c26095a3c276d93e73f Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Tue, 26 May 2026 10:24:00 +0100 Subject: [PATCH] =?UTF-8?q?music(player):=20=E4=BE=A7=E8=BE=B9=E6=A0=8F=20?= =?UTF-8?q?=E2=98=85=20=E6=A0=87=E8=AE=B0=20+=20sort-bar=20'=E4=BB=85?= =?UTF-8?q?=E7=9C=8B=E6=94=B6=E8=97=8F'=20=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/music/frontend/src/views/PlayerView.vue | 46 +++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/apps/music/frontend/src/views/PlayerView.vue b/apps/music/frontend/src/views/PlayerView.vue index f9366f6..246b63d 100644 --- a/apps/music/frontend/src/views/PlayerView.vue +++ b/apps/music/frontend/src/views/PlayerView.vue @@ -54,6 +54,12 @@ +
@@ -72,7 +78,10 @@ title="单击切换 / 双击切换并播放" >
-
{{ p.title }}
+
+ + {{ p.title }} +
{{ p.artist }} {{ p.category }} @@ -416,6 +425,7 @@ const activeTagName = ref(null) const search = ref('') const sortMode = ref(localStorage.getItem('music.sort') || 'name') +const favOnly = ref(localStorage.getItem('music.favOnly') === 'true') const repeatOne = ref(false) const volume = ref(parseFloat(localStorage.getItem('music.vol') || '1')) const muted = ref(localStorage.getItem('music.muted') === '1') @@ -648,6 +658,9 @@ const tabs = computed(() => { const filtered = computed(() => { const q = search.value.trim().toLowerCase() let arr = pieces.value + if (favOnly.value) { + arr = arr.filter(p => p.favorite) + } if (q) { arr = arr.filter(p => { const hay = `${p.title} ${p.artist || ''} ${p.category || ''} ${(p.tags || []).join(' ')}`.toLowerCase() @@ -655,6 +668,7 @@ const filtered = computed(() => { }) } arr = [...arr] + // 名称排序时,收藏的自然置顶;其它模式按用户选的指标排,不强行打断 switch (sortMode.value) { case 'hot': arr.sort((a, b) => b.play_count - a.play_count || a.title.localeCompare(b.title, 'zh')) @@ -676,11 +690,21 @@ const filtered = computed(() => { break } default: - arr.sort((a, b) => a.title.localeCompare(b.title, 'zh')) + arr.sort((a, b) => { + const fa = a.favorite ? 1 : 0 + const fb = b.favorite ? 1 : 0 + if (fa !== fb) return fb - fa + return a.title.localeCompare(b.title, 'zh') + }) } return arr }) +function toggleFavOnly() { + favOnly.value = !favOnly.value + localStorage.setItem('music.favOnly', favOnly.value ? 'true' : 'false') +} + function hash(id, seed) { let x = (id ^ Math.floor(seed * 1e9)) >>> 0 x = (x ^ (x << 13)) >>> 0 @@ -1378,6 +1402,24 @@ onBeforeUnmount(() => { border-color: var(--accent-strong); color: var(--accent); } +.sort-bar .fav-toggle { + margin-left: auto; + border-radius: 4px !important; + border-right-width: 1px !important; + font-size: 14px; + padding: 4px 8px; +} +.sort-bar .fav-toggle.active { + color: #f5b800; + border-color: #f5b800; + background: rgba(245, 184, 0, 0.12); +} + +.row-fav { + color: #f5b800; + margin-right: 4px; + font-size: 12px; +} .playlist { flex: 1; overflow-y: auto; } .hint { padding: 40px 20px; text-align: center; color: var(--text-mute); font-size: 14px; }