feat(perm): gate Queue.vue remove/clear/play-at controls by capability

This commit is contained in:
saopig1 committed 2026-05-30 14:00:27 +08:00
1 parent bb86f7e9ed
commit 5177b41951
1 file changed
+5 -2
+5 -2
View File
@@ -4,7 +4,7 @@
<h3 class="queue-title">播放队列</h3> <h3 class="queue-title">播放队列</h3>
<span class="queue-count">{{ botQueue.length }} 首</span> <span class="queue-count">{{ botQueue.length }} 首</span>
<button <button
v-if="botQueue.length > 0" v-if="botQueue.length > 0 && can('player.control')"
class="clear-btn" class="clear-btn"
@click="clearAndStop" @click="clearAndStop"
title="清空队列并停止播放" title="清空队列并停止播放"
@@ -33,7 +33,7 @@
<div class="queue-song-name">{{ song.name }}</div> <div class="queue-song-name">{{ song.name }}</div>
<div class="queue-song-artist">{{ song.artist }}</div> <div class="queue-song-artist">{{ song.artist }}</div>
</div> </div>
<button class="remove-btn" @click="removeSong(i)" title="移除"> <button v-if="can('player.queue')" class="remove-btn" @click="removeSong(i)" title="移除">
<Icon icon="mdi:close" /> <Icon icon="mdi:close" />
</button> </button>
</div> </div>
@@ -46,6 +46,7 @@ import { watch, computed } from 'vue';
import { Icon } from '@iconify/vue'; import { Icon } from '@iconify/vue';
import axios from 'axios'; import axios from 'axios';
import { usePlayerStore } from '../stores/player.js'; import { usePlayerStore } from '../stores/player.js';
import { useSession } from '../composables/useSession.js';
import CoverArt from './CoverArt.vue'; import CoverArt from './CoverArt.vue';
const props = defineProps<{ const props = defineProps<{
@@ -57,6 +58,7 @@ defineEmits<{
}>(); }>();
const store = usePlayerStore(); const store = usePlayerStore();
const { can } = useSession();
const botQueue = computed(() => store.queue); const botQueue = computed(() => store.queue);
// Fetch queue when panel opens // Fetch queue when panel opens
@@ -65,6 +67,7 @@ watch(() => props.open, (isOpen) => {
}); });
async function playAtIndex(index: number) { async function playAtIndex(index: number) {
if (!can('player.control')) return;
await store.playAtIndex(index); await store.playAtIndex(index);
await store.fetchQueue(); await store.fetchQueue();
} }