Skip to content

Commit

Permalink
修复刷新列表问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxi committed Jun 13, 2024
1 parent aa6bce7 commit e484164
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
40 changes: 22 additions & 18 deletions xiaomusic/static/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,32 @@ $(function(){
});

// 拉取播放列表
$.get("/musiclist", function(data, status) {
console.log(data, status);
$.each(data, function(key, value) {
$('#music_list').append($('<option></option>').val(key).text(key));
});

$('#music_list').change(function() {
const selectedValue = $(this).val();
$('#music_name').empty();
$.each(data[selectedValue], function(index, item) {
$('#music_name').append($('<option></option>').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($('<option></option>').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($('<option></option>').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();
Expand Down Expand Up @@ -96,7 +100,7 @@ $(function(){
data: JSON.stringify({cmd: cmd}),
success: () => {
if (cmd == "刷新列表") {
location.reload();
setTimeout(refresh_music_list, 3000);
}
},
error: () => {
Expand Down
1 change: 1 addition & 0 deletions xiaomusic/xiaomusic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e484164

Please sign in to comment.