@jiangood/open-admin 2.0.0 → 2.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/config/config.js CHANGED
@@ -32,14 +32,6 @@ const proxyConfig = {
32
32
  target: `http://${host}`,
33
33
  changeOrigin: true,
34
34
  },
35
- '/swagger-ui': {
36
- target: `http://${host}`,
37
- changeOrigin: true,
38
- },
39
- '/v3/api-docs': {
40
- target: `http://${host}`,
41
- changeOrigin: true,
42
- },
43
35
  '/admin/ws': {
44
36
  target: `ws://${host}`,
45
37
  changeOrigin: true,
package/package.json CHANGED
@@ -34,5 +34,5 @@
34
34
  "dev": "umi dev",
35
35
  "build": "umi build"
36
36
  },
37
- "version": "2.0.0"
37
+ "version": "2.0.1"
38
38
  }
@@ -36,7 +36,7 @@
36
36
  "dev": "umi dev",
37
37
  "build": "umi build"
38
38
  },
39
- "version": "2.0.0"
39
+ "version": "2.0.1"
40
40
  },
41
41
  "pkgPath": "/home/runner/work/open-admin/open-admin/web/package.json",
42
42
  "plugins": {
@@ -93,7 +93,7 @@
93
93
  "time": {
94
94
  "hooks": {
95
95
  "onStart": [
96
- 0
96
+ 1
97
97
  ]
98
98
  },
99
99
  "register": 2
@@ -113,7 +113,7 @@
113
113
  0
114
114
  ]
115
115
  },
116
- "register": 0
116
+ "register": 1
117
117
  },
118
118
  "enableBy": "register"
119
119
  },
@@ -140,7 +140,7 @@
140
140
  "time": {
141
141
  "hooks": {
142
142
  "modifyAppData": [
143
- 65
143
+ 58
144
144
  ]
145
145
  },
146
146
  "register": 21
@@ -190,7 +190,7 @@
190
190
  "time": {
191
191
  "hooks": {
192
192
  "onCheck": [
193
- 0
193
+ 1
194
194
  ]
195
195
  },
196
196
  "register": 1
@@ -206,7 +206,7 @@
206
206
  "config": {},
207
207
  "time": {
208
208
  "hooks": {},
209
- "register": 1
209
+ "register": 0
210
210
  },
211
211
  "enableBy": "config"
212
212
  },
@@ -1089,10 +1089,10 @@
1089
1089
  "time": {
1090
1090
  "hooks": {
1091
1091
  "onStart": [
1092
- 1
1092
+ 0
1093
1093
  ]
1094
1094
  },
1095
- "register": 1
1095
+ "register": 0
1096
1096
  },
1097
1097
  "enableBy": "register"
1098
1098
  },
@@ -1105,7 +1105,7 @@
1105
1105
  "config": {},
1106
1106
  "time": {
1107
1107
  "hooks": {},
1108
- "register": 0
1108
+ "register": 1
1109
1109
  },
1110
1110
  "enableBy": "register"
1111
1111
  },
@@ -1118,7 +1118,7 @@
1118
1118
  "config": {},
1119
1119
  "time": {
1120
1120
  "hooks": {},
1121
- "register": 96
1121
+ "register": 98
1122
1122
  },
1123
1123
  "enableBy": "register"
1124
1124
  },
@@ -1131,7 +1131,7 @@
1131
1131
  "config": {},
1132
1132
  "time": {
1133
1133
  "hooks": {},
1134
- "register": 29
1134
+ "register": 28
1135
1135
  },
1136
1136
  "enableBy": "config"
1137
1137
  },
@@ -1161,7 +1161,7 @@
1161
1161
  0
1162
1162
  ]
1163
1163
  },
1164
- "register": 1
1164
+ "register": 0
1165
1165
  },
1166
1166
  "enableBy": "register"
1167
1167
  },
@@ -1174,7 +1174,7 @@
1174
1174
  "config": {},
1175
1175
  "time": {
1176
1176
  "hooks": {},
1177
- "register": 0
1177
+ "register": 1
1178
1178
  },
