diff --git a/src/components/common/dark-mode-switch.vue b/src/components/common/dark-mode-switch.vue index 1e78337b..fc14db10 100644 --- a/src/components/common/dark-mode-switch.vue +++ b/src/components/common/dark-mode-switch.vue @@ -13,6 +13,8 @@ defineOptions({ name: 'DarkModeSwitch' }); interface Props { /** 暗黑模式 */ dark?: boolean; + /** 自定义暗黑模式动画过渡 */ + customizeTransition?: boolean; } const props = withDefaults(defineProps(), { @@ -38,7 +40,7 @@ async function handleSwitch(event: MouseEvent) { const x = event.clientX; const y = event.clientY; - if (!document.startViewTransition) { + if (!props.customizeTransition || !document.startViewTransition) { darkMode.value = !darkMode.value; return; } diff --git a/src/layouts/common/global-header/components/theme-mode.vue b/src/layouts/common/global-header/components/theme-mode.vue index 53bb32f2..a59eea4e 100644 --- a/src/layouts/common/global-header/components/theme-mode.vue +++ b/src/layouts/common/global-header/components/theme-mode.vue @@ -1,6 +1,11 @@ diff --git a/src/layouts/common/setting-drawer/components/dark-mode/index.vue b/src/layouts/common/setting-drawer/components/dark-mode/index.vue index 1d7992ea..e99bf566 100644 --- a/src/layouts/common/setting-drawer/components/dark-mode/index.vue +++ b/src/layouts/common/setting-drawer/components/dark-mode/index.vue @@ -21,6 +21,16 @@ + + + + + + diff --git a/src/settings/theme.json b/src/settings/theme.json index a812847e..faf4a0d4 100644 --- a/src/settings/theme.json +++ b/src/settings/theme.json @@ -1,6 +1,7 @@ { "darkMode": false, "followSystemTheme": true, + "isCustomizeDarkModeTransition": false, "layout": { "minWidth": 900, "mode": "vertical", diff --git a/src/settings/theme.ts b/src/settings/theme.ts index b678cb94..d1d592a3 100644 --- a/src/settings/theme.ts +++ b/src/settings/theme.ts @@ -37,6 +37,7 @@ const themeColorList = [ const defaultThemeSetting: Theme.Setting = { darkMode: false, followSystemTheme: true, + isCustomizeDarkModeTransition: false, layout: { minWidth: 900, mode: 'vertical', diff --git a/src/store/modules/theme/index.ts b/src/store/modules/theme/index.ts index 35be6f11..5b4bd65c 100644 --- a/src/store/modules/theme/index.ts +++ b/src/store/modules/theme/index.ts @@ -43,6 +43,10 @@ export const useThemeStore = defineStore('theme-store', { setFollowSystemTheme(visible: boolean) { this.followSystemTheme = visible; }, + /** 设置自动跟随系统主题 */ + setIsCustomizeDarkModeTransition(isCustomize: boolean) { + this.isCustomizeDarkModeTransition = isCustomize; + }, /** 自动跟随系统主题 */ setAutoFollowSystemMode(darkMode: boolean) { if (this.followSystemTheme) { diff --git a/src/typings/system.d.ts b/src/typings/system.d.ts index c47f6ccd..b01f459d 100644 --- a/src/typings/system.d.ts +++ b/src/typings/system.d.ts @@ -90,6 +90,8 @@ declare namespace Theme { darkMode: boolean; /** 是否自动跟随系统主题 */ followSystemTheme: boolean; + /** 自定义暗黑动画过渡 */ + isCustomizeDarkModeTransition: boolean; /** 布局样式 */ layout: Layout; /** 滚动模式 */