roui-element 1.0.0 → 1.0.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.md +189 -26
- package/dist/es/r-element.js +14061 -1347
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
# Roui - Vue 3 组件库
|
|
1
|
+
# Roui Element - Vue 3 组件库
|
|
2
2
|
|
|
3
3
|
[](https://opensource.org/licenses/MIT)
|
|
4
4
|
[](https://vuejs.org/)
|
|
5
5
|
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](https://www.npmjs.com/package/roui-element)
|
|
6
7
|
|
|
7
|
-
Roui 是一个基于 Vue 3 的现代化组件库,提供丰富的UI
|
|
8
|
+
Roui Element 是一个基于 Vue 3 的现代化组件库,提供丰富的UI组件和良好的开发体验,专为现代Web应用设计。
|
|
8
9
|
|
|
9
10
|
## ✨ 特性
|
|
10
11
|
|
|
@@ -15,62 +16,148 @@ Roui 是一个基于 Vue 3 的现代化组件库,提供丰富的UI组件和良
|
|
|
15
16
|
- 📖 **详细文档** - 提供完整的组件文档和使用示例
|
|
16
17
|
- 🎯 **高性能** - 优化的打包体积和渲染性能
|
|
17
18
|
- 🔌 **易于扩展** - 模块化设计,易于自定义和扩展
|
|
19
|
+
- 🌐 **多格式支持** - 支持 ES Module、UMD 等多种打包格式
|
|
18
20
|
|
|
19
21
|
## 🚀 快速开始
|
|
20
22
|
|
|
21
23
|
### 安装
|
|
22
24
|
|
|
23
25
|
```bash
|
|
24
|
-
|
|
26
|
+
# 使用 npm
|
|
27
|
+
npm install roui-element
|
|
28
|
+
|
|
29
|
+
# 使用 yarn
|
|
30
|
+
yarn add roui-element
|
|
31
|
+
|
|
32
|
+
# 使用 pnpm
|
|
33
|
+
pnpm add roui-element
|
|
25
34
|
```
|
|
26
35
|
|
|
27
|
-
###
|
|
36
|
+
### 完整引入
|
|
28
37
|
|
|
29
38
|
```javascript
|
|
30
|
-
// main.js
|
|
39
|
+
// main.js / main.ts
|
|
31
40
|
import { createApp } from 'vue'
|
|
32
41
|
import App from './App.vue'
|
|
33
|
-
import RElement from '
|
|
34
|
-
import '
|
|
42
|
+
import RElement from 'roui-element'
|
|
43
|
+
import 'roui-element/dist/style.css'
|
|
35
44
|
|
|
36
45
|
const app = createApp(App)
|
|
37
46
|
app.use(RElement)
|
|
38
47
|
app.mount('#app')
|
|
39
48
|
```
|
|
40
49
|
|
|
50
|
+
### 按需引入(推荐)
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
// 在组件中按需引入
|
|
54
|
+
import { ROButton, ROInput, ROSelect } from 'roui-element'
|
|
55
|
+
import 'roui-element/dist/style.css'
|
|
56
|
+
|
|
57
|
+
export default {
|
|
58
|
+
components: {
|
|
59
|
+
ROButton,
|
|
60
|
+
ROInput,
|
|
61
|
+
ROSelect,
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 基础使用示例
|
|
67
|
+
|
|
41
68
|
```vue
|
|
42
|
-
<!-- 在组件中使用 -->
|
|
43
69
|
<template>
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
70
|
+
<div class="demo-container">
|
|
71
|
+
<!-- 按钮组件 -->
|
|
72
|
+
<ROButton type="primary" @click="handleClick">主要按钮</ROButton>
|
|
73
|
+
<ROButton type="success">成功按钮</ROButton>
|
|
74
|
+
<ROButton type="warning">警告按钮</ROButton>
|
|
75
|
+
<ROButton type="danger">危险按钮</ROButton>
|
|
76
|
+
|
|
77
|
+
<!-- 输入框组件 -->
|
|
78
|
+
<ROInput v-model="inputValue" placeholder="请输入内容" clearable />
|
|
79
|
+
|
|
80
|
+
<!-- 下拉选择器 -->
|
|
81
|
+
<ROSelect v-model="selectedValue" :options="options" placeholder="请选择" />
|
|
82
|
+
|
|
83
|
+
<!-- 表单组件 -->
|
|
84
|
+
<ROForm :model="formData" :rules="formRules" ref="formRef">
|
|
85
|
+
<ROFormItem label="用户名" prop="username">
|
|
86
|
+
<ROInput v-model="formData.username" />
|
|
87
|
+
</ROFormItem>
|
|
88
|
+
<ROFormItem label="邮箱" prop="email">
|
|
89
|
+
<ROInput v-model="formData.email" />
|
|
90
|
+
</ROFormItem>
|
|
91
|
+
<ROButton type="primary" @click="handleSubmit">提交</ROButton>
|
|
92
|
+
</ROForm>
|
|
93
|
+
</div>
|
|
47
94
|
</template>
|
|
95
|
+
|
|
96
|
+
<script setup>
|
|
97
|
+
import { ref, reactive } from 'vue'
|
|
98
|
+
|
|
99
|
+
const inputValue = ref('')
|
|
100
|
+
const selectedValue = ref('')
|
|
101
|
+
const formRef = ref()
|
|
102
|
+
|
|
103
|
+
const options = [
|
|
104
|
+
{ label: '选项1', value: '1' },
|
|
105
|
+
{ label: '选项2', value: '2' },
|
|
106
|
+
{ label: '选项3', value: '3' },
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
const formData = reactive({
|
|
110
|
+
username: '',
|
|
111
|
+
email: '',
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
const formRules = {
|
|
115
|
+
username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
|
|
116
|
+
email: [
|
|
117
|
+
{ required: true, message: '请输入邮箱', trigger: 'blur' },
|
|
118
|
+
{ type: 'email', message: '邮箱格式不正确', trigger: 'blur' },
|
|
119
|
+
],
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const handleClick = () => {
|
|
123
|
+
console.log('按钮被点击')
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const handleSubmit = async () => {
|
|
127
|
+
try {
|
|
128
|
+
await formRef.value.validate()
|
|
129
|
+
console.log('表单验证通过', formData)
|
|
130
|
+
} catch (error) {
|
|
131
|
+
console.log('表单验证失败', error)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
</script>
|
|
48
135
|
```
|
|
49
136
|
|
|
50
137
|
## 📚 组件列表
|
|
51
138
|
|
|
52
139
|
### 基础组件
|
|
53
140
|
|
|
54
|
-
- **Button** -
|
|
55
|
-
- **Icon** -
|
|
141
|
+
- **Button** (`ROButton`) - 按钮组件,支持多种类型和状态
|
|
142
|
+
- **Icon** (`ROIcon`) - 图标组件,集成 Font Awesome
|
|
56
143
|
|
|
57
144
|
### 表单组件
|
|
58
145
|
|
|
59
|
-
- **Form** -
|
|
60
|
-
- **FormItem** -
|
|
61
|
-
- **Input** -
|
|
62
|
-
- **Select** - 下拉选择器
|
|
63
|
-
- **Switch** - 开关组件
|
|
146
|
+
- **Form** (`ROForm`) - 表单容器,提供验证功能
|
|
147
|
+
- **FormItem** (`ROFormItem`) - 表单项,支持标签和错误提示
|
|
148
|
+
- **Input** (`ROInput`) - 输入框组件,支持清空功能
|
|
149
|
+
- **Select** (`ROSelect`) - 下拉选择器
|
|
150
|
+
- **Switch** (`ROSwitch`) - 开关组件
|
|
64
151
|
|
|
65
152
|
### 数据展示
|
|
66
153
|
|
|
67
|
-
- **Collapse** -
|
|
68
|
-
- **Message** -
|
|
154
|
+
- **Collapse** (`ROCollapse`) - 折叠面板组件
|
|
155
|
+
- **Message** (`ROMessage`) - 消息提示组件
|
|
69
156
|
|
|
70
157
|
### 反馈组件
|
|
71
158
|
|
|
72
|
-
- **Tooltip** -
|
|
73
|
-
- **Dropdown** -
|
|
159
|
+
- **Tooltip** (`ROTooltip`) - 文字提示组件
|
|
160
|
+
- **Dropdown** (`RODropdown`) - 下拉菜单组件
|
|
74
161
|
|
|
75
162
|
## 🛠️ 开发指南
|
|
76
163
|
|
|
@@ -78,12 +165,13 @@ app.mount('#app')
|
|
|
78
165
|
|
|
79
166
|
- Node.js >= 20.19.0 或 >= 22.12.0
|
|
80
167
|
- Vue 3.3.4+
|
|
168
|
+
- TypeScript 5.9.0+
|
|
81
169
|
|
|
82
170
|
### 本地开发
|
|
83
171
|
|
|
84
172
|
```bash
|
|
85
173
|
# 克隆项目
|
|
86
|
-
git clone
|
|
174
|
+
git clone https://github.com/origin-mumu/roui.git
|
|
87
175
|
cd roui
|
|
88
176
|
|
|
89
177
|
# 安装依赖
|
|
@@ -126,6 +214,19 @@ npm run docs:preview
|
|
|
126
214
|
- **UMD** (`dist/umd/`) - 传统浏览器和直接使用
|
|
127
215
|
- **类型定义** (`dist/types/`) - TypeScript 支持
|
|
128
216
|
|
|
217
|
+
### 构建命令
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# 构建所有格式
|
|
221
|
+
npm run build
|
|
222
|
+
|
|
223
|
+
# 仅构建 ES 模块
|
|
224
|
+
npm run build-es
|
|
225
|
+
|
|
226
|
+
# 仅构建 UMD 格式
|
|
227
|
+
npm run build-umd
|
|
228
|
+
```
|
|
229
|
+
|
|
129
230
|
## 🧪 测试
|
|
130
231
|
|
|
131
232
|
项目使用 Vitest 进行单元测试:
|
|
@@ -142,6 +243,8 @@ npm run test:coverage
|
|
|
142
243
|
|
|
143
244
|
我们欢迎任何形式的贡献!请查看以下指南:
|
|
144
245
|
|
|
246
|
+
### 开发流程
|
|
247
|
+
|
|
145
248
|
1. Fork 本仓库
|
|
146
249
|
2. 创建功能分支 (`git checkout -b feature/AmazingFeature`)
|
|
147
250
|
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
|
|
@@ -154,6 +257,65 @@ npm run test:coverage
|
|
|
154
257
|
- 编写相应的单元测试
|
|
155
258
|
- 更新相关文档
|
|
156
259
|
- 确保所有测试通过
|
|
260
|
+
- 使用 TypeScript 编写代码
|
|
261
|
+
- 遵循 Vue 3 最佳实践
|
|
262
|
+
|
|
263
|
+
## 📄 API 参考
|
|
264
|
+
|
|
265
|
+
### Form 组件 API
|
|
266
|
+
|
|
267
|
+
#### Props
|
|
268
|
+
|
|
269
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
270
|
+
| ---------- | ---------------- | -------- | ------ |
|
|
271
|
+
| model | 表单数据对象 | `object` | - |
|
|
272
|
+
| rules | 表单验证规则 | `object` | - |
|
|
273
|
+
| labelWidth | 表单域标签的宽度 | `string` | - |
|
|
274
|
+
|
|
275
|
+
#### Methods
|
|
276
|
+
|
|
277
|
+
| 方法名 | 说明 | 参数 |
|
|
278
|
+
| ------------- | ------------------ | ---- |
|
|
279
|
+
| validate | 对整个表单进行验证 | - |
|
|
280
|
+
| clearValidate | 清除验证结果 | - |
|
|
281
|
+
| resetFields | 重置表单字段 | - |
|
|
282
|
+
|
|
283
|
+
### Button 组件 API
|
|
284
|
+
|
|
285
|
+
#### Props
|
|
286
|
+
|
|
287
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
288
|
+
| -------- | ---------- | ----------------------------------------------------------- | --------- |
|
|
289
|
+
| type | 按钮类型 | `'primary' \| 'success' \| 'warning' \| 'danger' \| 'info'` | - |
|
|
290
|
+
| size | 按钮尺寸 | `'large' \| 'default' \| 'small'` | 'default' |
|
|
291
|
+
| disabled | 是否禁用 | `boolean` | false |
|
|
292
|
+
| loading | 是否加载中 | `boolean` | false |
|
|
293
|
+
|
|
294
|
+
## 🔧 常见问题
|
|
295
|
+
|
|
296
|
+
### Q: 如何按需引入组件?
|
|
297
|
+
|
|
298
|
+
A: 可以直接从包中引入特定组件:
|
|
299
|
+
|
|
300
|
+
```javascript
|
|
301
|
+
import { ROButton, ROInput } from 'roui-element'
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Q: 样式文件需要单独引入吗?
|
|
305
|
+
|
|
306
|
+
A: 是的,需要单独引入样式文件:
|
|
307
|
+
|
|
308
|
+
```javascript
|
|
309
|
+
import 'roui-element/dist/style.css'
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Q: 支持 TypeScript 吗?
|
|
313
|
+
|
|
314
|
+
A: 完全支持,提供了完整的类型定义。
|
|
315
|
+
|
|
316
|
+
### Q: 如何自定义主题?
|
|
317
|
+
|
|
318
|
+
A: 可以通过 CSS 变量或覆盖样式来自定义主题。
|
|
157
319
|
|
|
158
320
|
## 📄 许可证
|
|
159
321
|
|
|
@@ -163,8 +325,9 @@ npm run test:coverage
|
|
|
163
325
|
|
|
164
326
|
如有问题或建议,请通过以下方式联系:
|
|
165
327
|
|
|
166
|
-
-
|
|
167
|
-
-
|
|
328
|
+
- 邮箱: 872709652@qq.com
|
|
329
|
+
- GitHub Issues: [项目 Issues](https://github.com/origin-mumu/roui/issues)
|
|
330
|
+
- 项目地址: [Roui Element](https://github.com/origin-mumu/roui)
|
|
168
331
|
|
|
169
332
|
## 🙏 致谢
|
|
170
333
|
|
|
@@ -178,4 +341,4 @@ npm run test:coverage
|
|
|
178
341
|
|
|
179
342
|
---
|
|
180
343
|
|
|
181
|
-
**Roui** - 让 Vue 3 开发更简单、更高效! 🎉
|
|
344
|
+
**Roui Element** - 让 Vue 3 开发更简单、更高效! 🎉
|