feat: 添加主题配置支持并优化 UI 组件页面的暗黑模式样式
This commit is contained in:
20
src/App.vue
20
src/App.vue
@ -1,5 +1,23 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { ThemeConfig } from 'ant-design-vue/es/config-provider/context';
|
||||||
|
|
||||||
|
import { theme } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useLayout } from './layouts/sakai-vue/composables/layout';
|
||||||
|
|
||||||
|
const { isDarkTheme } = useLayout();
|
||||||
|
|
||||||
|
const themeConfig = computed(() => {
|
||||||
|
return {
|
||||||
|
algorithm: isDarkTheme.value ? theme.darkAlgorithm : theme.defaultAlgorithm,
|
||||||
|
} satisfies ThemeConfig;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<RouterView />
|
<a-config-provider :theme="themeConfig">
|
||||||
|
<RouterView />
|
||||||
|
</a-config-provider>
|
||||||
|
|
||||||
<DynamicDialog /> <ConfirmDialog /> <Toast />
|
<DynamicDialog /> <ConfirmDialog /> <Toast />
|
||||||
</template>
|
</template>
|
||||||
|
@ -4,7 +4,7 @@ import { Input as ShaInput } from '@/shadcn/components/ui/input';
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col items-start justify-center gap-4 bg-white p-4">
|
<div class="flex flex-col items-start justify-center gap-4 bg-white p-4 dark:bg-gray-900">
|
||||||
<div class="demo-block">
|
<div class="demo-block">
|
||||||
<div class="demo-block">
|
<div class="demo-block">
|
||||||
<a-button type="primary">Primary Button</a-button>
|
<a-button type="primary">Primary Button</a-button>
|
||||||
@ -38,6 +38,6 @@ import { Input as ShaInput } from '@/shadcn/components/ui/input';
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.demo-block {
|
.demo-block {
|
||||||
@apply flex flex-wrap gap-4 b b-solid b-red-500 p-4;
|
@apply flex flex-wrap gap-4 b b-solid b-red-500 p-4 dark:bg-gray-800;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -8,7 +8,7 @@ const onClick = () => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<ShadcnButton variant="link" :onClick>s</ShadcnButton>
|
<ShadcnButton :onClick>ShadcnButton</ShadcnButton>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user