音乐模块调整

This commit is contained in:
LFeng committed 2026-09-12 15:47:16 +08:00
1 parent d702ed0d31
commit ffa410b399
33 files changed
+5452 -2237

No files matched your search

+439 -205
View File
@@ -1,269 +1,503 @@
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import { toast } from 'vue-sonner'
import { FolderOpen, Loader2, Music2, Plus, RefreshCw, Trash2 } from '@lucide/vue'
import { useFeiniuStore, type Playlist } from '@/stores/feiniuStore'
import {
Cloud,
FolderOpen,
HardDrive,
ListMusic,
ListPlus,
Loader2,
Music2,
Pencil,
Play,
Plus,
RefreshCw,
Search,
Trash2
} from '@lucide/vue'
import { useFeiniuStore } from '@/stores/feiniuStore'
import TrackItem from './TrackItem.vue'
import PlaylistEditorDialog from './PlaylistEditorDialog.vue'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Empty } from '@/components/ui/empty'
import { Empty, EmptyDescription, EmptyMedia, EmptyTitle } from '@/components/ui/empty'
import { ScrollArea } from '@/components/ui/scroll-area'
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog'
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle
} from '@/components/ui/dialog'
const store = useFeiniuStore()
type SubTab = 'feiniu' | 'local' | 'playlists'
const subTab = ref<SubTab>('feiniu')
/** 曲库视图:飞牛 / 本地 / 歌单 */
type LibraryView = 'feiniu' | 'local' | 'playlists'
const view = ref<LibraryView>('feiniu')
// 未登录(无激活连接且未登录)
const needsLogin = computed(() => !store.config.loggedIn && !store.activeConn)
const keywordInput = ref('')
let searchTimer: ReturnType<typeof setTimeout> | undefined
const sourceNav = computed(() => [
{ value: 'feiniu' as const, label: '飞牛曲库', icon: Cloud, count: store.total || store.tracks.length },
{ value: 'local' as const, label: '本地曲库', icon: HardDrive, count: store.localTracks.length },
{ value: 'playlists' as const, label: '我的歌单', icon: ListMusic, count: store.playlists.length }
])
// ===== 飞牛曲库:搜索(直接绑定 store.searchKeyword,此前绑定的是孤立局部变量,导致搜索完全无效)=====
let searchTimer: ReturnType<typeof setTimeout> | undefined
let searchSeq = 0
function onSearchInput() {
clearTimeout(searchTimer)
searchTimer = setTimeout(() => {
store.loadTracks(1).catch((e) => toast.error(String(e)))
searchTimer = setTimeout(async () => {
const seq = ++searchSeq
try {
await store.loadTracks(1)
} catch (e) {
if (seq === searchSeq) toast.error(String(e))
}
}, 400)
}
function refreshFeiniu() {
store.loadTracks(store.page).catch((e) => toast.error(String(e)))
store.loadTracks(1).catch((e) => toast.error(String(e)))
}
function refreshLocal() {
store.scanLocal().catch((e) => toast.error(String(e)))
}
function playAll() {
const list =
subTab.value === 'feiniu' ? store.tracks : subTab.value === 'local' ? store.localTracks : []
if (list.length) store.playQueue(list, 0)
function playFeiniu() {
if (store.tracks.length) store.playQueue(store.tracks, 0)
}
function playLocal() {
if (store.localTracks.length) store.playQueue(store.localTracks, 0)
}
function playActivePlaylist() {
if (activePlaylist.value?.items.length) store.playQueue(activePlaylist.value.items, 0)
}
// ===== 滚动加载更多(飞牛曲库分页)=====
const loadMoreRef = ref<HTMLElement | null>(null)
let loadMoreObserver: IntersectionObserver | null = null
onMounted(() => {
loadMoreObserver = new IntersectionObserver(
(entries) => {
if (!entries.some((e) => e.isIntersecting)) return
store.loadMoreTracks().catch(() => {})
},
{ rootMargin: '400px' }
)
watch(
loadMoreRef,
(el) => {
if (!loadMoreObserver) return
loadMoreObserver.disconnect()
if (el) loadMoreObserver.observe(el)
},
{ immediate: true }
)
})
onBeforeUnmount(() => {
clearTimeout(searchTimer)
loadMoreObserver?.disconnect()
})
// ===== 歌单 =====
const playlistName = ref('')
const createOpen = ref(false)
const activePlaylistId = ref('')
const activePlaylist = computed<Playlist | null>(
() => store.playlists.find((p) => p.id === activePlaylistId.value) || null
const activePlaylist = computed(() => store.playlists.find((p) => p.id === activePlaylistId.value) || null)
const createOpen = ref(false)
const newName = ref('')
const renameOpen = ref(false)
const renameValue = ref('')
/** 编辑歌单音乐(勾选加入 / 批量移出) */
const editorOpen = ref(false)
// 切换歌单时关闭编辑器,避免对着已切换的目标继续编辑
watch(activePlaylistId, () => (editorOpen.value = false))
// 切到歌单视图时自动选中第一个
watch(
[view, () => store.playlists.length],
() => {
if (view.value !== 'playlists') return
if (activePlaylistId.value && store.playlists.some((p) => p.id === activePlaylistId.value)) return
activePlaylistId.value = store.playlists[0]?.id ?? ''
},
{ immediate: true }
)
function createPlaylist() {
if (!playlistName.value.trim()) {
const name = newName.value.trim()
if (!name) {
toast.error('请输入歌单名称')
return
}
const id = store.createPlaylist(playlistName.value.trim())
activePlaylistId.value = id
playlistName.value = ''
activePlaylistId.value = store.createPlaylist(name)
newName.value = ''
createOpen.value = false
view.value = 'playlists'
}
function openRename() {
if (!activePlaylist.value) return
renameValue.value = activePlaylist.value.name
renameOpen.value = true
}
function confirmRename() {
const name = renameValue.value.trim()
if (!name || !activePlaylist.value) return
store.renamePlaylist(activePlaylist.value.id, name)
renameOpen.value = false
}
function removePlaylist() {
if (!activePlaylist.value) return
store.deletePlaylist(activePlaylist.value.id)
activePlaylistId.value = ''
}
onMounted(async () => {
await store.init()
if (store.config.loggedIn) {
store.loadTracks(1).catch(() => {})
if (store.config.loggedIn) store.loadTracks(1).catch(() => {})
})
/** 表格表头与 TrackItem 行保持同一条网格 */
const GRID = { gridTemplateColumns: '28px 36px minmax(0,1fr) 74px 28px' }
const listEmptyHint = computed(() => {
if (view.value === 'feiniu') {
if (store.searchKeyword.trim()) return '没有匹配「' + store.searchKeyword.trim() + '」的曲目'
return store.config.loggedIn ? '曲库为空,试试刷新或检查 NAS 曲库目录' : '请先在「设置 → 飞牛音乐连接」登录'
}
return '暂无本地音乐,点击「扫描本地曲库」或先到「发现音乐」下载'
})
</script>
<template>
<ScrollArea class="h-full pr-3">
<div class="flex flex-col gap-4 px-1 pt-1 pb-4 min-w-0">
<!-- 未登录态:引导配置连接 -->
<div v-if="needsLogin" class="flex flex-col items-center gap-3 py-16 text-center">
<Music2 class="size-10 text-muted-foreground" />
<p class="text-sm text-muted-foreground">
还没有可用的飞牛音乐连接。请到「设置 → 飞牛音乐连接」添加并登录,
<br />
或先到「发现音乐」下载歌曲到本地曲库。
</p>
</div>
<div class="flex h-full min-h-0">
<!-- ===== 左:来源导航 ===== -->
<aside class="flex w-[168px] shrink-0 flex-col border-r">
<ScrollArea class="min-h-0 flex-1">
<div class="flex flex-col p-2">
<p class="px-2 pb-1.5 pt-0.5 text-[11px] font-medium tracking-wide text-muted-foreground">曲库</p>
<template v-else>
<!-- 页头 + 子导航 -->
<div class="flex flex-col gap-3">
<div class="flex items-center justify-between">
<div class="flex items-center gap-1 rounded-lg border bg-card p-1">
<button
type="button"
class="rounded-md px-3 py-1 text-sm transition-colors"
:class="subTab === 'feiniu' ? 'bg-primary text-primary-foreground' : 'text-muted-foreground hover:text-foreground'"
@click="subTab = 'feiniu'"
<!-- 来源:选中态与顶部 Tabs 一致(无容器底色,选中项为浮起胶囊) -->
<div class="flex flex-col gap-0.5">
<button
v-for="nav in sourceNav"
:key="nav.value"
type="button"
class="flex h-8 items-center gap-1.5 rounded-md px-2 text-[13px] transition-colors duration-150"
:class="
view === nav.value
? 'bg-background font-medium text-foreground shadow-sm ring-1 ring-border'
: 'text-muted-foreground hover:bg-accent/60 hover:text-foreground'
"
@click="view = nav.value"
>
<component :is="nav.icon" class="size-3.5 shrink-0" />
<span class="min-w-0 flex-1 truncate">{{ nav.label }}</span>
<!-- 数量始终渲染(无歌曲时显示 0),并固定宽度右对齐,保证数字列竖向对齐 -->
<span
class="min-w-[3ch] shrink-0 text-right text-[10.5px] tabular-nums"
:class="view === nav.value ? 'text-muted-foreground' : 'text-muted-foreground/70'"
>
飞牛曲库
</button>
<button
type="button"
class="rounded-md px-3 py-1 text-sm transition-colors"
:class="subTab === 'local' ? 'bg-primary text-primary-foreground' : 'text-muted-foreground hover:text-foreground'"
@click="subTab = 'local'"
>
本地曲库
</button>
<button
type="button"
class="rounded-md px-3 py-1 text-sm transition-colors"
:class="subTab === 'playlists' ? 'bg-primary text-primary-foreground' : 'text-muted-foreground hover:text-foreground'"
@click="subTab = 'playlists'"
>
我的歌单
</button>
</div>
<Button v-if="store.config.loggedIn" variant="outline" size="sm" @click="playAll">
▶ 播放全部
</Button>
</div>
</div>
<!-- ===== 飞牛曲库 ===== -->
<template v-if="subTab === 'feiniu'">
<div class="flex items-center gap-2">
<div class="flex-1">
<Input v-model="keywordInput" placeholder="搜索飞牛曲库(歌名 / 歌手)" @input="onSearchInput" @keydown.enter="onSearchInput" />
</div>
<Button variant="outline" size="icon" :disabled="store.loading" @click="refreshFeiniu">
<RefreshCw :class="store.loading ? 'size-4 animate-spin' : 'size-4'" />
</Button>
</div>
<div class="flex flex-col gap-1.5">
<div v-if="store.loading" class="flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground">
<Loader2 class="size-4 animate-spin" /> 加载曲库…
</div>
<Empty v-else-if="!store.tracks.length" class="min-h-40">
<Music2 class="size-10 text-muted-foreground" />
<p class="text-sm text-muted-foreground">
{{ store.config.loggedIn ? '曲库为空或未匹配到结果' : '请先在设置中登录飞牛音乐连接' }}
</p>
</Empty>
<template v-else>
<TrackItem
v-for="(t, i) in store.tracks"
:key="t.guid || i"
:item="t"
:active="store.current?.guid === t.guid"
@dblclick="store.playQueue(store.tracks, i)"
/>
</template>
</div>
</template>
<!-- ===== 本地曲库 ===== -->
<template v-else-if="subTab === 'local'">
<div class="flex items-center gap-2">
<Button variant="outline" size="sm" :disabled="store.localScanBusy" @click="refreshLocal">
<Loader2 v-if="store.localScanBusy" class="size-4 animate-spin" />
<FolderOpen v-else class="size-4" />
扫描本地
</Button>
<span class="text-xs text-muted-foreground">{{ store.localTracks.length }} 首(目录:音乐下载目录 + 自定义)</span>
</div>
<div class="flex flex-col gap-1.5">
<Empty v-if="!store.localTracks.length && !store.localScanBusy" class="min-h-40">
<FolderOpen class="size-10 text-muted-foreground" />
<p class="text-sm text-muted-foreground">暂无本地音乐,点击「扫描本地」或先到发现音乐下载</p>
</Empty>
<template v-else>
<TrackItem
v-for="(t, i) in store.localTracks"
:key="t.guid || i"
:item="t"
:active="store.current?.guid === t.guid"
@dblclick="store.playQueue(store.localTracks, i)"
/>
</template>
</div>
</template>
<!-- ===== 我的歌单 ===== -->
<template v-else>
<div class="flex items-center gap-2">
<Button variant="outline" size="sm" @click="createOpen = true">
<Plus class="size-4" /> 新建歌单
</Button>
{{ nav.count > 999 ? '999+' : nav.count }}
</span>
</button>
</div>
<!-- 歌单列表(左) + 详情(右) -->
<div class="grid grid-cols-1 gap-4 md:grid-cols-[220px_1fr]">
<div class="flex flex-col gap-1 rounded-lg border bg-card p-2">
<!-- 歌单列表(选中「我的歌单」时展开) -->
<Transition name="pl-list">
<div v-if="view === 'playlists'" class="mt-1.5 ml-1.5 flex flex-col gap-0.5 border-l pl-1.5">
<button
v-for="p in store.playlists"
:key="p.id"
type="button"
class="flex items-center justify-between rounded-md px-3 py-2 text-sm transition-colors"
:class="activePlaylistId === p.id ? 'bg-primary/10 text-foreground' : 'text-muted-foreground hover:bg-muted/40'"
class="flex h-7 items-center gap-1.5 rounded-md px-2 text-left text-[12.5px] transition-colors duration-150"
:class="
activePlaylistId === p.id
? 'bg-background font-medium text-foreground shadow-sm ring-1 ring-border'
: 'text-muted-foreground hover:bg-accent/60 hover:text-foreground'
"
@click="activePlaylistId = p.id"
>
<span class="truncate">{{ p.name }}</span>
<span class="text-xs">{{ p.items.length }}</span>
<span class="min-w-0 flex-1 truncate">{{ p.name }}</span>
<span class="min-w-[3ch] shrink-0 text-right text-[10.5px] tabular-nums">
{{ p.items.length > 999 ? '999+' : p.items.length }}
</span>
</button>
<Empty v-if="!store.playlists.length" class="min-h-32">
<p class="text-sm text-muted-foreground">还没有歌单</p>
</Empty>
<button
type="button"
class="flex h-7 items-center gap-1.5 rounded-md px-2 text-[12.5px] text-muted-foreground transition-colors duration-150 hover:bg-accent/60 hover:text-foreground"
@click="createOpen = true"
>
<Plus class="size-3.5 shrink-0" />
<span class="min-w-0 flex-1 truncate">新建歌单</span>
</button>
<p v-if="!store.playlists.length" class="px-2 py-1 text-[11.5px] text-muted-foreground">
还没有歌单
</p>
</div>
</Transition>
</div>
</ScrollArea>
</aside>
<!-- ===== 右:内容(key 随来源变化,复用全局 tab-animate 切换动画) ===== -->
<section :key="view" class="tab-animate flex min-w-0 flex-1 flex-col">
<!-- 未登录态 -->
<div v-if="needsLogin" class="flex min-h-0 flex-1 items-center justify-center px-6">
<Empty>
<EmptyMedia>
<Music2 class="size-8 text-muted-foreground" />
</EmptyMedia>
<EmptyTitle>还没有可用的飞牛音乐连接</EmptyTitle>
<EmptyDescription>
到「设置 → 飞牛音乐连接」添加并登录,或先到「发现音乐」下载歌曲到本地曲库。
</EmptyDescription>
</Empty>
</div>
<template v-else>
<!-- 工具栏 -->
<header class="flex shrink-0 items-center gap-2 border-b px-4 py-2.5">
<template v-if="view === 'feiniu'">
<div class="relative w-full max-w-sm">
<Search class="pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground" />
<Input
v-model="store.searchKeyword"
class="h-8 pl-8"
placeholder="搜索歌名 / 歌手 / 专辑"
@input="onSearchInput"
@keydown.enter="onSearchInput"
/>
</div>
<Button variant="outline" size="sm" class="h-8" :disabled="store.loading" @click="refreshFeiniu">
<RefreshCw :class="store.loading ? 'size-3.5 animate-spin' : 'size-3.5'" />
刷新
</Button>
<span class="ml-1 text-[11.5px] text-muted-foreground">
{{ store.tracks.length }}<template v-if="store.total > store.tracks.length"> / {{ store.total }}</template> 首
</span>
<Button size="sm" class="ml-auto h-8" :disabled="!store.tracks.length" @click="playFeiniu">
<Play class="size-3.5" /> 播放全部
</Button>
</template>
<template v-else-if="view === 'local'">
<Button variant="outline" size="sm" class="h-8" :disabled="store.localScanBusy" @click="refreshLocal">
<Loader2 v-if="store.localScanBusy" class="size-3.5 animate-spin" />
<FolderOpen v-else class="size-3.5" />
扫描本地曲库
</Button>
<span class="text-[11.5px] text-muted-foreground">{{ store.localTracks.length }} 首</span>
<Button size="sm" class="ml-auto h-8" :disabled="!store.localTracks.length" @click="playLocal">
<Play class="size-3.5" /> 播放全部
</Button>
</template>
<template v-else>
<template v-if="activePlaylist">
<div class="min-w-0">
<div class="truncate text-[13px] font-medium">{{ activePlaylist.name }}</div>
<div class="text-[11.5px] text-muted-foreground">{{ activePlaylist.items.length }} 首</div>
</div>
<div class="ml-auto flex items-center gap-1.5">
<Button variant="outline" size="sm" class="h-8" @click="editorOpen = true">
<ListPlus class="size-3.5" />
编辑音乐
</Button>
<Button
variant="ghost"
size="icon"
class="size-8"
aria-label="重命名歌单"
@click="openRename"
>
<Pencil class="size-3.5" />
</Button>
<Button
variant="ghost"
size="icon"
class="size-8 text-destructive hover:text-destructive"
aria-label="删除歌单"
@click="removePlaylist"
>
<Trash2 class="size-3.5" />
</Button>
<Button size="sm" class="h-8" :disabled="!activePlaylist.items.length" @click="playActivePlaylist">
<Play class="size-3.5" /> 播放全部
</Button>
</div>
</template>
<span v-else class="text-[12.5px] text-muted-foreground">选择左侧歌单查看内容</span>
</template>
</header>
<!-- 列表 -->
<ScrollArea class="min-h-0 flex-1">
<div class="px-2 pb-4">
<!-- 表头 -->
<div
v-if="
(view === 'feiniu' && store.tracks.length) ||
(view === 'local' && store.localTracks.length) ||
(view === 'playlists' && activePlaylist?.items.length)
"
class="grid h-8 items-center gap-3 px-2 text-[11px] text-muted-foreground"
:style="GRID"
>
<span class="text-center">#</span>
<span />
<span>标题</span>
<span class="text-right">时长</span>
<span />
</div>
<div class="flex flex-col gap-2">
<div v-if="activePlaylist" class="flex items-center justify-between">
<div>
<div class="text-base font-semibold">{{ activePlaylist.name }}</div>
<div class="text-xs text-muted-foreground">{{ activePlaylist.items.length }} 首</div>
</div>
<div class="flex items-center gap-2">
<Button variant="outline" size="sm" :disabled="!activePlaylist.items.length" @click="store.playQueue(activePlaylist.items, 0)">
▶ 播放全部
</Button>
<Button
variant="ghost"
size="icon"
class="size-8 text-destructive"
@click="store.deletePlaylist(activePlaylist.id); activePlaylistId = ''"
>
<Trash2 class="size-4" />
</Button>
</div>
<!-- 飞牛曲库 -->
<template v-if="view === 'feiniu'">
<div v-if="store.loading" class="flex items-center justify-center gap-2 py-14 text-[12.5px] text-muted-foreground">
<Loader2 class="size-4 animate-spin" /> 加载曲库…
</div>
<div v-if="activePlaylist" class="flex flex-col gap-1.5">
<Empty v-else-if="!store.tracks.length">
<EmptyMedia><Music2 class="size-8 text-muted-foreground" /></EmptyMedia>
<EmptyTitle>{{ store.searchKeyword.trim() ? '没有匹配的曲目' : '曲库为空' }}</EmptyTitle>
<EmptyDescription>{{ listEmptyHint }}</EmptyDescription>
</Empty>
<template v-else>
<TrackItem
v-for="(t, i) in activePlaylist.items"
:key="`${t.source}-${t.guid}-${i}`"
v-for="(t, i) in store.tracks"
:key="t.guid || i"
:item="t"
:index="i"
:context="store.tracks"
:active="store.current?.guid === t.guid"
/>
<div class="mt-1 flex justify-end">
<Button
variant="ghost"
size="sm"
class="text-xs text-muted-foreground"
@click="store.removeFromPlaylist(activePlaylist.id, activePlaylist.items.length - 1)"
>
移除最后一首
</Button>
<div
v-if="store.hasMoreTracks"
ref="loadMoreRef"
class="flex items-center justify-center gap-2 py-4 text-[12px] text-muted-foreground"
>
<Loader2 v-if="store.loadingMore" class="size-3.5 animate-spin" />
正在加载更多…
</div>
</div>
<Empty v-else class="min-h-40">
<p class="text-sm text-muted-foreground">选择左侧歌单查看内容</p>
</Empty>
</div>
</div>
</template>
</template>
</div>
</ScrollArea>
</template>
</template>
<!-- 新建歌单弹窗 -->
<Dialog v-model:open="createOpen">
<DialogContent class="sm:max-w-sm">
<DialogHeader>
<DialogTitle>新建歌单</DialogTitle>
<DialogDescription>歌单保存在本机,可混合飞牛 NAS 与本地曲目。</DialogDescription>
</DialogHeader>
<Input v-model="playlistName" placeholder="歌单名称" @keydown.enter="createPlaylist" />
<DialogFooter>
<Button variant="outline" @click="createOpen = false">取消</Button>
<Button @click="createPlaylist">创建</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</template>
<!-- 本地曲库 -->
<template v-else-if="view === 'local'">
<Empty v-if="!store.localTracks.length && !store.localScanBusy">
<EmptyMedia><HardDrive class="size-8 text-muted-foreground" /></EmptyMedia>
<EmptyTitle>暂无本地音乐</EmptyTitle>
<EmptyDescription>{{ listEmptyHint }}</EmptyDescription>
</Empty>
<template v-else>
<TrackItem
v-for="(t, i) in store.localTracks"
:key="t.guid || i"
:item="t"
:index="i"
:context="store.localTracks"
:active="store.current?.guid === t.guid"
/>
</template>
</template>
<!-- 歌单详情 -->
<template v-else>
<template v-if="activePlaylist">
<Empty v-if="!activePlaylist.items.length">
<EmptyMedia><ListMusic class="size-8 text-muted-foreground" /></EmptyMedia>
<EmptyTitle>歌单还是空的</EmptyTitle>
<EmptyDescription>
点击「编辑音乐」从全部音乐里勾选加入,或在曲库列表中通过「⋯」菜单单首添加。
</EmptyDescription>
<Button size="sm" class="mt-1" @click="editorOpen = true">
<ListPlus class="size-3.5" />
编辑音乐
</Button>
</Empty>
<TrackItem
v-for="(t, i) in activePlaylist.items"
:key="`${t.source}:${t.guid}:${i}`"
:item="t"
:index="i"
:context="activePlaylist.items"
:playlist-id="activePlaylist.id"
:playlist-index="i"
:active="store.current?.guid === t.guid"
show-source
/>
</template>
<Empty v-else>
<EmptyMedia><ListMusic class="size-8 text-muted-foreground" /></EmptyMedia>
<EmptyTitle>还没有歌单</EmptyTitle>
<EmptyDescription>点击左侧「新建歌单」开始整理你的收藏。</EmptyDescription>
</Empty>
</template>
</div>
</ScrollArea>
</template>
</section>
<!-- 新建歌单 -->
<Dialog v-model:open="createOpen">
<DialogContent class="sm:max-w-sm">
<DialogHeader>
<DialogTitle>新建歌单</DialogTitle>
<DialogDescription>歌单保存在本机,可混合飞牛 NAS 与本地曲目。</DialogDescription>
</DialogHeader>
<Input v-model="newName" placeholder="歌单名称" @keydown.enter="createPlaylist" />
<DialogFooter>
<Button variant="outline" @click="createOpen = false">取消</Button>
<Button @click="createPlaylist">创建</Button>
</DialogFooter>
</DialogContent>
</Dialog>
<!-- 重命名歌单 -->
<Dialog v-model:open="renameOpen">
<DialogContent class="sm:max-w-sm">
<DialogHeader>
<DialogTitle>重命名歌单</DialogTitle>
</DialogHeader>
<Input v-model="renameValue" placeholder="歌单名称" @keydown.enter="confirmRename" />
<DialogFooter>
<Button variant="outline" @click="renameOpen = false">取消</Button>
<Button @click="confirmRename">保存</Button>
</DialogFooter>
</DialogContent>
</Dialog>
<!-- 编辑歌单音乐:从全部音乐勾选加入 / 批量移出 -->
<PlaylistEditorDialog
v-if="activePlaylist"
v-model:open="editorOpen"
:playlist-id="activePlaylist.id"
/>
</div>
</template>
<style scoped>
/* 歌单子树展开 / 收起 */
.pl-list-enter-active,
.pl-list-leave-active {
transition: opacity 0.18s ease, transform 0.18s ease;
}
.pl-list-enter-from,
.pl-list-leave-to {
opacity: 0;
transform: translateY(-6px);
}
@media (prefers-reduced-motion: reduce) {
.pl-list-enter-active,
.pl-list-leave-active {
transition: none;
}
}
</style>