feat: 完善界面基础样式和 CSS 变量

This commit is contained in:
2024-08-29 14:28:53 +08:00
parent da9fc065c3
commit f66d388ff7

View File

@@ -4,6 +4,11 @@
:inline-theme-disabled="configProviderProps.inlineThemeDisabled" :inline-theme-disabled="configProviderProps.inlineThemeDisabled"
:locale="configProviderProps.locale" :locale="configProviderProps.locale"
:style="{ :style="{
'--box-shadow-1': themeVars.boxShadow1,
'--box-shadow-2': themeVars.boxShadow2,
'--box-shadow-3': themeVars.boxShadow3,
'--color-action': themeVars.actionColor,
'--color-border': themeVars.borderColor,
'--color-error': themeCommon.errorColor, '--color-error': themeCommon.errorColor,
'--color-info': themeCommon.infoColor, '--color-info': themeCommon.infoColor,
'--color-primary': themeCommon.primaryColor, '--color-primary': themeCommon.primaryColor,
@@ -30,6 +35,7 @@
<script setup> <script setup>
import { import {
NConfigProvider, NGlobalStyle, NConfigProvider, NGlobalStyle,
useThemeVars,
} from 'naive-ui'; } from 'naive-ui';
import { import {
@@ -43,6 +49,9 @@ const themeOverrides = configProviderProps.themeOverrides;
/** 主题变量配置 - common */ /** 主题变量配置 - common */
const themeCommon = themeOverrides.common; const themeCommon = themeOverrides.common;
/** 默认主题变量 */
const themeVars = useThemeVars();
</script> </script>
<style lang="less"> <style lang="less">
@@ -78,6 +87,17 @@ const themeCommon = themeOverrides.common;
} }
} }
// 预设样式
.shadow-1 {
box-shadow: var(--box-shadow-1);
}
.shadow-2 {
box-shadow: var(--box-shadow-2);
}
.shadow-3 {
box-shadow: var(--box-shadow-3);
}
html, body, #app, .n-config-provider { html, body, #app, .n-config-provider {
width: 100%; width: 100%;
height: 100%; height: 100%;
@@ -88,10 +108,15 @@ html, body {
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
} }
html { html {
box-sizing: border-box;
background-color: #FFF; background-color: #FFF;
color: var(--color-black); color: var(--color-black);
font-size: 16px; font-size: 16px;
line-height: 1; line-height: 1;
* {
box-sizing: inherit;
}
} }
.n-config-provider { .n-config-provider {
@@ -105,11 +130,42 @@ html {
.app-aside-wrapper { .app-aside-wrapper {
width: 64px; width: 64px;
border-right: 1px solid var(--color-gray); border-right: 1px solid var(--color-border);
} }
.app-view { .app-view {
flex-grow: 1; flex-grow: 1;
width: 0; width: 0;
background-color: var(--color-action);
&.flex-col {
display: flex;
flex-direction: column;
}
.app-view-header {
display: flex;
align-items: center;
padding: 0 16px;
height: 64px;
background-color: #FFF;
border-bottom: 1px solid var(--color-border);
font-size: 18px;
font-weight: bold;
}
.app-view-content {
padding: 20px;
width: 100%;
height: 100%;
background-color: #FFF;
&.with-margin {
margin: 20px;
width: calc(100% - 40px);
height: calc(100% - 40px);
border: 1px solid var(--color-border);
}
}
} }
</style> </style>