summaryrefslogtreecommitdiff
path: root/layouts/_partials/scripts
diff options
context:
space:
mode:
authorBigCoke233 <hi@guhub.cn>2026-02-02 14:28:38 +0800
committerBigCoke233 <hi@guhub.cn>2026-02-02 14:28:38 +0800
commitad6d7859250f4ce543fc186716021e7ac84470ca (patch)
tree9afda5be82e7f0d3269bc7f1328e51407ff7af7b /layouts/_partials/scripts
parentc4e0b6bbbdff34be40a98f9229deb1107942b294 (diff)
refactor: remove aPlayer and replace with <audio>
Diffstat (limited to 'layouts/_partials/scripts')
-rw-r--r--layouts/_partials/scripts/aplayer-js.html47
1 files changed, 0 insertions, 47 deletions
diff --git a/layouts/_partials/scripts/aplayer-js.html b/layouts/_partials/scripts/aplayer-js.html
deleted file mode 100644
index 2aa3db3d..00000000
--- a/layouts/_partials/scripts/aplayer-js.html
+++ /dev/null
@@ -1,47 +0,0 @@
-{{ if and (not .IsHome) .Params.hasAplayer }}
-<script>
-document.addEventListener("DOMContentLoaded", function () {
- const lazyPlayers = document.querySelectorAll(".lazy-aplayer");
- if (!lazyPlayers.length) return;
-
- const loadAPlayer = () => {
- if (window.APlayer) return Promise.resolve();
- return new Promise((resolve, reject) => {
- const script = document.createElement('script');
- script.src = "https://unpkg.com/aplayer@1.10.1/dist/APlayer.min.js";
- script.onload = resolve;
- script.onerror = reject;
- document.body.appendChild(script);
- });
- };
-
- const observer = new IntersectionObserver((entries, obs) => {
- entries.forEach(entry => {
- if (entry.isIntersecting) {
- loadAPlayer().then(() => {
- const el = entry.target;
- const id = el.dataset.id ? `-` + el.dataset.id : ``;
- const container = document.createElement('div');
- container.id = `aplayer${id}`;
- el.appendChild(container);
-
- const ap = new APlayer({
- container: container,
- audio: [{
- name: el.dataset.name,
- artist: el.dataset.artist,
- url: el.dataset.url,
- cover: el.dataset.cover
- }]
- });
-
- obs.unobserve(el);
- });
- }
- });
- });
-
- lazyPlayers.forEach(player => observer.observe(player));
-});
-</script>
-{{ end }}