1179
1179
  "enableBy": "register"
1180
1180
  },
@@ -1212,7 +1212,7 @@
1212
1212
  "config": {},
1213
1213
  "time": {
1214
1214
  "hooks": {},
1215
- "register": 1
1215
+ "register": 0
1216
1216
  },
1217
1217
  "enableBy": "config"
1218
1218
  },
@@ -1305,7 +1305,7 @@
1305
1305
  "config": {},
1306
1306
  "time": {
1307
1307
  "hooks": {},
1308
- "register": 0
1308
+ "register": 1
1309
1309
  },
1310
1310
  "enableBy": "config"
1311
1311
  },
@@ -1318,7 +1318,7 @@
1318
1318
  "config": {},
1319
1319
  "time": {
1320
1320
  "hooks": {},
1321
- "register": 1
1321
+ "register": 0
1322
1322
  },
1323
1323
  "enableBy": "config"
1324
1324
  },
@@ -1331,7 +1331,7 @@
1331
1331
  "config": {},
1332
1332
  "time": {
1333
1333
  "hooks": {},
1334
- "register": 0
1334
+ "register": 1
1335
1335
  },
1336
1336
  "enableBy": "register"
1337
1337
  },
@@ -1370,7 +1370,7 @@
1370
1370
  "config": {},
1371
1371
  "time": {
1372
1372
  "hooks": {},
1373
- "register": 1
1373
+ "register": 0
1374
1374
  }
1375
1375
  },
1376
1376
  "./node_modules/@umijs/preset-umi/dist/features/ssr/ssr": {
@@ -1395,7 +1395,7 @@
1395
1395
  "config": {},
1396
1396
  "time": {
1397
1397
  "hooks": {},
1398
- "register": 1
1398
+ "register": 2
1399
1399
  },
1400
1400
  "enableBy": "register"
1401
1401
  },
@@ -1447,7 +1447,7 @@
1447
1447
  "config": {},
1448
1448
  "time": {
1449
1449
  "hooks": {},
1450
- "register": 3
1450
+ "register": 4
1451
1451
  }
1452
1452
  },
1453
1453
  "./node_modules/@umijs/preset-umi/dist/features/monorepo/redirect": {
@@ -1600,7 +1600,7 @@
1600
1600
  "config": {},
1601
1601
  "time": {
1602
1602
  "hooks": {},
1603
- "register": 28
1603
+ "register": 27
1604
1604
  }
1605
1605
  },
1606
1606
  "./node_modules/@umijs/preset-umi/dist/features/forget/forget": {
@@ -1612,7 +1612,7 @@
1612
1612
  "config": {},
1613
1613
  "time": {
1614
1614
  "hooks": {},
1615
- "register": 1
1615
+ "register": 2
1616
1616
  },
1617
1617
  "enableBy": "config"
1618
1618
  },
@@ -1651,7 +1651,7 @@
1651
1651
  "config": {},
1652
1652
  "time": {
1653
1653
  "hooks": {},
1654
- "register": 44
1654
+ "register": 45
1655
1655
  },
1656
1656
  "enableBy": "register"
1657
1657
  },
@@ -1676,7 +1676,7 @@
1676
1676
  "config": {},
1677
1677
  "time": {
1678
1678
  "hooks": {},
1679
- "register": 0
1679
+ "register": 1
1680
1680
  },
1681
1681
  "enableBy": "register"
1682
1682
  },
@@ -1754,7 +1754,7 @@
1754
1754
  "config": {},
1755
1755
  "time": {
1756
1756
  "hooks": {},
1757
- "register": 0
1757
+ "register": 1
1758
1758
  },
1759
1759
  "enableBy": "register"
1760
1760
  },
@@ -1767,7 +1767,7 @@
1767
1767
  "config": {},
1768
1768
  "time": {
1769
1769
  "hooks": {},
1770
- "register": 1
1770
+ "register": 0
1771
1771
  },
1772
1772
  "enableBy": "register"
