@jiangood/open-admin 3.0.15 → 3.1.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/package.json +15 -2
- package/src/framework/biz/OrgTree.tsx +10 -6
- package/src/framework/biz/PermActions.tsx +5 -3
- package/src/framework/biz/RoleTree.tsx +10 -6
- package/src/framework/biz/index.tsx +1 -0
- package/src/framework/components/ContextMenu/index.tsx +17 -1
- package/src/framework/components/DownloadModal/index.tsx +40 -33
- package/src/framework/components/DrawerForm/index.tsx +108 -0
- package/src/framework/components/FormModal/index.tsx +16 -9
- package/src/framework/components/NamedIcon/index.tsx +2 -2
- package/src/framework/components/OrgSwitcher/index.tsx +6 -7
- package/src/framework/components/PageLoading/index.tsx +3 -3
- package/src/framework/components/ProTable/index.tsx +28 -25
- package/src/framework/components/ValueType/index.tsx +1 -1
- package/src/framework/components/index.ts +1 -0
- package/src/framework/config/themeConfig.ts +5 -5
- package/src/framework/fields/BaseRemoteSelect/index.tsx +23 -21
- package/src/framework/fields/FieldBoolean/index.tsx +6 -6
- package/src/framework/fields/FieldDate/index.tsx +10 -10
- package/src/framework/fields/FieldDateRange/index.tsx +20 -20
- package/src/framework/fields/FieldDictSelect/index.tsx +2 -2
- package/src/framework/fields/FieldEditor/index.tsx +1 -1
- package/src/framework/fields/FieldNumberRange/index.tsx +16 -17
- package/src/framework/fields/FieldPercent/index.tsx +2 -2
- package/src/framework/fields/FieldRemoteSelect/index.tsx +4 -4
- package/src/framework/fields/FieldRemoteTree/index.tsx +1 -1
- package/src/framework/fields/FieldRemoteTreeCascader/index.tsx +1 -1
- package/src/framework/fields/FieldRemoteTreeSelect/index.tsx +1 -1
- package/src/framework/fields/FieldSysOrgTree/index.tsx +1 -1
- package/src/framework/fields/FieldSysOrgTreeSelect/index.tsx +1 -1
- package/src/framework/fields/FieldTable/index.tsx +15 -13
- package/src/framework/fields/FieldTableSelect/index.tsx +5 -5
- package/src/framework/fields/FieldUploadFile/index.tsx +3 -3
- package/src/framework/fields/FieldUploadImage/index.tsx +31 -29
- package/src/framework/fields/types.ts +0 -2
- package/src/framework/router/PageFrame.tsx +1 -1
- package/src/framework/router/matcher.ts +2 -2
- package/src/framework/utils/ArrayUtils.ts +2 -2
- package/src/framework/utils/DateUtils.ts +1 -1
- package/src/framework/utils/{system/DictUtils.ts → DictUtils.ts} +1 -1
- package/src/framework/utils/EventBus.ts +7 -7
- package/src/framework/utils/HttpClient.ts +283 -0
- package/src/framework/utils/{system/PageUtils.ts → PageUtils.ts} +4 -4
- package/src/framework/utils/{system/PermUtils.ts → PermUtils.ts} +3 -3
- package/src/framework/utils/StringUtils.ts +10 -8
- package/src/framework/utils/TreeUtils.ts +3 -3
- package/src/framework/utils/UrlUtils.ts +2 -2
- package/src/framework/utils/index.ts +4 -1
- package/src/framework/views/ViewApproveStatus/index.tsx +1 -2
- package/src/framework/views/ViewBoolean/index.tsx +4 -1
- package/src/framework/views/ViewFile/index.tsx +4 -4
- package/src/framework/views/ViewImage/index.tsx +2 -2
- package/src/framework/views/ViewPassword/index.tsx +3 -2
- package/src/framework/views/ViewText/index.tsx +12 -3
- package/src/framework/views/types.ts +2 -4
- package/src/layouts/admin/AdminTabs.jsx +9 -0
- package/src/layouts/admin/AdminTabs.less +2 -2
- package/src/layouts/admin/HeaderRight.jsx +8 -7
- package/src/layouts/admin/TabLayout.jsx +2 -2
- package/src/layouts/admin/index.jsx +15 -11
- package/src/layouts/admin/index.less +16 -1
- package/src/layouts/index.tsx +24 -18
- package/src/pages/404.jsx +1 -1
- package/src/pages/article/$code.jsx +4 -4
- package/src/pages/index.jsx +1 -1
- package/src/pages/public/login.jsx +34 -27
- package/src/pages/public/test.jsx +1 -1
- package/src/pages/standalone/forceUpdatePwd.jsx +9 -7
- package/src/pages/system/article/index.jsx +9 -8
- package/src/pages/system/dict/index.jsx +19 -16
- package/src/pages/system/file/index.jsx +9 -9
- package/src/pages/system/job/index.jsx +17 -17
- package/src/pages/system/log/index.jsx +5 -7
- package/src/pages/system/org/index.jsx +31 -18
- package/src/pages/system/role/index.jsx +13 -12
- package/src/pages/system/role/rolePerm.jsx +25 -21
- package/src/pages/system/user/index.jsx +35 -33
- package/src/pages/system/user/userPerm.jsx +12 -12
- package/src/pages/userCenter/index.jsx +11 -9
- package/src/pages/userCenter/permView.jsx +7 -7
- package/src/framework/utils/system/HttpUtils.ts +0 -97
- package/src/framework/utils/system/index.ts +0 -4
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import {Button, Card, Descriptions, Form, Input, Modal} from "antd";
|
|
3
3
|
import PermView from "./permView";
|
|
4
|
-
import {
|
|
4
|
+
import {HttpClient, history, Page} from "../../framework";
|
|
5
5
|
|
|
6
|
-
export default class extends React.Component {
|
|
6
|
+
export default class UserCenterPage extends React.Component {
|
|
7
7
|
|
|
8
8
|
formRef = React.createRef();
|
|
9
9
|
|
|
@@ -14,20 +14,21 @@ export default class extends React.Component {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
componentDidMount() {
|
|
17
|
-
|
|
18
|
-
this.setState({info: rs})
|
|
17
|
+
HttpClient.get('admin/userCenter/info', null).then(rs => {
|
|
18
|
+
this.setState({info: rs.data})
|
|
19
19
|
})
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
onPwdFinish = (values) => {
|
|
23
|
-
|
|
23
|
+
HttpClient.post('admin/userCenter/update-pwd', values, null).then(() => {
|
|
24
24
|
this.setState({changePwdOpen: false, changePwdSuccess: true});
|
|
25
25
|
})
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
pwdValidator = (rule, value) => {
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
pwdValidator = (rule, value) => HttpClient.get("admin/sysUser/pwd-strength", {password: value}, {toastError: false})
|
|
29
|
+
.catch(e => {
|
|
30
|
+
throw new Error(e.message)
|
|
31
|
+
})
|
|
31
32
|
|
|
32
33
|
render() {
|
|
33
34
|
const {info, changePwdOpen, changePwdSuccess} = this.state;
|
|
@@ -67,12 +68,13 @@ export default class extends React.Component {
|
|
|
67
68
|
extra={'请输入字母、数字、特殊字符'}
|
|
68
69
|
rules={[
|
|
69
70
|
{required: true, message: '请输入新密码'},
|
|
71
|
+
{pattern: /^[\x20-\x7E]{1,64}$/, message: '密码仅支持英文、数字与常见符号,长度不超过64位'},
|
|
70
72
|
{
|
|
71
73
|
validator: this.pwdValidator
|
|
72
74
|
}
|
|
73
75
|
]}
|
|
74
76
|
>
|
|
75
|
-
<Input.Password></Input.Password>
|
|
77
|
+
<Input.Password maxLength={64}></Input.Password>
|
|
76
78
|
</Form.Item>
|
|
77
79
|
</Form>
|
|
78
80
|
</Modal>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import {Empty, Table, Tag} from "antd";
|
|
3
|
-
import {
|
|
3
|
+
import {HttpClient, Gap} from "../../framework";
|
|
4
4
|
|
|
5
5
|
export default class PermView extends React.Component {
|
|
6
6
|
|
|
@@ -9,8 +9,8 @@ export default class PermView extends React.Component {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
componentDidMount() {
|
|
12
|
-
|
|
13
|
-
this.setState({data: rs})
|
|
12
|
+
HttpClient.get('admin/userCenter/perms', null).then(rs => {
|
|
13
|
+
this.setState({data: rs.data})
|
|
14
14
|
})
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -26,7 +26,7 @@ export default class PermView extends React.Component {
|
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
title: '状态', dataIndex: 'status', key: 'status', width: 140,
|
|
29
|
-
render: (status) => {
|
|
29
|
+
render: (status) => { // NOSONAR: 返回元素或占位文本,类型不同属预期
|
|
30
30
|
if (status === 'mine') {
|
|
31
31
|
return <Tag color='blue'>我的机构</Tag>;
|
|
32
32
|
}
|
|
@@ -48,7 +48,7 @@ export default class PermView extends React.Component {
|
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
title: '状态', dataIndex: 'status', key: 'status', width: 140,
|
|
51
|
-
render: (status) => {
|
|
51
|
+
render: (status) => { // NOSONAR: 返回元素或占位文本,类型不同属预期
|
|
52
52
|
if (status === 'all') {
|
|
53
53
|
return <Tag color='green'>已授权</Tag>;
|
|
54
54
|
}
|
|
@@ -66,12 +66,12 @@ export default class PermView extends React.Component {
|
|
|
66
66
|
<Tag color='processing'>{data.dataPermLabel || '-'}</Tag>
|
|
67
67
|
</span>
|
|
68
68
|
</div>
|
|
69
|
-
{data.orgRows
|
|
69
|
+
{data.orgRows?.length
|
|
70
70
|
? <Table size='small' rowKey='key' columns={orgColumns} dataSource={data.orgRows}
|
|
71
71
|
pagination={false} expandable={{defaultExpandAllRows: true}}/>
|
|
72
72
|
: <Empty description='暂无机构数据'/>}
|
|
73
73
|
<Gap/>
|
|
74
|
-
{data.menuRows
|
|
74
|
+
{data.menuRows?.length
|
|
75
75
|
? <Table size='small' rowKey='key' columns={menuColumns} dataSource={data.menuRows}
|
|
76
76
|
pagination={false} expandable={{defaultExpandAllRows: true}}/>
|
|
77
77
|
: <Empty description='暂无权限数据'/>}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import type {AxiosRequestConfig} from "axios";
|
|
3
|
-
import qs from 'qs';
|
|
4
|
-
import {PageUtils} from "./PageUtils";
|
|
5
|
-
import {message as messageApi} from "antd";
|
|
6
|
-
import {EventBus} from "../EventBus";
|
|
7
|
-
|
|
8
|
-
interface RequestOptions extends AxiosRequestConfig {
|
|
9
|
-
showError?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const axiosInstance = axios.create({
|
|
13
|
-
baseURL: import.meta.env.VITE_SERVER_SERVLET_CONTEXT_PATH,
|
|
14
|
-
withCredentials: true,
|
|
15
|
-
headers: { 'Content-Type': 'application/json' },
|
|
16
|
-
paramsSerializer: (params: Record<string, unknown>) => qs.stringify(params, {indices: false})
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export class HttpUtils {
|
|
20
|
-
static coreRequest<T = any>(config: RequestOptions, transformData = true): Promise<T> {
|
|
21
|
-
const url = config.url as string;
|
|
22
|
-
config.url = url.startsWith('admin') ? '/' + url : url;
|
|
23
|
-
|
|
24
|
-
// FormData 请求交由浏览器自动生成带 boundary 的 multipart Content-Type,
|
|
25
|
-
// 否则手动指定 Content-Type 会缺失 boundary 导致后端解析失败
|
|
26
|
-
if (typeof FormData !== 'undefined' && config.data instanceof FormData) {
|
|
27
|
-
config.headers = {...config.headers, 'Content-Type': undefined};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return new Promise<T>((resolve, reject) => {
|
|
31
|
-
axiosInstance(config).then((response) => {
|
|
32
|
-
const body = response.data;
|
|
33
|
-
let {success, message, data} = body;
|
|
34
|
-
if (success == undefined) {
|
|
35
|
-
resolve(response as unknown as T);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (!success) {
|
|
39
|
-
console.error(`[HttpUtils] 请求失败: ${url}`, {code: body.code, message, data: body});
|
|
40
|
-
if (config.showError !== false) {
|
|
41
|
-
messageApi.error(message || '操作失败');
|
|
42
|
-
}
|
|
43
|
-
reject(message || '操作失败');
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (message) {
|
|
47
|
-
messageApi.success(message);
|
|
48
|
-
}
|
|
49
|
-
resolve((transformData ? data : response) as T);
|
|
50
|
-
}).catch((e) => {
|
|
51
|
-
console.error(`[HttpUtils] 请求异常: ${url}`, e);
|
|
52
|
-
if (axios.isAxiosError(e) && e.response?.status === 401) {
|
|
53
|
-
EventBus.emit('loginExpired');
|
|
54
|
-
reject('登录过期');
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const msg = HttpUtils.extractErrorMessage(e);
|
|
58
|
-
if (config.showError !== false) {
|
|
59
|
-
messageApi.error(msg);
|
|
60
|
-
}
|
|
61
|
-
reject(msg);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
static extractErrorMessage(e: unknown, defaultMsg = '操作失败'): string {
|
|
67
|
-
if (axios.isAxiosError(e)) {
|
|
68
|
-
const responseData = e.response?.data;
|
|
69
|
-
const status = e.response?.status;
|
|
70
|
-
if (status === 504) return '504 请求后端服务失败';
|
|
71
|
-
if (responseData && responseData.message) return responseData.message;
|
|
72
|
-
if (e.message) return e.message;
|
|
73
|
-
return defaultMsg;
|
|
74
|
-
}
|
|
75
|
-
if (e instanceof Error) return e.message || defaultMsg;
|
|
76
|
-
return defaultMsg;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
static get<T = any>(url: string, params: any = null, options: Partial<RequestOptions> = {}): Promise<T> {
|
|
80
|
-
return HttpUtils.coreRequest<T>({...options, url, method: 'GET', params});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
static post<T = any>(url: string, data: any = null, params: any = null, options: Partial<RequestOptions> = {}): Promise<T> {
|
|
84
|
-
return HttpUtils.coreRequest<T>({...options, url, method: 'POST', data, params});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static postForm<T = any>(url: string, data: any, options: Partial<RequestOptions> = {}): Promise<T> {
|
|
88
|
-
return HttpUtils.coreRequest<T>({
|
|
89
|
-
...options,
|
|
90
|
-
url,
|
|
91
|
-
method: 'POST',
|
|
92
|
-
data: qs.stringify(data),
|
|
93
|
-
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
}
|