|
|
|
@ -1,38 +1,71 @@
|
|
|
|
|
<!--
|
|
|
|
|
* @Desc:
|
|
|
|
|
* @Author: lijj
|
|
|
|
|
* @Date: 2024-05-13 09:06:51
|
|
|
|
|
-->
|
|
|
|
|
<template>
|
|
|
|
|
<div v-if="getShowDarkModeToggle" :class="getClass" @click="toggleDarkMode">
|
|
|
|
|
<!-- <div v-if="getShowDarkModeToggle" :class="getClass" @click="toggleDarkMode">
|
|
|
|
|
<div :class="`${prefixCls}-inner`"></div>
|
|
|
|
|
<SvgIcon size="14" name="sun" />
|
|
|
|
|
<SvgIcon size="14" name="moon" />
|
|
|
|
|
</div> -->
|
|
|
|
|
<div>
|
|
|
|
|
<a-radio-group v-model:value="themeValue" button-style="solid">
|
|
|
|
|
<a-radio-button value="black">主题1</a-radio-button>
|
|
|
|
|
<a-radio-button value="blue">主题2</a-radio-button>
|
|
|
|
|
<a-radio-button value="white">主题3</a-radio-button>
|
|
|
|
|
</a-radio-group>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { computed, unref } from 'vue'
|
|
|
|
|
import { SvgIcon } from '/@/components/Icon'
|
|
|
|
|
import { useDesign } from '/@/hooks/web/useDesign'
|
|
|
|
|
import { ref, watch } from 'vue'
|
|
|
|
|
// import { SvgIcon } from '/@/components/Icon'
|
|
|
|
|
// import { useDesign } from '/@/hooks/web/useDesign'
|
|
|
|
|
import { useRootSetting } from '/@/hooks/setting/useRootSetting'
|
|
|
|
|
import { updateHeaderBgColor, updateSidebarBgColor } from '/@/logics/theme/updateBackground'
|
|
|
|
|
import { updateDarkTheme } from '/@/logics/theme/dark'
|
|
|
|
|
import { ThemeEnum } from '/@/enums/appEnum'
|
|
|
|
|
// import { updateHeaderBgColor, updateSidebarBgColor } from '/@/logics/theme/updateBackground'
|
|
|
|
|
// import { updateDarkTheme } from '/@/logics/theme/dark'
|
|
|
|
|
import { baseHandler } from '/@/layouts/default/setting/handler'
|
|
|
|
|
// import { ThemeEnum } from '/@/enums/appEnum'
|
|
|
|
|
|
|
|
|
|
const { prefixCls } = useDesign('dark-switch')
|
|
|
|
|
const { getDarkMode, setDarkMode, getShowDarkModeToggle } = useRootSetting()
|
|
|
|
|
|
|
|
|
|
const isDark = computed(() => getDarkMode.value === ThemeEnum.DARK)
|
|
|
|
|
|
|
|
|
|
const getClass = computed(() => [
|
|
|
|
|
prefixCls,
|
|
|
|
|
{
|
|
|
|
|
[`${prefixCls}--dark`]: unref(isDark),
|
|
|
|
|
},
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
function toggleDarkMode() {
|
|
|
|
|
const darkMode = getDarkMode.value === ThemeEnum.DARK ? ThemeEnum.LIGHT : ThemeEnum.DARK
|
|
|
|
|
setDarkMode(darkMode)
|
|
|
|
|
updateDarkTheme(darkMode)
|
|
|
|
|
updateHeaderBgColor()
|
|
|
|
|
updateSidebarBgColor()
|
|
|
|
|
// const { prefixCls } = useDesign('dark-switch')
|
|
|
|
|
// console.log(prefixCls)
|
|
|
|
|
const { getDarkMode, setDarkMode } = useRootSetting()
|
|
|
|
|
// 当前主题颜色
|
|
|
|
|
const themeValue = ref(getDarkMode.value)
|
|
|
|
|
// const isDark = computed(() => getDarkMode.value === ThemeEnum.DARK)
|
|
|
|
|
// const getClass = computed(() => [
|
|
|
|
|
// prefixCls,
|
|
|
|
|
// {
|
|
|
|
|
// [`${prefixCls}--dark`]: unref(isDark),
|
|
|
|
|
// },
|
|
|
|
|
// ])
|
|
|
|
|
watch(
|
|
|
|
|
() => themeValue.value,
|
|
|
|
|
(v) => {
|
|
|
|
|
if (v == 'black') {
|
|
|
|
|
baseHandler(11, '#121826')
|
|
|
|
|
baseHandler(18, '#2A303C')
|
|
|
|
|
baseHandler(1, '#FF6600')
|
|
|
|
|
} else if (v == 'blue') {
|
|
|
|
|
baseHandler(11, '#1247B3')
|
|
|
|
|
baseHandler(18, '#275ECC')
|
|
|
|
|
baseHandler(1, '#275ECC')
|
|
|
|
|
} else {
|
|
|
|
|
baseHandler(11, '#FFFFFF')
|
|
|
|
|
baseHandler(18, '#FFFFFF')
|
|
|
|
|
baseHandler(1, '#275ECC')
|
|
|
|
|
}
|
|
|
|
|
setDarkMode(v)
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
// function toggleDarkMode() {
|
|
|
|
|
// console.log(getDarkMode)
|
|
|
|
|
// const darkMode = getDarkMode.value === ThemeEnum.DARK ? ThemeEnum.LIGHT : ThemeEnum.DARK
|
|
|
|
|
// setDarkMode(darkMode)
|
|
|
|
|
// updateDarkTheme(darkMode)
|
|
|
|
|
// updateHeaderBgColor()
|
|
|
|
|
// updateSidebarBgColor()
|
|
|
|
|
// }
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
@prefix-cls: ~'@{namespace}-dark-switch';
|
|
|
|
|