@jiangood/open-admin 2.0.0 → 2.2.4

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 (39) hide show
  1. package/config/config.js +9 -22
  2. package/package.json +5 -1
  3. package/src/.umi-production/appData.json +67 -108
  4. package/src/.umi-production/core/route.tsx +1 -2
  5. package/src/.umi-production/umi.ts +2 -2
  6. package/src/framework/components/Gap/index.tsx +37 -41
  7. package/src/framework/components/Page/index.less +1 -1
  8. package/src/framework/components/Page/index.tsx +19 -22
  9. package/src/framework/components/ViewRange/index.tsx +12 -17
  10. package/src/framework/components/system/ButtonList.tsx +12 -32
  11. package/src/framework/fields/FieldEditor/index.tsx +3 -2
  12. package/src/framework/fields/FieldUploadFile/index.tsx +8 -4
  13. package/src/framework/utils/MessageUtils.tsx +21 -99
  14. package/src/framework/utils/system/HttpUtils.ts +2 -1
  15. package/src/framework/utils/system/SysUtils.ts +8 -0
  16. package/src/layouts/PageRender.d.ts +2 -17
  17. package/src/layouts/PageRender.jsx +14 -76
  18. package/src/layouts/admin/TabPageRender.jsx +138 -158
  19. package/src/layouts/admin/index.jsx +120 -17
  20. package/src/layouts/admin/index.less +123 -5
  21. package/src/layouts/index.jsx +78 -161
  22. package/src/loading.jsx +17 -16
  23. package/src/pages/404.jsx +7 -5
  24. package/src/pages/about.jsx +3 -3
  25. package/src/pages/index.jsx +4 -5
  26. package/src/pages/login.jsx +16 -9
  27. package/src/pages/login.less +0 -1
  28. package/src/pages/system/dict/index.jsx +7 -10
  29. package/src/pages/system/file/index.jsx +5 -5
  30. package/src/pages/system/job/index.jsx +9 -7
  31. package/src/pages/system/log/index.jsx +4 -5
  32. package/src/pages/system/manual/index.jsx +6 -4
  33. package/src/pages/system/org/index.jsx +4 -2
  34. package/src/pages/system/role/index.jsx +9 -7
  35. package/src/pages/system/role/perm.jsx +3 -4
  36. package/src/pages/system/user/index.jsx +8 -6
  37. package/src/pages/userCenter/index.jsx +1 -1
  38. package/src/pages/userCenter/message.jsx +4 -2
  39. package/src/pages/system/api/index.jsx +0 -279
@@ -16,7 +16,7 @@ import {
16
16
  } from 'antd'
17
17
  import {PlusOutlined} from "@ant-design/icons";
18
18
 
19
- import {ButtonList, HttpUtils, Page, ProTable, StringUtils, ValueType} from "../../../framework";
19
+ import {ButtonList, HttpUtils, Page, ProTable, StringUtils, SysUtils, ValueType} from "../../../framework";
20
20
 
21
21
 
