@admin-core/design 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +698 -0
- package/README.md +588 -285
- package/dist/index.cjs +5 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2616 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +5 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/theme/composables.d.ts +89 -0
- package/dist/theme/composables.d.ts.map +1 -0
- package/dist/theme/constants.d.ts +56 -0
- package/dist/theme/constants.d.ts.map +1 -0
- package/dist/theme/i18n/en-US.d.ts +3 -0
- package/dist/theme/i18n/en-US.d.ts.map +1 -0
- package/dist/theme/i18n/index.d.ts +34 -0
- package/dist/theme/i18n/index.d.ts.map +1 -0
- package/dist/theme/i18n/zh-CN.d.ts +69 -0
- package/dist/theme/i18n/zh-CN.d.ts.map +1 -0
- package/dist/theme/index.d.ts +52 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/integration.d.ts +124 -0
- package/dist/theme/integration.d.ts.map +1 -0
- package/dist/theme/types.d.ts +135 -0
- package/dist/theme/types.d.ts.map +1 -0
- package/dist/theme/utils.d.ts +230 -0
- package/dist/theme/utils.d.ts.map +1 -0
- package/package.json +32 -4
- package/src/css/base.css +145 -0
- package/src/css/components.css +96 -0
- package/src/css/index.css +21 -0
- package/src/css/integrations/ant-design-vue.css +64 -0
- package/src/css/integrations/arco-design.css +62 -0
- package/src/css/integrations/element-plus.css +157 -0
- package/src/css/integrations/index.css +17 -0
- package/src/css/integrations/naive-ui.css +60 -0
- package/src/css/nprogress.css +74 -0
- package/src/css/transition.css +256 -0
- package/src/css/ui.css +117 -0
- package/src/css/utilities.css +138 -0
- package/src/tokens/dark.css +406 -0
- package/src/tokens/index.ts +6 -0
- package/src/tokens/light.css +297 -0
package/README.md
CHANGED
|
@@ -1,395 +1,698 @@
|
|
|
1
1
|
# @admin-core/design
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<div align="center">
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**现代化的 Vue 3 设计系统**
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
npm
|
|
7
|
+
基于 Tailwind CSS v4 的完整设计系统,提供主题管理、设计令牌和第三方组件库集成
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/@admin-core/design)
|
|
10
|
+
[](https://github.com/jackBoVip/admin-kit/blob/main/LICENSE)
|
|
11
|
+
|
|
12
|
+
[English](./README.en.md) | 简体中文
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## ✨ 特性
|
|
19
|
+
|
|
20
|
+
- 🎨 **15+ 预设主题** - 2026 流行色系列,支持浅色/暗色模式
|
|
21
|
+
- 🔧 **Tailwind CSS v4** - 使用最新的 Tailwind CSS v4 特性
|
|
22
|
+
- 🎯 **设计令牌** - 基于 CSS 变量的设计令牌系统
|
|
23
|
+
- 🔌 **第三方集成** - 开箱即用的 Element Plus、Ant Design Vue 等组件库主题集成
|
|
24
|
+
- 🌍 **国际化** - 支持中英文主题名称和描述
|
|
25
|
+
- 🎭 **自定义主题** - 智能配色算法,只需选择主色即可生成完整主题
|
|
26
|
+
- 📦 **TypeScript** - 完整的 TypeScript 类型支持
|
|
27
|
+
- 🚀 **零配置** - 导入即用,无需复杂配置
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 📦 安装
|
|
10
32
|
|
|
11
|
-
|
|
33
|
+
```bash
|
|
34
|
+
# 使用 pnpm
|
|
12
35
|
pnpm add @admin-core/design
|
|
13
36
|
|
|
14
|
-
#
|
|
37
|
+
# 使用 npm
|
|
38
|
+
npm install @admin-core/design
|
|
39
|
+
|
|
40
|
+
# 使用 yarn
|
|
15
41
|
yarn add @admin-core/design
|
|
16
42
|
```
|
|
17
43
|
|
|
18
|
-
|
|
44
|
+
---
|
|
19
45
|
|
|
20
|
-
|
|
46
|
+
## 🚀 快速开始
|
|
21
47
|
|
|
22
|
-
|
|
48
|
+
### 基础使用
|
|
23
49
|
|
|
24
50
|
```typescript
|
|
51
|
+
// main.ts
|
|
52
|
+
import { createApp } from 'vue'
|
|
53
|
+
import App from './App.vue'
|
|
54
|
+
|
|
55
|
+
// 导入设计系统
|
|
25
56
|
import '@admin-core/design/css'
|
|
26
57
|
|
|
27
|
-
|
|
28
|
-
|
|
58
|
+
const app = createApp(App)
|
|
59
|
+
app.mount('#app')
|
|
29
60
|
```
|
|
30
61
|
|
|
31
|
-
|
|
62
|
+
### 在组件中使用
|
|
32
63
|
|
|
33
|
-
```
|
|
34
|
-
|
|
64
|
+
```vue
|
|
65
|
+
<template>
|
|
66
|
+
<div class="min-h-screen bg-background text-foreground">
|
|
67
|
+
<div class="card-box p-6 rounded-lg">
|
|
68
|
+
<h1 class="text-2xl font-bold text-primary">欢迎使用 Admin Core</h1>
|
|
69
|
+
<p class="text-muted-foreground mt-2">现代化的设计系统</p>
|
|
70
|
+
|
|
71
|
+
<button class="mt-4 bg-primary text-primary-foreground px-4 py-2 rounded-md hover:bg-primary/90">
|
|
72
|
+
开始使用
|
|
73
|
+
</button>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</template>
|
|
35
77
|
```
|
|
36
78
|
|
|
37
|
-
|
|
79
|
+
---
|
|
38
80
|
|
|
39
|
-
|
|
81
|
+
## 🎨 主题系统
|
|
40
82
|
|
|
41
|
-
|
|
42
|
-
// 导入 BEM Mixin 工具
|
|
43
|
-
@use '@admin-core/design/scss-bem' as *;
|
|
83
|
+
### 切换暗色模式
|
|
44
84
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
@include e(icon) {
|
|
50
|
-
margin-right: 8px;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@include m(primary) {
|
|
54
|
-
background: blue;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
@include is(disabled) {
|
|
58
|
-
opacity: 0.5;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
85
|
+
```typescript
|
|
86
|
+
// 切换暗色模式
|
|
87
|
+
document.documentElement.classList.toggle('dark')
|
|
61
88
|
```
|
|
62
89
|
|
|
63
|
-
|
|
90
|
+
```html
|
|
91
|
+
<!-- 浅色模式(默认) -->
|
|
92
|
+
<html>
|
|
93
|
+
<body>...</body>
|
|
94
|
+
</html>
|
|
64
95
|
|
|
65
|
-
|
|
96
|
+
<!-- 暗色模式 -->
|
|
97
|
+
<html class="dark">
|
|
98
|
+
<body>...</body>
|
|
99
|
+
</html>
|
|
100
|
+
```
|
|
66
101
|
|
|
67
|
-
|
|
102
|
+
### 切换主题变体
|
|
68
103
|
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<!-- JavaScript -->
|
|
74
|
-
<script src="https://unpkg.com/@admin-core/design/dist/index.umd.js"></script>
|
|
75
|
-
<script>
|
|
76
|
-
// 全局变量 AdminKitDesign
|
|
77
|
-
console.log(AdminKitDesign)
|
|
78
|
-
</script>
|
|
104
|
+
```typescript
|
|
105
|
+
// 设置主题
|
|
106
|
+
document.documentElement.setAttribute('data-theme', 'deep-teal')
|
|
79
107
|
```
|
|
80
108
|
|
|
81
|
-
#### jsDelivr
|
|
82
|
-
|
|
83
109
|
```html
|
|
84
|
-
<!--
|
|
85
|
-
<
|
|
110
|
+
<!-- 深邃青主题 -->
|
|
111
|
+
<html data-theme="deep-teal">
|
|
112
|
+
<body>...</body>
|
|
113
|
+
</html>
|
|
114
|
+
|
|
115
|
+
<!-- 暗色 + 深邃青主题 -->
|
|
116
|
+
<html class="dark" data-theme="deep-teal">
|
|
117
|
+
<body>...</body>
|
|
118
|
+
</html>
|
|
119
|
+
```
|
|
86
120
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
121
|
+
### 可用主题(15 个 2026 流行色)
|
|
122
|
+
|
|
123
|
+
| 主题 ID | 名称 | 描述 |
|
|
124
|
+
|---------|------|------|
|
|
125
|
+
| `default` | 经典蓝 | 适合大多数场景的经典蓝色主题 |
|
|
126
|
+
| `slate` | 石板灰 | 专业沉稳的中性灰色调 |
|
|
127
|
+
| `burnished-lilac` | 烟熏薰衣草 | 优雅神秘的紫灰色调 |
|
|
128
|
+
| `teaberry` | 茶莓红 | 活力四射的玫瑰红色调 |
|
|
129
|
+
| `amaranth` | 苋菜紫 | 高贵典雅的深紫色调 |
|
|
130
|
+
| `pulse-blue` | 脉冲蓝 | 充满活力的明亮蓝色 |
|
|
131
|
+
| `deep-teal` | 深邃青 | 沉稳大气的青色调 |
|
|
132
|
+
| `mermaid-aqua` | 美人鱼蓝 | 清新梦幻的水蓝色 |
|
|
133
|
+
| `pearl-purple` | 珍珠紫 | 柔和优雅的淡紫色 |
|
|
134
|
+
| `burgundy` | 勃艮第 | 成熟稳重的酒红色 |
|
|
135
|
+
| `burnt-sienna` | 焦赭石 | 温暖复古的橙棕色 |
|
|
136
|
+
| `olive-sage` | 橄榄绿 | 自然清新的橄榄绿 |
|
|
137
|
+
| `champagne-gold` | 香槟金 | 奢华典雅的金色调 |
|
|
138
|
+
| `dusty-rose` | 灰玫瑰 | 温柔浪漫的粉灰色 |
|
|
139
|
+
| `citrus-green` | 柑橘绿 | 清新活力的柠檬绿 |
|
|
140
|
+
|
|
141
|
+
### 使用 Vue Composable
|
|
142
|
+
|
|
143
|
+
```vue
|
|
144
|
+
<script setup lang="ts">
|
|
145
|
+
import { useTheme } from '@admin-core/design'
|
|
146
|
+
|
|
147
|
+
const {
|
|
148
|
+
mode, // 当前模式:'light' | 'dark'
|
|
149
|
+
variant, // 当前主题变体
|
|
150
|
+
isDark, // 是否暗色模式
|
|
151
|
+
setMode, // 设置模式
|
|
152
|
+
setVariant, // 设置主题变体
|
|
153
|
+
toggleDarkMode, // 切换暗色模式
|
|
154
|
+
} = useTheme()
|
|
155
|
+
|
|
156
|
+
// 切换暗色模式
|
|
157
|
+
const handleToggle = () => {
|
|
158
|
+
toggleDarkMode()
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// 切换主题
|
|
162
|
+
const handleThemeChange = (theme: string) => {
|
|
163
|
+
setVariant(theme)
|
|
164
|
+
}
|
|
91
165
|
</script>
|
|
166
|
+
|
|
167
|
+
<template>
|
|
168
|
+
<div>
|
|
169
|
+
<button @click="handleToggle">
|
|
170
|
+
{{ isDark ? '切换到浅色' : '切换到暗色' }}
|
|
171
|
+
</button>
|
|
172
|
+
|
|
173
|
+
<select @change="handleThemeChange($event.target.value)">
|
|
174
|
+
<option value="default">经典蓝</option>
|
|
175
|
+
<option value="deep-teal">深邃青</option>
|
|
176
|
+
<option value="teaberry">茶莓红</option>
|
|
177
|
+
</select>
|
|
178
|
+
</div>
|
|
179
|
+
</template>
|
|
92
180
|
```
|
|
93
181
|
|
|
94
|
-
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## 🎯 自定义主题
|
|
185
|
+
|
|
186
|
+
### 智能配色
|
|
187
|
+
|
|
188
|
+
只需选择主色,系统会自动生成完整的配色方案:
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
import { applyThemeFromPrimary } from '@admin-core/design'
|
|
192
|
+
|
|
193
|
+
// 使用 HEX 颜色
|
|
194
|
+
applyThemeFromPrimary('#8B5CF6')
|
|
95
195
|
|
|
96
|
-
|
|
196
|
+
// 使用 HSL 颜色
|
|
197
|
+
applyThemeFromPrimary('280 60% 50%')
|
|
97
198
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
199
|
+
// 指定模式并持久化
|
|
200
|
+
applyThemeFromPrimary('#8B5CF6', 'dark', true)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### 完全自定义
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
import { applyCustomTheme } from '@admin-core/design'
|
|
207
|
+
|
|
208
|
+
applyCustomTheme({
|
|
209
|
+
primary: '280 60% 50%',
|
|
210
|
+
secondary: '280 30% 90%',
|
|
211
|
+
accent: '280 55% 85%',
|
|
212
|
+
// ... 更多颜色
|
|
213
|
+
}, true) // true 表示持久化到 localStorage
|
|
214
|
+
```
|
|
104
215
|
|
|
105
216
|
---
|
|
106
217
|
|
|
107
|
-
|
|
218
|
+
## 🔌 第三方组件库集成
|
|
108
219
|
|
|
109
|
-
|
|
220
|
+
### 一行代码集成
|
|
110
221
|
|
|
111
|
-
|
|
222
|
+
我们提供了开箱即用的第三方组件库主题集成文件:
|
|
112
223
|
|
|
113
|
-
|
|
224
|
+
#### Element Plus
|
|
114
225
|
|
|
115
|
-
|
|
226
|
+
```typescript
|
|
227
|
+
// main.ts
|
|
228
|
+
import ElementPlus from 'element-plus'
|
|
229
|
+
import 'element-plus/dist/index.css'
|
|
230
|
+
import '@admin-core/design/css'
|
|
116
231
|
|
|
117
|
-
|
|
118
|
-
-
|
|
119
|
-
- 提供 12 种预设主题变体(default、violet、pink、rose、sky-blue、deep-blue、green、deep-green、orange、yellow、zinc、neutral、slate、gray)
|
|
120
|
-
- 作为整个设计系统的颜色基础
|
|
232
|
+
// 一行代码集成!
|
|
233
|
+
import '@admin-core/design/css/integrations/element-plus.css'
|
|
121
234
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
- `--foreground` - 文字颜色
|
|
125
|
-
- `--primary` - 主题色
|
|
126
|
-
- `--secondary` - 次要色
|
|
127
|
-
- `--accent` - 强调色
|
|
128
|
-
- `--destructive` - 危险操作色
|
|
129
|
-
- `--success` - 成功提示色
|
|
130
|
-
- `--warning` - 警告提示色
|
|
131
|
-
- `--border` - 边框色
|
|
132
|
-
- `--input` - 输入框边框色
|
|
133
|
-
- `--card` - 卡片背景色
|
|
134
|
-
- `--popover` - 弹出层背景色
|
|
235
|
+
app.use(ElementPlus)
|
|
236
|
+
```
|
|
135
237
|
|
|
136
|
-
|
|
137
|
-
```html
|
|
138
|
-
<!-- 默认主题 -->
|
|
139
|
-
<html>
|
|
140
|
-
<body>默认浅色主题</body>
|
|
141
|
-
</html>
|
|
238
|
+
#### Ant Design Vue
|
|
142
239
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
240
|
+
```typescript
|
|
241
|
+
import Antd from 'ant-design-vue'
|
|
242
|
+
import 'ant-design-vue/dist/reset.css'
|
|
243
|
+
import '@admin-core/design/css'
|
|
244
|
+
import '@admin-core/design/css/integrations/ant-design-vue.css'
|
|
245
|
+
|
|
246
|
+
app.use(Antd)
|
|
147
247
|
```
|
|
148
248
|
|
|
149
|
-
|
|
249
|
+
#### Naive UI
|
|
150
250
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
-
|
|
154
|
-
-
|
|
155
|
-
- 通过 `.dark` 类名自动应用
|
|
251
|
+
```typescript
|
|
252
|
+
import naive from 'naive-ui'
|
|
253
|
+
import '@admin-core/design/css'
|
|
254
|
+
import '@admin-core/design/css/integrations/naive-ui.css'
|
|
156
255
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
- 前景色使用浅色调(高亮度值)
|
|
160
|
-
- 优化的对比度,确保文字可读性
|
|
161
|
-
- 减少夜间使用时的眼睛疲劳
|
|
256
|
+
app.use(naive)
|
|
257
|
+
```
|
|
162
258
|
|
|
163
|
-
|
|
164
|
-
```html
|
|
165
|
-
<!-- 暗色模式 -->
|
|
166
|
-
<html class="dark">
|
|
167
|
-
<body>默认暗色主题</body>
|
|
168
|
-
</html>
|
|
259
|
+
#### Arco Design
|
|
169
260
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
261
|
+
```typescript
|
|
262
|
+
import ArcoVue from '@arco-design/web-vue'
|
|
263
|
+
import '@arco-design/web-vue/dist/arco.css'
|
|
264
|
+
import '@admin-core/design/css'
|
|
265
|
+
import '@admin-core/design/css/integrations/arco-design.css'
|
|
266
|
+
|
|
267
|
+
app.use(ArcoVue)
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### 集成效果
|
|
271
|
+
|
|
272
|
+
✅ **主题自动同步** - 切换主题,组件库颜色立即更新
|
|
273
|
+
✅ **暗色模式支持** - 切换暗色模式,组件库自动适配
|
|
274
|
+
✅ **自定义主题** - 使用自定义主题,组件库同步应用
|
|
275
|
+
✅ **零配置** - 无需任何额外配置
|
|
276
|
+
✅ **高性能** - 基于 CSS 变量,性能优秀
|
|
277
|
+
|
|
278
|
+
### 高级用法:使用 ConfigProvider
|
|
279
|
+
|
|
280
|
+
```vue
|
|
281
|
+
<template>
|
|
282
|
+
<a-config-provider :theme="antdTheme">
|
|
283
|
+
<router-view />
|
|
284
|
+
</a-config-provider>
|
|
285
|
+
</template>
|
|
286
|
+
|
|
287
|
+
<script setup lang="ts">
|
|
288
|
+
import { computed } from 'vue'
|
|
289
|
+
import { theme } from 'ant-design-vue'
|
|
290
|
+
import { useTheme, getRGBColor } from '@admin-core/design'
|
|
291
|
+
|
|
292
|
+
const { isDark } = useTheme()
|
|
293
|
+
|
|
294
|
+
const antdTheme = computed(() => ({
|
|
295
|
+
algorithm: isDark.value ? theme.darkAlgorithm : theme.defaultAlgorithm,
|
|
296
|
+
token: {
|
|
297
|
+
colorPrimary: getRGBColor('primary'),
|
|
298
|
+
colorSuccess: getRGBColor('success'),
|
|
299
|
+
colorWarning: getRGBColor('warning'),
|
|
300
|
+
colorError: getRGBColor('destructive'),
|
|
301
|
+
},
|
|
302
|
+
}))
|
|
303
|
+
</script>
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### 集成工具函数
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
import {
|
|
310
|
+
getHSLColor, // 获取 HSL 格式颜色
|
|
311
|
+
getRGBColor, // 获取 RGB 格式颜色
|
|
312
|
+
getHexColor, // 获取 HEX 格式颜色
|
|
313
|
+
getThemeColors, // 批量获取所有颜色(HSL)
|
|
314
|
+
getThemeColorsRGB,// 批量获取所有颜色(RGB)
|
|
315
|
+
getThemeColorsHex,// 批量获取所有颜色(HEX)
|
|
316
|
+
} from '@admin-core/design'
|
|
317
|
+
|
|
318
|
+
// 获取单个颜色
|
|
319
|
+
const primaryHSL = getHSLColor('primary') // 'hsl(212, 100%, 48%)'
|
|
320
|
+
const primaryRGB = getRGBColor('primary') // 'rgb(0, 102, 245)'
|
|
321
|
+
const primaryHex = getHexColor('primary') // '#0066F5'
|
|
322
|
+
|
|
323
|
+
// 批量获取所有颜色
|
|
324
|
+
const allColors = getThemeColors()
|
|
174
325
|
```
|
|
175
326
|
|
|
176
|
-
|
|
327
|
+
---
|
|
177
328
|
|
|
178
|
-
|
|
329
|
+
## 🌍 国际化
|
|
179
330
|
|
|
180
|
-
|
|
181
|
-
|---------|--------------|------|
|
|
182
|
-
| 默认 | 不设置 | 蓝色系主题 |
|
|
183
|
-
| 紫罗兰 | `violet` | 紫色系主题 |
|
|
184
|
-
| 粉色 | `pink` | 粉色系主题 |
|
|
185
|
-
| 玫瑰 | `rose` | 玫瑰色系主题 |
|
|
186
|
-
| 天蓝 | `sky-blue` | 天蓝色系主题 |
|
|
187
|
-
| 深蓝 | `deep-blue` | 深蓝色系主题 |
|
|
188
|
-
| 绿色 | `green` | 绿色系主题 |
|
|
189
|
-
| 深绿 | `deep-green` | 深绿色系主题 |
|
|
190
|
-
| 橙色 | `orange` | 橙色系主题 |
|
|
191
|
-
| 黄色 | `yellow` | 黄色系主题 |
|
|
192
|
-
| 锌灰 | `zinc` | 锌灰色系主题 |
|
|
193
|
-
| 中性灰 | `neutral` | 中性灰色系主题 |
|
|
194
|
-
| 石板灰 | `slate` | 石板灰色系主题 |
|
|
195
|
-
| 灰色 | `gray` | 灰色系主题 |
|
|
331
|
+
### 设置语言
|
|
196
332
|
|
|
197
|
-
|
|
333
|
+
```typescript
|
|
334
|
+
import { setLocale, getLocale } from '@admin-core/design'
|
|
198
335
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
// 切换到暗色模式
|
|
202
|
-
document.documentElement.classList.add('dark')
|
|
336
|
+
// 设置为英文
|
|
337
|
+
setLocale('en-US')
|
|
203
338
|
|
|
204
|
-
//
|
|
205
|
-
|
|
339
|
+
// 设置为中文
|
|
340
|
+
setLocale('zh-CN')
|
|
206
341
|
|
|
207
|
-
//
|
|
208
|
-
|
|
342
|
+
// 获取当前语言
|
|
343
|
+
const currentLocale = getLocale() // 'zh-CN' | 'en-US'
|
|
209
344
|
```
|
|
210
345
|
|
|
211
|
-
|
|
346
|
+
### 获取国际化主题信息
|
|
347
|
+
|
|
212
348
|
```typescript
|
|
213
|
-
import {
|
|
349
|
+
import { getThemeName, getThemeDescription, getThemeMetadata } from '@admin-core/design'
|
|
214
350
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
351
|
+
// 获取主题名称(根据当前语言)
|
|
352
|
+
const name = getThemeName('deep-teal')
|
|
353
|
+
// 中文: '深邃青'
|
|
354
|
+
// 英文: 'Deep Teal'
|
|
218
355
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
356
|
+
// 获取主题描述
|
|
357
|
+
const description = getThemeDescription('deep-teal')
|
|
358
|
+
// 中文: '2026流行色 - 深邃的青色,沉稳大气'
|
|
359
|
+
// 英文: '2026 Trending Color - Deep teal, calm and atmospheric'
|
|
223
360
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
361
|
+
// 获取所有主题(自动国际化)
|
|
362
|
+
const themes = getThemeMetadata()
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### 在 Vue 组件中使用
|
|
366
|
+
|
|
367
|
+
```vue
|
|
368
|
+
<script setup lang="ts">
|
|
369
|
+
import { ref, computed } from 'vue'
|
|
370
|
+
import { setLocale, getLocale, getThemeMetadata, type Locale } from '@admin-core/design'
|
|
228
371
|
|
|
229
|
-
|
|
372
|
+
const currentLocale = ref<Locale>(getLocale())
|
|
373
|
+
const themes = ref(getThemeMetadata())
|
|
374
|
+
|
|
375
|
+
const changeLanguage = (locale: Locale) => {
|
|
376
|
+
setLocale(locale)
|
|
377
|
+
currentLocale.value = locale
|
|
378
|
+
themes.value = getThemeMetadata() // 重新获取以更新语言
|
|
230
379
|
}
|
|
380
|
+
</script>
|
|
381
|
+
|
|
382
|
+
<template>
|
|
383
|
+
<div>
|
|
384
|
+
<select v-model="currentLocale" @change="changeLanguage(currentLocale)">
|
|
385
|
+
<option value="zh-CN">🇨🇳 中文</option>
|
|
386
|
+
<option value="en-US">🇺🇸 English</option>
|
|
387
|
+
</select>
|
|
388
|
+
|
|
389
|
+
<select>
|
|
390
|
+
<option v-for="theme in themes" :key="theme.id" :value="theme.id">
|
|
391
|
+
{{ theme.icon }} {{ theme.name }}
|
|
392
|
+
</option>
|
|
393
|
+
</select>
|
|
394
|
+
</div>
|
|
395
|
+
</template>
|
|
231
396
|
```
|
|
232
397
|
|
|
233
|
-
|
|
398
|
+
---
|
|
234
399
|
|
|
235
|
-
|
|
400
|
+
## 🎨 设计令牌
|
|
401
|
+
|
|
402
|
+
所有颜色都使用 HSL 格式的 CSS 变量定义,支持透明度修饰符:
|
|
403
|
+
|
|
404
|
+
### 基础颜色
|
|
405
|
+
|
|
406
|
+
```html
|
|
407
|
+
<!-- 背景和前景 -->
|
|
408
|
+
<div class="bg-background text-foreground">内容</div>
|
|
409
|
+
|
|
410
|
+
<!-- 卡片 -->
|
|
411
|
+
<div class="bg-card text-card-foreground">卡片内容</div>
|
|
412
|
+
|
|
413
|
+
<!-- 弹出层 -->
|
|
414
|
+
<div class="bg-popover text-popover-foreground">弹出内容</div>
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
### 语义颜色
|
|
418
|
+
|
|
419
|
+
```html
|
|
420
|
+
<!-- 主色 -->
|
|
421
|
+
<button class="bg-primary text-primary-foreground">主要按钮</button>
|
|
422
|
+
|
|
423
|
+
<!-- 次要色 -->
|
|
424
|
+
<button class="bg-secondary text-secondary-foreground">次要按钮</button>
|
|
425
|
+
|
|
426
|
+
<!-- 强调色 -->
|
|
427
|
+
<div class="bg-accent text-accent-foreground">强调内容</div>
|
|
428
|
+
|
|
429
|
+
<!-- 柔和色 -->
|
|
430
|
+
<div class="bg-muted text-muted-foreground">柔和内容</div>
|
|
431
|
+
|
|
432
|
+
<!-- 破坏性操作 -->
|
|
433
|
+
<button class="bg-destructive text-destructive-foreground">删除</button>
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### 状态颜色
|
|
437
|
+
|
|
438
|
+
```html
|
|
439
|
+
<!-- 成功 -->
|
|
440
|
+
<div class="bg-success text-success-foreground">操作成功</div>
|
|
441
|
+
|
|
442
|
+
<!-- 警告 -->
|
|
443
|
+
<div class="bg-warning text-warning-foreground">警告信息</div>
|
|
444
|
+
|
|
445
|
+
<!-- 信息 -->
|
|
446
|
+
<div class="bg-info text-info-foreground">提示信息</div>
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### 透明度修饰符
|
|
450
|
+
|
|
451
|
+
```html
|
|
452
|
+
<div class="bg-primary/10">10% 透明度</div>
|
|
453
|
+
<div class="bg-primary/50">50% 透明度</div>
|
|
454
|
+
<div class="bg-primary/90">90% 透明度</div>
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### 在 CSS 中使用
|
|
236
458
|
|
|
237
459
|
```css
|
|
238
|
-
.my-
|
|
239
|
-
/* 使用主题色 */
|
|
460
|
+
.my-component {
|
|
240
461
|
background-color: hsl(var(--primary));
|
|
241
462
|
color: hsl(var(--primary-foreground));
|
|
242
|
-
|
|
243
|
-
/* 使用边框色 */
|
|
244
463
|
border: 1px solid hsl(var(--border));
|
|
245
|
-
|
|
246
|
-
/* 使用圆角 */
|
|
247
464
|
border-radius: var(--radius);
|
|
248
465
|
}
|
|
249
466
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
background-color: hsl(var(--
|
|
467
|
+
/* 使用透明度 */
|
|
468
|
+
.my-overlay {
|
|
469
|
+
background-color: hsl(var(--primary) / 0.5);
|
|
253
470
|
}
|
|
471
|
+
```
|
|
254
472
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
473
|
+
---
|
|
474
|
+
|
|
475
|
+
## 🛠️ 工具类
|
|
476
|
+
|
|
477
|
+
### 布局工具类
|
|
478
|
+
|
|
479
|
+
```html
|
|
480
|
+
<!-- 水平居中 -->
|
|
481
|
+
<div class="flex-center">
|
|
482
|
+
<div>居中内容</div>
|
|
483
|
+
</div>
|
|
484
|
+
|
|
485
|
+
<!-- 垂直居中 -->
|
|
486
|
+
<div class="flex-col-center">
|
|
487
|
+
<div>垂直居中</div>
|
|
488
|
+
</div>
|
|
489
|
+
|
|
490
|
+
<!-- 卡片容器 -->
|
|
491
|
+
<div class="card-box p-6">
|
|
492
|
+
<h3>卡片标题</h3>
|
|
493
|
+
<p>卡片内容</p>
|
|
494
|
+
</div>
|
|
495
|
+
|
|
496
|
+
<!-- 轮廓框 -->
|
|
497
|
+
<div class="outline-box">
|
|
498
|
+
可点击的框
|
|
499
|
+
</div>
|
|
500
|
+
|
|
501
|
+
<div class="outline-box outline-box-active">
|
|
502
|
+
激活状态的框
|
|
503
|
+
</div>
|
|
260
504
|
```
|
|
261
505
|
|
|
262
|
-
###
|
|
506
|
+
### 链接样式
|
|
263
507
|
|
|
264
|
-
|
|
508
|
+
```html
|
|
509
|
+
<a href="#" class="admin-link">链接文本</a>
|
|
510
|
+
```
|
|
265
511
|
|
|
266
|
-
|
|
267
|
-
/* ✅ 正确 */
|
|
268
|
-
background-color: hsl(var(--primary));
|
|
512
|
+
---
|
|
269
513
|
|
|
270
|
-
|
|
271
|
-
|
|
514
|
+
## 📱 响应式设计
|
|
515
|
+
|
|
516
|
+
```html
|
|
517
|
+
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
|
518
|
+
<div class="card-box p-4">卡片 1</div>
|
|
519
|
+
<div class="card-box p-4">卡片 2</div>
|
|
520
|
+
<div class="card-box p-4">卡片 3</div>
|
|
521
|
+
</div>
|
|
272
522
|
```
|
|
273
523
|
|
|
274
|
-
|
|
524
|
+
---
|
|
275
525
|
|
|
276
|
-
|
|
526
|
+
## 🎭 特殊模式
|
|
277
527
|
|
|
278
|
-
|
|
279
|
-
/* 50% 透明度的主题色 */
|
|
280
|
-
background-color: hsl(var(--primary) / 0.5);
|
|
528
|
+
### 反色模式
|
|
281
529
|
|
|
282
|
-
|
|
283
|
-
|
|
530
|
+
```html
|
|
531
|
+
<html class="invert-mode">
|
|
532
|
+
<body>所有颜色反转</body>
|
|
533
|
+
</html>
|
|
284
534
|
```
|
|
285
535
|
|
|
286
|
-
|
|
536
|
+
### 灰度模式
|
|
287
537
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
538
|
+
```html
|
|
539
|
+
<html class="grayscale-mode">
|
|
540
|
+
<body>所有颜色变为灰度</body>
|
|
541
|
+
</html>
|
|
542
|
+
```
|
|
292
543
|
|
|
293
|
-
|
|
294
|
-
- `--card` - 卡片背景
|
|
295
|
-
- `--popover` - 弹出层背景
|
|
296
|
-
- `--input` - 输入框边框
|
|
297
|
-
- `--muted` - 柔和背景
|
|
544
|
+
---
|
|
298
545
|
|
|
299
|
-
|
|
300
|
-
- `--primary` - 主题色(品牌色)
|
|
301
|
-
- `--secondary` - 次要色
|
|
302
|
-
- `--accent` - 强调色(悬停效果)
|
|
303
|
-
- `--destructive` - 危险操作(删除、警告)
|
|
304
|
-
- `--success` - 成功提示
|
|
305
|
-
- `--warning` - 警告提示
|
|
306
|
-
- `--info` - 信息提示
|
|
307
|
-
|
|
308
|
-
### 布局组件
|
|
309
|
-
- `--sidebar` - 侧边栏背景
|
|
310
|
-
- `--header` - 头部背景
|
|
311
|
-
- `--menu` - 菜单背景
|
|
312
|
-
|
|
313
|
-
### 其他
|
|
314
|
-
- `--radius` - 圆角大小
|
|
315
|
-
- `--ring` - 焦点环颜色
|
|
316
|
-
- `--overlay` - 遮罩颜色
|
|
317
|
-
- `--font-size-base` - 基础字体大小
|
|
318
|
-
|
|
319
|
-
## 最佳实践
|
|
320
|
-
|
|
321
|
-
1. **始终使用语义化变量**
|
|
322
|
-
```css
|
|
323
|
-
/* ✅ 推荐 */
|
|
324
|
-
color: hsl(var(--foreground));
|
|
325
|
-
|
|
326
|
-
/* ❌ 不推荐 */
|
|
327
|
-
color: #000000;
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
2. **为不同状态使用对应的颜色**
|
|
331
|
-
```css
|
|
332
|
-
.button-primary { background: hsl(var(--primary)); }
|
|
333
|
-
.button-danger { background: hsl(var(--destructive)); }
|
|
334
|
-
.button-success { background: hsl(var(--success)); }
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
3. **利用前景色变量确保对比度**
|
|
338
|
-
```css
|
|
339
|
-
.card {
|
|
340
|
-
background: hsl(var(--card));
|
|
341
|
-
color: hsl(var(--card-foreground));
|
|
342
|
-
}
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
4. **使用 accent 系列实现悬停效果**
|
|
346
|
-
```css
|
|
347
|
-
.menu-item {
|
|
348
|
-
background: transparent;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
.menu-item:hover {
|
|
352
|
-
background: hsl(var(--accent));
|
|
353
|
-
color: hsl(var(--accent-foreground));
|
|
354
|
-
}
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
## 扩展自定义主题
|
|
358
|
-
|
|
359
|
-
如需添加新的主题变体,在对应的 CSS 文件中添加:
|
|
546
|
+
## ⚙️ Tailwind CSS 配置
|
|
360
547
|
|
|
361
|
-
|
|
362
|
-
/* light.css */
|
|
363
|
-
[data-theme='my-theme'] {
|
|
364
|
-
--primary: 200 100% 50%;
|
|
365
|
-
--primary-foreground: 0 0% 100%;
|
|
366
|
-
/* ... 其他变量 */
|
|
367
|
-
}
|
|
548
|
+
如果你的项目需要扩展 Tailwind 配置:
|
|
368
549
|
|
|
369
|
-
|
|
370
|
-
.
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
550
|
+
```typescript
|
|
551
|
+
// tailwind.config.ts
|
|
552
|
+
import designConfig from '@admin-core/design/tailwind.config'
|
|
553
|
+
import type { Config } from 'tailwindcss'
|
|
554
|
+
|
|
555
|
+
export default {
|
|
556
|
+
...designConfig,
|
|
557
|
+
content: [
|
|
558
|
+
...designConfig.content,
|
|
559
|
+
'./src/**/*.{vue,js,ts,jsx,tsx}',
|
|
560
|
+
],
|
|
561
|
+
theme: {
|
|
562
|
+
...designConfig.theme,
|
|
563
|
+
extend: {
|
|
564
|
+
...designConfig.theme.extend,
|
|
565
|
+
// 你的自定义扩展
|
|
566
|
+
colors: {
|
|
567
|
+
brand: '#FF6B6B',
|
|
568
|
+
},
|
|
569
|
+
},
|
|
570
|
+
},
|
|
571
|
+
} satisfies Config
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
---
|
|
575
|
+
|
|
576
|
+
## 📚 API 参考
|
|
577
|
+
|
|
578
|
+
### 主题管理
|
|
579
|
+
|
|
580
|
+
```typescript
|
|
581
|
+
// Composable
|
|
582
|
+
const {
|
|
583
|
+
mode, // 当前模式
|
|
584
|
+
variant, // 当前主题变体
|
|
585
|
+
isDark, // 是否暗色模式
|
|
586
|
+
setMode, // 设置模式
|
|
587
|
+
setVariant, // 设置主题变体
|
|
588
|
+
toggleDarkMode, // 切换暗色模式
|
|
589
|
+
getCurrentThemeMetadata, // 获取当前主题元数据
|
|
590
|
+
} = useTheme()
|
|
591
|
+
|
|
592
|
+
// 工具函数
|
|
593
|
+
initTheme() // 初始化主题
|
|
594
|
+
applyTheme(config, options) // 应用主题配置
|
|
595
|
+
detectSystemTheme() // 检测系统主题
|
|
596
|
+
watchSystemTheme(callback) // 监听系统主题变化
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
### 自定义主题
|
|
600
|
+
|
|
601
|
+
```typescript
|
|
602
|
+
// 智能配色
|
|
603
|
+
applyThemeFromPrimary(color, mode?, persist?)
|
|
604
|
+
|
|
605
|
+
// 完全自定义
|
|
606
|
+
applyCustomTheme(colors, persist?)
|
|
607
|
+
|
|
608
|
+
// 清除自定义主题
|
|
609
|
+
clearCustomTheme()
|
|
610
|
+
|
|
611
|
+
// 恢复自定义主题
|
|
612
|
+
restoreCustomTheme()
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
### 颜色工具
|
|
616
|
+
|
|
617
|
+
```typescript
|
|
618
|
+
// 获取颜色
|
|
619
|
+
getHSLColor(token) // 获取 HSL 格式
|
|
620
|
+
getRGBColor(token) // 获取 RGB 格式
|
|
621
|
+
getHexColor(token) // 获取 HEX 格式
|
|
622
|
+
|
|
623
|
+
// 批量获取
|
|
624
|
+
getThemeColors() // 所有颜色(HSL)
|
|
625
|
+
getThemeColorsRGB() // 所有颜色(RGB)
|
|
626
|
+
getThemeColorsHex() // 所有颜色(HEX)
|
|
627
|
+
|
|
628
|
+
// 颜色转换
|
|
629
|
+
hexToHSL(hex) // HEX 转 HSL
|
|
630
|
+
rgbToHSL(r, g, b) // RGB 转 HSL
|
|
631
|
+
hslToRgb(hsl) // HSL 转 RGB
|
|
632
|
+
hslToHex(hsl) // HSL 转 HEX
|
|
375
633
|
```
|
|
376
634
|
|
|
635
|
+
### 国际化
|
|
636
|
+
|
|
637
|
+
```typescript
|
|
638
|
+
setLocale(locale) // 设置语言
|
|
639
|
+
getLocale() // 获取当前语言
|
|
640
|
+
getThemeName(themeId) // 获取主题名称
|
|
641
|
+
getThemeDescription(themeId) // 获取主题描述
|
|
642
|
+
getThemeMetadata() // 获取所有主题元数据
|
|
643
|
+
getTranslations() // 获取当前语言的翻译
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
---
|
|
647
|
+
|
|
648
|
+
## 🌐 浏览器兼容性
|
|
649
|
+
|
|
650
|
+
- Chrome >= 90
|
|
651
|
+
- Firefox >= 88
|
|
652
|
+
- Safari >= 14
|
|
653
|
+
- Edge >= 90
|
|
654
|
+
|
|
377
655
|
---
|
|
378
656
|
|
|
379
|
-
##
|
|
657
|
+
## 📦 导出说明
|
|
658
|
+
|
|
659
|
+
```typescript
|
|
660
|
+
// 主入口
|
|
661
|
+
import '@admin-core/design'
|
|
662
|
+
|
|
663
|
+
// 只导入 CSS
|
|
664
|
+
import '@admin-core/design/css'
|
|
380
665
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
- `dist/index.umd.js` - UMD 格式,用于 CDN(已压缩)
|
|
384
|
-
- `dist/index.d.ts` - TypeScript 类型定义
|
|
385
|
-
- `dist/style.css` - 合并的样式文件(42.20 kB,gzip: 9.01 kB)
|
|
666
|
+
// 导入主题系统
|
|
667
|
+
import { useTheme, setLocale } from '@admin-core/design'
|
|
386
668
|
|
|
387
|
-
|
|
669
|
+
// 导入集成文件
|
|
670
|
+
import '@admin-core/design/css/integrations/element-plus.css'
|
|
671
|
+
import '@admin-core/design/css/integrations/ant-design-vue.css'
|
|
672
|
+
import '@admin-core/design/css/integrations/naive-ui.css'
|
|
673
|
+
import '@admin-core/design/css/integrations/arco-design.css'
|
|
388
674
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
675
|
+
// 导入 Tailwind 配置
|
|
676
|
+
import designConfig from '@admin-core/design/tailwind.config'
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
---
|
|
680
|
+
|
|
681
|
+
## 🤝 贡献
|
|
682
|
+
|
|
683
|
+
欢迎贡献代码、报告问题或提出建议!
|
|
684
|
+
|
|
685
|
+
---
|
|
686
|
+
|
|
687
|
+
## 📄 许可证
|
|
688
|
+
|
|
689
|
+
MIT License © 2024 [Admin Kit Team](https://github.com/jackBoVip/admin-kit)
|
|
690
|
+
|
|
691
|
+
---
|
|
392
692
|
|
|
393
|
-
##
|
|
693
|
+
## 🔗 相关链接
|
|
394
694
|
|
|
395
|
-
|
|
695
|
+
- [GitHub 仓库](https://github.com/jackBoVip/admin-kit)
|
|
696
|
+
- [问题反馈](https://github.com/jackBoVip/admin-kit/issues)
|
|
697
|
+
- [更新日志](./CHANGELOG.md)
|
|
698
|
+
- [Tailwind CSS 文档](https://tailwindcss.com/docs)
|