From e484164fada1e1549dd3cfe1f926bab443383450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Thu, 13 Jun 2024 14:49:36 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=B7=E6=96=B0=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaomusic/static/app.js | 40 ++++++++++++++++++++++------------------ xiaomusic/xiaomusic.py | 1 + 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/xiaomusic/static/app.js b/xiaomusic/static/app.js index 2a7ce650a..5e25f417d 100644 --- a/xiaomusic/static/app.js +++ b/xiaomusic/static/app.js @@ -27,28 +27,32 @@ $(function(){ }); // 拉取播放列表 - $.get("/musiclist", function(data, status) { - console.log(data, status); - $.each(data, function(key, value) { - $('#music_list').append($('').val(key).text(key)); - }); - - $('#music_list').change(function() { - const selectedValue = $(this).val(); - $('#music_name').empty(); - $.each(data[selectedValue], function(index, item) { - $('#music_name').append($('').val(item).text(item)); + function refresh_music_list() { + $('#music_list').empty(); + $.get("/musiclist", function(data, status) { + console.log(data, status); + $.each(data, function(key, value) { + $('#music_list').append($('').val(key).text(key)); }); - }); - $('#music_list').trigger('change'); + $('#music_list').change(function() { + const selectedValue = $(this).val(); + $('#music_name').empty(); + $.each(data[selectedValue], function(index, item) { + $('#music_name').append($('').val(item).text(item)); + }); + }); - // 获取当前播放列表 - $.get("curplaylist", function(data, status) { - $('#music_list').val(data); $('#music_list').trigger('change'); + + // 获取当前播放列表 + $.get("curplaylist", function(data, status) { + $('#music_list').val(data); + $('#music_list').trigger('change'); + }) }) - }) + } + refresh_music_list(); $("#play_music_list").on("click", () => { var music_list = $("#music_list").val(); @@ -96,7 +100,7 @@ $(function(){ data: JSON.stringify({cmd: cmd}), success: () => { if (cmd == "刷新列表") { - location.reload(); + setTimeout(refresh_music_list, 3000); } }, error: () => { diff --git a/xiaomusic/xiaomusic.py b/xiaomusic/xiaomusic.py index 1ebd39668..927281a38 100644 --- a/xiaomusic/xiaomusic.py +++ b/xiaomusic/xiaomusic.py @@ -411,6 +411,7 @@ def get_next_music(self): filename = self.get_filename(name) if len(filename) <= 0: self._play_list.pop(next_index) + self.log.info(f'pop not exist music:{name}') return self.get_next_music() return name