feat(#119): saved queues web UI + behavior-settings toggles

- Settings → 行为设置: two new toggles (保存/加载播放清单, 单曲直接播放不清空队列)
  that round-trip savedQueuesEnabled / playKeepsQueue and keep the nav gate in sync.
- New "已存队列" page (/saved-queues): save the current queue (with a 共享 option),
  load (replace) / append / delete saved queues; renders a "feature disabled"
  state on 403 so it degrades gracefully when the flag is off.
- Nav entry gated on the savedQueuesEnabled store flag (hidden for guests).
- useSavedQueues API composable + a pure, unit-tested list/ownership helper.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
saopig1andClaude Fable 5 committed 2026-07-17 01:29:00 +08:00
1 parent 69a2e8c264
commit 0b10f9553c
9 files changed
+488

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
// Pure, framework-free helpers for the Saved Queues feature (#119). Kept
// separate from the API composable so the list/ownership logic is unit-testable
// without a DOM or axios.
export interface SavedQueueMeta {
id: number;
ownerId: string;
name: string;
songCount: number;
createdAt: string;
updatedAt: string;
}
/** Must match SHARED_QUEUE_OWNER in src/data/database.ts. */
export const SHARED_OWNER = '__shared__';
/** Whether a saved queue lives in the shared bucket (vs. private to a user). */
export function isShared(q: Pick<SavedQueueMeta, 'ownerId'>): boolean {
return q.ownerId === SHARED_OWNER;
}
/** Newest-updated first; stable for equal timestamps. */
export function sortQueues<T extends { updatedAt: string }>(qs: T[]): T[] {
return [...qs].sort((a, b) =>
a.updatedAt < b.updatedAt ? 1 : a.updatedAt > b.updatedAt ? -1 : 0,
);
}