@mc-markets/ui 1.0.0 → 1.0.2

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.
Files changed (41) hide show
  1. package/README.md +441 -329
  2. package/USAGE.md +383 -0
  3. package/dist/index-36fc8778.js +5 -0
  4. package/dist/index.js +2 -23
  5. package/dist/packages/components/Dialog/index.vue.d.ts +4 -4
  6. package/dist/packages/index.d.ts +154 -19
  7. package/dist/packages/styles/theme-config.d.ts +83 -0
  8. package/dist/src/utils/theme.d.ts +66 -0
  9. package/dist/style.css +1 -1
  10. package/package.json +35 -42
  11. package/packages/styles/css-variables.css +197 -0
  12. package/packages/styles/theme-config.ts +261 -0
  13. package/packages/styles/variables.scss +70 -0
  14. package/dist/packages/components/Grid/components/GridItem.vue.d.ts +0 -37
  15. package/dist/packages/components/Grid/index.vue.d.ts +0 -31
  16. package/dist/packages/components/Grid/interface/index.d.ts +0 -5
  17. package/dist/packages/components/Icon/index.vue.d.ts +0 -2
  18. package/dist/packages/components/SearchBar/index.vue.d.ts +0 -42
  19. package/dist/packages/components/SearchForm/components/SearchFormItem.vue.d.ts +0 -24
  20. package/dist/packages/components/SearchForm/index.vue.d.ts +0 -3019
  21. package/dist/packages/components/proForm/components/FormItem.vue.d.ts +0 -46
  22. package/dist/packages/components/proForm/components/interface/index.d.ts +0 -66
  23. package/dist/packages/components/proForm/index.vue.d.ts +0 -230
  24. package/dist/packages/components/proTable/components/ColSetting.vue.d.ts +0 -8
  25. package/dist/packages/components/proTable/components/Pagination.vue.d.ts +0 -17
  26. package/dist/packages/components/proTable/components/TableColumn.vue.d.ts +0 -6
  27. package/dist/packages/components/proTable/interface/index.d.ts +0 -66
  28. package/dist/packages/hooks/interface/index.d.ts +0 -28
  29. package/dist/packages/hooks/useSelection.d.ts +0 -16
  30. package/dist/packages/hooks/useTable.d.ts +0 -54
  31. package/dist/packages/utils/common.d.ts +0 -13
  32. package/dist/packages/utils/composables/useGlobalProperties.d.ts +0 -1
  33. package/dist/packages/utils/dayjs.d.ts +0 -2
  34. package/dist/packages/utils/directive.d.ts +0 -2
  35. package/dist/packages/utils/eventBus.d.ts +0 -2
  36. package/dist/packages/utils/index.d.ts +0 -152
  37. package/dist/packages/utils/is/index.d.ts +0 -72
  38. package/dist/packages/utils/validate.d.ts +0 -112
  39. package/dist/src/api/index.d.ts +0 -24
  40. package/dist/src/api/interface/index.d.ts +0 -34
  41. package/dist/src/api/test.d.ts +0 -1
package/README.md CHANGED
@@ -1,26 +1,36 @@
1
- # mc-pro-ui
1
+ # @mc-markets/ui
2
2
 
3
- 一个功能强大的 Vue 3 UI 组件库,提供完整的 TypeScript 支持,基于 Element Plus 构建,包含专业的表格、表单、搜索等组件。
3
+ 一个功能强大的 Element Plus 完整导出包,提供所有组件、指令、服务、样式、主题和国际化支持。现已修复 Element Plus 组件自动导入问题,确保所有组件正常渲染。
4
4
 
5
5
  ## ✨ 特性
6
6
 
7
7
  - 🚀 **Vue 3 + TypeScript** - 完全支持 Vue 3 Composition API 和 TypeScript
8
- - 🎨 **Element Plus 集成** - 基于 Element Plus 构建,保持一致的视觉风格
9
- - 📊 **专业表格组件** - ProTable 支持搜索、分页、列设置、拖拽排序等
10
- - 🔍 **智能搜索表单** - SearchForm 支持响应式布局和多种表单控件
11
- - 📝 **高级表单组件** - ProForm 支持动态表单和复杂布局
12
- - 🎯 **响应式网格系统** - Grid 组件支持断点响应式布局
13
- - 🎭 **灵活对话框** - Dialog 组件支持多种配置选项
8
+ - 🎨 **Element Plus 完整导出** - 导出所有 Element Plus 组件、指令、服务
9
+ - 🌍 **多语言支持** - 内置 50+ 种语言包,支持国际化
10
+ - 🎨 **主题定制** - 支持动态主题切换和暗色模式
14
11
  - 🔧 **开箱即用** - 提供完整的类型定义和示例代码
