From 4005345f4ec104afb611add3a9a6617845d4f267 Mon Sep 17 00:00:00 2001 From: lsy Date: Tue, 13 May 2025 19:17:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=BB=E9=A2=98=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E5=92=8Cswup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ThemeToggle.astro | 1556 ++++++++++++------------------ src/scripts/swup-init.js | 7 +- 2 files changed, 603 insertions(+), 960 deletions(-) diff --git a/src/components/ThemeToggle.astro b/src/components/ThemeToggle.astro index 7b16334..a2da222 100644 --- a/src/components/ThemeToggle.astro +++ b/src/components/ThemeToggle.astro @@ -4,9 +4,9 @@ interface Props { width?: number; fill?: string; className?: string; - // 更新主题过渡动画模式配置 + // 过渡动画模式配置 transitionMode?: "expand" | "shrink" | "auto" | "reverse-auto"; - // 新增自定义主题切换动画时间 + // 自定义主题切换动画时间 transitionDuration?: number; } @@ -66,950 +66,544 @@ import "../styles/theme-toggle.css"; \ No newline at end of file diff --git a/src/scripts/swup-init.js b/src/scripts/swup-init.js index 16df6d3..7cf125d 100644 --- a/src/scripts/swup-init.js +++ b/src/scripts/swup-init.js @@ -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插件 - 确保页面转场后脚本能重新执行