@@ -20,7 +36,11 @@ const { themeList, activeThemeName, setTheme } = useTheme()
v-for="(theme, index) in themeList"
:key="index"
:disabled="activeThemeName === theme.name"
- :command="theme.name"
+ @click="
+ (e) => {
+ handleChangeTheme(e, theme.name)
+ }
+ "
>
{{ theme.title }}
diff --git a/src/styles/index.scss b/src/styles/index.scss
index fb4938e..cbb6149 100644
--- a/src/styles/index.scss
+++ b/src/styles/index.scss
@@ -10,6 +10,8 @@
@import "./theme/register.scss";
// mixin
@import "./mixins.scss";
+// View Transition
+@import "./view-transition.scss";
// 业务页面几乎都应该在根元素上挂载 class="app-container",以保持页面美观
.app-container {
diff --git a/src/styles/view-transition.scss b/src/styles/view-transition.scss
new file mode 100644
index 0000000..debaac8
--- /dev/null
+++ b/src/styles/view-transition.scss
@@ -0,0 +1,20 @@
+/** 控制切换主题时的动画效果(只在较新的浏览器上生效,例如 Chrome 111+) */
+
+::view-transition-old(root) {
+ animation: none;
+ mix-blend-mode: normal;
+}
+
+::view-transition-new(root) {
+ animation: 0.5s ease-in clip-animation;
+ mix-blend-mode: normal;
+}
+
+@keyframes clip-animation {
+ from {
+ clip-path: circle(0 at var(--v3-theme-x) var(--v3-theme-y));
+ }
+ to {
+ clip-path: circle(var(--v3-theme-r) at var(--v3-theme-x) var(--v3-theme-y));
+ }
+}