@admin-core/design 0.2.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 +574 -181
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1142 -877
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +4 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/theme/constants.d.ts +5 -0
- package/dist/theme/constants.d.ts.map +1 -1
- 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 +4 -2
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/integration.d.ts +124 -0
- package/dist/theme/integration.d.ts.map +1 -0
- package/dist/theme/utils.d.ts +1 -1
- package/dist/theme/utils.d.ts.map +1 -1
- package/package.json +18 -11
- 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,88 +1,92 @@
|
|
|
1
|
-
# @admin-
|
|
1
|
+
# @admin-core/design
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<div align="center">
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**现代化的 Vue 3 设计系统**
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- ✅ **主题系统** - 支持浅色/暗色模式,提供 13+ 预设主题
|
|
9
|
-
- ✅ **设计令牌** - 基于 CSS 变量的设计令牌系统
|
|
10
|
-
- ✅ **BEM 工具** - SCSS BEM 命名规范 Mixin 工具集
|
|
11
|
-
- ✅ **动画库** - 丰富的 Vue 过渡动画和 CSS 动画
|
|
12
|
-
- ✅ **TypeScript** - 完整的 TypeScript 类型支持
|
|
7
|
+
基于 Tailwind CSS v4 的完整设计系统,提供主题管理、设计令牌和第三方组件库集成
|
|
13
8
|
|
|
14
|
-
|
|
9
|
+
[](https://www.npmjs.com/package/@admin-core/design)
|
|
10
|
+
[](https://github.com/jackBoVip/admin-kit/blob/main/LICENSE)
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
pnpm add @admin-kit/design
|
|
18
|
-
```
|
|
12
|
+
[English](./README.en.md) | 简体中文
|
|
19
13
|
|
|
20
|
-
|
|
14
|
+
</div>
|
|
21
15
|
|
|
22
|
-
|
|
16
|
+
---
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
// 导入所有样式和令牌
|
|
26
|
-
import '@admin-kit/design'
|
|
27
|
-
```
|
|
18
|
+
## ✨ 特性
|
|
28
19
|
|
|
29
|
-
|
|
20
|
+
- 🎨 **15+ 预设主题** - 2026 流行色系列,支持浅色/暗色模式
|
|
21
|
+
- 🔧 **Tailwind CSS v4** - 使用最新的 Tailwind CSS v4 特性
|
|
22
|
+
- 🎯 **设计令牌** - 基于 CSS 变量的设计令牌系统
|
|
23
|
+
- 🔌 **第三方集成** - 开箱即用的 Element Plus、Ant Design Vue 等组件库主题集成
|
|
24
|
+
- 🌍 **国际化** - 支持中英文主题名称和描述
|
|
25
|
+
- 🎭 **自定义主题** - 智能配色算法,只需选择主色即可生成完整主题
|
|
26
|
+
- 📦 **TypeScript** - 完整的 TypeScript 类型支持
|
|
27
|
+
- 🚀 **零配置** - 导入即用,无需复杂配置
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
// 只导入 CSS
|
|
33
|
-
import '@admin-kit/design/css'
|
|
29
|
+
---
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
import '@admin-kit/design/tokens'
|
|
37
|
-
```
|
|
31
|
+
## 📦 安装
|
|
38
32
|
|
|
39
|
-
|
|
33
|
+
```bash
|
|
34
|
+
# 使用 pnpm
|
|
35
|
+
pnpm add @admin-core/design
|
|
40
36
|
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
# 使用 npm
|
|
38
|
+
npm install @admin-core/design
|
|
43
39
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
@include e(icon) {
|
|
48
|
-
margin-right: 8px;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@include m(primary) {
|
|
52
|
-
background: blue;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
40
|
+
# 使用 yarn
|
|
41
|
+
yarn add @admin-core/design
|
|
55
42
|
```
|
|
56
43
|
|
|
57
|
-
|
|
44
|
+
---
|
|
58
45
|
|
|
59
|
-
|
|
46
|
+
## 🚀 快速开始
|
|
47
|
+
|
|
48
|
+
### 基础使用
|
|
60
49
|
|
|
61
50
|
```typescript
|
|
62
|
-
//
|
|
63
|
-
import
|
|
64
|
-
import
|
|
51
|
+
// main.ts
|
|
52
|
+
import { createApp } from 'vue'
|
|
53
|
+
import App from './App.vue'
|
|
65
54
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
],
|
|
72
|
-
theme: {
|
|
73
|
-
...designConfig.theme,
|
|
74
|
-
extend: {
|
|
75
|
-
...designConfig.theme.extend,
|
|
76
|
-
// 你的自定义扩展
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
} satisfies Config
|
|
55
|
+
// 导入设计系统
|
|
56
|
+
import '@admin-core/design/css'
|
|
57
|
+
|
|
58
|
+
const app = createApp(App)
|
|
59
|
+
app.mount('#app')
|
|
80
60
|
```
|
|
81
61
|
|
|
82
|
-
|
|
62
|
+
### 在组件中使用
|
|
63
|
+
|
|
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>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 🎨 主题系统
|
|
83
82
|
|
|
84
83
|
### 切换暗色模式
|
|
85
84
|
|
|
85
|
+
```typescript
|
|
86
|
+
// 切换暗色模式
|
|
87
|
+
document.documentElement.classList.toggle('dark')
|
|
88
|
+
```
|
|
89
|
+
|
|
86
90
|
```html
|
|
87
91
|
<!-- 浅色模式(默认) -->
|
|
88
92
|
<html>
|
|
@@ -97,157 +101,406 @@ export default {
|
|
|
97
101
|
|
|
98
102
|
### 切换主题变体
|
|
99
103
|
|
|
104
|
+
```typescript
|
|
105
|
+
// 设置主题
|
|
106
|
+
document.documentElement.setAttribute('data-theme', 'deep-teal')
|
|
107
|
+
```
|
|
108
|
+
|
|
100
109
|
```html
|
|
101
|
-
<!--
|
|
102
|
-
<html data-theme="
|
|
110
|
+
<!-- 深邃青主题 -->
|
|
111
|
+
<html data-theme="deep-teal">
|
|
103
112
|
<body>...</body>
|
|
104
113
|
</html>
|
|
105
114
|
|
|
106
|
-
<!-- 暗色 +
|
|
107
|
-
<html class="dark" data-theme="
|
|
115
|
+
<!-- 暗色 + 深邃青主题 -->
|
|
116
|
+
<html class="dark" data-theme="deep-teal">
|
|
108
117
|
<body>...</body>
|
|
109
118
|
</html>
|
|
110
119
|
```
|
|
111
120
|
|
|
112
|
-
###
|
|
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
|
|
113
142
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
+
}
|
|
127
160
|
|
|
128
|
-
|
|
161
|
+
// 切换主题
|
|
162
|
+
const handleThemeChange = (theme: string) => {
|
|
163
|
+
setVariant(theme)
|
|
164
|
+
}
|
|
165
|
+
</script>
|
|
129
166
|
|
|
130
|
-
|
|
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>
|
|
180
|
+
```
|
|
131
181
|
|
|
132
|
-
|
|
133
|
-
<!-- 使用 Tailwind 工具类 -->
|
|
134
|
-
<div class="bg-primary text-primary-foreground">主色按钮</div>
|
|
135
|
-
<div class="bg-primary/50">50% 透明度的主色背景</div>
|
|
182
|
+
---
|
|
136
183
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
184
|
+
## 🎯 自定义主题
|
|
185
|
+
|
|
186
|
+
### 智能配色
|
|
187
|
+
|
|
188
|
+
只需选择主色,系统会自动生成完整的配色方案:
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
import { applyThemeFromPrimary } from '@admin-core/design'
|
|
192
|
+
|
|
193
|
+
// 使用 HEX 颜色
|
|
194
|
+
applyThemeFromPrimary('#8B5CF6')
|
|
195
|
+
|
|
196
|
+
// 使用 HSL 颜色
|
|
197
|
+
applyThemeFromPrimary('280 60% 50%')
|
|
198
|
+
|
|
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
|
|
144
214
|
```
|
|
145
215
|
|
|
146
|
-
|
|
216
|
+
---
|
|
147
217
|
|
|
148
|
-
|
|
149
|
-
- `--background` / `--foreground` - 背景和前景色
|
|
150
|
-
- `--card` / `--card-foreground` - 卡片颜色
|
|
151
|
-
- `--popover` / `--popover-foreground` - 弹出层颜色
|
|
218
|
+
## 🔌 第三方组件库集成
|
|
152
219
|
|
|
153
|
-
|
|
154
|
-
- `--primary` / `--primary-foreground` - 主色
|
|
155
|
-
- `--secondary` / `--secondary-foreground` - 次要色
|
|
156
|
-
- `--muted` / `--muted-foreground` - 柔和色
|
|
157
|
-
- `--accent` / `--accent-foreground` - 强调色
|
|
158
|
-
- `--destructive` / `--destructive-foreground` - 破坏性操作色
|
|
220
|
+
### 一行代码集成
|
|
159
221
|
|
|
160
|
-
|
|
161
|
-
- `--info` / `--info-foreground` - 信息提示色
|
|
162
|
-
- `--success` / `--success-foreground` - 成功提示色
|
|
163
|
-
- `--warning` / `--warning-foreground` - 警告提示色
|
|
222
|
+
我们提供了开箱即用的第三方组件库主题集成文件:
|
|
164
223
|
|
|
165
|
-
####
|
|
166
|
-
- `--border` - 边框颜色
|
|
167
|
-
- `--input` - 输入框边框颜色
|
|
168
|
-
- `--ring` - 焦点环颜色
|
|
224
|
+
#### Element Plus
|
|
169
225
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
226
|
+
```typescript
|
|
227
|
+
// main.ts
|
|
228
|
+
import ElementPlus from 'element-plus'
|
|
229
|
+
import 'element-plus/dist/index.css'
|
|
230
|
+
import '@admin-core/design/css'
|
|
231
|
+
|
|
232
|
+
// 一行代码集成!
|
|
233
|
+
import '@admin-core/design/css/integrations/element-plus.css'
|
|
234
|
+
|
|
235
|
+
app.use(ElementPlus)
|
|
236
|
+
```
|
|
174
237
|
|
|
175
|
-
|
|
238
|
+
#### Ant Design Vue
|
|
176
239
|
|
|
177
|
-
|
|
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)
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### Naive UI
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
import naive from 'naive-ui'
|
|
253
|
+
import '@admin-core/design/css'
|
|
254
|
+
import '@admin-core/design/css/integrations/naive-ui.css'
|
|
255
|
+
|
|
256
|
+
app.use(naive)
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
#### Arco Design
|
|
260
|
+
|
|
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
|
|
178
279
|
|
|
179
280
|
```vue
|
|
180
281
|
<template>
|
|
181
|
-
<
|
|
182
|
-
<
|
|
183
|
-
</
|
|
282
|
+
<a-config-provider :theme="antdTheme">
|
|
283
|
+
<router-view />
|
|
284
|
+
</a-config-provider>
|
|
184
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()
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## 🌍 国际化
|
|
330
|
+
|
|
331
|
+
### 设置语言
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
import { setLocale, getLocale } from '@admin-core/design'
|
|
335
|
+
|
|
336
|
+
// 设置为英文
|
|
337
|
+
setLocale('en-US')
|
|
338
|
+
|
|
339
|
+
// 设置为中文
|
|
340
|
+
setLocale('zh-CN')
|
|
341
|
+
|
|
342
|
+
// 获取当前语言
|
|
343
|
+
const currentLocale = getLocale() // 'zh-CN' | 'en-US'
|
|
185
344
|
```
|
|
186
345
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
346
|
+
### 获取国际化主题信息
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
import { getThemeName, getThemeDescription, getThemeMetadata } from '@admin-core/design'
|
|
350
|
+
|
|
351
|
+
// 获取主题名称(根据当前语言)
|
|
352
|
+
const name = getThemeName('deep-teal')
|
|
353
|
+
// 中文: '深邃青'
|
|
354
|
+
// 英文: 'Deep Teal'
|
|
355
|
+
|
|
356
|
+
// 获取主题描述
|
|
357
|
+
const description = getThemeDescription('deep-teal')
|
|
358
|
+
// 中文: '2026流行色 - 深邃的青色,沉稳大气'
|
|
359
|
+
// 英文: '2026 Trending Color - Deep teal, calm and atmospheric'
|
|
360
|
+
|
|
361
|
+
// 获取所有主题(自动国际化)
|
|
362
|
+
const themes = getThemeMetadata()
|
|
363
|
+
```
|
|
195
364
|
|
|
196
|
-
###
|
|
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'
|
|
371
|
+
|
|
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() // 重新获取以更新语言
|
|
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>
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
---
|
|
399
|
+
|
|
400
|
+
## 🎨 设计令牌
|
|
401
|
+
|
|
402
|
+
所有颜色都使用 HSL 格式的 CSS 变量定义,支持透明度修饰符:
|
|
403
|
+
|
|
404
|
+
### 基础颜色
|
|
197
405
|
|
|
198
406
|
```html
|
|
199
|
-
|
|
200
|
-
<div class="
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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 中使用
|
|
458
|
+
|
|
459
|
+
```css
|
|
460
|
+
.my-component {
|
|
461
|
+
background-color: hsl(var(--primary));
|
|
462
|
+
color: hsl(var(--primary-foreground));
|
|
463
|
+
border: 1px solid hsl(var(--border));
|
|
464
|
+
border-radius: var(--radius);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/* 使用透明度 */
|
|
468
|
+
.my-overlay {
|
|
469
|
+
background-color: hsl(var(--primary) / 0.5);
|
|
229
470
|
}
|
|
230
471
|
```
|
|
231
472
|
|
|
232
|
-
|
|
473
|
+
---
|
|
233
474
|
|
|
234
|
-
## 工具类
|
|
475
|
+
## 🛠️ 工具类
|
|
235
476
|
|
|
236
477
|
### 布局工具类
|
|
237
478
|
|
|
238
479
|
```html
|
|
239
480
|
<!-- 水平居中 -->
|
|
240
|
-
<div class="flex-center"
|
|
481
|
+
<div class="flex-center">
|
|
482
|
+
<div>居中内容</div>
|
|
483
|
+
</div>
|
|
241
484
|
|
|
242
485
|
<!-- 垂直居中 -->
|
|
243
|
-
<div class="flex-col-center"
|
|
486
|
+
<div class="flex-col-center">
|
|
487
|
+
<div>垂直居中</div>
|
|
488
|
+
</div>
|
|
244
489
|
|
|
245
490
|
<!-- 卡片容器 -->
|
|
246
|
-
<div class="card-box"
|
|
491
|
+
<div class="card-box p-6">
|
|
492
|
+
<h3>卡片标题</h3>
|
|
493
|
+
<p>卡片内容</p>
|
|
494
|
+
</div>
|
|
247
495
|
|
|
248
496
|
<!-- 轮廓框 -->
|
|
249
|
-
<div class="outline-box"
|
|
250
|
-
|
|
497
|
+
<div class="outline-box">
|
|
498
|
+
可点击的框
|
|
499
|
+
</div>
|
|
500
|
+
|
|
501
|
+
<div class="outline-box outline-box-active">
|
|
502
|
+
激活状态的框
|
|
503
|
+
</div>
|
|
251
504
|
```
|
|
252
505
|
|
|
253
506
|
### 链接样式
|
|
@@ -256,7 +509,21 @@ export default {
|
|
|
256
509
|
<a href="#" class="admin-link">链接文本</a>
|
|
257
510
|
```
|
|
258
511
|
|
|
259
|
-
|
|
512
|
+
---
|
|
513
|
+
|
|
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>
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
## 🎭 特殊模式
|
|
260
527
|
|
|
261
528
|
### 反色模式
|
|
262
529
|
|
|
@@ -274,32 +541,158 @@ export default {
|
|
|
274
541
|
</html>
|
|
275
542
|
```
|
|
276
543
|
|
|
277
|
-
|
|
544
|
+
---
|
|
545
|
+
|
|
546
|
+
## ⚙️ Tailwind CSS 配置
|
|
547
|
+
|
|
548
|
+
如果你的项目需要扩展 Tailwind 配置:
|
|
549
|
+
|
|
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
|
|
633
|
+
```
|
|
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
|
+
## 🌐 浏览器兼容性
|
|
278
649
|
|
|
279
650
|
- Chrome >= 90
|
|
280
651
|
- Firefox >= 88
|
|
281
652
|
- Safari >= 14
|
|
282
653
|
- Edge >= 90
|
|
283
654
|
|
|
284
|
-
|
|
655
|
+
---
|
|
285
656
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
657
|
+
## 📦 导出说明
|
|
658
|
+
|
|
659
|
+
```typescript
|
|
660
|
+
// 主入口
|
|
661
|
+
import '@admin-core/design'
|
|
662
|
+
|
|
663
|
+
// 只导入 CSS
|
|
664
|
+
import '@admin-core/design/css'
|
|
289
665
|
|
|
290
|
-
|
|
291
|
-
|
|
666
|
+
// 导入主题系统
|
|
667
|
+
import { useTheme, setLocale } from '@admin-core/design'
|
|
292
668
|
|
|
293
|
-
|
|
294
|
-
|
|
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'
|
|
674
|
+
|
|
675
|
+
// 导入 Tailwind 配置
|
|
676
|
+
import designConfig from '@admin-core/design/tailwind.config'
|
|
295
677
|
```
|
|
296
678
|
|
|
297
|
-
|
|
679
|
+
---
|
|
680
|
+
|
|
681
|
+
## 🤝 贡献
|
|
682
|
+
|
|
683
|
+
欢迎贡献代码、报告问题或提出建议!
|
|
684
|
+
|
|
685
|
+
---
|
|
686
|
+
|
|
687
|
+
## 📄 许可证
|
|
688
|
+
|
|
689
|
+
MIT License © 2024 [Admin Kit Team](https://github.com/jackBoVip/admin-kit)
|
|
298
690
|
|
|
299
|
-
|
|
691
|
+
---
|
|
300
692
|
|
|
301
|
-
## 相关链接
|
|
693
|
+
## 🔗 相关链接
|
|
302
694
|
|
|
303
|
-
- [
|
|
304
|
-
- [
|
|
305
|
-
- [
|
|
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)
|