feat(web/store): route guest play to non-destructive play-now-song

This commit is contained in:
saopig1 committed 2026-06-25 12:12:28 +08:00
1 parent 9d8c95b2f9
commit 15fcb11f4f
1 file changed
+5 -1
+5 -1
View File
@@ -1,6 +1,7 @@
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import axios from 'axios'; import axios from 'axios';
import { resolveScopedBot } from './scope.js'; import { resolveScopedBot } from './scope.js';
import { useSession } from '../composables/useSession.js';
export interface Song { export interface Song {
id: string; id: string;
@@ -334,7 +335,10 @@ export const usePlayerStore = defineStore('player', {
async playSong(song: Song) { async playSong(song: Song) {
if (!this.activeBotId) return; if (!this.activeBotId) return;
const res = await axios.post(`/api/player/${this.activeBotId}/play-song`, { song }); // Guests use the non-destructive "play now" (insert-next + skip) so they
// can't wipe everyone else's queue; members/admins keep the normal behavior.
const endpoint = useSession().isGuest.value ? 'play-now-song' : 'play-song';
const res = await axios.post(`/api/player/${this.activeBotId}/${endpoint}`, { song });
if (res.data?.ok === false && res.data?.message) { if (res.data?.ok === false && res.data?.message) {
this.notify(res.data.message, 'error'); this.notify(res.data.message, 'error');
} }