es-plus-ui 1.2.0 → 1.2.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 +128 -5
- package/dist/es-plus.js +4 -4
- package/dist/es-plus.js.map +1 -1
- package/dist/es-plus.umd.cjs +1 -1
- package/dist/es-plus.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +83 -83
package/README.md
CHANGED
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
- **自适应高度** — `ResizeObserver` 自动重算表格高度,表单展开/收起自动响应
|
|
18
18
|
- **跨页选择** — `rowkey` + `cachePageSelection` 解决分页选择丢失痛点
|
|
19
19
|
- **任意后端适配** — `configTableOut` + `qrcb` 配置化适配不同后端响应格式
|
|
20
|
-
-
|
|
20
|
+
- **权限控制** — `permissionValue` 声明式按钮权限,无需 v-if
|
|
21
|
+
- **国际化** — `labelKey` + 自定义翻译函数,兼容任意 i18n 方案
|
|
22
|
+
- **TypeScript** — 完整类型定义,11 个核心接口可导入
|
|
23
|
+
- **AI 原生支持** — 配套 [@es-plus/mcp-server](https://www.npmjs.com/package/@es-plus/mcp-server) 和 [@es-plus/cli](https://www.npmjs.com/package/@es-plus/cli)
|
|
21
24
|
- **13 种表单类型** — Input、Select、datePicker、timePicker、Slider、ColorPicker、Transfer、Cascader、Radio、Checkbox、Switch、Rate、Upload
|
|
22
25
|
|
|
23
26
|
## 为什么选择 es-plus-ui?
|
|
@@ -187,7 +190,7 @@ const items = [
|
|
|
187
190
|
]
|
|
188
191
|
const btns = [
|
|
189
192
|
{ name: '查询', type: 'primary', key: 'query', triggerEvent: true },
|
|
190
|
-
{ name: '重置', key: '
|
|
193
|
+
{ name: '重置', key: 'rest', triggerEvent: true }
|
|
191
194
|
]
|
|
192
195
|
</script>
|
|
193
196
|
```
|
|
@@ -347,7 +350,7 @@ function openAddDialog() {
|
|
|
347
350
|
| click | `(model, formRef, httpRequestInstance?) => void` | 点击回调 |
|
|
348
351
|
| triggerEvent | `boolean` | `true` 时自动触发表格查询/表单重置 |
|
|
349
352
|
|
|
350
|
-
> `triggerEvent: true` + `key: 'query'` → 自动调用父级 EsTable 的 `httpRequestInstance`;`triggerEvent: true` + `key: '
|
|
353
|
+
> `triggerEvent: true` + `key: 'query'` → 自动调用父级 EsTable 的 `httpRequestInstance`;`triggerEvent: true` + `key: 'rest'` → 自动重置表单。
|
|
351
354
|
|
|
352
355
|
### Events
|
|
353
356
|
|
|
@@ -901,7 +904,7 @@ const queryItems = [
|
|
|
901
904
|
]
|
|
902
905
|
const queryBtns = [
|
|
903
906
|
{ name: '查询', type: 'primary', key: 'query', triggerEvent: true },
|
|
904
|
-
{ name: '重置', key: '
|
|
907
|
+
{ name: '重置', key: 'rest', triggerEvent: true }
|
|
905
908
|
]
|
|
906
909
|
const tableOptions = {
|
|
907
910
|
httpRequest: mockRequest,
|
|
@@ -910,7 +913,7 @@ const tableOptions = {
|
|
|
910
913
|
}
|
|
911
914
|
```
|
|
912
915
|
|
|
913
|
-
> `triggerEvent: true` + `key: 'query'` → EsForm 自动调用父级 EsTable 的 `httpRequestInstance`;`key: '
|
|
916
|
+
> `triggerEvent: true` + `key: 'query'` → EsForm 自动调用父级 EsTable 的 `httpRequestInstance`;`key: 'rest'` → 自动重置表单。
|
|
914
917
|
|
|
915
918
|
### CRUD 弹窗
|
|
916
919
|
|
|
@@ -1042,8 +1045,128 @@ const handleSelectionChange = (rows) => {
|
|
|
1042
1045
|
|
|
1043
1046
|
---
|
|
1044
1047
|
|
|
1048
|
+
## 权限控制
|
|
1049
|
+
|
|
1050
|
+
安装时配置权限函数,按钮自动按权限显隐,无需 v-if:
|
|
1051
|
+
|
|
1052
|
+
```typescript
|
|
1053
|
+
app.use(ESPlus, {
|
|
1054
|
+
permission: (value) => userPermissions.includes(value)
|
|
1055
|
+
})
|
|
1056
|
+
```
|
|
1057
|
+
|
|
1058
|
+
在任意 `BtnConfig` 中声明 `permissionValue`:
|
|
1059
|
+
|
|
1060
|
+
```typescript
|
|
1061
|
+
const btns = [
|
|
1062
|
+
{ name: '新增', type: 'primary', permissionValue: 'user:add', click: () => add() },
|
|
1063
|
+
{ name: '删除', type: 'danger', permissionValue: 'user:delete', click: (row) => del(row) }
|
|
1064
|
+
]
|
|
1065
|
+
// 用户无 'user:delete' 权限时,删除按钮自动隐藏
|
|
1066
|
+
```
|
|
1067
|
+
|
|
1068
|
+
适用于 EsForm `configBtn`、EsTable `configBtn`、表格列 `btns`、useDialog `configBtn`。
|
|
1069
|
+
|
|
1070
|
+
---
|
|
1071
|
+
|
|
1072
|
+
## 国际化(i18n)
|
|
1073
|
+
|
|
1074
|
+
安装时配置翻译函数,兼容任意 i18n 库:
|
|
1075
|
+
|
|
1076
|
+
```typescript
|
|
1077
|
+
app.use(ESPlus, {
|
|
1078
|
+
t: (key) => i18n.global.t(key)
|
|
1079
|
+
})
|
|
1080
|
+
```
|
|
1081
|
+
|
|
1082
|
+
表单项和表格列使用 `labelKey` 字段:
|
|
1083
|
+
|
|
1084
|
+
```typescript
|
|
1085
|
+
const formItems = [
|
|
1086
|
+
{ prop: 'name', label: '姓名', labelKey: 'form.name', formtype: 'Input' }
|
|
1087
|
+
]
|
|
1088
|
+
const columns = [
|
|
1089
|
+
{ prop: 'name', label: '姓名', labelKey: 'table.name' }
|
|
1090
|
+
]
|
|
1091
|
+
// 有 labelKey 且配置了 t 函数时,使用 t(labelKey);否则回退到 label
|
|
1092
|
+
```
|
|
1093
|
+
|
|
1094
|
+
---
|
|
1095
|
+
|
|
1096
|
+
## EsCrudPage — 一键 CRUD 页面
|
|
1097
|
+
|
|
1098
|
+
传入 Schema 即可生成完整的查询表单 + 数据表格 + 弹窗编辑页面:
|
|
1099
|
+
|
|
1100
|
+
```vue
|
|
1101
|
+
<template>
|
|
1102
|
+
<es-crud-page :schema="schema" :http-request="fetchList" />
|
|
1103
|
+
</template>
|
|
1104
|
+
|
|
1105
|
+
<script setup>
|
|
1106
|
+
const schema = {
|
|
1107
|
+
formItems: [
|
|
1108
|
+
{ prop: 'name', label: '姓名', formtype: 'Input', span: 6 },
|
|
1109
|
+
{ prop: 'status', label: '状态', formtype: 'Select', span: 6,
|
|
1110
|
+
dataOptions: [{ label: '启用', value: 1 }, { label: '禁用', value: 0 }] }
|
|
1111
|
+
],
|
|
1112
|
+
columns: [
|
|
1113
|
+
{ prop: 'name', label: '姓名' },
|
|
1114
|
+
{ prop: 'status', label: '状态' }
|
|
1115
|
+
],
|
|
1116
|
+
actions: ['add', 'edit', 'delete']
|
|
1117
|
+
}
|
|
1118
|
+
</script>
|
|
1119
|
+
```
|
|
1120
|
+
|
|
1121
|
+
```typescript
|
|
1122
|
+
import type { CrudPageSchema, CrudAction } from 'es-plus-ui'
|
|
1123
|
+
```
|
|
1124
|
+
|
|
1125
|
+
---
|
|
1126
|
+
|
|
1127
|
+
## AI 工具链
|
|
1128
|
+
|
|
1129
|
+
ES-Plus 配套两个官方 AI 工具,支持自然语言生成完整 CRUD 页面:
|
|
1130
|
+
|
|
1131
|
+
### @es-plus/mcp-server
|
|
1132
|
+
|
|
1133
|
+
让 Claude Code、Cursor 等 AI 编码工具直接调用 CRUD 生成能力:
|
|
1134
|
+
|
|
1135
|
+
```bash
|
|
1136
|
+
claude mcp add es-plus -- npx -y @es-plus/mcp-server
|
|
1137
|
+
```
|
|
1138
|
+
|
|
1139
|
+
在 AI 对话中直接说"生成一个用户管理页面",AI 自动调用 MCP Server 生成完整 .vue 文件。
|
|
1140
|
+
|
|
1141
|
+
详见:[@es-plus/mcp-server](https://www.npmjs.com/package/@es-plus/mcp-server)
|
|
1142
|
+
|
|
1143
|
+
### @es-plus/cli
|
|
1144
|
+
|
|
1145
|
+
终端生成 CRUD 页面、校验配置、生成脚手架:
|
|
1146
|
+
|
|
1147
|
+
```bash
|
|
1148
|
+
npx @es-plus/cli create user-management
|
|
1149
|
+
npx @es-plus/cli validate ./config.json --schema form-item
|
|
1150
|
+
npx @es-plus/cli scaffold dashboard --features query,table,dialog
|
|
1151
|
+
```
|
|
1152
|
+
|
|
1153
|
+
详见:[@es-plus/cli](https://www.npmjs.com/package/@es-plus/cli)
|
|
1154
|
+
|
|
1155
|
+
---
|
|
1156
|
+
|
|
1045
1157
|
## 更新日志
|
|
1046
1158
|
|
|
1159
|
+
### v1.2.0
|
|
1160
|
+
|
|
1161
|
+
- 导出全部 TypeScript 类型定义(FormItemOption、TableColumn 等 11 个核心接口)
|
|
1162
|
+
- 新增 EsCrudPage 一键 CRUD 页面组件
|
|
1163
|
+
- 新增权限控制(permissionValue 声明式按钮权限)
|
|
1164
|
+
- 新增国际化支持(labelKey + 自定义翻译函数)
|
|
1165
|
+
- 新增 @es-plus/mcp-server AI 编码工具集成
|
|
1166
|
+
- 新增 @es-plus/cli 命令行工具
|
|
1167
|
+
- 修复 EsForm 按钮模板嵌套问题
|
|
1168
|
+
- 修复 EsDialog v-if/v-for 优先级问题
|
|
1169
|
+
|
|
1047
1170
|
### v1.0.0
|
|
1048
1171
|
|
|
1049
1172
|
- 初始发布
|
package/dist/es-plus.js
CHANGED
|
@@ -2,7 +2,7 @@ import { defineComponent as fe, reactive as Je, onMounted as pt, onUpdated as _t
|
|
|
2
2
|
import { ElConfigProvider as We, ElTableColumn as Ee, ElButton as de, ElTable as $t, ElPagination as jt, vLoading as Ut, ElInput as dt, ElSelect as Nt, ElOption as Mt, ElDatePicker as Kt, ElTimePicker as Qt, ElSlider as Wt, ElColorPicker as Gt, ElTransfer as Yt, ElCascader as Jt, ElRadioGroup as Xt, ElRadio as Zt, ElCheckboxGroup as en, ElCheckbox as tn, ElSwitch as nn, ElRate as on, ElUpload as an, ElForm as ln, ElRow as rn, ElCol as Ct, ElFormItem as Qe, ElDropdown as St, ElDropdownMenu as It, ElDropdownItem as Be, ElDialog as sn, ElIcon as wt } from "element-plus";
|
|
3
3
|
import * as ft from "@element-plus/icons-vue";
|
|
4
4
|
import { FullScreen as cn, CopyDocument as un, Close as dn } from "@element-plus/icons-vue";
|
|
5
|
-
const fn = "1.2.
|
|
5
|
+
const fn = "1.2.1";
|
|
6
6
|
var Ve = {
|
|
7
7
|
name: "zh-cn",
|
|
8
8
|
el: {
|
|
@@ -437,7 +437,7 @@ const it = fe({
|
|
|
437
437
|
for (const [e, a] of g)
|
|
438
438
|
h[e] = a;
|
|
439
439
|
return h;
|
|
440
|
-
}, In = /* @__PURE__ */ De(Sn, [["__scopeId", "data-v-
|
|
440
|
+
}, In = /* @__PURE__ */ De(Sn, [["__scopeId", "data-v-aa1d960e"]]);
|
|
441
441
|
function wn(t, g, h, e, a) {
|
|
442
442
|
const n = V(400), o = V(null), r = (f) => Math.sign(f) === -1, i = () => {
|
|
443
443
|
var E, R, k, H;
|
|
@@ -2153,7 +2153,7 @@ const jn = { class: "dp-dialog_wrapper" }, Un = { class: "dialog-title" }, Nn =
|
|
|
2153
2153
|
]);
|
|
2154
2154
|
};
|
|
2155
2155
|
}
|
|
2156
|
-
}), Ae = /* @__PURE__ */ De(Kn, [["__scopeId", "data-v-
|
|
2156
|
+
}), Ae = /* @__PURE__ */ De(Kn, [["__scopeId", "data-v-f84d929e"]]);
|
|
2157
2157
|
Ae.install = function(t) {
|
|
2158
2158
|
t.component(Ae.name, Ae);
|
|
2159
2159
|
};
|
|
@@ -2317,7 +2317,7 @@ const Qn = { class: "es-crud-page" }, Wn = /* @__PURE__ */ fe({
|
|
|
2317
2317
|
]), 1040, ["columns", "options", "data-source", "pagination"])
|
|
2318
2318
|
]));
|
|
2319
2319
|
}
|
|
2320
|
-
}), Ge = /* @__PURE__ */ De(Wn, [["__scopeId", "data-v-
|
|
2320
|
+
}), Ge = /* @__PURE__ */ De(Wn, [["__scopeId", "data-v-62d0182a"]]);
|
|
2321
2321
|
Ge.install = function(t) {
|
|
2322
2322
|
t.component(Ge.name, Ge);
|
|
2323
2323
|
};
|