diff --git a/doc_images/1.jpg b/doc_images/1.jpg index a32a1a9..a1014cc 100644 Binary files a/doc_images/1.jpg and b/doc_images/1.jpg differ diff --git a/doc_images/2.jpg b/doc_images/2.jpg index e962460..d6d36b0 100644 Binary files a/doc_images/2.jpg and b/doc_images/2.jpg differ diff --git a/doc_images/3.jpg b/doc_images/3.jpg index d73fb19..3aeda22 100644 Binary files a/doc_images/3.jpg and b/doc_images/3.jpg differ diff --git a/doc_images/4.jpg b/doc_images/4.jpg index 4dfd3cb..67b3cea 100644 Binary files a/doc_images/4.jpg and b/doc_images/4.jpg differ diff --git a/doc_images/5.jpg b/doc_images/5.jpg index e35b9cd..1cd68af 100644 Binary files a/doc_images/5.jpg and b/doc_images/5.jpg differ diff --git a/doc_images/6.jpg b/doc_images/6.jpg index 5b72dea..ad1af43 100644 Binary files a/doc_images/6.jpg and b/doc_images/6.jpg differ diff --git a/doc_images/7.jpg b/doc_images/7.jpg new file mode 100644 index 0000000..b32331c Binary files /dev/null and b/doc_images/7.jpg differ diff --git a/doc_images/merge.gif b/doc_images/merge.gif index 9b1caf0..b6702ea 100644 Binary files a/doc_images/merge.gif and b/doc_images/merge.gif differ diff --git a/web/src/store/index.js b/web/src/store/index.js index 5c4bcef..e3fb987 100644 --- a/web/src/store/index.js +++ b/web/src/store/index.js @@ -114,32 +114,24 @@ const useStore = defineStore({ setTheme(isDark, animate = true) { // $store.setThemeConfig({ isDark: val }) const html = document.documentElement + let setAttribute = () => { + if (isDark) html.setAttribute('class', 'dark') + else html.setAttribute('class', '') + localStorage.setItem('isDark', isDark) + this.$patch({ isDark }) + } if(animate) { let transition = document.startViewTransition(() => { - // 在 startViewTransition 中修改 DOM 状态产生动画 document.documentElement.classList.toggle('dark') }) transition.ready.then(() => { - // 由于我们要从鼠标点击的位置开始做动画,所以我们需要先获取到鼠标的位置 - // 假设 'e' 是从某个事件监听器传入的事件对象 - - // 窗口中心点 - // const screenWidth = window.innerWidth - // const screenHeight = window.innerHeight - // const centerX = screenWidth / 2 - // const centerY = screenHeight / 2 const centerX = 0 const centerY = 0 - - // 现在 centerX 和 centerY 包含了屏幕中心的坐标 - console.log('Screen center X:', centerX, 'Screen center Y:', centerY) - - // 计算半径,以鼠标点击的位置为圆心,到四个角的距离中最大的那个作为半径 const radius = Math.hypot( - Math.max(centerX, innerWidth - centerX), - Math.max(centerY, innerHeight - centerY) + Math.max(centerX, window.innerWidth - centerX), + Math.max(centerY, window.innerHeight - centerY) ) - + console.log('radius: ', innerWidth, innerHeight, radius) // 自定义动画 document.documentElement.animate( { @@ -153,12 +145,10 @@ const useStore = defineStore({ pseudoElement: '::view-transition-new(root)' } ) - - if (isDark) html.setAttribute('class', 'dark') - else html.setAttribute('class', '') - localStorage.setItem('isDark', isDark) - this.$patch({ isDark }) + setAttribute() }) + } else { + setAttribute() } }, setDefaultTheme() {