左下角添加音乐播放元素(进电脑端生效)

This commit is contained in:
2026-05-28 18:54:36 +08:00
parent bf8bd7be26
commit 4a60769d87
5 changed files with 343 additions and 3 deletions
+27
View File
@@ -4,6 +4,7 @@ import "@fontsource/roboto/500.css";
import "@fontsource/roboto/700.css";
import ConfigCarrier from "@components/ConfigCarrier.astro";
import MusicPlayer from "@components/widget/MusicPlayer.astro";
import { profileConfig, siteConfig } from "@/config";
import {
AUTO_MODE,
@@ -157,6 +158,8 @@ const bannerOffset =
<SpeedInsights />
<MusicPlayer />
<!-- increase the page height during page transition to prevent the scrolling animation from jumping -->
<div id="page-height-extend" class="hidden h-[300vh]"></div>
</body>
@@ -568,3 +571,27 @@ if (window.swup) {
document.addEventListener("swup:enable", setup)
}
</script>
<script>
function adjustTocLayout() {
const hasToc = !!document.querySelector('[data-has-toc]');
const isWide = window.innerWidth >= 1536;
if (hasToc && isWide) {
document.body.classList.add('toc-offset');
} else {
document.body.classList.remove('toc-offset');
}
}
adjustTocLayout();
window.addEventListener('resize', adjustTocLayout);
if (window.swup) {
window.swup.hooks.on('content:replace', () => requestAnimationFrame(adjustTocLayout));
window.swup.hooks.on('page:view', () => requestAnimationFrame(adjustTocLayout));
} else {
document.addEventListener('swup:enable', () => {
adjustTocLayout();
window.swup.hooks.on('content:replace', () => requestAnimationFrame(adjustTocLayout));
window.swup.hooks.on('page:view', () => requestAnimationFrame(adjustTocLayout));
});
}
</script>