12
+ - 📦 **轻量级** - 基于 Element Plus 构建,保持一致的视觉风格
13
+ - 🛠️ **开发友好** - 完整的 TypeScript 支持和自动导入配置
15
14
 
16
15
  ## 📦 安装
17
16
 
18
17
  ```bash
19
- npm install mc-pro-ui
18
+ npm install @mc-markets/ui
20
19
  # 或
21
- yarn add mc-pro-ui
20
+ yarn add @mc-markets/ui
22
21
  # 或
23
- pnpm add mc-pro-ui
22
+ pnpm add @mc-markets/ui
23
+ ```
24
+
25
+ ### 依赖要求
26
+
27
+ ```bash
28
+ # 安装 Element Plus(必需)
29
+ npm install element-plus
30
+ # 或
31
+ yarn add element-plus
32
+ # 或
33
+ pnpm add element-plus
24
34
  ```
25
35
 
26
36
  ## 🔧 使用
@@ -29,11 +39,14 @@ pnpm add mc-pro-ui
29
39
 
30
40
  ```typescript
31
41
  import { createApp } from 'vue'
32
- import mcProUi from 'mc-pro-ui'
33
- import 'mc-pro-ui/dist/style.css'
42
+ import ElementPlus from 'element-plus'
43
+ import 'element-plus/dist/index.css'
44
+ import McMarketsUI from '@mc-markets/ui'
45
+ import '@mc-markets/ui/dist/style.css'
34
46
 
35
47
  const app = createApp(App)
36
- app.use(mcProUi)
48
+ app.use(ElementPlus)
49
+ app.use(McMarketsUI)
37
50
  app.mount('#app')
38
51
  ```
39
52
 
@@ -41,374 +54,448 @@ app.mount('#app')
41
54
 
42
55
  ```typescript
43
56
  import { createApp } from 'vue'
44
- import { ProTable, SearchForm, ProForm, Grid, Dialog } from 'mc-pro-ui'
45
- import 'mc-pro-ui/dist/style.css'
57
+ import ElementPlus from 'element-plus'
58
+ import 'element-plus/dist/index.css'
59
+ import { ElButton, ElInput, ElTable } from '@mc-markets/ui'
60
+ import '@mc-markets/ui/dist/style.css'
46
61
 
47
62
  const app = createApp(App)
48
- app.component('ProTable', ProTable)
49
- app.component('SearchForm', SearchForm)
50
- app.component('ProForm', ProForm)
51
- app.component('Grid', Grid)
52
- app.component('Dialog', Dialog)
63
+ app.use(ElementPlus)
64
+ app.component('ElButton', ElButton)
65
+ app.component('ElInput', ElInput)
66
+ app.component('ElTable', ElTable)
53
67
  app.mount('#app')
54
68
  ```
55
69
 
56
- ## 🎯 组件使用
70
+ ### 自动导入配置(推荐)
57
71
 
58
- ### ProTable - 专业表格组件
72
+ 如果使用 Vite,可以配置自动导入:
59
73
 
60
- 功能强大的表格组件,支持搜索、分页、列设置、拖拽排序等。
74
+ ```typescript
75
+ // vite.config.ts
76
+ import { defineConfig } from 'vite'
77
+ import vue from '@vitejs/plugin-vue'
78
+ import AutoImport from 'unplugin-auto-import/vite'
79
+ import Components from 'unplugin-vue-components/vite'
80
+ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
81
+
82
+ export default defineConfig({
83
+ plugins: [
84
+ vue(),
85
+ AutoImport({
86
+ resolvers: [ElementPlusResolver()],
87
+ }),
88
+ Components({
89
+ resolvers: [ElementPlusResolver({
90
+ importStyle: 'css'
91
+ })],
92
+ }),
93
+ ],
94
+ })
95
+ ```
61
96
 