1773
1773
  },
@@ -1780,7 +1780,7 @@
1780
1780
  "config": {},
1781
1781
  "time": {
1782
1782
  "hooks": {},
1783
- "register": 0
1783
+ "register": 1
1784
1784
  },
1785
1785
  "enableBy": "register"
1786
1786
  },
@@ -1793,7 +1793,7 @@
1793
1793
  "config": {},
1794
1794
  "time": {
1795
1795
  "hooks": {},
1796
- "register": 1
1796
+ "register": 0
1797
1797
  },
1798
1798
  "enableBy": "register"
1799
1799
  },
@@ -1845,7 +1845,7 @@
1845
1845
  "config": {},
1846
1846
  "time": {
1847
1847
  "hooks": {},
1848
- "register": 0
1848
+ "register": 1
1849
1849
  },
1850
1850
  "enableBy": "register"
1851
1851
  },
@@ -1858,7 +1858,7 @@
1858
1858
  "config": {},
1859
1859
  "time": {
1860
1860
  "hooks": {},
1861
- "register": 1
1861
+ "register": 0
1862
1862
  },
1863
1863
  "enableBy": "register"
1864
1864
  },
@@ -1884,7 +1884,7 @@
1884
1884
  "config": {},
1885
1885
  "time": {
1886
1886
  "hooks": {},
1887
- "register": 0
1887
+ "register": 1
1888
1888
  },
1889
1889
  "enableBy": "register"
1890
1890
  },
@@ -1910,7 +1910,7 @@
1910
1910
  "config": {},
1911
1911
  "time": {
1912
1912
  "hooks": {},
1913
- "register": 21
1913
+ "register": 20
1914
1914
  },
1915
1915
  "enableBy": "register"
1916
1916
  },
@@ -1936,7 +1936,7 @@
1936
1936
  "config": {},
1937
1937
  "time": {
1938
1938
  "hooks": {},
1939
- "register": 2
1939
+ "register": 1
1940
1940
  },
1941
1941
  "enableBy": "register"
1942
1942
  },
@@ -1949,7 +1949,7 @@
1949
1949
  "config": {},
1950
1950
  "time": {
1951
1951
  "hooks": {},
1952
- "register": 0
1952
+ "register": 1
1953
1953
  },
1954
1954
  "enableBy": "register"
1955
1955
  },
@@ -1962,7 +1962,7 @@
1962
1962
  "config": {},
1963
1963
  "time": {
1964
1964
  "hooks": {},
1965
- "register": 7
1965
+ "register": 6
1966
1966
  },
1967
1967
  "enableBy": "register"
1968
1968
  }
@@ -1995,14 +1995,6 @@
1995
1995
  "target": "http://127.0.0.1:8080",
1996
1996
  "changeOrigin": true
1997
1997
  },
1998
- "/swagger-ui": {
1999
- "target": "http://127.0.0.1:8080",
2000
- "changeOrigin": true
2001
- },
2002
- "/v3/api-docs": {
2003
- "target": "http://127.0.0.1:8080",
2004
- "changeOrigin": true
2005
- },
2006
1998
  "/admin/ws": {
2007
1999
  "target": "ws://127.0.0.1:8080",
2008
2000
  "changeOrigin": true,
@@ -2054,14 +2046,6 @@
2054
2046
  "target": "http://127.0.0.1:8080",
2055
2047
  "changeOrigin": true
2056
2048
  },
2057
- "/swagger-ui": {
2058
- "target": "http://127.0.0.1:8080",
2059
- "changeOrigin": true
2060
- },
2061
- "/v3/api-docs": {
2062
- "target": "http://127.0.0.1:8080",
2063
- "changeOrigin": true
2064
- },
2065
2049
  "/admin/ws": {
2066
2050
  "target": "ws://127.0.0.1:8080",
2067
2051
  "changeOrigin": true,
@@ -2173,16 +2157,6 @@
2173
2157
  "__isJSFile": true,
2174
2158
  "__absFile": "/home/runner/work/open-admin/open-admin/web/src/pages/userCenter/manual.jsx"
2175
2159
  },
