📝 更新系统gif描述

This commit is contained in:
chaos-zhu 2024-08-18 14:11:12 +08:00
parent 1512b71165
commit ad444fc124
9 changed files with 12 additions and 22 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 KiB

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 248 KiB

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 KiB

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 KiB

After

Width:  |  Height:  |  Size: 117 KiB

BIN
doc_images/7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 900 KiB

View File

@ -114,32 +114,24 @@ const useStore = defineStore({
setTheme(isDark, animate = true) { setTheme(isDark, animate = true) {
// $store.setThemeConfig({ isDark: val }) // $store.setThemeConfig({ isDark: val })
const html = document.documentElement 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) { if(animate) {
let transition = document.startViewTransition(() => { let transition = document.startViewTransition(() => {
// 在 startViewTransition 中修改 DOM 状态产生动画
document.documentElement.classList.toggle('dark') document.documentElement.classList.toggle('dark')
}) })
transition.ready.then(() => { transition.ready.then(() => {
// 由于我们要从鼠标点击的位置开始做动画,所以我们需要先获取到鼠标的位置
// 假设 'e' 是从某个事件监听器传入的事件对象
// 窗口中心点
// const screenWidth = window.innerWidth
// const screenHeight = window.innerHeight
// const centerX = screenWidth / 2
// const centerY = screenHeight / 2
const centerX = 0 const centerX = 0
const centerY = 0 const centerY = 0
// 现在 centerX 和 centerY 包含了屏幕中心的坐标
console.log('Screen center X:', centerX, 'Screen center Y:', centerY)
// 计算半径,以鼠标点击的位置为圆心,到四个角的距离中最大的那个作为半径
const radius = Math.hypot( const radius = Math.hypot(
Math.max(centerX, innerWidth - centerX), Math.max(centerX, window.innerWidth - centerX),
Math.max(centerY, innerHeight - centerY) Math.max(centerY, window.innerHeight - centerY)
) )
console.log('radius: ', innerWidth, innerHeight, radius)
// 自定义动画 // 自定义动画
document.documentElement.animate( document.documentElement.animate(
{ {
@ -153,12 +145,10 @@ const useStore = defineStore({
pseudoElement: '::view-transition-new(root)' pseudoElement: '::view-transition-new(root)'
} }
) )
setAttribute()
if (isDark) html.setAttribute('class', 'dark')
else html.setAttribute('class', '')
localStorage.setItem('isDark', isDark)
this.$patch({ isDark })
}) })
} else {
setAttribute()
} }
}, },
setDefaultTheme() { setDefaultTheme() {