62
- ```vue
63
- <template>
64
- <ProTable
65
- :columns="columns"
66
- :request-api="getTableList"
67
- :pagination="true"
68
- :tool-button="['refresh', 'setting', 'search']"
69
- @search="handleSearch"
70
- @reset="handleReset"
71
- >
72
- <!-- 自定义表格头部 -->
73
- <template #tableHeader="{ selectedList, isSelected }">
74
- <el-button
75
- type="primary"
76
- :disabled="!isSelected"
77
- @click="handleBatchDelete(selectedList)"
78
- >
79
- 批量删除
80
- </el-button>
81
- </template>
82
-
83
- <!-- 自定义操作列 -->
84
- <template #operation="{ row }">
85
- <el-button type="primary" @click="handleEdit(row)">编辑</el-button>
86
- <el-button type="danger" @click="handleDelete(row)">删除</el-button>
87
- </template>
88
- </ProTable>
89
- </template>
97
+ 然后在 `main.ts` 中:
90
98
 
91
- <script setup lang="ts">
92
- import { ref } from 'vue'
93
- import { ProTable } from 'mc-pro-ui'
94
- import type { ColumnProps } from 'mc-pro-ui'
95
-
96
- // 表格列配置
97
- const columns: ColumnProps[] = [
98
- {
99
- type: 'selection',
100
- width: 55,
101
- align: 'center'
102
- },
103
- {
104
- type: 'index',
105
- label: '序号',
106
- width: 60,
107
- align: 'center'
108
- },
109
- {
110
- prop: 'name',
111
- label: '姓名',
112
- search: {
113
- el: 'input',
114
- props: {
115
- placeholder: '请输入姓名'
116
- }
117
- }
118
- },
119
- {
120
- prop: 'age',
121
- label: '年龄',
122
- search: {
123
- el: 'input-number',
124
- props: {
125
- placeholder: '请输入年龄'
126
- }
127
- }
128
- },
129
- {
130
- prop: 'status',
131
- label: '状态',
132
- search: {
133
- el: 'select',
134
- props: {
135
- placeholder: '请选择状态'
136
- },
137
- enum: [
138
- { label: '启用', value: 1 },
139
- { label: '禁用', value: 0 }
140
- ]
141
- },
142
- tag: true
143
- },
144
- {
145
- prop: 'operation',
146
- label: '操作',
147
- width: 180,
148
- align: 'center',
149
- fixed: 'right'
150
- }
151
- ]
99
+ ```typescript
100
+ import { createApp } from 'vue'
101
+ import App from './App.vue'
102
+ import ElementPlus from 'element-plus'
103
+ import 'element-plus/dist/index.css'
152
104
 
153
- // 获取表格数据
154
- const getTableList = async (params: any) => {
155
- // 模拟 API 请求
156
- const response = await fetch('/api/users', { params })
157
- return response.json()
158
- }
105
+ const app = createApp(App)
106
+ app.use(ElementPlus)
107
+ app.mount('#app')
108
+ ```
159
109
 
160
- const handleSearch = () => {
161
- console.log('搜索')
162
- }
110
+ ## 🚀 快速开始
163
111
 
164
- const handleReset = () => {
165
- console.log('重置')
166
- }
112
+ ### 在线演示
167
113
 
168
- const handleEdit = (row: any) => {
169
- console.log('编辑', row)
170
- }
114
+ 访问 [在线演示](http://localhost:5175/) 查看所有组件的实际效果。
171
115
 
172
- const handleDelete = (row: any) => {
173
- console.log('删除', row)
174
- }
116
+ ### 本地演示
175
117
 
176
- const handleBatchDelete = (selectedList: any[]) => {
177
- console.log('批量删除', selectedList)
178
- }
179
- </script>
118
+ ```bash
119
+ # 克隆项目
120
+ git clone https://gitee.com/daboluoxigua/npm-mc-markets-ui.git
121
+
122
+ # 进入项目目录
123
+ cd npm-mc-markets-ui
124
+
125
+ # 安装依赖
126
+ npm install
127
+
128
+ # 启动演示服务器
129
+ npm run dev
130
+
131
+ # 访问 http://localhost:5173
180
132
  ```
181
133
 
182
- ### SearchForm - 智能搜索表单
134
+ ## 🔧 问题修复
183
135
 
184
- 响应式搜索表单组件,支持多种表单控件和布局配置。
136
+ ### Element Plus 组件导入问题
185
137
 
186
- ```vue
187
- <template>
188
- <SearchForm
189
- :columns="searchColumns"
190
- :search-param="searchParam"
191
- :search-col="{ xs: 1, sm: 2, md: 3, lg: 4, xl: 5 }"
192
- @search="handleSearch"
193
- @reset="handleReset"
194
- >
195
- <template #searchButton>
196
- <el-button type="primary" @click="handleSearch">搜索</el-button>
197
- <el-button @click="handleReset">重置</el-button>
198
- </template>
199
- </SearchForm>
200
- </template>
138
+ **问题描述:** 在之前的版本中,Element Plus 组件(如 `el-form`、`el-table` 等)无法正确自动导入,导致组件无法渲染。
201
139
 
