11<script lang="ts" setup>
2- import type { ThemeName } from " @@/composables/useTheme"
32import { useTheme } from " @@/composables/useTheme"
43import { MagicStick } from " @element-plus/icons-vue"
54
65const { themeList, activeThemeName, setTheme } = useTheme ()
7-
8- function handleChangeTheme({ clientX , clientY }: MouseEvent , themeName : ThemeName ) {
9- const maxRadius = Math .hypot (
10- Math .max (clientX , window .innerWidth - clientX ),
11- Math .max (clientY , window .innerHeight - clientY )
12- )
13- const style = document .documentElement .style
14- style .setProperty (" --v3-theme-x" , ` ${clientX }px ` )
15- style .setProperty (" --v3-theme-y" , ` ${clientY }px ` )
16- style .setProperty (" --v3-theme-r" , ` ${maxRadius }px ` )
17- const handler = () => {
18- setTheme (themeName )
19- }
20- document .startViewTransition ? document .startViewTransition (handler ) : handler ()
21- }
226 </script >
237
248<template >
@@ -36,7 +20,7 @@ function handleChangeTheme({ clientX, clientY }: MouseEvent, themeName: ThemeNam
3620 v-for =" (theme, index) in themeList"
3721 :key =" index"
3822 :disabled =" activeThemeName === theme.name"
39- @click =" (e: MouseEvent) => handleChangeTheme (e, theme.name)"
23+ @click =" (e: MouseEvent) => setTheme (e, theme.name)"
4024 >
4125 <span >{{ theme.title }}</span >
4226 </el-dropdown-item >
0 commit comments