2176
- "system/api/index": {
2177
- "path": "system/api",
2178
- "id": "system/api/index",
2179
- "parentId": "@@/global-layout",
2180
- "file": "system/api/index.jsx",
2181
- "absPath": "/system/api",
2182
- "__content": "import {PlusOutlined} from '@ant-design/icons'\nimport {Button, Form, Input, message, Modal, Popconfirm, Switch, Table, Tabs} from 'antd'\nimport React from 'react'\nimport {\n ArrayUtils,\n ButtonList,\n FieldBoolean,\n FieldDate,\n HttpUtils, ObjectUtils,\n Page,\n ProTable,\n StringUtils,\n ViewPassword\n} from \"../../../framework\";\n\n\nexport default class extends React.Component {\n\n state = {\n formValues: {},\n formOpen: false,\n\n list: [],\n grantFormOpen: false\n }\n\n formRef = React.createRef()\n tableRef = React.createRef()\n\n componentDidMount() {\n HttpUtils.get(\"/admin/apiAccount/perm-list\").then(rs => {\n this.setState({list: rs})\n })\n }\n\n handleAdd = () => {\n this.setState({formOpen: true, formValues: {}})\n }\n\n handleEdit = record => {\n this.setState({formOpen: true, formValues: record})\n }\n\n onFinish = values => {\n HttpUtils.post('admin/apiAccount/save', values).then(rs => {\n this.setState({formOpen: false})\n this.tableRef.current.reload()\n })\n }\n\n handleDelete = record => {\n HttpUtils.post('admin/apiAccount/delete', {id: record.id}).then(rs => {\n this.tableRef.current.reload()\n })\n }\n\n columns = [\n {\n title: '账户名称',\n dataIndex: 'name',\n },\n {\n title: 'appSecret',\n dataIndex: 'appSecret',\n render(v) {\n return <ViewPassword value={v}></ViewPassword>;\n }\n },\n {\n title: '准入IP',\n dataIndex: 'accessIp',\n },\n {\n title: '有效期',\n dataIndex: 'endTime',\n },\n {\n title: '启用',\n dataIndex: 'enabled',\n render(v) {\n return v == null ? null : (v ? '是' : '否')\n },\n },\n {\n title: '权限',\n dataIndex: 'perms',\n render(perms) {\n if (!perms) {\n return\n }\n return perms.join(', ')\n }\n },\n {\n title: '操作',\n dataIndex: 'option',\n render: (_, record) => (\n <ButtonList>\n <Button size='small' perm='api'\n onClick={() => {\n this.handlePreGrant(record);\n }}\n type='primary'>授权</Button>\n <Button size='small' perm='api' onClick={() => this.handleEdit(record)}>编辑</Button>\n <Popconfirm perm='api' title='是否确定删除接口访客' onConfirm={() => this.handleDelete(record)}>\n <Button size='small'>删除</Button>\n </Popconfirm>\n <Button size='small' perm='api' href={'/admin/apiAccount/export/' + record.id} target={'_blank'}>下载文档</Button>\n </ButtonList>\n ),\n },\n ]\n\n handlePreGrant(record) {\n this.setState({grantFormOpen: true, formValues: ObjectUtils.clone(record)})\n }\n\n randomAppSecret = () => {\n const appSecret = StringUtils.random(32)\n this.formRef.current.setFieldsValue({appSecret})\n }\n\n onGrantItemChange = (id, checked) => {\n const perms = this.state.formValues.perms\n if (checked) {\n ArrayUtils.add(perms, id)\n } else {\n ArrayUtils.remove(perms, id)\n }\n this.setState({formValues: this.state.formValues})\n }\n\n onGrant = () => {\n const hide = message.loading('授权中...', 0)\n const accountId = this.state.formValues.id;\n HttpUtils.post('admin/apiAccount/grant/'+accountId, this.state.formValues.perms).then(rs => {\n this.setState({grantFormOpen: false})\n this.tableRef.current.reload()\n }).finally(hide)\n };\n\n\n render() {\n return <Page padding>\n <Tabs items={[\n {\n label: '接口文档',\n key: 'doc',\n children: <iframe src={'/admin/swagger-ui/index.html'} width=\"100%\" height=\"1000px\"></iframe>\n },\n {\n label: '账号管理',\n key: '1',\n children: <ProTable\n actionRef={this.tableRef}\n toolBarRender={() => {\n return <ButtonList>\n <Button perm='api' type='primary' onClick={this.handleAdd}>\n <PlusOutlined/> 新增\n </Button>\n </ButtonList>\n }}\n request={(params) => HttpUtils.get('admin/apiAccount/page', params)}\n columns={this.columns}\n />\n },\n {\n label: '访问记录',\n key: 'log',\n children: <ProTable\n request={(params) => HttpUtils.get('admin/apiLog/page', params)}\n columns={[\n {\n title: '接口',\n dataIndex: 'url',\n },\n {\n title: 'ip',\n dataIndex: 'ip',\n },\n {\n title: 'ipLocation',\n dataIndex: 'ipLocation',\n },\n {\n title: '执行时间',\n dataIndex: 'executionTime',\n },\n {\n title: '接口账户',\n dataIndex: 'accountName',\n }\n ]}\n />\n },\n\n ]}>\n\n </Tabs>\n\n\n <Modal title='接口访客'\n open={this.state.formOpen}\n onOk={() => this.formRef.current.submit()}\n onCancel={() => this.setState({formOpen: false})}\n destroyOnClose\n mask={{closable:false}}\n >\n\n <Form ref={this.formRef} labelCol={{flex: '100px'}}\n initialValues={this.state.formValues}\n onFinish={this.onFinish}\n\n >\n <Form.Item name='id' noStyle></Form.Item>\n\n <Form.Item label='名称' name='name' rules={[{required: true}]}>\n <Input/>\n </Form.Item>\n\n\n <Form.Item label='appId' name='appId'>\n <Input placeholder='多个用逗号分隔'/>\n </Form.Item>\n <Form.Item label='appSecret' name='appSecret' rules={[{required: true}, {len: 32}]}\n help={<Button size='small' type='link' onClick={this.randomAppSecret}>随机生成</Button>}\n >\n <Input/>\n </Form.Item>\n\n <Form.Item label='准入IP' name='accessIp'>\n <Input placeholder='多个用逗号分隔'/>\n </Form.Item>\n <Form.Item label='有效期' name='endTime' style={{marginTop: 32}}>\n <FieldDate type='YYYY-MM-DD'/>\n </Form.Item>\n <Form.Item label='启用' name='enabled' rules={[{required: true}]}>\n <FieldBoolean/>\n </Form.Item>\n\n </Form>\n </Modal>\n\n\n <Modal title='权限列表' destroyOnClose={true} width={800}\n open={this.state.grantFormOpen}\n onCancel={() => this.setState({grantFormOpen: false, formValues: null})}\n onOk={this.onGrant}\n >\n <Table\n dataSource={this.state.list}\n pagination={false}\n rowKey='id'\n size={'small'}\n columns={[\n {dataIndex: 'id', title: '标识'},\n {dataIndex: 'name', title: '名称'},\n {dataIndex: 'description', title: '描述'},\n {dataIndex: 'path', title: '路径'},\n {\n dataIndex: 'option', title: '操作',\n render: (_, record) => {\n const id = record.id;\n return <Switch checked={this.state.formValues.perms.includes(id)}\n onChange={(checked) => {\n this.onGrantItemChange(id, checked)\n }} />\n }\n }\n ]}\n\n />\n </Modal>\n </Page>\n\n\n }\n}\n\n",
2183
- "__isJSFile": true,
2184
- "__absFile": "/home/runner/work/open-admin/open-admin/web/src/pages/system/api/index.jsx"
2185
- },
2186
2160
  "system/job/index": {
2187
2161
  "path": "system/job",
2188
2162
  "id": "system/job/index",
@@ -19,7 +19,7 @@ if (process.env.NODE_ENV === 'development') {
19
19
  import React from 'react';
20
20
 
21
21
  export async function getRoutes() {
22
- const routes = {"404":{"path":"*","id":"404","parentId":"@@/global-layout"},"userCenter/ChangePassword":{"path":"userCenter/ChangePassword","id":"userCenter/ChangePassword","parentId":"@@/global-layout"},"system/user/UserPerm":{"path":"system/user/UserPerm","id":"system/user/UserPerm","parentId":"@@/global-layout"},"system/manual/index":{"path":"system/manual","id":"system/manual/index","parentId":"@@/global-layout"},"userCenter/message":{"path":"userCenter/message","id":"userCenter/message","parentId":"@@/global-layout"},"system/dict/index":{"path":"system/dict","id":"system/dict/index","parentId":"@@/global-layout"},"system/file/index":{"path":"system/file","id":"system/file/index","parentId":"@@/global-layout"},"system/role/index":{"path":"system/role","id":"system/role/index","parentId":"@@/global-layout"},"system/user/index":{"path":"system/user","id":"system/user/index","parentId":"@@/global-layout"},"userCenter/manual":{"path":"userCenter/manual","id":"userCenter/manual","parentId":"@@/global-layout"},"system/api/index":{"path":"system/api","id":"system/api/index","parentId":"@@/global-layout"},"system/job/index":{"path":"system/job","id":"system/job/index","parentId":"@@/global-layout"},"system/log/index":{"path":"system/log","id":"system/log/index","parentId":"@@/global-layout"},"system/org/index":{"path":"system/org","id":"system/org/index","parentId":"@@/global-layout"},"system/role/perm":{"path":"system/role/perm","id":"system/role/perm","parentId":"@@/global-layout"},"userCenter/index":{"path":"userCenter","id":"userCenter/index","parentId":"@@/global-layout"},"about":{"path":"about","id":"about","parentId":"@@/global-layout"},"index":{"path":"/","id":"index","parentId":"@@/global-layout"},"login":{"path":"login","id":"login","parentId":"@@/global-layout"},"@@/global-layout":{"id":"@@/global-layout","path":"/","isLayout":true}} as const;
22
+ const routes = {"404":{"path":"*","id":"404","parentId":"@@/global-layout"},"userCenter/ChangePassword":{"path":"userCenter/ChangePassword","id":"userCenter/ChangePassword","parentId":"@@/global-layout"},"system/user/UserPerm":{"path":"system/user/UserPerm","id":"system/user/UserPerm","parentId":"@@/global-layout"},"system/manual/index":{"path":"system/manual","id":"system/manual/index","parentId":"@@/global-layout"},"userCenter/message":{"path":"userCenter/message","id":"userCenter/message","parentId":"@@/global-layout"},"system/dict/index":{"path":"system/dict","id":"system/dict/index","parentId":"@@/global-layout"},"system/file/index":{"path":"system/file","id":"system/file/index","parentId":"@@/global-layout"},"system/role/index":{"path":"system/role","id":"system/role/index","parentId":"@@/global-layout"},"system/user/index":{"path":"system/user","id":"system/user/index","parentId":"@@/global-layout"},"userCenter/manual":{"path":"userCenter/manual","id":"userCenter/manual","parentId":"@@/global-layout"},"system/job/index":{"path":"system/job","id":"system/job/index","parentId":"@@/global-layout"},"system/log/index":{"path":"system/log","id":"system/log/index","parentId":"@@/global-layout"},"system/org/index":{"path":"system/org","id":"system/org/index","parentId":"@@/global-layout"},"system/role/perm":{"path":"system/role/perm","id":"system/role/perm","parentId":"@@/global-layout"},"userCenter/index":{"path":"userCenter","id":"userCenter/index","parentId":"@@/global-layout"},"about":{"path":"about","id":"about","parentId":"@@/global-layout"},"index":{"path":"/","id":"index","parentId":"@@/global-layout"},"login":{"path":"login","id":"login","parentId":"@@/global-layout"},"@@/global-layout":{"id":"@@/global-layout","path":"/","isLayout":true}} as const;
23
23
  return {
24
24
  routes,
25
25
  routeComponents: {
@@ -33,7 +33,6 @@ export async function getRoutes() {
33
33
  'system/role/index': React.lazy(() => import(/* webpackChunkName: "src__pages__system__role__index" */'../../../src/pages/system/role/index.jsx')),
34
34
  'system/user/index': React.lazy(() => import(/* webpackChunkName: "src__pages__system__user__index" */'../../../src/pages/system/user/index.jsx')),
35
35
  'userCenter/manual': React.lazy(() => import(/* webpackChunkName: "src__pages__userCenter__manual" */'../../../src/pages/userCenter/manual.jsx')),
36
- 'system/api/index': React.lazy(() => import(/* webpackChunkName: "src__pages__system__api__index" */'../../../src/pages/system/api/index.jsx')),
37
36
  'system/job/index': React.lazy(() => import(/* webpackChunkName: "src__pages__system__job__index" */'../../../src/pages/system/job/index.jsx')),
38
37
  'system/log/index': React.lazy(() => import(/* webpackChunkName: "src__pages__system__log__index" */'../../../src/pages/system/log/index.jsx')),
39
38
  'system/org/index': React.lazy(() => import(/* webpackChunkName: "src__pages__system__org__index" */'../../../src/pages/system/org/index.jsx')),
@@ -1,46 +1,42 @@
1
1
  import React from "react";
2
2
 
3
+ const SizeMap = {
4
+ xs: 4,
5
+ sm: 8,
6
+ md: 16,
7
+ lg: 24,
8
+ xl: 32,
9
+ xxl: 40,
10
+ };
11
+
12
+ type GapProps = {
13
+ size?: keyof typeof SizeMap;
14
+ direction?: "horizontal" | "vertical";
15
+ } & React.HTMLAttributes<HTMLDivElement>;
16
+
3
17
  /**
4
18
  * 上下间隔
5
19
  */
6
- export class Gap extends React.Component {
7
-
8
- static defaultProps = {
9
- size: 'middle',
10
- direction: 'vertical',
11
- };
12
-
13
- render() {
14
- const {n = 0, size, direction} = this.props;
15
- if (n) {
16
- console.warn('参数 n 已经不被支持')
17
- return
18
- }
19
-
20
- const SizeMap = {
21
- x: 4,
22
- small: 8,
23
- middle: 16,
24
- large: 24,
25
- xLarge: 32,
26
- xxLarge: 40,
27
- };
28
-
29
-
30
- const sizePx = SizeMap[size];
31
- const isHorizontal = direction === 'horizontal';
32
-
33
-
34
- // 水平间隔:有宽度,无高度
35
- // 垂直间隔:有高度,无宽度
36
- const width = isHorizontal ? sizePx : 0;
37
- const height = isHorizontal ? 0 : sizePx;
38
-
39
- // 水平间隔用 inline-block(避免换行),垂直间隔用 block
40
- const display = isHorizontal ? 'inline-block' : 'block';
41
-
42
- const style = {display, height, width}
43
-
44
- return <div style={style}></div>
45
- }
46
- }
20
+ export const Gap: React.FC<GapProps> = ({
21
+ size = "md",
22
+ direction = "vertical",
23
+ ...rest
24
+ }) => {
25
+ if (size && !Object.hasOwn(SizeMap, size)) {
26
+ throw new Error(
27
+ `Gap: size 属性必须为 [${Object.keys(SizeMap).join(", ")}] 之一,当前传入:${size}`
28
+ );
29
+ }
30
+
31
+ const sizePx = SizeMap[size];
32
+ const isHorizontal = direction === "horizontal";
33
+
34
+ const style: React.CSSProperties = {
35
+ display: isHorizontal ? "inline-block" : "block",
36
+ width: isHorizontal ? sizePx : 0,
37
+ height: isHorizontal ? 0 : sizePx,
38
+ ...rest.style,
39
+ };
40
+
41
+ return <div style={style} {...rest} />;
42
+ };
@@ -1,20 +1,15 @@
1
1
  import React from "react";
2
2
 
3
- export class ViewRange extends React.Component {
4
-
5
- static defaultProps = {
6
- min : '未知',max : '未知'
7
- }
8
-
9
- render() {
10
- let {min,max} = this.props
11
- if(min == null && max == null){
12
- return null;
13
- }
14
- min = min == null ? '未知': min;
15
- max = max == null ? '未知': max;
16
-
17
- return min + ' - ' + max;
18
-
19
- }
3
+ interface ViewRangeProps {
4
+ min?: string;
5
+ max?: string;
20
6
  }
7
+
8
+ export const ViewRange: React.FC<ViewRangeProps> = ({ min, max }) => {
9
+ if ((min == null || min === "") && (max == null || max === "")) {
10
+ return null;
11
+ }
12
+ const showMin = min ?? '未知';
13
+ const showMax = max ?? '未知';
14
+ return <>{showMin} - {showMax}</>;
15
+ };
@@ -1,42 +1,22 @@
1
1
  import React from 'react';
2
- import {Space} from 'antd';
3
- import {PermUtils} from "../../utils";
4
-
2
+ import { Space } from 'antd';
3
+ import { PermUtils } from '../../utils';
5
4
 
6
5
  /**
7
6
  * 带权限的按钮列表
8
7
  * @param maxNum: 显示子节点的个数, 超过的为收缩起来
9
- *
10
8
  */
11
- export class ButtonList extends React.Component {
12
-
13
-
14
- render() {
15
- const {children} = this.props;
16
-
17
- // 单节点的情况
18
- if (!Array.isArray(children)) {
19
- if (this.checkPerm(children)) {
20
- return children;
21
- }
22
- return null
23
- }
9
+ export function ButtonList(props) {
10
+ const { children } = props;
24
11
 
25
- const menus = [];
26
- for (let child of children) {
27
- if (child === null || child === undefined) {
28
- continue;
29
- }
30
- if (this.checkPerm(child)) {
31
- menus.push(child);
32
- }
33
- }
34
- return <Space>{menus}</Space>;
35
- }
12
+ const checkPerm = (element) => {
13
+ const _props = element?.props;
14
+ return !_props?.perm || PermUtils.hasPermission(_props.perm);
15
+ };
36
16
 
37
- checkPerm = element => {
38
- const props = element.props;
39
- return props == null || props.perm == null || PermUtils.hasPermission(props.perm);
17
+ const nodes = React.Children.toArray(children).filter(
18
+ (child) => child != null && checkPerm(child)
19
+ );
40
20
 
41
- };
21
+ return <Space>{nodes}</Space>;
42
22
  }
package/src/loading.jsx CHANGED
@@ -1,18 +1,19 @@
1
1
  import React from "react";
2
- import {Spin} from "antd";
3
- import {ThemeUtils} from "./framework";
2
+ import { Spin } from "antd";
3
+ import { ThemeUtils } from "./framework";
4
4
 
5
- export default class extends React.Component {
6
- render() {
7
- return <div
8
- style={{
9
- display: 'flex',
10
- alignItems: 'center',
11
- justifyContent: 'center',
12
- height: '100vh',
13
- background: ThemeUtils.getColor("background-color")
14
- }}>
15
- <Spin size='large'/>
16
- </div>
17
- }
18
- }
5
+ const Loading = () => (
6
+ <div
7
+ style={{
8
+ display: 'flex',
9
+ alignItems: 'center',
10
+ justifyContent: 'center',
11
+ height: '100vh',
12
+ background: ThemeUtils.getColor("background-color")
13
+ }}
14
+ >
15
+ <Spin size='large' />
16
+ </div>
17
+ );
18
+
19
+ export default Loading;
@@ -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
-