@yetuzi/vue3-query-components 1.0.0
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/LICENSE +21 -0
- package/README.md +222 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +127 -0
- package/dist/index.js +963 -0
- package/dist/index.js.map +1 -0
- package/package.json +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Vue3 Common Components
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# Vue3 Query Components
|
|
2
|
+
|
|
3
|
+
基于 Vue 3 + Element Plus 的查询页面组件库,专注于表格查询场景,开箱即用。
|
|
4
|
+
|
|
5
|
+
## ✨ 特性
|
|
6
|
+
|
|
7
|
+
- 🚀 **开箱即用** - 高度封装的业务组件,减少重复开发
|
|
8
|
+
- 🎨 **统一设计** - 基于 Element Plus 设计语言
|
|
9
|
+
- 🔧 **高度可配置** - 灵活的配置选项,满足不同业务需求
|
|
10
|
+
- 📦 **TypeScript 支持** - 完整的类型定义
|
|
11
|
+
- 🌳 **Tree Shaking** - 按需引入,减小打包体积
|
|
12
|
+
- 🔥 **热更新** - 支持开发模式热更新
|
|
13
|
+
|
|
14
|
+
## 📦 安装
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install vue3-query-components
|
|
18
|
+
# 或
|
|
19
|
+
yarn add vue3-query-components
|
|
20
|
+
# 或
|
|
21
|
+
pnpm add vue3-query-components
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 🚀 快速开始
|
|
25
|
+
|
|
26
|
+
### 1. 全局引入
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { createApp } from 'vue'
|
|
30
|
+
import Vue3QueryComponents from 'vue3-query-components'
|
|
31
|
+
import 'vue3-query-components/dist/style.css'
|
|
32
|
+
|
|
33
|
+
const app = createApp(App)
|
|
34
|
+
app.use(Vue3QueryComponents)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 2. 按需引入
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { CommonTable, CommonForm } from 'vue3-query-components'
|
|
41
|
+
import 'vue3-query-components/dist/style.css'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 3. 基础使用
|
|
45
|
+
|
|
46
|
+
#### 表格组件
|
|
47
|
+
|
|
48
|
+
```vue
|
|
49
|
+
<template>
|
|
50
|
+
<CommonTable
|
|
51
|
+
:columns="columns"
|
|
52
|
+
:data="tableData"
|
|
53
|
+
:loading="loading"
|
|
54
|
+
:pagination="pagination"
|
|
55
|
+
@page-change="handlePageChange"
|
|
56
|
+
/>
|
|
57
|
+
</template>
|
|
58
|
+
|
|
59
|
+
<script setup>
|
|
60
|
+
import { ref } from 'vue'
|
|
61
|
+
import { CommonTable } from 'vue3-query-components'
|
|
62
|
+
|
|
63
|
+
const columns = ref([
|
|
64
|
+
{ prop: 'name', label: '姓名' },
|
|
65
|
+
{ prop: 'age', label: '年龄' },
|
|
66
|
+
{ prop: 'email', label: '邮箱' }
|
|
67
|
+
])
|
|
68
|
+
|
|
69
|
+
const tableData = ref([
|
|
70
|
+
{ name: '张三', age: 25, email: 'zhangsan@example.com' },
|
|
71
|
+
{ name: '李四', age: 30, email: 'lisi@example.com' }
|
|
72
|
+
])
|
|
73
|
+
|
|
74
|
+
const loading = ref(false)
|
|
75
|
+
const pagination = ref({
|
|
76
|
+
current: 1,
|
|
77
|
+
pageSize: 10,
|
|
78
|
+
total: 100
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
function handlePageChange(page) {
|
|
82
|
+
pagination.value.current = page
|
|
83
|
+
// 加载数据
|
|
84
|
+
}
|
|
85
|
+
</script>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### 表单组件
|
|
89
|
+
|
|
90
|
+
```vue
|
|
91
|
+
<template>
|
|
92
|
+
<CommonForm
|
|
93
|
+
:model="formModel"
|
|
94
|
+
:items="formItems"
|
|
95
|
+
@submit="handleSubmit"
|
|
96
|
+
@reset="handleReset"
|
|
97
|
+
/>
|
|
98
|
+
</template>
|
|
99
|
+
|
|
100
|
+
<script setup>
|
|
101
|
+
import { ref } from 'vue'
|
|
102
|
+
import { CommonForm } from 'vue3-query-components'
|
|
103
|
+
|
|
104
|
+
const formModel = ref({
|
|
105
|
+
name: '',
|
|
106
|
+
email: '',
|
|
107
|
+
age: null
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
const formItems = ref([
|
|
111
|
+
{
|
|
112
|
+
prop: 'name',
|
|
113
|
+
label: '姓名',
|
|
114
|
+
type: 'input',
|
|
115
|
+
rules: [{ required: true, message: '请输入姓名' }]
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
prop: 'email',
|
|
119
|
+
label: '邮箱',
|
|
120
|
+
type: 'input',
|
|
121
|
+
rules: [{ type: 'email', message: '请输入正确的邮箱格式' }]
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
prop: 'age',
|
|
125
|
+
label: '年龄',
|
|
126
|
+
type: 'number'
|
|
127
|
+
}
|
|
128
|
+
])
|
|
129
|
+
|
|
130
|
+
function handleSubmit() {
|
|
131
|
+
console.log('提交表单:', formModel.value)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function handleReset() {
|
|
135
|
+
console.log('重置表单')
|
|
136
|
+
}
|
|
137
|
+
</script>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## 📚 API 文档
|
|
141
|
+
|
|
142
|
+
### CommonTable Props
|
|
143
|
+
|
|
144
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
145
|
+
|------|------|------|--------|
|
|
146
|
+
| columns | 表格列配置 | `Column[]` | - |
|
|
147
|
+
| data | 表格数据 | `any[]` | [] |
|
|
148
|
+
| loading | 加载状态 | `boolean` | false |
|
|
149
|
+
| pagination | 分页配置 | `PaginationConfig` | - |
|
|
150
|
+
| border | 是否显示边框 | `boolean` | true |
|
|
151
|
+
| stripe | 是否显示斑马纹 | `boolean` | true |
|
|
152
|
+
|
|
153
|
+
### CommonForm Props
|
|
154
|
+
|
|
155
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
156
|
+
|------|------|------|--------|
|
|
157
|
+
| model | 表单数据对象 | `object` | - |
|
|
158
|
+
| items | 表单项配置 | `FormItem[]` | - |
|
|
159
|
+
| labelWidth | 标签宽度 | `string \| number` | '100px' |
|
|
160
|
+
| inline | 是否行内表单 | `boolean` | false |
|
|
161
|
+
| submitText | 提交按钮文本 | `string` | '提交' |
|
|
162
|
+
| resetText | 重置按钮文本 | `string` | '重置' |
|
|
163
|
+
|
|
164
|
+
## 🛠️ 开发
|
|
165
|
+
|
|
166
|
+
### 环境要求
|
|
167
|
+
|
|
168
|
+
- Node.js >= 16.0.0
|
|
169
|
+
- Vue 3.5+
|
|
170
|
+
- Element Plus 2.11+
|
|
171
|
+
|
|
172
|
+
### 本地开发
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# 克隆项目
|
|
176
|
+
git clone https://gitee.com/yetuzi/vue3-common.git
|
|
177
|
+
cd vue3-common/common
|
|
178
|
+
|
|
179
|
+
# 安装依赖
|
|
180
|
+
npm install
|
|
181
|
+
|
|
182
|
+
# 开发模式(构建并监听文件变化)
|
|
183
|
+
npm run dev
|
|
184
|
+
|
|
185
|
+
# 构建
|
|
186
|
+
npm run build
|
|
187
|
+
|
|
188
|
+
# 类型检查
|
|
189
|
+
npm run type-check
|
|
190
|
+
|
|
191
|
+
# 代码格式化
|
|
192
|
+
npm run format
|
|
193
|
+
|
|
194
|
+
# Lint
|
|
195
|
+
npm run lint
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### 测试
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# 运行测试
|
|
202
|
+
npm test
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## 📄 许可证
|
|
206
|
+
|
|
207
|
+
[MIT](./LICENSE)
|
|
208
|
+
|
|
209
|
+
## 🤝 贡献
|
|
210
|
+
|
|
211
|
+
欢迎提交 Issue 和 Pull Request!
|
|
212
|
+
|
|
213
|
+
## 📞 支持
|
|
214
|
+
|
|
215
|
+
如有问题,请提交 [Issue](https://gitee.com/yetuzi/vue3-common/issues)
|
|
216
|
+
|
|
217
|
+
## 🗺️ 路线图
|
|
218
|
+
|
|
219
|
+
- [ ] 更多业务组件(抽屉、模态框等)
|
|
220
|
+
- [ ] 国际化支持
|
|
221
|
+
- [ ] 主题定制功能
|
|
222
|
+
- [ ] 单元测试覆盖
|
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.common-query-table[data-v-36a95823]{--spacing: 15px;width:100%;height:100%;flex:1;display:flex;flex-direction:column;box-sizing:border-box;padding:var(--spacing) 12px;overflow:hidden}[class^=common-query-table-][data-v-36a95823]{width:100%}[class^=common-query-table-]+[class^=common-query-table-][data-v-36a95823]{margin-top:var(--spacing)}.common-query-table .common-query-table-table[data-v-36a95823]{flex:1;overflow:hidden}.el-form[data-v-6b862115]{margin-bottom:-18px!important}.el-form .el-form-item[data-v-6b862115] .el-form-item__content{width:var(--v58512696)}.common-table[data-v-5da80890]{width:100%;height:100%;display:flex;flex-direction:column}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Vue3 Common Components 类型声明文件
|
|
2
|
+
import type { Plugin, DefineComponent } from 'vue'
|
|
3
|
+
import type { InputProps, ButtonProps } from 'element-plus'
|
|
4
|
+
|
|
5
|
+
// 基础配置类型
|
|
6
|
+
export interface Config {
|
|
7
|
+
component: {
|
|
8
|
+
placeholder: string
|
|
9
|
+
pagination: {
|
|
10
|
+
defaultPageCount: number
|
|
11
|
+
defaultPageSize: number
|
|
12
|
+
}
|
|
13
|
+
table: {
|
|
14
|
+
headerCellStyle: Record<string, any>
|
|
15
|
+
}
|
|
16
|
+
form: {
|
|
17
|
+
submitText: string
|
|
18
|
+
resetText: string
|
|
19
|
+
formItem: {
|
|
20
|
+
components: {
|
|
21
|
+
width: string
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 表格列配置
|
|
29
|
+
export interface CommonTableColumn {
|
|
30
|
+
prop: string
|
|
31
|
+
label: string
|
|
32
|
+
width?: string | number
|
|
33
|
+
minWidth?: string | number
|
|
34
|
+
fixed?: boolean | string
|
|
35
|
+
sortable?: boolean | string
|
|
36
|
+
formatter?: (row: any, column: any, cellValue: any, index: number) => string
|
|
37
|
+
renderHeader?: (h: any, column: any) => any
|
|
38
|
+
[key: string]: any
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 表单配置
|
|
42
|
+
export interface CommonFormPropForm {
|
|
43
|
+
components: {
|
|
44
|
+
width: string
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 分页参数
|
|
49
|
+
export interface PaginationParam {
|
|
50
|
+
page: number
|
|
51
|
+
size: number
|
|
52
|
+
total?: number
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 列表参数
|
|
56
|
+
export interface ListParam extends PaginationParam {
|
|
57
|
+
[key: string]: any
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 表格属性
|
|
61
|
+
export interface CommonTableProps {
|
|
62
|
+
columns: CommonTableColumn[]
|
|
63
|
+
data: any[]
|
|
64
|
+
loading?: boolean
|
|
65
|
+
pagination?: boolean | PaginationParam
|
|
66
|
+
[key: string]: any
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 表单属性
|
|
70
|
+
export interface CommonFormProps {
|
|
71
|
+
formItems: any[]
|
|
72
|
+
modelValue: Record<string, any>
|
|
73
|
+
form?: CommonFormPropForm
|
|
74
|
+
[key: string]: any
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 查询表格属性
|
|
78
|
+
export interface CommonQueryTableProps extends CommonTableProps {
|
|
79
|
+
queryFormItems?: any[]
|
|
80
|
+
[key: string]: any
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 组件属性类型
|
|
84
|
+
export type CommonInputProps = InputProps
|
|
85
|
+
export type CommonButtonProps = ButtonProps
|
|
86
|
+
export interface CommonSelectProps {
|
|
87
|
+
[key: string]: any
|
|
88
|
+
}
|
|
89
|
+
export interface CommonDatePickerProps {
|
|
90
|
+
[key: string]: any
|
|
91
|
+
}
|
|
92
|
+
export interface CommonPaginationProps {
|
|
93
|
+
[key: string]: any
|
|
94
|
+
}
|
|
95
|
+
export interface CommonCheckboxProps {
|
|
96
|
+
[key: string]: any
|
|
97
|
+
}
|
|
98
|
+
export interface CommonRadioProps {
|
|
99
|
+
[key: string]: any
|
|
100
|
+
}
|
|
101
|
+
export interface CommonSwitchProps {
|
|
102
|
+
[key: string]: any
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// 组件类型定义
|
|
106
|
+
export declare const CommonInput: DefineComponent<CommonInputProps>
|
|
107
|
+
export declare const CommonButton: DefineComponent<CommonButtonProps>
|
|
108
|
+
export declare const CommonForm: DefineComponent<CommonFormProps>
|
|
109
|
+
export declare const CommonTable: DefineComponent<CommonTableProps>
|
|
110
|
+
export declare const CommonQueryTable: DefineComponent<CommonQueryTableProps>
|
|
111
|
+
export declare const CommonPagination: DefineComponent<CommonPaginationProps>
|
|
112
|
+
export declare const CommonSelect: DefineComponent<CommonSelectProps>
|
|
113
|
+
export declare const CommonDatePicker: DefineComponent<CommonDatePickerProps>
|
|
114
|
+
export declare const CommonCheckbox: DefineComponent<CommonCheckboxProps>
|
|
115
|
+
export declare const CommonRadio: DefineComponent<CommonRadioProps>
|
|
116
|
+
export declare const CommonSwitch: DefineComponent<CommonSwitchProps>
|
|
117
|
+
export declare const CommonConfigProvider: DefineComponent<any>
|
|
118
|
+
|
|
119
|
+
// 配置对象
|
|
120
|
+
export declare const config: Config
|
|
121
|
+
|
|
122
|
+
// 插件定义
|
|
123
|
+
export declare const plugin: Plugin
|
|
124
|
+
|
|
125
|
+
// 默认导出
|
|
126
|
+
declare const defaultExport: Plugin
|
|
127
|
+
export default defaultExport
|