优化主题切换和swup

This commit is contained in:
lsy 2025-05-13 19:17:11 +08:00
parent 20276f1a86
commit 4005345f4e
2 changed files with 603 additions and 960 deletions

File diff suppressed because it is too large Load Diff

View File

@ -111,7 +111,12 @@ document.addEventListener('DOMContentLoaded', () => {
swup.use(preloadPlugin);
// 创建并注册Head插件用于解决CSS丢失问题
const headPlugin = new SwupHeadPlugin();
const headPlugin = new SwupHeadPlugin({
persistTags: 'link[rel="stylesheet"], style, meta', // 保留所有样式表和相关标签
persistAssets: true, // 保留已加载的资源
keepScrollOnReload: true, // 保持滚动位置
awaitAssets: true // 等待资源加载完成再显示页面
});
swup.use(headPlugin);
// 添加Scripts插件 - 确保页面转场后脚本能重新执行