diff --git a/web/src/views/Search.vue b/web/src/views/Search.vue index 0536e36..8822277 100644 --- a/web/src/views/Search.vue +++ b/web/src/views/Search.vue @@ -20,22 +20,54 @@
搜索中...
-
- -
+ + +
未找到相关结果
@@ -45,15 +77,21 @@ import { useRoute } from 'vue-router'; import { Icon } from '@iconify/vue'; import axios from 'axios'; import { usePlayerStore } from '../stores/player.js'; +import type { Song } from '../stores/player.js'; import SongCard from '../components/SongCard.vue'; +import CoverArt from '../components/CoverArt.vue'; const store = usePlayerStore(); const route = useRoute(); const query = ref((route.query.q as string) || ''); -import { Song } from '../stores/player.js'; -const results = ref([]); +interface Album { id: string; name: string; artist: string; coverUrl: string; songCount?: number; platform: string; } +interface Playlist { id: string; name: string; coverUrl: string; songCount?: number; platform: string; } + +const songs = ref([]); +const albums = ref([]); +const playlists = ref([]); const loading = ref(false); const searched = ref(false); @@ -62,12 +100,12 @@ async function doSearch() { loading.value = true; searched.value = true; try { - const res = await axios.get('/api/music/search/all', { - params: { q: query.value }, - }); - results.value = res.data.songs; + const res = await axios.get('/api/music/search/all', { params: { q: query.value } }); + songs.value = res.data.songs ?? []; + albums.value = res.data.albums ?? []; + playlists.value = res.data.playlists ?? []; } catch { - results.value = []; + songs.value = []; albums.value = []; playlists.value = []; } finally { loading.value = false; } @@ -141,4 +179,23 @@ onMounted(() => { flex-direction: column; gap: 2px; } + +.result-section { + margin-bottom: 32px; + .section-title { font-size: 18px; margin: 0 0 12px; opacity: 0.85; } +} +.card-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); + gap: 16px; +} +.card { + display: flex; + flex-direction: column; + gap: 6px; + text-decoration: none; + color: inherit; + .card-name { font-size: 14px; line-height: 1.3; max-height: 2.6em; overflow: hidden; } + .card-sub { font-size: 12px; opacity: 0.6; } +}