优化更新

This commit is contained in:
2026-09-13 18:12:07 +08:00
parent 7f758cc6e9
commit d7a081e8b7
92 changed files with 2429 additions and 1117 deletions
@@ -3,7 +3,7 @@
<!-- Copyright (c) 2021-2026 小蚂蚁云团队 版权所有 -->
:::tip 说明
前端样式方案采用 Tailwind CSS + SCSS + ElementPlus 主题覆盖,支持深色模式切换。全局 SCSS 变量通过 Vite 的 `additionalData` 注入。
前端样式方案采用 Tailwind CSS + SCSS + NaiveUI 主题覆盖,支持深色模式切换。全局 SCSS 变量通过 Vite 的 `additionalData` 注入。
:::
## 样式架构
@@ -13,7 +13,7 @@ src/styles/
├── var.scss # SCSS 全局变量(通过 Vite additionalData 注入)
├── index.scss # 入口文件,引入所有样式
├── tailwindbase.css # Tailwind CSS 基础样式
└── element-override.css # ElementPlus 主题覆盖(可选)
└── naive-override.css # NaiveUI 主题覆盖(可选)
```
## SCSS 全局变量
@@ -58,36 +58,33 @@ import './styles/tailwindbase.css';
<div class="w-full md:w-1/2 lg:w-1/3">响应式宽度</div>
```
## ElementPlus 主题
## NaiveUI 主题
ElementPlus 通过 CSS 变量支持主题定制:
NaiveUI 通过 CSS 变量和 ConfigProvider 支持主题定制:
```typescript
// main.ts
import 'element-plus/dist/index.css';
import 'element-plus/theme-chalk/display.css';
import 'element-plus/theme-chalk/dark/css-vars.css'; // 深色模式 CSS 变量
// App.vue 或入口组件
import { zhCN, dateZhCN } from 'naive-ui';
```
### ElementPlus 全局引入
### NaiveUI 全局引入
```typescript
// src/plugins/setupElement.ts
import ElementPlus from 'element-plus';
import zhCn from 'element-plus/es/locale/lang/zh-cn';
// src/plugins/naive.ts
import { setupNaiveUI } from '@/plugins/naive';
export function setupElement(app) {
app.use(ElementPlus, { locale: zhCn, size: 'default' });
export function setupNaive(app) {
setupNaiveUI(app);
}
```
## 深色模式
通过 ElementPlus 的 `dark/css-vars.css` 和 Tailwind 的 `dark` 模式实现深色主题:
通过 NaiveUI 的暗色主题和 Tailwind 的 `dark` 模式实现深色主题:
```vue
<template>
<el-switch v-model="isDark" @change="toggleDark" />
<n-switch v-model:value="isDark" @update:value="toggleDark" />
</template>
<script setup>
@@ -102,9 +99,9 @@ const toggleDark = (val) => {
```css
.dark {
--el-bg-color: #1d1e1f;
--el-text-color-primary: #e5eaf3;
--el-border-color: #4c4d4f;
--n-color: #1d1e1f;
--n-text-color: #e5eaf3;
--n-border-color: #4c4d4f;
}
```
@@ -131,14 +128,14 @@ export function useDesignSetting() {
```vue
<template>
<PageWrapper>
<el-card :bordered="false" class="pt-3 mb-3 proCard">
<div>
<n-card :bordered="false" class="pt-3 mb-3 proCard">
<!-- 搜索区域 -->
</el-card>
<el-card :bordered="false" class="proCard">
</n-card>
<n-card :bordered="false" class="proCard">
<!-- 表格区域 -->
</el-card>
</PageWrapper>
</n-card>
</div>
</template>
```
@@ -152,4 +149,4 @@ export function useDesignSetting() {
## 总结
样式方案采用 Tailwind CSS 提供原子化样式 + SCSS 全局变量(Vite `additionalData` 注入)+ ElementPlus 主题覆盖,支持深色模式切换。`designSetting` store 管理主题配置,`PageWrapper` 组件提供统一页面容器。
样式方案采用 Tailwind CSS 提供原子化样式 + SCSS 全局变量(Vite `additionalData` 注入)+ NaiveUI 主题覆盖,支持深色模式切换。`designSetting` store 管理主题配置,`PageWrapper` 组件提供统一页面容器。