element-plus-suite 0.0.1 → 0.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 (2) hide show
  1. package/README.md +128 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,128 @@
1
+ # Element Plus Suite
2
+
3
+ Element Plus Suite 是基于 Element Plus 二次封装的组件库,开箱即用。可以显著地提升制作 CRUD 页面的效率,轻松搬砖。
4
+
5
+ [文档](https://th74100.github.io/element-plus-suite/) · [GitHub](https://github.com/th74100/element-plus-suite)
6
+
7
+ ## 特性
8
+
9
+ - **🚀 高效开发**:提供常用业务组件,减少重复代码
10
+ - **🎯 灵活配置**:支持 JSON 配置式和模板式,满足不同场景需求
11
+ - **💪 TypeScript**:提供完整的类型定义,更好的开发体验
12
+ - **🔥 Element Plus**:基于 Element Plus,支持主题定制
13
+
14
+ ## 环境要求
15
+
16
+ - Vue 3.2 或更高版本
17
+ - Element Plus 2.0 或更高版本
18
+ - 支持 ESM 的现代构建工具
19
+
20
+ ## 安装
21
+
22
+ ```bash
23
+ npm install element-plus-suite
24
+ ```
25
+
26
+ ## 注册组件
27
+
28
+ 如果项目已经全局注册 Element Plus,可以直接注册组件库:
29
+
30
+ ```ts
31
+ import { createApp } from 'vue'
32
+ import ElementPlusSuite from 'element-plus-suite'
33
+ import App from './App.vue'
34
+
35
+ const app = createApp(App)
36
+
37
+ app.use(ElementPlusSuite)
38
+ app.mount('#app')
39
+ ```
40
+
41
+ 如果需要一起注册 Element Plus:
42
+
43
+ ```ts
44
+ import { createApp } from 'vue'
45
+ import ElementPlus from 'element-plus'
46
+ import 'element-plus/dist/index.css'
47
+ import ElementPlusSuite from 'element-plus-suite'
48
+ import App from './App.vue'
49
+
50
+ const app = createApp(App)
51
+
52
+ app.use(ElementPlus)
53
+ app.use(ElementPlusSuite)
54
+ app.mount('#app')
55
+ ```
56
+
57
+ 也可以按需导入:
58
+
59
+ ```ts
60
+ import { ElTablePro } from 'element-plus-suite'
61
+ ```
62
+
63
+ ## 快速开始
64
+
65
+ ```vue
66
+ <script setup lang="ts">
67
+ import { ElTablePro, type TableProColumn } from 'element-plus-suite'
68
+
69
+ interface User {
70
+ id: number
71
+ name: string
72
+ email: string
73
+ }
74
+
75
+ const columns: TableProColumn<User>[] = [
76
+ { prop: 'name', label: '姓名', minWidth: 140 },
77
+ { prop: 'email', label: '邮箱', minWidth: 220 },
78
+ ]
79
+
80
+ const dataSource: User[] = [
81
+ { id: 1, name: '林晓', email: 'linxiao@example.com' },
82
+ { id: 2, name: '陈默', email: 'chenmo@example.com' },
83
+ ]
84
+ </script>
85
+
86
+ <template>
87
+ <ElTablePro
88
+ :columns="columns"
89
+ :data="dataSource"
90
+ row-key="id"
91
+ :pagination="false"
92
+ />
93
+ </template>
94
+ ```
95
+
96
+ ## 远程数据
97
+
98
+ 将 `data` 换成 `request` 即可接入远程数据。`request` 接收当前分页参数和取消信号,并返回统一的数据结构:
99
+
100
+ ```ts
101
+ import type { TableProRequest } from 'element-plus-suite'
102
+
103
+ const requestUsers: TableProRequest<User> = async ({
104
+ page,
105
+ pageSize,
106
+ signal,
107
+ }) => {
108
+ const params = new URLSearchParams({
109
+ page: String(page ?? 1),
110
+ pageSize: String(pageSize ?? 20),
111
+ })
112
+ const response = await fetch(`/api/users?${params}`, { signal })
113
+ const payload = await response.json()
114
+
115
+ return {
116
+ data: payload.list,
117
+ total: payload.total,
118
+ }
119
+ }
120
+ ```
121
+
122
+ 接口的原始返回结构在 `request` 内部适配即可,组件只接收 `data` 和 `total`。
123
+
124
+ 更多用法请查看[文档](https://th74100.github.io/element-plus-suite/)。
125
+
126
+ ## License
127
+
128
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "element-plus-suite",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Unofficial enhancement components for Element Plus",
5
5
  "type": "module",
6
6
  "sideEffects": false,