202
- <script setup lang="ts">
203
- import { ref } from 'vue'
204
- import { SearchForm } from 'mc-pro-ui'
205
- import type { ColumnProps } from 'mc-pro-ui'
140
+ **解决方案:**
141
+ 1. `main.ts` 中显式导入 Element Plus
142
+ 2. 配置 Vite 自动导入插件
143
+ 3. 确保样式文件正确加载
144
+
145
+ **修复后的配置:**
146
+
147
+ ```typescript
148
+ // main.ts
149
+ import { createApp } from 'vue'
150
+ import App from './App.vue'
151
+ import ElementPlus from 'element-plus'
152
+ import 'element-plus/dist/index.css'
153
+
154
+ const app = createApp(App)
155
+ app.use(ElementPlus)
156
+ app.mount('#app')
157
+ ```
206
158
 
207
- const searchParam = ref({
208
- name: '',
209
- age: '',
210
- status: ''
159
+ ```typescript
160
+ // vite.config.ts
161
+ import AutoImport from 'unplugin-auto-import/vite'
162
+ import Components from 'unplugin-vue-components/vite'
163
+ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
164
+
165
+ export default defineConfig({
166
+ plugins: [
167
+ AutoImport({
168
+ resolvers: [ElementPlusResolver()],
169
+ }),
170
+ Components({
171
+ resolvers: [ElementPlusResolver({
172
+ importStyle: 'css'
173
+ })],
174
+ }),
175
+ ],
211
176
  })
177
+ ```
212
178
 
213
- const searchColumns: ColumnProps[] = [
214
- {
215
- prop: 'name',
216
- label: '姓名',
217
- search: {
218
- el: 'input',
219
- props: {
220
- placeholder: '请输入姓名'
221
- }
222
- }
223
- },
224
- {
225
- prop: 'age',
226
- label: '年龄',
227
- search: {
228
- el: 'input-number',
229
- props: {
230
- placeholder: '请输入年龄'
231
- }
232
- }
233
- },
234
- {
235
- prop: 'status',
236
- label: '状态',
237
- search: {
238
- el: 'select',
239
- props: {
240
- placeholder: '请选择状态'
241
- },
242
- enum: [
243
- { label: '启用', value: 1 },
244
- { label: '禁用', value: 0 }
245
- ]
246
- }
247
- }
248
- ]
179
+ ## 🌍 国际化支持
180
+
181
+ ### 支持的语言
182
+
183
+ 支持 50+ 种语言,包括:
184
+
185
+ - **中文** - zh-cn, zh-tw
186
+ - **英语** - en
187
+ - **日语** - ja
188
+ - **韩语** - ko
189
+ - **西班牙语** - es
190
+ - **法语** - fr
191
+ - **德语** - de
192
+ - **意大利语** - it
193
+ - **葡萄牙语** - pt
194
+ - **俄语** - ru
195
+ - **土耳其语** - tr
196
+ - **乌克兰语** - uk
197
+ - **越南语** - vi
198
+ - **泰语** - th
199
+ - **印尼语** - id
200
+ - **马来语** - ms
201
+ - **荷兰语** - nl
202
+ - **瑞典语** - sv
203
+ - **挪威语** - no
204
+ - **丹麦语** - da
205
+ - **芬兰语** - fi
206
+ - **波兰语** - pl
207
+ - **捷克语** - cs
208
+ - **匈牙利语** - hu
209
+ - **罗马尼亚语** - ro
210
+ - **斯洛伐克语** - sk
211
+ - **斯洛文尼亚语** - sl
212
+ - **克罗地亚语** - hr
213
+ - **保加利亚语** - bg
214
+ - **爱沙尼亚语** - et
215
+ - **拉脱维亚语** - lv
216
+ - **立陶宛语** - lt
217
+ - **希腊语** - el
218
+ - **希伯来语** - he
219
+ - **阿拉伯语** - ar
220
+ - **波斯语** - fa
221
+ - **印地语** - hi
222
+ - **孟加拉语** - bn
223
+ - **泰米尔语** - ta
224
+ - **泰卢固语** - te
225
+ - **旁遮普语** - pa
226
+ - **高棉语** - km
227
+ - **老挝语** - lo
228
+ - **缅甸语** - my
229
+ - **阿塞拜疆语** - az
230
+ - **哈萨克语** - kk
231
+ - **吉尔吉斯语** - ky
232
+ - **土库曼语** - tk
233
+ - **蒙古语** - mn
234
+
235
+ ### 使用示例
249
236
 
250
- const handleSearch = () => {
251
- console.log('搜索参数:', searchParam.value)
252
- }
237
+ ```typescript
238
+ import { createApp } from 'vue'
239
+ import ElementPlus from 'element-plus'
240
+ import McMarketsUI, {
241
+ ElementPlusLocaleZhCn,
242
+ ElementPlusLocaleEn,
243
+ getLocale,
244
+ switchLocale
245
+ } from '@mc-markets/ui'
246
+
247
+ const app = createApp(App)
248
+
249
+ // 使用中文语言包
250
+ app.use(ElementPlus, {
251
+ locale: ElementPlusLocaleZhCn
252
+ })
253
+
254
+ // 或者使用工具函数
255
+ const locale = getLocale('zh-cn')
256
+ app.use(ElementPlus, { locale })
253
257
 
254
- const handleReset = () => {
255
- searchParam.value = {
256
- name: '',
257
- age: '',
258
- status: ''
258
+ app.use(McMarketsUI)
259
+ app.mount('#app')
260
+ ```
261
+
262
+ ## 🎨 主题定制
263
+
264
+ ### 主题配置
265
+
266
+ ```typescript
267
+ import { createApp } from 'vue'
268
+ import ElementPlus from 'element-plus'
269
+ import McMarketsUI, { themeManager } from '@mc-markets/ui'
270
+
271
+ const app = createApp(App)
272
+
273
+ // 设置主题
274
+ themeManager.setTheme({
275
+ name: 'custom',
276
+ dark: false,
277
+ cssVars: {
278
+ '--el-color-primary': '#409eff',
279
+ '--el-color-success': '#67c23a',
280
+ '--el-color-warning': '#e6a23c',
281
+ '--el-color-danger': '#f56c6c',
282
+ '--el-color-info': '#909399'
259
283
  }
260
- }
261
- </script>
284
+ })
285
+
286
+ app.use(ElementPlus)
287
+ app.use(McMarketsUI)
288
+ app.mount('#app')
289
+ ```
290
+
291
+ ### 暗色模式
292
+
293
+ ```typescript
294
+ import { themeManager } from '@mc-markets/ui'
295
+
296
+ // 切换暗色模式
297
+ themeManager.toggleDark()
298
+
299
+ // 设置暗色模式
300
+ themeManager.setTheme({
301
+ name: 'dark',
302
+ dark: true
303
+ })
262
304
  ```
263
305
 
264
- ### ProForm - 高级表单组件
306
+ ## 🎯 组件使用
265
307
 
266
- 支持动态表单和复杂布局的表单组件。
308
+ ### 基础组件
267
309
 
268
310
  ```vue
269
311
  <template>
270
- <ProForm
271
- :form-json="formConfig"
272
- :form-col="{ xs: 24, sm: 12, md: 8, lg: 6, xl: 4 }"
273
- />
312
+ <div class="demo">
313
+ <!-- 按钮组件 -->
314
+ <el-button type="primary">主要按钮</el-button>
315
+ <el-button type="success">成功按钮</el-button>
316
+ <el-button type="warning">警告按钮</el-button>
317
+ <el-button type="danger">危险按钮</el-button>
318
+ <el-button type="info">信息按钮</el-button>
319
+
320
+ <!-- 输入组件 -->
321
+ <el-input v-model="inputValue" placeholder="请输入内容" />
322
+
323
+ <!-- 选择器 -->
324
+ <el-select v-model="selectValue" placeholder="请选择">
325
+ <el-option label="选项1" value="1" />
326
+ <el-option label="选项2" value="2" />
327
+ </el-select>
328
+ </div>
274
329
  </template>
275
330
 
276
331
  <script setup lang="ts">
277
332
  import { ref } from 'vue'
278
- import { ProForm } from 'mc-pro-ui'
279
-
280
- const formConfig = ref({
281
- config: {
282
- labelWidth: '120px',
283
- labelPosition: 'right'
284
- },
285
- fields: {
286
- name: {
287
- label: '姓名',
288
- el: 'input',
289
- props: {
290
- placeholder: '请输入姓名'
291
- }
292
- },
293
- age: {
294
- label: '年龄',
295
- el: 'input-number',
296
- props: {
297
- placeholder: '请输入年龄',
298
- min: 0,
299
- max: 150
300
- }
301
- },
302
- gender: {
303
- label: '性别',
304
- el: 'radio-group',
305
- options: [
306
- { label: '男', value: 'male' },
307
- { label: '女', value: 'female' }
308
- ]
309
- },
310
- city: {
311
- label: '城市',
312
- el: 'select',
313
- options: [
314
- { label: '北京', value: 'beijing' },
315
- { label: '上海', value: 'shanghai' },
316
- { label: '广州', value: 'guangzhou' }
317
- ]
318
- }
319
- }
320
- })
333
+
334
+ const inputValue = ref('')
335
+ const selectValue = ref('')
321
336
  </script>
322
337
  ```
323
338
 
324
- ### Grid - 响应式网格系统
325
-
326
- 基于 CSS Grid 的响应式布局系统。
339
+ ### 表格组件
327
340
 
328
341
  ```vue
329
342
  <template>
330
- <Grid :cols="{ xs: 1, sm: 2, md: 3, lg: 4, xl: 6 }" :gap="[20, 20]">
331
- <GridItem v-for="i in 12" :key="i" :span="1">
332
- <div class="grid-item">
333
- Grid Item {{ i }}
334
- </div>
335
- </GridItem>
336
- </Grid>
343
+ <el-table :data="tableData" style="width: 100%">
344
+ <el-table-column prop="name" label="姓名" width="120" />
345
+ <el-table-column prop="age" label="年龄" width="80" />
346
+ <el-table-column prop="email" label="邮箱" />
347
+ <el-table-column prop="status" label="状态" width="100">
348
+ <template #default="scope">
349
+ <el-tag :type="scope.row.status === 'active' ? 'success' : 'danger'">
350
+ {{ scope.row.status === 'active' ? '活跃' : '禁用' }}
351
+ </el-tag>
352
+ </template>
353
+ </el-table-column>
354
+ <el-table-column label="操作" width="150">
355
+ <template #default="scope">
356
+ <el-button size="small" @click="handleEdit(scope.row)">编辑</el-button>
357
+ <el-button size="small" type="danger" @click="handleDelete(scope.row)">删除</el-button>
358
+ </template>
359
+ </el-table-column>
360
+ </el-table>
361
+
362
+ <el-pagination
363
+ v-model:current-page="currentPage"
364
+ v-model:page-size="pageSize"
365
+ :page-sizes="[10, 20, 50, 100]"
366
+ :total="total"
367
+ layout="total, sizes, prev, pager, next, jumper"
368
+ style="margin-top: 20px; text-align: right;"
369
+ />
337
370
  </template>
338
371
 
339
372
  <script setup lang="ts">
340
- import { Grid, GridItem } from 'mc-pro-ui'
341
- </script>
373
+ import { ref } from 'vue'
374
+
375
+ const currentPage = ref(1)
376
+ const pageSize = ref(10)
377
+ const total = ref(100)
342
378
 
343
- <style scoped>
344
- .grid-item {
345
- background: #f5f5f5;
346
- padding: 20px;
347
- text-align: center;
348
- border-radius: 4px;
379
+ const tableData = ref([
380
+ { name: '张三', age: 25, email: 'zhangsan@example.com', status: 'active' },
381
+ { name: '李四', age: 30, email: 'lisi@example.com', status: 'inactive' },
382
+ { name: '王五', age: 28, email: 'wangwu@example.com', status: 'active' }
383
+ ])
384
+
385
+ const handleEdit = (row: any) => {
386
+ console.log('编辑', row)
349
387
  }
350
- </style>
351
- ```
352
388
 
353
- ### Dialog - 灵活对话框
389
+ const handleDelete = (row: any) => {
390
+ console.log('删除', row)
391
+ }
392
+ </script>
393
+ ```
354
394
 
355
- 可配置的对话框组件。
395
+ ### 表单组件
356
396
 
357
397
  ```vue
358
398
  <template>
359
- <Dialog
360
- v-model="dialogVisible"
361
- title="用户信息"
362
- width="600px"
363
- :draggable="true"
364
- @confirm="handleConfirm"
365
- >
366
- <div>对话框内容</div>
367
- </Dialog>
399
+ <el-form :model="form" :rules="rules" ref="formRef" label-width="100px">
400
+ <el-form-item label="用户名" prop="username">
401
+ <el-input v-model="form.username" placeholder="请输入用户名" />
402
+ </el-form-item>
403
+ <el-form-item label="邮箱" prop="email">
404
+ <el-input v-model="form.email" placeholder="请输入邮箱" />
405
+ </el-form-item>
406
+ <el-form-item label="性别" prop="gender">
407
+ <el-select v-model="form.gender" placeholder="请选择性别">
408
+ <el-option label="男" value="male" />
409
+ <el-option label="女" value="female" />
410
+ </el-select>
411
+ </el-form-item>
412
+ <el-form-item label="生日" prop="birthday">
413
+ <el-date-picker
414
+ v-model="form.birthday"
415
+ type="date"
416
+ placeholder="选择日期"
417
+ style="width: 100%;"
418
+ />
419
+ </el-form-item>
420
+ <el-form-item>
421
+ <el-button type="primary" @click="submitForm">提交</el-button>
422
+ <el-button @click="resetForm">重置</el-button>
423
+ </el-form-item>
424
+ </el-form>
368
425
  </template>
369
426
 
370
427
  <script setup lang="ts">
371
- import { ref } from 'vue'
372
- import { Dialog } from 'mc-pro-ui'
428
+ import { ref, reactive } from 'vue'
429
+
430
+ const formRef = ref()
431
+
432
+ const form = reactive({
433
+ username: '',
434
+ email: '',
435
+ gender: '',
436
+ birthday: ''
437
+ })
373
438
 
374
- const dialogVisible = ref(false)
439
+ const rules = {
440
+ username: [
441
+ { required: true, message: '请输入用户名', trigger: 'blur' }
442
+ ],
443
+ email: [
444
+ { required: true, message: '请输入邮箱', trigger: 'blur' },
445
+ { type: 'email', message: '请输入正确的邮箱格式', trigger: 'blur' }
446
+ ],
447
+ gender: [
448
+ { required: true, message: '请选择性别', trigger: 'change' }
449
+ ]
450
+ }
375
451
 
376
- const handleConfirm = () => {
377
- console.log('确认')
378
- dialogVisible.value = false
452
+ const submitForm = async () => {
453
+ try {
454
+ await formRef.value.validate()
455
+ console.log('表单提交成功!', form)
456
+ } catch (error) {
457
+ console.log('表单验证失败!')
458
+ }
459
+ }
460
+
461
+ const resetForm = () => {
462
+ formRef.value.resetFields()
379
463
  }
380
464
  </script>
381
465
  ```
382
466
 
383
467
  ## 🔧 API 配置
384
468
 
385
- ### ProTable Props
469
+ ### 主题管理
386
470
 
387
- | 参数 | 说明 | 类型 | 默认值 |
388
- |------|------|------|--------|
389
- | columns | 列配置项 | ColumnProps[] | [] |
390
- | data | 静态表格数据 | any[] | - |
391
- | requestApi | 请求表格数据的 API | Function | - |
392
- | requestAuto | 是否自动执行请求 | boolean | true |
393
- | pagination | 是否需要分页组件 | boolean | true |
394
- | toolButton | 功能按钮配置 | string[] \| boolean | false |
395
- | rowKey | 行数据的 Key | string | 'id' |
396
- | searchCol | 搜索项每列占比配置 | number \| Record<BreakPoint, number> | { xs: 1, sm: 2, md: 3, lg: 4, xl: 5 } |
397
-
398
- ### SearchForm Props
399
-
400
- | 参数 | 说明 | 类型 | 默认值 |
471
+ | 方法 | 说明 | 参数 | 返回值 |
401
472
  |------|------|------|--------|
402
- | columns | 搜索列配置 | ColumnProps[] | [] |
403
- | searchParam | 搜索参数 | object | {} |
404
- | searchCol | 搜索项每列占比配置 | number \| Record<BreakPoint, number> | { xs: 1, sm: 2, md: 3, lg: 4, xl: 5 } |
473
+ | setTheme | 设置主题 | theme: ThemeConfig | void |
474
+ | getTheme | 获取当前主题 | - | ThemeConfig |
475
+ | toggleDark | 切换暗色模式 | - | void |
405
476
 
406
- ### Grid Props
477
+ ### 国际化
407
478
 
408
- | 参数 | 说明 | 类型 | 默认值 |
479
+ | 方法 | 说明 | 参数 | 返回值 |
409
480
  |------|------|------|--------|
410
- | cols | 列数配置 | number \| Record<BreakPoint, number> | 12 |
411
- | gap | 间距配置 | number \| [number, number] | 0 |
481
+ | getLocale | 获取语言包 | locale: string | Locale |
482
+ | switchLocale | 切换语言 | locale: string | Locale |
483
+ | getSupportedLocales | 获取支持的语言列表 | - | string[] |
484
+
485
+ ### 主题配置接口
486
+
487
+ ```typescript
488
+ interface ThemeConfig {
489
+ /** 主题名称 */
490
+ name?: string
491
+ /** 是否暗色主题 */
492
+ dark?: boolean
493
+ /** 自定义CSS变量 */
494
+ cssVars?: Record<string, string>
495
+ /** 自定义类名 */
496
+ customClass?: string
497
+ }
498
+ ```
412
499
 
413
500
  ## 🎨 样式定制
414
501
 
@@ -416,11 +503,14 @@ const handleConfirm = () => {
416
503
 
417
504
  ```css
418
505
  :root {
419
- --mc-primary-color: #409eff;
420
- --mc-success-color: #67c23a;
421
- --mc-warning-color: #e6a23c;
422
- --mc-danger-color: #f56c6c;
423
- --mc-info-color: #909399;
506
+ --el-color-primary: #409eff;
507
+ --el-color-success: #67c23a;
508
+ --el-color-warning: #e6a23c;
509
+ --el-color-danger: #f56c6c;
510
+ --el-color-info: #909399;
511
+ --el-border-radius-base: 4px;
512
+ --el-font-size-base: 14px;
513
+ --el-spacing-base: 20px;
424
514
  }
425
515
  ```
426
516
 
@@ -430,12 +520,18 @@ const handleConfirm = () => {
430
520
 
431
521
  ```typescript
432
522
  import type {
433
- ColumnProps,
434
- SearchProps,
435
- ProTableProps,
436
- RenderScope,
437
- HeaderRenderScope
438
- } from 'mc-pro-ui'
523
+ ThemeConfig,
524
+ ThemeManager,
525
+ McMarketsUI
526
+ } from '@mc-markets/ui'
527
+
528
+ // 导入所有 Element Plus 类型
529
+ import type {
530
+ ButtonProps,
531
+ InputProps,
532
+ TableProps,
533
+ FormProps
534
+ } from '@mc-markets/ui'
439
535
  ```
440
536
 
441
537
  ## 🤝 贡献
@@ -488,15 +584,31 @@ npm run publish:lib
488
584
  ### 项目结构
489
585
 
490
586
  ```
491
- npm-pro-ui/
587
+ @mc-markets/ui/
492
588
  ├── packages/ # 组件库源码
493
- │ ├── components/ # 组件
494
- │ ├── hooks/ # 组合式函数
589
+ │ ├── styles/ # 样式文件
495
590
  │ ├── types/ # 类型定义
496
- │ ├── utils/ # 工具函数
497
591
  │ └── index.ts # 入口文件
592
+ ├── src/ # 演示应用源码
593
+ │ ├── components/ # 演示组件
594
+ │ ├── styles/ # 演示样式
595
+ │ ├── utils/ # 工具函数
596
+ │ ├── App.vue # 主应用组件
597
+ │ └── main.ts # 应用入口
498
598
  ├── dist/ # 构建输出
499
599
  ├── vite.config.ts # Vite 配置
500
600
  ├── package.json # 项目配置
501
601
  └── README.md # 项目文档
502
602
  ```
603
+
604
+ ### 演示功能
605
+
606
+ 当前演示应用包含以下功能:
607
+
608
+ - **组件展示** - 按钮、输入框、开关、评分、进度条等基础组件
609
+ - **表单组件** - 完整的表单示例,包含验证规则
610
+ - **表格组件** - 数据表格展示,支持分页和操作
611
+ - **主题配置** - 动态主题切换和颜色配置
612
+ - **国际化** - 多语言支持演示
613
+
614
+ 访问 http://localhost:5175/ 查看完整演示。