Skip to content

Commit

Permalink
fix: 收藏 (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
52fisher authored Dec 8, 2024
1 parent e434faf commit baedee5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
8 changes: 4 additions & 4 deletions xiaomusic/static/default/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ progress::-webkit-progress-value {
.button-group {
display: flex;
justify-content: center;
margin: 15px 0;
margin: 5px 0;
}

.player-controls {
Expand Down Expand Up @@ -285,12 +285,12 @@ textarea {
align-items: center;
justify-content: center;
}
/* 媒体查询 屏幕宽度小于440px时 */



@media screen and (max-width: 440px) {
.player{
width: 90%;
}
.footer {
position: relative;
}
}
46 changes: 24 additions & 22 deletions xiaomusic/static/default/md.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,17 @@ function togglePlayMode(isSend = true) {
}

function addToFavorites() {

const cmd = $(".favorite").hasClass("favorite-active")
? "取消收藏"
: "加入收藏";
if ($(".favorite").hasClass("favorite-active")) {
$(".favorite").removeClass("favorite-active");
} else {
$(".favorite").addClass("favorite-active");
}
const isLiked = $(".favorite").hasClass("favorite-active");
const cmd = isLiked? "取消收藏": "加入收藏";
if (isLiked) {
$(".favorite").removeClass("favorite-active");
// 取消收藏
favoritelist = favoritelist.filter((item) => item != $("#music_name").val());
} else {
$(".favorite").addClass("favorite-active");
// 加入收藏
favoritelist.push($("#music_name").val());
}
sendcmd(cmd);
}

Expand Down Expand Up @@ -116,19 +118,19 @@ function confirmDelete() {
var del_music_name = $("#music_name").val();
console.log(`删除歌曲 ${del_music_name}`);
$("#delete-component").hide(); // 隐藏删除框
$.ajax({
type: "POST",
url: "/delmusic",
data: JSON.stringify({ name: del_music_name }),
contentType: "application/json; charset=utf-8",
success: () => {
alert(`删除 ${del_music_name} 成功`);
refresh_music_list();
},
error: () => {
alert(`删除 ${del_music_name} 失败`);
},
});
$.ajax({
type: "POST",
url: "/delmusic",
data: JSON.stringify({ name: del_music_name }),
contentType: "application/json; charset=utf-8",
success: () => {
alert(`删除 ${del_music_name} 成功`);
refresh_music_list();
},
error: () => {
alert(`删除 ${del_music_name} 失败`);
},
});
}
function formatTime(seconds) {
const minutes = Math.floor(seconds / 60);
Expand Down

0 comments on commit baedee5

Please sign in to comment.