morghulis 1.0.31 → 1.0.32
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 +74 -350
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -374
- package/dist/index.js +2857 -7666
- package/dist/index.js.map +1 -0
- package/package.json +25 -48
- package/dist/components/cell/MCell.vue.d.ts +0 -11
- package/dist/components/cell/char/CharCell.vue.d.ts +0 -15
- package/dist/components/cell/date/DateCell.vue.d.ts +0 -15
- package/dist/components/cell/refer/SelectCell.vue.d.ts +0 -15
- package/dist/components/cell/simple/BooleanCell.vue.d.ts +0 -15
- package/dist/components/cell/simple/DefaultCell.vue.d.ts +0 -15
- package/dist/components/cell/simple/NumberCell.vue.d.ts +0 -18
- package/dist/components/cell/useCellComponents.d.ts +0 -2
- package/dist/components/common/MCtrlBtn.vue.d.ts +0 -30
- package/dist/components/common/MOption.vue.d.ts +0 -10
- package/dist/components/dialog/MDialog.vue.d.ts +0 -57
- package/dist/components/dialog/MDialogHeader.vue.d.ts +0 -9
- package/dist/components/form/MForm.vue.d.ts +0 -13
- package/dist/components/table/MTable.vue.d.ts +0 -65
- package/dist/components/table/MTableButtons.vue.d.ts +0 -17
- package/dist/components/table/MTableHeader.vue.d.ts +0 -17
- package/dist/components/table/data/DCell.vue.d.ts +0 -18
- package/dist/components/table/data/DForm.vue.d.ts +0 -16
- package/dist/components/table/data/DTable.vue.d.ts +0 -78
- package/dist/components/table/data/DTableController.vue.d.ts +0 -19
- package/dist/components/table/data/DTablePopController.vue.d.ts +0 -13
- package/dist/components/table/data/useDTable.d.ts +0 -77
- package/dist/components/table/data/useDTableCell.d.ts +0 -6
- package/dist/components/table/useMTable.d.ts +0 -25
- package/dist/hooks/authorize.d.ts +0 -13
- package/dist/hooks/channel.d.ts +0 -13
- package/dist/hooks/cookies.d.ts +0 -6
- package/dist/hooks/request.d.ts +0 -5
- package/dist/hooks/socket.d.ts +0 -7
- package/dist/index.umd.cjs +0 -38
- package/dist/tools/dao.d.ts +0 -27
- package/dist/tools/feedback.d.ts +0 -4
- package/dist/tools/query.d.ts +0 -20
- package/dist/types/dialog/dialog.types.d.ts +0 -41
- package/dist/types/index.d.ts +0 -1
- package/dist/types/table/m.table.types.d.ts +0 -55
package/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Morghulis
|
2
2
|
|
3
|
-
|
3
|
+
Morghulis是一个基于Vue 3的UI组件和工具函数库,提供了常用的UI交互、请求处理、Cookie管理等功能。
|
4
4
|
|
5
5
|
## 安装
|
6
6
|
|
@@ -8,15 +8,14 @@
|
|
8
8
|
npm install morghulis
|
9
9
|
```
|
10
10
|
|
11
|
-
##
|
11
|
+
## 使用方法
|
12
12
|
|
13
|
-
###
|
13
|
+
### 作为Vue插件使用
|
14
14
|
|
15
|
-
```
|
15
|
+
```js
|
16
16
|
import { createApp } from 'vue'
|
17
|
-
import { createMorghulis } from 'morghulis'
|
18
|
-
import 'morghulis/dist/index.css'
|
19
17
|
import App from './App.vue'
|
18
|
+
import { createMorghulis } from 'morghulis'
|
20
19
|
|
21
20
|
const app = createApp(App)
|
22
21
|
|
@@ -25,385 +24,110 @@ app.use(createMorghulis())
|
|
25
24
|
|
26
25
|
// 或者自定义配置
|
27
26
|
app.use(createMorghulis({
|
28
|
-
baseURL: '/api/',
|
29
|
-
minioURL: '/dfs/'
|
27
|
+
baseURL: '/custom-api/',
|
28
|
+
minioURL: '/custom-dfs/'
|
30
29
|
}))
|
31
30
|
|
32
31
|
app.mount('#app')
|
33
32
|
```
|
34
33
|
|
35
|
-
### 样式导入
|
36
|
-
|
37
|
-
你可以通过以下任意方式导入样式:
|
38
|
-
|
39
|
-
```typescript
|
40
|
-
// 推荐方式
|
41
|
-
import 'morghulis/dist/index.css'
|
42
|
-
|
43
|
-
// 或使用以下方式之一
|
44
|
-
import 'morghulis/style'
|
45
|
-
import 'morghulis/dist/style'
|
46
|
-
import 'morghulis/dist/style.css'
|
47
|
-
```
|
48
|
-
|
49
|
-
### 单独使用组件
|
50
|
-
|
51
|
-
```typescript
|
52
|
-
import { MDialog, MTable, MForm, DTable, DCell, DForm, DController, MCell } from 'morghulis'
|
53
|
-
import 'morghulis/dist/index.css'
|
54
|
-
|
55
|
-
// 在组件中使用
|
56
|
-
export default {
|
57
|
-
components: {
|
58
|
-
MDialog,
|
59
|
-
MTable,
|
60
|
-
MForm,
|
61
|
-
DTable,
|
62
|
-
DCell,
|
63
|
-
DForm,
|
64
|
-
DController,
|
65
|
-
MCell
|
66
|
-
}
|
67
|
-
}
|
68
|
-
```
|
69
|
-
|
70
34
|
### 使用工具函数
|
71
35
|
|
72
|
-
```
|
73
|
-
import {
|
74
|
-
|
75
|
-
// 在组件中使用
|
76
|
-
setup() {
|
77
|
-
const { get, post } = useMorghulisRequest()
|
78
|
-
const { get: getCookie, set: setCookie } = useMorghulisCookies()
|
79
|
-
const { login, logout, check, bearer } = useMorghulisAuthorize()
|
80
|
-
|
81
|
-
// 使用这些函数...
|
82
|
-
}
|
83
|
-
```
|
84
|
-
|
85
|
-
## 组件详解
|
86
|
-
|
87
|
-
### MDialog 对话框组件
|
88
|
-
|
89
|
-
对话框组件,用于创建自定义对话框。
|
90
|
-
|
91
|
-
#### 属性
|
92
|
-
|
93
|
-
```typescript
|
94
|
-
import { MDialog } from 'morghulis'
|
95
|
-
import type { MorDialogProps, MorDialogConfig } from 'morghulis'
|
96
|
-
|
97
|
-
// 在模板中使用
|
98
|
-
<MDialog
|
99
|
-
v-model="dialogVisible" // 控制对话框显示/隐藏
|
100
|
-
title="标题" // 对话框标题
|
101
|
-
subTitle="副标题" // 对话框副标题
|
102
|
-
:width="600" // 宽度,支持数字或字符串
|
103
|
-
:fullscreen="false" // 是否全屏
|
104
|
-
:modal="true" // 是否显示遮罩层
|
105
|
-
:modalClass="'custom-modal'" // 遮罩层自定义类名
|
106
|
-
:headerClass="'custom-header'" // 头部自定义类名
|
107
|
-
:bodyClass="'custom-body'" // 内容区自定义类名
|
108
|
-
:footerClass="'custom-footer'" // 底部自定义类名
|
109
|
-
:appendToBody="true" // 是否将对话框插入至body元素
|
110
|
-
:lockScroll="true" // 是否在显示对话框时将body滚动锁定
|
111
|
-
:closeOnClickModal="false" // 是否可通过点击遮罩层关闭对话框
|
112
|
-
:closeOnPressEscape="false" // 是否可通过按ESC键关闭对话框
|
113
|
-
:showClose="true" // 是否显示关闭按钮
|
114
|
-
:draggable="true" // 是否可拖拽
|
115
|
-
:center="false" // 是否居中布局
|
116
|
-
:destroyOnClose="true" // 关闭时销毁其中的元素
|
117
|
-
:confirmButtonText="'确认'" // 确认按钮文字
|
118
|
-
:cancelButtonText="'取消'" // 取消按钮文字
|
119
|
-
:confirm="handleConfirm" // 确认回调,接收(data, done)参数
|
120
|
-
:cancel="handleCancel" // 取消回调,接收(data, done)参数
|
121
|
-
@close="handleClose"
|
122
|
-
@update:modelValue="(val) => dialogVisible = val"
|
123
|
-
@update:title="(val) => title = val"
|
124
|
-
@update:subTitle="(val) => subTitle = val"
|
125
|
-
/>
|
126
|
-
```
|
127
|
-
|
128
|
-
#### 方法
|
129
|
-
|
130
|
-
```typescript
|
131
|
-
// 在组件中使用方法
|
132
|
-
const dialog = ref()
|
133
|
-
|
134
|
-
// 打开对话框,可传入数据和配置
|
135
|
-
dialog.value.open(
|
136
|
-
{ id: 1, name: '张三' }, // 传递给对话框的数据
|
137
|
-
{ title: '用户详情', subTitle: '编辑用户信息' } // 可选配置
|
138
|
-
)
|
139
|
-
|
140
|
-
// 关闭对话框
|
141
|
-
dialog.value.close()
|
142
|
-
```
|
36
|
+
```js
|
37
|
+
import { $message, $alert, $confirm, useMCookies, useMoRequest, useMAuthorize } from 'morghulis'
|
143
38
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
```typescript
|
151
|
-
import { MTable } from 'morghulis'
|
152
|
-
import type { MorghulisTableProps, MTableButton, MTableColumn } from 'morghulis'
|
153
|
-
|
154
|
-
<MTable
|
155
|
-
:data="tableData" // 表格数据
|
156
|
-
:view="metaView" // 元数据视图,定义表格结构
|
157
|
-
:loading="isLoading" // 加载状态
|
158
|
-
:buttons="tableButtons" // 操作按钮配置
|
159
|
-
:columns="tableColumns" // 自定义列配置
|
160
|
-
:sortableCallback="handleSort" // 排序回调
|
161
|
-
|
162
|
-
// 以下是基础表格属性
|
163
|
-
:border="true" // 是否带有边框
|
164
|
-
:stripe="true" // 是否为斑马纹表格
|
165
|
-
:highlightCurrentRow="true" // 是否高亮当前行
|
166
|
-
:row-key="'id'" // 行数据的唯一标识
|
167
|
-
:headerCellClassName="'custom-header'" // 表头单元格类名
|
168
|
-
|
169
|
-
@selection-change="handleSelectionChange" // 选择项变化事件
|
170
|
-
@sort="handleColumnSort" // 排序事件
|
171
|
-
>
|
172
|
-
<!-- 自定义插槽 -->
|
173
|
-
<template #header>
|
174
|
-
<!-- 自定义表格头部内容 -->
|
175
|
-
</template>
|
176
|
-
|
177
|
-
<template #header-tool>
|
178
|
-
<!-- 自定义表格头部工具区 -->
|
179
|
-
</template>
|
180
|
-
|
181
|
-
<template #cell="{ field, row, prop }">
|
182
|
-
<!-- 自定义单元格内容 -->
|
183
|
-
</template>
|
184
|
-
|
185
|
-
<template #footer>
|
186
|
-
<!-- 自定义表格底部内容 -->
|
187
|
-
</template>
|
188
|
-
|
189
|
-
<template #footer-tool>
|
190
|
-
<!-- 自定义表格底部工具区 -->
|
191
|
-
</template>
|
192
|
-
</MTable>
|
193
|
-
```
|
39
|
+
// 使用消息提示
|
40
|
+
$message.success('操作成功')
|
41
|
+
$message.error('操作失败')
|
42
|
+
$message.warning('警告信息')
|
43
|
+
$message.info('提示信息')
|
194
44
|
|
195
|
-
|
45
|
+
// 使用警告框
|
46
|
+
$alert.info('信息内容', '标题').then(() => {
|
47
|
+
// 用户点击确定按钮后的操作
|
48
|
+
})
|
196
49
|
|
197
|
-
|
198
|
-
|
199
|
-
|
50
|
+
// 使用确认框
|
51
|
+
$confirm.warning('确定要删除吗?', '警告').then(() => {
|
52
|
+
// 用户点击确定按钮后的操作
|
53
|
+
}).catch(() => {
|
54
|
+
// 用户点击取消按钮后的操作
|
55
|
+
})
|
200
56
|
|
201
|
-
//
|
202
|
-
const
|
57
|
+
// 使用Cookie管理
|
58
|
+
const { get, set, remove, load } = useMCookies()
|
59
|
+
set('user.name', '张三')
|
60
|
+
const userName = get('user.name') // 获取Cookie值
|
203
61
|
|
204
|
-
//
|
205
|
-
|
62
|
+
// 使用授权管理
|
63
|
+
const { login, logout, user, check } = useMAuthorize()
|
64
|
+
login('user123') // 登录
|
65
|
+
logout() // 登出
|
66
|
+
const currentUser = user() // 获取当前用户ID
|
206
67
|
|
207
|
-
//
|
208
|
-
|
68
|
+
// 使用请求工具
|
69
|
+
const { getHttpRequest, getMinioRequest } = useMoRequest()
|
70
|
+
const httpRequest = getHttpRequest()
|
71
|
+
httpRequest.get('/users').then(data => {
|
72
|
+
console.log(data)
|
73
|
+
})
|
209
74
|
```
|
210
75
|
|
211
|
-
|
76
|
+
## 类型支持
|
212
77
|
|
213
|
-
|
78
|
+
Morghulis提供了完整的TypeScript类型定义,支持IDE的代码补全:
|
214
79
|
|
215
|
-
|
80
|
+
```ts
|
81
|
+
import type { MOptions, MFeedback, MMsg, MBox } from 'morghulis'
|
216
82
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
<MForm
|
222
|
-
:item="formData" // 表单数据
|
223
|
-
:view="metaView" // 元数据视图,定义表单结构
|
224
|
-
:db="databaseObject" // 数据库对象,用于CRUD操作
|
225
|
-
/>
|
226
|
-
```
|
227
|
-
|
228
|
-
#### 方法
|
229
|
-
|
230
|
-
```typescript
|
231
|
-
// 引用表单组件
|
232
|
-
const form = ref()
|
233
|
-
|
234
|
-
// 获取表单数据
|
235
|
-
const formData = form.value.getData()
|
236
|
-
|
237
|
-
// 重置特定字段
|
238
|
-
form.value.reset('fieldName')
|
239
|
-
```
|
240
|
-
|
241
|
-
### DTable 数据表格组件
|
242
|
-
|
243
|
-
基于MTable的数据表格组件,提供完整的CRUD功能。
|
244
|
-
|
245
|
-
#### 属性
|
246
|
-
|
247
|
-
```typescript
|
248
|
-
import { DTable } from 'morghulis'
|
249
|
-
import type { DTableProps } from 'morghulis'
|
250
|
-
|
251
|
-
<DTable
|
252
|
-
:db="databaseObject" // 数据库对象,用于CRUD操作
|
253
|
-
:entity="'users'" // 实体名称,对应后端接口
|
254
|
-
:code="'user'" // 代码标识,用于元数据
|
255
|
-
:size="10" // 每页数量
|
256
|
-
:page="1" // 当前页码
|
257
|
-
:includes="includeFields" // 包含的字段
|
258
|
-
:excludes="excludeFields" // 排除的字段
|
259
|
-
:orders="orderConfig" // 排序配置
|
260
|
-
:buttons="actionButtons" // 操作按钮
|
261
|
-
:columns="customColumns" // 自定义列
|
262
|
-
:auth="requireAuth" // 是否需要授权
|
263
|
-
>
|
264
|
-
<!-- 自定义插槽 -->
|
265
|
-
<template #header>
|
266
|
-
<!-- 自定义头部 -->
|
267
|
-
</template>
|
268
|
-
|
269
|
-
<template #cell="{ field, row, prop }">
|
270
|
-
<!-- 自定义单元格 -->
|
271
|
-
</template>
|
272
|
-
</DTable>
|
83
|
+
// 使用类型定义
|
84
|
+
const customMessage: MMsg = {
|
85
|
+
// IDE将提供代码补全
|
86
|
+
}
|
273
87
|
```
|
274
88
|
|
275
|
-
|
89
|
+
## 组件
|
276
90
|
|
277
|
-
|
278
|
-
// 引用数据表格组件
|
279
|
-
const dataTable = ref()
|
91
|
+
库中集成了Element Plus和FontAwesome图标库:
|
280
92
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
dataTable.value.remove(row)
|
292
|
-
|
293
|
-
// 加载数据
|
294
|
-
dataTable.value.load()
|
295
|
-
|
296
|
-
// 上传数据
|
297
|
-
dataTable.value.upload(dataArray)
|
298
|
-
|
299
|
-
// 修改每页显示数量
|
300
|
-
dataTable.value.handlePageSizeChange(20)
|
301
|
-
|
302
|
-
// 修改当前页码
|
303
|
-
dataTable.value.handleCurrentPageChange(2)
|
93
|
+
```vue
|
94
|
+
<template>
|
95
|
+
<div>
|
96
|
+
<!-- FontAwesome图标使用 -->
|
97
|
+
<fa icon="user" />
|
98
|
+
|
99
|
+
<!-- Element Plus组件可以直接使用 -->
|
100
|
+
<el-button type="primary">按钮</el-button>
|
101
|
+
</div>
|
102
|
+
</template>
|
304
103
|
```
|
305
104
|
|
306
|
-
|
105
|
+
## Recommended IDE Setup
|
307
106
|
|
308
|
-
|
107
|
+
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
|
309
108
|
|
310
|
-
|
109
|
+
## Type Support for `.vue` Imports in TS
|
311
110
|
|
312
|
-
|
313
|
-
import { DForm } from 'morghulis'
|
314
|
-
import type { DFormProps } from 'morghulis'
|
111
|
+
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
|
315
112
|
|
316
|
-
|
317
|
-
:selection="selectedRows" // 选中的数据行
|
318
|
-
:view="metaView" // 元数据视图
|
319
|
-
:db="databaseObject" // 数据库对象
|
320
|
-
:bean="formData" // 表单数据
|
321
|
-
/>
|
322
|
-
```
|
113
|
+
## Customize configuration
|
323
114
|
|
324
|
-
|
115
|
+
See [Vite Configuration Reference](https://vite.dev/config/).
|
325
116
|
|
326
|
-
|
327
|
-
// 引用数据表单
|
328
|
-
const dataForm = ref()
|
117
|
+
## Project Setup
|
329
118
|
|
330
|
-
|
331
|
-
|
119
|
+
```sh
|
120
|
+
npm install
|
332
121
|
```
|
333
122
|
|
334
|
-
###
|
335
|
-
|
336
|
-
用于表格中单个数据单元格的编辑。
|
123
|
+
### Compile and Hot-Reload for Development
|
337
124
|
|
338
|
-
|
339
|
-
|
340
|
-
```typescript
|
341
|
-
import { DCell } from 'morghulis'
|
342
|
-
import type { DCellProps } from 'morghulis'
|
343
|
-
|
344
|
-
<DCell
|
345
|
-
:view="metaView" // 元数据视图
|
346
|
-
:prop="fieldName" // 字段名称
|
347
|
-
:bean="rowData" // 行数据
|
348
|
-
:db="databaseObject" // 数据库对象
|
349
|
-
:disabled="false" // 是否禁用
|
350
|
-
@cancel="handleCancel" // 取消事件
|
351
|
-
@save="handleSave" // 保存事件
|
352
|
-
/>
|
125
|
+
```sh
|
126
|
+
npm run dev
|
353
127
|
```
|
354
128
|
|
355
|
-
|
356
|
-
|
357
|
-
组件库提供全局类型支持,导入后可以在模板中直接使用组件名称,TypeScript 会自动提供类型检查和属性提示:
|
129
|
+
### Type-Check, Compile and Minify for Production
|
358
130
|
|
359
|
-
```
|
360
|
-
|
361
|
-
<MDialog
|
362
|
-
v-model="dialogVisible"
|
363
|
-
title="标题"
|
364
|
-
@close="handleClose"
|
365
|
-
/>
|
366
|
-
|
367
|
-
<!-- Element Plus 组件也有类型提示 -->
|
368
|
-
<ElButton type="primary">按钮</ElButton>
|
369
|
-
</template>
|
370
|
-
|
371
|
-
<script setup lang="ts">
|
372
|
-
import { ref } from 'vue'
|
373
|
-
// 无需导入组件,但需要导入库
|
374
|
-
import 'morghulis'
|
375
|
-
|
376
|
-
const dialogVisible = ref(false)
|
377
|
-
const handleClose = () => {
|
378
|
-
dialogVisible.value = false
|
379
|
-
}
|
380
|
-
</script>
|
131
|
+
```sh
|
132
|
+
npm run build
|
381
133
|
```
|
382
|
-
|
383
|
-
## 版本历史
|
384
|
-
|
385
|
-
### 1.0.30
|
386
|
-
- 优化了组件类型定义,修复IDE无法识别和自动补全组件属性的问题
|
387
|
-
- 改进了类型导出机制,增强了组件与IDE的集成
|
388
|
-
- 添加了对v-model属性的明确类型支持
|
389
|
-
- 扩展了组件的方法类型定义,使API更加清晰
|
390
|
-
|
391
|
-
### 1.0.29
|
392
|
-
- 增强了类型定义,补充了 MTable, MForm, DTable 组件的方法导出
|
393
|
-
- 更新了 README.md,添加了详细的组件属性和方法说明
|
394
|
-
|
395
|
-
### 1.0.28
|
396
|
-
- 修复了类型声明冲突问题
|
397
|
-
- 添加了完整的组件类型定义
|
398
|
-
- 增加了全局类型支持,现在可以在模板中获得完整的属性提示
|
399
|
-
- 解决了CSS导入问题,支持多种导入路径
|
400
|
-
|
401
|
-
### 1.0.27
|
402
|
-
- 修改了类型定义,避免与 Vue 内置类型冲突
|
403
|
-
- 优化了组件属性和事件定义
|
404
|
-
|
405
|
-
## 工具函数
|
406
|
-
|
407
|
-
### 授权功能
|
408
|
-
|
409
|
-
```
|