22
22
  const cronOptions = [
@@ -85,7 +85,9 @@ export default class extends React.Component {
85
85
  }
86
86
 
87
87
  onFinish = (values) => {
88
- HttpUtils.post('admin/job/save', values).then(rs => {
88
+ const isNew = !values.id;
89
+ const url = isNew ? 'admin/job/create' : 'admin/job/update';
90
+ HttpUtils.post(url, values).then(rs => {
89
91
  this.setState({formOpen: false})
90
92
  this.tableRef.current.reload();
91
93
  })
@@ -149,9 +151,9 @@ export default class extends React.Component {
149
151
  return (
150
152
  <Space>
151
153
  <Button size='small' onClick={() => this.showExecuteRecord(record)}>执行记录</Button>
152
- <Button size='small' onClick={() => this.handleTriggerJob(record)}>执行一次</Button>
153
- <Button size='small' onClick={() => this.handleEdit(record)}> 编辑 </Button>
154
- <Popconfirm title='是否确定删除?' onConfirm={() => this.handleDelete(record)}>
154
+ <Button size='small' perm='job:trigger' onClick={() => this.handleTriggerJob(record)}>执行一次</Button>
155
+ <Button size='small' perm='job:update' onClick={() => this.handleEdit(record)}> 编辑 </Button>
156
+ <Popconfirm perm='job:delete' title='是否确定删除?' onConfirm={() => this.handleDelete(record)}>
155
157
  <Button size='small'>删除</Button>
156
158
  </Popconfirm>
157
159
  </Space>
@@ -174,7 +176,7 @@ export default class extends React.Component {
174
176
 
175
177
 
176
178
  render() {
177
- return <Page padding>
179
+ return <Page>
178
180
  <ProTable
179
181
  actionRef={this.tableRef}
180
182
  toolBarRender={() => {
@@ -289,7 +291,7 @@ export default class extends React.Component {
289
291
  title: '操作',
290
292
  dataIndex: 'option',
291
293
  render: (_, record) => {
292
- const url = '/admin/sys/log/' + record.id;
294
+ const url = SysUtils.contextPath('/admin/sys/log/' + record.id);
293
295
  return <a href={url} target='_blank'>日志</a>;
294
296
  },
295
297
  }
@@ -1,6 +1,6 @@
1
- import React, {Fragment} from 'react';
1
+ import React from 'react';
2
2
  import {Form, Input, Tag} from "antd";
3
- import {ViewText, FieldDateRange, HttpUtils, ProTable} from "../../../framework";
3
+ import {ViewText, FieldDateRange, HttpUtils, Page, ProTable} from "../../../framework";
4
4
 
5
5
  export default class extends React.Component {
6
6
 
@@ -54,7 +54,7 @@ export default class extends React.Component {
54
54
 
55
55
 
56
56
  render() {
57
- return <>
57
+ return <Page>
58
58
  <ProTable
59
59
  request={(params) => HttpUtils.get('admin/sysLog/page', params)}
60
60
  columns={this.columns}
@@ -66,8 +66,7 @@ export default class extends React.Component {
66
66
  <FieldDateRange/>
67
67
  </Form.Item>
68
68
  </ProTable>
69
-
70
- </>
69
+ </Page>
71
70
  }
72
71
 
73
72
 
@@ -23,7 +23,9 @@ export default class extends React.Component {
23
23
  }
24
24
 
25
25
  onFinish = values => {
26
- HttpUtils.post('admin/sysManual/save', values).then(rs => {
26
+ const isNew = !values.id;
27
+ const url = isNew ? 'admin/sysManual/create' : 'admin/sysManual/update';
28
+ HttpUtils.post(url, values).then(rs => {
27
29
  this.setState({formOpen: false})
28
30
  this.tableRef.current.reload()
29
31
  })
@@ -66,8 +68,8 @@ export default class extends React.Component {
66
68
  dataIndex: 'option',
67
69
  render: (_, record) => (
68
70
  <ButtonList>
69
- <Button size='small' perm='sysManual:save' onClick={() => this.handleEdit(record)}>编辑</Button>
70
- <Popconfirm perm='sysManual:delete' title='是否确定删除操作手册'
71
+ <Button size='small' perm='sys-manual:update' onClick={() => this.handleEdit(record)}>编辑</Button>
72
+ <Popconfirm perm='sys-manual:delete' title='是否确定删除操作手册'
71
73
  onConfirm={() => this.handleDelete(record)}>
72
74
  <Button size='small'>删除</Button>
73
75
  </Popconfirm>
@@ -83,7 +85,7 @@ export default class extends React.Component {
83
85
  actionRef={this.tableRef}
84
86
  toolBarRender={(params, {selectedRows, selectedRowKeys}) => {
85
87
  return <ButtonList>
86
- <Button perm='sysManual:save' type='primary' onClick={this.handleAdd}>
88
+ <Button perm='sys-manual:create' type='primary' onClick={this.handleAdd}>
87
89
  <PlusOutlined/> 新增
88
90
  </Button>
89
91
  </ButtonList>
@@ -77,7 +77,9 @@ export default class extends React.Component {
77
77
 
78
78
  onFinish = (values) => {
79
79
  this.setState({submitLoading: true, formEditing: false})
80
- HttpUtils.post('admin/sysOrg/save', values).then(rs => {
80
+ const isNew = !values.id;
81
+ const url = isNew ? 'admin/sysOrg/create' : 'admin/sysOrg/update';
82
+ HttpUtils.post(url, values).then(rs => {
81
83
  this.loadTree()
82
84
  }).finally(() => {
83
85
  this.setState({submitLoading: false})
@@ -94,7 +96,7 @@ export default class extends React.Component {
94
96
  const {formValues} = this.state;
95
97
  const disabled = formValues == null;
96
98
  const params = this.state.params;
97
- return <Page padding>
99
+ return <Page>
98
100
  <Card>
99
101
  <Space>
100
102
 
@@ -45,7 +45,9 @@ export default class extends React.Component {
45
45
  }
46
46
 
47
47
  onFinish = values => {
48
- HttpUtils.post('admin/sysRole/save', values).then(rs => {
48
+ const isNew = !values.id;
49
+ const url = isNew ? 'admin/sysRole/create' : 'admin/sysRole/update';
50
+ HttpUtils.post(url, values).then(rs => {
49
51
  this.setState({formOpen: false})
50
52
  this.tableRef.current.reload()
51
53
  })
@@ -130,15 +132,15 @@ export default class extends React.Component {
130
132
 
131
133
  return (
132
134
  <ButtonList>
133
- <Button size='small' perm='sysRole:manage'
135
+ <Button size='small' perm='sys-role:grant-permission'
134
136
  onClick={() => this.handleEditUser(record)}>用户设置</Button>
135
137
 
136
- <Button size='small' perm='sysRole:manage' disabled={record.builtin}
138
+ <Button size='small' perm='sys-role:grant-permission' disabled={record.builtin}
137
139
  onClick={() => PageUtils.open('/system/role/perm?id=' + record.id, '角色权限设置')}>权限设置</Button>
138
140
 
139
- <Button size='small' perm='sysRole:manage' disabled={record.builtin}
141
+ <Button size='small' perm='sys-role:update' disabled={record.builtin}
140
142
  onClick={() => this.handleEdit(record)}>编辑</Button>
141
- <Popconfirm perm='sysRole:manage' disabled={record.builtin} title='是否确定删除系统角色'
143
+ <Popconfirm perm='sys-role:delete' disabled={record.builtin} title='是否确定删除系统角色'
142
144
  onConfirm={() => this.handleDelete(record)}>
143
145
  <Button size='small'>删除</Button>
144
146
  </Popconfirm>
@@ -178,12 +180,12 @@ export default class extends React.Component {
178
180
  }
179
181
 
180
182
  render() {
181
- return <Page padding>
183
+ return <Page>
182
184
  <ProTable
183
185
  actionRef={this.tableRef}
184
186
  toolBarRender={() => {
185
187
  return <ButtonList>
186
- <Button perm='sysRole:manage' type='primary' onClick={this.handleAdd}>
188
+ <Button perm='sys-role:create' type='primary' onClick={this.handleAdd}>
187
189
  <PlusOutlined/> 新增
188
190
  </Button>
189
191
  </ButtonList>
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import {Button, Card, Checkbox, Table, Typography} from "antd";
3
3
  import {SaveOutlined} from "@ant-design/icons";
4
- import {ArrayUtils, HttpUtils, PageUtils} from "../../../framework";
4
+ import {ArrayUtils, HttpUtils, Page, PageUtils} from "../../../framework";
5
5
  export default class extends React.Component {
6
6
 
7
7
 
@@ -89,8 +89,7 @@ export default class extends React.Component {
89
89
 
90
90
 
91
91
  render() {
92
- return <>
93
-
92
+ return <Page>
94
93
 
95
94
  <Card title='角色权限设置' loading={this.state.loading}
96
95
  variant={"borderless"}
@@ -102,6 +101,6 @@ export default class extends React.Component {
102
101
  expandable={{defaultExpandAllRows: true}}
103
102
  ></Table>
104
103
  </Card>
105
- </>
104
+ </Page>
106
105
  }
107
106
  }
@@ -125,16 +125,16 @@ export default class extends React.Component {
125
125
  fixed: 'right',
126
126
  render: (_, record) => {
127
127
  return <ButtonList>
128
- <Button size='small' perm='sysUser:save' onClick={() => this.handleEdit(record)}> 编辑 </Button>
128
+ <Button size='small' perm='sys-user:update' onClick={() => this.handleEdit(record)}> 编辑 </Button>
129
129
 
130
- <Button size='small' perm='sysUser:grantPerm'
130
+ <Button size='small' perm='sys-user:grant-permission'
131
131
  onClick={() => this.permRef.current.show(record)}> 授权 </Button>
132
132
 
133
- <Popconfirm perm='sysUser:resetPwd' title='确认重置密码?' onConfirm={() => this.resetPwd(record)}>
133
+ <Popconfirm perm='sys-user:reset-password' title='确认重置密码?' onConfirm={() => this.resetPwd(record)}>
134
134
  <Button size='small'>重置密码</Button>
135
135
  </Popconfirm>
136
136
 
137
- <Popconfirm perm='sysUser:delete' title={'是否确定删除用户'}
137
+ <Popconfirm perm='sys-user:delete' title={'是否确定删除用户'}
138
138
  onConfirm={() => this.handleDelete(record)}>
139
139
  <Button size='small'>删除</Button>
140
140
  </Popconfirm>
@@ -144,7 +144,9 @@ export default class extends React.Component {
144
144
  ];
145
145
 
146
146
  onFinish = values => {
147
- HttpUtils.post('admin/sysUser/save', values).then(rs => {
147
+ const isNew = !values.id;
148
+ const url = isNew ? 'admin/sysUser/create' : 'admin/sysUser/update';
149
+ HttpUtils.post(url, values).then(rs => {
148
150
  this.setState({formOpen: false})
149
151
  this.tableRef.current.reload()
150
152
  })
@@ -178,7 +180,7 @@ export default class extends React.Component {
178
180
  toolBarRender={() => {
179
181
  return <ButtonList>
180
182
  <Button
181
- perm='sysUser:save'
183
+ perm='sys-user:create'
182
184
  type="primary"
183
185
  onClick={this.handleAdd}>
184
186
  <PlusOutlined/> 新增
@@ -17,7 +17,7 @@ export default class extends React.Component {
17
17
 
18
18
  render() {
19
19
  const {info} = this.state;
20
- return <Page padding backgroundGray>
20
+ return <Page backgroundGray>
21
21
  <Row gutter={[16, 16]}>
22
22
  <Col md={6} sm={24}>
23
23
  <Card title='个人信息'>
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import {Button, Card, Tabs, Tag} from "antd";
3
- import {ProTable} from "../../framework";
3
+ import {HttpUtils, Page, ProTable} from "../../framework";
4
4
 
5
5
  export default class extends React.Component {
6
6
 
@@ -54,7 +54,8 @@ export default class extends React.Component {
54
54
  ]
55
55
 
56
56
  render() {
57
- return <Card variant={"borderless"}>
57
+ return <Page>
58
+ <Card variant={"borderless"}>
58
59
 
59
60
  <Tabs defaultActiveKey="0" destroyOnClose
60
61
  >
@@ -99,5 +100,6 @@ export default class extends React.Component {
99
100
  </Tabs>
100
101
 
101
102
  </Card>
103
+ </Page>
102
104
  }
103
105
  }
@@ -1,279 +0,0 @@
1
- import {PlusOutlined} from '@ant-design/icons'
2
- import {Button, Form, Input, message, Modal, Popconfirm, Switch, Table, Tabs} from 'antd'
3
- import React from 'react'
4
- import {
5
- ArrayUtils,
6
- ButtonList,
7
- FieldBoolean,
8
- FieldDate,
9
- HttpUtils, ObjectUtils,
10
- Page,
11
- ProTable,
12
- StringUtils,
13
- ViewPassword
14
- } from "../../../framework";
15
-
16
-
17
- export default class extends React.Component {
18
-
19
- state = {
20
- formValues: {},
21
- formOpen: false,
22
-
23
- list: [],
24
- grantFormOpen: false
25
- }
26
-
27
- formRef = React.createRef()
28
- tableRef = React.createRef()
29
-
30
- componentDidMount() {
31
- HttpUtils.get("/admin/apiAccount/perm-list").then(rs => {
32
- this.setState({list: rs})
33
- })
34
- }
35
-
36
- handleAdd = () => {
37
- this.setState({formOpen: true, formValues: {}})
38
- }
39
-
40
- handleEdit = record => {
41
- this.setState({formOpen: true, formValues: record})
42
- }
43
-
44
- onFinish = values => {
45
- HttpUtils.post('admin/apiAccount/save', values).then(rs => {
46
- this.setState({formOpen: false})
47
- this.tableRef.current.reload()
48
- })
49
- }
50
-
51
- handleDelete = record => {
52
- HttpUtils.post('admin/apiAccount/delete', {id: record.id}).then(rs => {
53
- this.tableRef.current.reload()
54
- })
55
- }
56
-
57
- columns = [
58
- {
59
- title: '账户名称',
60
- dataIndex: 'name',
61
- },
62
- {
63
- title: 'appSecret',
64
- dataIndex: 'appSecret',
65
- render(v) {
66
- return <ViewPassword value={v}></ViewPassword>;
67
- }
68
- },
69
- {
70
- title: '准入IP',
71
- dataIndex: 'accessIp',
72
- },
73
- {
74
- title: '有效期',
75
- dataIndex: 'endTime',
76
- },
77
- {
78
- title: '启用',
79
- dataIndex: 'enabled',
80
- render(v) {
81
- return v == null ? null : (v ? '是' : '否')
82
- },
83
- },
84
- {
85
- title: '权限',
86
- dataIndex: 'perms',
87
- render(perms) {
88
- if (!perms) {
89
- return
90
- }
91
- return perms.join(', ')
92
- }
93
- },
94
- {
95
- title: '操作',
96
- dataIndex: 'option',
97
- render: (_, record) => (
98
- <ButtonList>
99
- <Button size='small' perm='api'
100
- onClick={() => {
101
- this.handlePreGrant(record);
102
- }}
103
- type='primary'>授权</Button>
104
- <Button size='small' perm='api' onClick={() => this.handleEdit(record)}>编辑</Button>
105
- <Popconfirm perm='api' title='是否确定删除接口访客' onConfirm={() => this.handleDelete(record)}>
106
- <Button size='small'>删除</Button>
107
- </Popconfirm>
108
- <Button size='small' perm='api' href={'/admin/apiAccount/export/' + record.id} target={'_blank'}>下载文档</Button>
109
- </ButtonList>
110
- ),
111
- },
112
- ]
113
-
114
- handlePreGrant(record) {
115
- this.setState({grantFormOpen: true, formValues: ObjectUtils.clone(record)})
116
- }
117
-
118
- randomAppSecret = () => {
119
- const appSecret = StringUtils.random(32)
120
- this.formRef.current.setFieldsValue({appSecret})
121
- }
122
-
123
- onGrantItemChange = (id, checked) => {
124
- const perms = this.state.formValues.perms
125
- if (checked) {
126
- ArrayUtils.add(perms, id)
127
- } else {
128
- ArrayUtils.remove(perms, id)
129
- }
130
- this.setState({formValues: this.state.formValues})
131
- }
132
-
133
- onGrant = () => {
134
- const hide = message.loading('授权中...', 0)
135
- const accountId = this.state.formValues.id;
136
- HttpUtils.post('admin/apiAccount/grant/'+accountId, this.state.formValues.perms).then(rs => {
137
- this.setState({grantFormOpen: false})
138
- this.tableRef.current.reload()
139
- }).finally(hide)
140
- };
141
-
142
-
143
- render() {
144
- return <Page padding>
145
- <Tabs items={[
146
- {
147
- label: '接口文档',
148
- key: 'doc',
149
- children: <iframe src={'/admin/swagger-ui/index.html'} width="100%" height="1000px"></iframe>
150
- },
151
- {
152
- label: '账号管理',
153
- key: '1',
154
- children: <ProTable
155
- actionRef={this.tableRef}
156
- toolBarRender={() => {
157
- return <ButtonList>
158
- <Button perm='api' type='primary' onClick={this.handleAdd}>
159
- <PlusOutlined/> 新增
160
- </Button>
161
- </ButtonList>
162
- }}
163
- request={(params) => HttpUtils.get('admin/apiAccount/page', params)}
164
- columns={this.columns}
165
- />
166
- },
167
- {
168
- label: '访问记录',
169
- key: 'log',
170
- children: <ProTable
171
- request={(params) => HttpUtils.get('admin/apiLog/page', params)}
172
- columns={[
173
- {
174
- title: '接口',
175
- dataIndex: 'url',
176
- },
177
- {
178
- title: 'ip',
179
- dataIndex: 'ip',
180
- },
181
- {
182
- title: 'ipLocation',
183
- dataIndex: 'ipLocation',
184
- },
185
- {
186
- title: '执行时间',
187
- dataIndex: 'executionTime',
188
- },
189
- {
190
- title: '接口账户',
191
- dataIndex: 'accountName',
192
- }
193
- ]}
194
- />
195
- },
196
-
197
- ]}>
198
-
199
- </Tabs>
200
-
201
-
202
- <Modal title='接口访客'
203
- open={this.state.formOpen}
204
- onOk={() => this.formRef.current.submit()}
205
- onCancel={() => this.setState({formOpen: false})}
206
- destroyOnClose
207
- mask={{closable:false}}
208
- >
209
-
210
- <Form ref={this.formRef} labelCol={{flex: '100px'}}
211
- initialValues={this.state.formValues}
212
- onFinish={this.onFinish}
213
-
214
- >
215
- <Form.Item name='id' noStyle></Form.Item>
216
-
217
- <Form.Item label='名称' name='name' rules={[{required: true}]}>
218
- <Input/>
219
- </Form.Item>
220
-
221
-
222
- <Form.Item label='appId' name='appId'>
223
- <Input placeholder='多个用逗号分隔'/>
224
- </Form.Item>
225
- <Form.Item label='appSecret' name='appSecret' rules={[{required: true}, {len: 32}]}
226
- help={<Button size='small' type='link' onClick={this.randomAppSecret}>随机生成</Button>}
227
- >
228
- <Input/>
229
- </Form.Item>
230
-
231
- <Form.Item label='准入IP' name='accessIp'>
232
- <Input placeholder='多个用逗号分隔'/>
233
- </Form.Item>
234
- <Form.Item label='有效期' name='endTime' style={{marginTop: 32}}>
235
- <FieldDate type='YYYY-MM-DD'/>
236
- </Form.Item>
237
- <Form.Item label='启用' name='enabled' rules={[{required: true}]}>
238
- <FieldBoolean/>
239
- </Form.Item>
240
-
241
- </Form>
242
- </Modal>
243
-
244
-
245
- <Modal title='权限列表' destroyOnClose={true} width={800}
246
- open={this.state.grantFormOpen}
247
- onCancel={() => this.setState({grantFormOpen: false, formValues: null})}
248
- onOk={this.onGrant}
249
- >
250
- <Table
251
- dataSource={this.state.list}
252
- pagination={false}
253
- rowKey='id'
254
- size={'small'}
255
- columns={[
256
- {dataIndex: 'id', title: '标识'},
257
- {dataIndex: 'name', title: '名称'},
258
- {dataIndex: 'description', title: '描述'},
259
- {dataIndex: 'path', title: '路径'},
260
- {
261
- dataIndex: 'option', title: '操作',
262
- render: (_, record) => {
263
- const id = record.id;
264
- return <Switch checked={this.state.formValues.perms.includes(id)}
265
- onChange={(checked) => {
266
- this.onGrantItemChange(id, checked)
267
- }} />
268
- }
269
- }
270
- ]}
271
-
272
- />
273
- </Modal>
274
- </Page>
275
-
276
-
277
- }
278
- }
279
-