mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
fix(projects): 修复主题相关,自适应操作系统暗黑模式
This commit is contained in:
@ -20,7 +20,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
import { computed, watch } from 'vue';
|
||||
import {
|
||||
NConfigProvider,
|
||||
darkTheme,
|
||||
@ -31,18 +31,29 @@ import {
|
||||
NNotificationProvider,
|
||||
NMessageProvider
|
||||
} from 'naive-ui';
|
||||
import { useDark } from '@vueuse/core';
|
||||
import { AppProviderContent } from '@/components';
|
||||
import { useThemeStore } from '@/store';
|
||||
import { addColorAlpha } from '@/utils';
|
||||
|
||||
const osDark = useDark();
|
||||
const theme = useThemeStore();
|
||||
const { handleDarkMode } = useThemeStore();
|
||||
|
||||
/** 系统暗黑模式 */
|
||||
const dark = computed(() => (theme.darkMode ? darkTheme : undefined));
|
||||
|
||||
// 主题颜色
|
||||
const primary = computed(() => theme.themeColor);
|
||||
const primaryWithAlpha = computed(() => {
|
||||
const alpha = theme.darkMode ? 0.15 : 0.1;
|
||||
return addColorAlpha(primary.value, alpha);
|
||||
});
|
||||
|
||||
// 操作系统的暗黑模式
|
||||
watch(osDark, newValue => {
|
||||
handleDarkMode(newValue);
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
/* 全局与主题颜色相关 */
|
||||
|
Reference in New Issue
Block a user