Skip to content

Commit

Permalink
fix: use IIFE for aplayer #463
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanNotFound committed Nov 30, 2024
1 parent deb0358 commit 09aa3f5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion source/build/js/plugins/aplayer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion source/build/js/plugins/aplayer.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 31 additions & 29 deletions source/js/plugins/aplayer.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
const audioList = [];
const isFixed = theme.plugins.aplayer.type == "fixed";
const isMini = theme.plugins.aplayer.type == "mini";
(function() {
const audioList = [];
const isFixed = theme.plugins.aplayer.type === "fixed";
const isMini = theme.plugins.aplayer.type === "mini";

for (const audio of theme.plugins.aplayer.audios) {
const a = {
name: audio.name,
artist: audio.artist,
url: audio.url,
cover: audio.cover,
lrc: audio.lrc,
theme: audio.theme,
};
audioList.push(a);
}
for (const audio of theme.plugins.aplayer.audios) {
const audioObj = {
name: audio.name,
artist: audio.artist,
url: audio.url,
cover: audio.cover,
lrc: audio.lrc,
theme: audio.theme,
};
audioList.push(audioObj);
}

if (isMini) {
const ap = new APlayer({
container: document.getElementById("aplayer"),
mini: true,
audio: audioList,
});
} else if (isFixed) {
const ap = new APlayer({
container: document.getElementById("aplayer"),
fixed: true,
lrcType: 3,
audio: audioList,
});
document.querySelector(".aplayer-icon-lrc").click();
}
if (isMini) {
new APlayer({
container: document.getElementById("aplayer"),
mini: true,
audio: audioList,
});
} else if (isFixed) {
const player = new APlayer({
container: document.getElementById("aplayer"),
fixed: true,
lrcType: 3,
audio: audioList,
});
document.querySelector(".aplayer-icon-lrc").click();
}
})();

0 comments on commit 09aa3f5

Please sign in to comment.