Forráskód Böngészése

增加清空队列功能

sequoia00 2 hete
szülő
commit
53ad5e8695
3 módosított fájl, 26 hozzáadás és 8 törlés
  1. 11 0
      playlists.json
  2. 10 6
      static/js/app.js
  3. 5 2
      templates/index.html

+ 11 - 0
playlists.json

@@ -5,5 +5,16 @@
     "tracks": [
       "萨克斯风/《回家》CD1.mp3"
     ]
+  },
+  {
+    "id": "749a5594a8d84bc58495be200043bc0e",
+    "name": "最新",
+    "tracks": [
+      "经典老歌/212 伍佰 And China Blue-挪威的森林.mp3",
+      "经典老歌/211 吴奇隆-祝你一路顺风.mp3",
+      "陈小春/04 献世.mp3",
+      "陈小春/13 友情岁月.mp3",
+      "经典老歌/209 巫启贤-思念谁.mp3"
+    ]
   }
 ]

+ 10 - 6
static/js/app.js

@@ -117,11 +117,6 @@ async function fetchLibrary() {
     renderAlbumDetail(state.activeAlbumPath);
   }
 
-  if (!state.currentQueue.length) {
-    state.currentQueue = [...state.library.all_tracks];
-    renderQueue();
-  }
-
   startFeaturedCarousel();
 }
 
@@ -454,6 +449,11 @@ function renderQueue() {
   });
 }
 
+function clearQueue() {
+  state.currentQueue = [];
+  clearCurrentTrack();
+}
+
 function renderPlaylists() {
   const container = document.getElementById("playlistList");
   container.innerHTML = "";
@@ -522,7 +522,6 @@ function renderAlbumMenu() {
     button.onclick = () => {
       setCurrentFolder(album.path);
       renderAlbumDetail(album.path);
-      startQueue(album.tracks, 0);
       toggleAlbumMenu(false);
     };
     container.appendChild(button);
@@ -720,6 +719,11 @@ document.getElementById("backHomeBtn").onclick = () => {
   scrollToPageTop();
 };
 document.getElementById("saveQueueBtn").onclick = () => renderQueue();
+document.getElementById("clearQueueBtn").onclick = () => {
+  if (!state.currentQueue.length) return;
+  showIconToast("清空队列");
+  clearQueue();
+};
 document.getElementById("playModeBtn").onclick = () => {
   const modes = ["shuffle", "one", "list", "once"];
   const nextIndex = (modes.indexOf(state.playMode) + 1) % modes.length;

+ 5 - 2
templates/index.html

@@ -101,7 +101,10 @@
         <section class="content-section">
           <div class="section-head">
             <h2>当前播放队列</h2>
-            <button id="saveQueueBtn" class="text-btn">刷新</button>
+            <div class="card-actions">
+              <button id="saveQueueBtn" class="text-btn">刷新</button>
+              <button id="clearQueueBtn" class="text-btn">清空</button>
+            </div>
           </div>
           <div id="queueList" class="queue-list"></div>
         </section>
@@ -218,6 +221,6 @@
       </div>
     </template>
 
-    <script src="/static/js/app.js"></script>
+    <script src="/static/js/app.js?v=20260509-1"></script>
   </body>
 </html>