vsoft-ui 1.0.2 → 1.0.3

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 +214 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,214 @@
1
+ # VSoft UI
2
+
3
+ 基于 Element Plus 的 Vue3 组件库,支持全局权限控制
4
+
5
+ [![npm version](https://img.shields.io/npm/v/vsoft-ui.svg)](https://www.npmjs.com/package/vsoft-ui)
6
+ [![license](https://img.shields.io/npm/l/vsoft-ui.svg)](https://github.com/your-username/vsoft-ui/blob/main/LICENSE)
7
+ [![vue](https://img.shields.io/badge/Vue-3.3+-brightgreen.svg)](https://vuejs.org/)
8
+ [![element-plus](https://img.shields.io/badge/Element%20Plus-2.13+-blue.svg)](https://element-plus.org/)
9
+
10
+ ## 简介
11
+
12
+ VSoft UI 是一个基于 Vue 3 和 Element Plus 的二次封装组件库,专注于提供简单高效的权限控制解决方案。通过组件级、指令级和 Hook 级三种权限控制方式,帮助开发者快速构建具有权限管理功能的应用。
13
+
14
+ ## 主要特性
15
+
16
+ - 📦 基于 Element Plus,提供一致的设计语言
17
+ - 🔒 内置权限控制功能,支持三种权限控制方式
18
+ - 🚀 零学习成本,基于 Vue 3 Composition API
19
+ - 📝 完整的 TypeScript 支持
20
+ - 🛠️ 丰富的示例和详细文档
21
+
22
+ ## 快速开始
23
+
24
+ ### 安装
25
+
26
+ ```bash
27
+ # 使用 pnpm(推荐)
28
+ pnpm add vsoft-ui
29
+
30
+ # 或使用 npm
31
+ npm install vsoft-ui
32
+
33
+ # 或使用 yarn
34
+ yarn add vsoft-ui
35
+ ```
36
+
37
+ ### 引入
38
+
39
+ ```typescript
40
+ import { createApp } from 'vue'
41
+ import ElementPlus from 'element-plus'
42
+ import 'element-plus/dist/index.css'
43
+ import VSoftUI from 'vsoft-ui'
44
+ import App from './App.vue'
45
+
46
+ const app = createApp(App)
47
+ app.use(ElementPlus)
48
+ app.use(VSoftUI)
49
+ app.mount('#app')
50
+ ```
51
+
52
+ ### 设置权限
53
+
54
+ 在应用启动时设置用户权限:
55
+
56
+ ```typescript
57
+ // main.ts
58
+ import { permission } from 'vsoft-ui'
59
+
60
+ // 设置用户权限
61
+ permission.setPermissions(['button:add', 'button:edit', 'input:query'])
62
+ ```
63
+
64
+ ## 组件使用
65
+
66
+ ### 按钮组件
67
+
68
+ ```vue
69
+ <template>
70
+ <!-- 基本用法 -->
71
+ <v-button type="primary">主要按钮</v-button>
72
+
73
+ <!-- 权限控制 -->
74
+ <v-button type="success" permission="button:add">添加按钮</v-button>
75
+ <v-button type="warning" permission="['button:edit', 'button:update']">编辑按钮</v-button>
76
+ <v-button type="danger" permission="['button:delete', 'button:manage']" permission-mode="all">删除按钮</v-button>
77
+ </template>
78
+ ```
79
+
80
+ ### 输入框组件
81
+
82
+ ```vue
83
+ <template>
84
+ <!-- 基本用法 -->
85
+ <v-input v-model="value" placeholder="请输入内容" />
86
+
87
+ <!-- 权限控制 -->
88
+ <v-input v-model="value" permission="input:query" placeholder="查询输入框" />
89
+ </template>
90
+
91
+ <script setup lang="ts">
92
+ import { ref } from 'vue'
93
+
94
+ const value = ref('')
95
+ </script>
96
+ ```
97
+
98
+ ## 权限控制
99
+
100
+ VSoft UI 提供三种权限控制方式:
101
+
102
+ ### 1. 组件级权限控制
103
+
104
+ 所有 VSoft UI 组件都支持 `permission` 和 `permission-mode` 属性:
105
+
106
+ ```vue
107
+ <template>
108
+ <!-- 基本权限控制 -->
109
+ <v-button permission="button:add">添加按钮</v-button>
110
+
111
+ <!-- 多权限控制(任一权限) -->
112
+ <v-button permission="['button:edit', 'button:update']">编辑按钮</v-button>
113
+
114
+ <!-- 多权限控制(所有权限) -->
115
+ <v-button permission="['button:delete', 'button:manage']" permission-mode="all">删除按钮</v-button>
116
+ </template>
117
+ ```
118
+
119
+ ### 2. 指令级权限控制
120
+
121
+ 使用 `v-permission` 指令对任何元素进行权限控制:
122
+
123
+ ```vue
124
+ <template>
125
+ <!-- 基本权限控制 -->
126
+ <el-button v-permission="'button:delete'" type="danger">删除按钮</el-button>
127
+
128
+ <!-- 使用 any 修饰符 -->
129
+ <el-button v-permission:any="['button:edit', 'button:update']" type="warning">编辑按钮</el-button>
130
+
131
+ <!-- 使用 all 修饰符 -->
132
+ <el-button v-permission:all="['button:manage', 'button:admin']" type="primary">管理按钮</el-button>
133
+ </template>
134
+ ```
135
+
136
+ ### 3. Hook 级权限控制
137
+
138
+ 使用 `usePermission` Hook 进行更灵活的权限判断:
139
+
140
+ ```vue
141
+ <template>
142
+ <el-button v-if="canAdd" type="primary" @click="handleAdd">添加按钮</el-button>
143
+ <el-button v-if="canEdit" type="success" @click="handleEdit">编辑按钮</el-button>
144
+ </template>
145
+
146
+ <script setup lang="ts">
147
+ import { usePermission } from 'vsoft-ui'
148
+
149
+ const { hasPermission } = usePermission()
150
+
151
+ const canAdd = hasPermission('button:add')
152
+ const canEdit = hasPermission('button:edit')
153
+
154
+ const handleAdd = () => { /* ... */ }
155
+ const handleEdit = () => { /* ... */ }
156
+ </script>
157
+ ```
158
+
159
+ ## 开发
160
+
161
+ ### 运行示例
162
+
163
+ ```bash
164
+ pnpm dev
165
+ ```
166
+
167
+ ### 构建
168
+
169
+ ```bash
170
+ pnpm build
171
+ ```
172
+
173
+ ### 文档
174
+
175
+ ```bash
176
+ # 启动文档开发服务器
177
+ pnpm dev:docs
178
+
179
+ # 构建文档
180
+ pnpm build:docs
181
+ ```
182
+
183
+ ## 文档
184
+
185
+ - [完整文档](https://your-username.github.io/vsoft-ui/)
186
+ - [权限控制指南](/permission/usage)
187
+ - [组件文档](/components)
188
+
189
+ ## 贡献
190
+
191
+ 欢迎提交 Issue 和 Pull Request!
192
+
193
+ ## 许可证
194
+
195
+ [MIT](LICENSE)
196
+
197
+ ## 更新日志
198
+
199
+ ### v1.0.2
200
+
201
+ - 修复组件构建问题
202
+ - 优化权限控制逻辑
203
+ - 完善文档内容
204
+
205
+ ### v1.0.1
206
+
207
+ - 修复组件级权限控制问题
208
+ - 优化组件传参机制
209
+
210
+ ### v1.0.0
211
+
212
+ - 初始版本发布
213
+ - 实现 Button 和 Input 组件
214
+ - 添加三种权限控制方式
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vsoft-ui",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "基于Element Plus的二次封装组件库,支持全局按钮级权限控制",
5
5
  "type": "module",
6
6
  "main": "dist/vsoft-ui.umd.js",