@jiangood/admin-spring-boot-starter 0.2.4 → 0.2.5
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
CHANGED
|
@@ -57,22 +57,24 @@ export class MessageUtils {
|
|
|
57
57
|
const isNumber = typeof initialValue === 'number';
|
|
58
58
|
return new Promise((resolve) => {
|
|
59
59
|
const ref = React.createRef()
|
|
60
|
+
let element:any = isNumber ? <InputNumber placeholder={placeholder}/> : <Input placeholder={placeholder}/>;
|
|
61
|
+
const content:any = <div>
|
|
62
|
+
<div style={{marginBottom: 4}}>{message}</div>
|
|
63
|
+
<Form ref={ref}>
|
|
64
|
+
<Form.Item name='inputValue' initialValue={initialValue}>
|
|
65
|
+
{element}
|
|
66
|
+
</Form.Item>
|
|
67
|
+
</Form>
|
|
68
|
+
</div>;
|
|
60
69
|
this.modalApi.confirm({
|
|
61
70
|
icon: null,
|
|
62
71
|
title: '提示',
|
|
63
|
-
content:
|
|
64
|
-
<div style={{marginBottom: 4}}>{message}</div>
|
|
65
|
-
<Form ref={ref}>
|
|
66
|
-
<Form.Item name='inputValue' initialValue={initialValue}>
|
|
67
|
-
{isNumber ? <InputNumber placeholder={placeholder}/> : <Input placeholder={placeholder}/>}
|
|
68
|
-
</Form.Item>
|
|
69
|
-
</Form>
|
|
70
|
-
</div>,
|
|
72
|
+
content:content,
|
|
71
73
|
okText: '确定',
|
|
72
74
|
cancelText: '取消',
|
|
73
75
|
onOk: () => {
|
|
74
76
|
const form = ref.current;
|
|
75
|
-
|
|
77
|
+
const values = form.getFieldsValue()
|
|
76
78
|
resolve(values.inputValue)
|
|
77
79
|
},
|
|
78
80
|
onCancel: () => {
|
|
@@ -89,6 +91,10 @@ export class MessageUtils {
|
|
|
89
91
|
* 成功消息
|
|
90
92
|
*/
|
|
91
93
|
static success(content: String, duration: number = 3) {
|
|
94
|
+
if(!this.messageApi){
|
|
95
|
+
alert(content)
|
|
96
|
+
return
|
|
97
|
+
}
|
|
92
98
|
this.messageApi.success(content, duration);
|
|
93
99
|
}
|
|
94
100
|
|
|
@@ -96,6 +102,11 @@ export class MessageUtils {
|
|
|
96
102
|
* 错误消息
|
|
97
103
|
*/
|
|
98
104
|
static error(content: String, duration: number = 3) {
|
|
105
|
+
console.error('调用 MessageUtils.error',content)
|
|
106
|
+
if(!this.messageApi){
|
|
107
|
+
alert(content)
|
|
108
|
+
return
|
|
109
|
+
}
|
|
99
110
|
this.messageApi.error(content, duration);
|
|
100
111
|
}
|
|
101
112
|
|
|
@@ -103,6 +114,10 @@ export class MessageUtils {
|
|
|
103
114
|
* 警告消息
|
|
104
115
|
*/
|
|
105
116
|
static warning(content: String, duration: number = 3) {
|
|
117
|
+
if(!this.messageApi){
|
|
118
|
+
alert(content)
|
|
119
|
+
return
|
|
120
|
+
}
|
|
106
121
|
this.messageApi.warning(content, duration);
|
|
107
122
|
}
|
|
108
123
|
|
|
@@ -110,6 +125,10 @@ export class MessageUtils {
|
|
|
110
125
|
* 通用消息
|
|
111
126
|
*/
|
|
112
127
|
static info(content: React.ReactNode, duration: number = 3) {
|
|
128
|
+
if(!this.messageApi){
|
|
129
|
+
alert(content)
|
|
130
|
+
return
|
|
131
|
+
}
|
|
113
132
|
this.messageApi.info(content, duration);
|
|
114
133
|
}
|
|
115
134
|
|
|
@@ -135,10 +154,15 @@ export class MessageUtils {
|
|
|
135
154
|
* antd6 推荐使用这个hooks,这里统一设置, 供公共layout使用
|
|
136
155
|
* @constructor
|
|
137
156
|
*/
|
|
138
|
-
export function MessageHolder(){
|
|
157
|
+
export function MessageHolder(props){
|
|
139
158
|
const [modalApi, modalContextHolder] = Modal.useModal();
|
|
140
159
|
const [messageApi, messageContextHolder] = message.useMessage();
|
|
141
|
-
|
|
160
|
+
|
|
161
|
+
React.useEffect(()=>{
|
|
162
|
+
console.log('MessageHolder Rendered')
|
|
163
|
+
MessageUtils.config(messageApi,modalApi);
|
|
164
|
+
props.onFinish()
|
|
165
|
+
},[])
|
|
142
166
|
return <>
|
|
143
167
|
{modalContextHolder} {messageContextHolder}
|
|
144
168
|
</>
|
package/src/layouts/index.jsx
CHANGED
|
@@ -5,7 +5,15 @@ import {ConfigProvider} from "antd";
|
|
|
5
5
|
|
|
6
6
|
import {Outlet, withRouter} from "umi";
|
|
7
7
|
import zhCN from 'antd/locale/zh_CN';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
ArrUtils,
|
|
10
|
+
HttpUtils,
|
|
11
|
+
MessageHolder,
|
|
12
|
+
PageLoading,
|
|
13
|
+
PageUtils,
|
|
14
|
+
SysUtils,
|
|
15
|
+
ThemeUtils,
|
|
16
|
+
} from "../framework";
|
|
9
17
|
import dayjs from 'dayjs';
|
|
10
18
|
import 'dayjs/locale/zh-cn';
|
|
11
19
|
|
|
@@ -21,24 +29,28 @@ class _Layouts extends React.Component {
|
|
|
21
29
|
|
|
22
30
|
|
|
23
31
|
state = {
|
|
32
|
+
messageHolderInit:false,
|
|
24
33
|
siteInfoLoading: true,
|
|
25
34
|
loginInfoFinish: false
|
|
26
35
|
}
|
|
27
36
|
|
|
37
|
+
onMessageHolderFinish = () => {
|
|
38
|
+
this.loadSiteInfo()
|
|
39
|
+
this.setState({messageHolderInit:true});
|
|
40
|
+
}
|
|
41
|
+
|
|
28
42
|
|
|
29
|
-
|
|
43
|
+
loadSiteInfo = () => {
|
|
30
44
|
HttpUtils.get("/admin/public/site-info").then(rs => {
|
|
31
45
|
SysUtils.setSiteInfo(rs)
|
|
32
46
|
this.setState({siteInfoLoading: false})
|
|
33
|
-
|
|
34
47
|
this.loadLoginInfo()
|
|
35
48
|
})
|
|
36
|
-
}
|
|
49
|
+
};
|
|
37
50
|
|
|
38
51
|
componentDidUpdate(prevProps, prevState, snapshot) {
|
|
39
52
|
const pre = prevProps.location.pathname
|
|
40
53
|
const cur = this.props.location.pathname
|
|
41
|
-
|
|
42
54
|
if (pre !== cur) {
|
|
43
55
|
this.loadLoginInfo()
|
|
44
56
|
}
|
|
@@ -46,7 +58,10 @@ class _Layouts extends React.Component {
|
|
|
46
58
|
|
|
47
59
|
isSimplePage() {
|
|
48
60
|
let {pathname} = this.props.location;
|
|
49
|
-
|
|
61
|
+
let isSimplePage = ArrUtils.contains(SIMPLE_URLS, pathname);
|
|
62
|
+
console.log('简单页面列表定义', SIMPLE_URLS)
|
|
63
|
+
console.log('当前页面是否简单页面',pathname,isSimplePage)
|
|
64
|
+
return isSimplePage
|
|
50
65
|
}
|
|
51
66
|
|
|
52
67
|
loadLoginInfo = () => {
|
|
@@ -74,11 +89,6 @@ class _Layouts extends React.Component {
|
|
|
74
89
|
})
|
|
75
90
|
}
|
|
76
91
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
92
|
render() {
|
|
83
93
|
return <ConfigProvider
|
|
84
94
|
input={{autoComplete: 'off'}}
|
|
@@ -115,15 +125,22 @@ class _Layouts extends React.Component {
|
|
|
115
125
|
}
|
|
116
126
|
}
|
|
117
127
|
}}>
|
|
118
|
-
|
|
128
|
+
|
|
119
129
|
{this.renderContent()}
|
|
120
130
|
</ConfigProvider>
|
|
121
131
|
}
|
|
122
132
|
|
|
133
|
+
|
|
123
134
|
renderContent = () => {
|
|
135
|
+
if(!this.state.messageHolderInit) {
|
|
136
|
+
console.log('先加载message holder')
|
|
137
|
+
return <MessageHolder onFinish={this.onMessageHolderFinish} />
|
|
138
|
+
}
|
|
139
|
+
|
|
124
140
|
if (this.state.siteInfoLoading) {
|
|
125
141
|
return <PageLoading message='加载站点信息...'/>
|
|
126
142
|
}
|
|
143
|
+
|
|
127
144
|
let {params = {}} = this.props.location;
|
|
128
145
|
console.log('layout: params', params)
|
|
129
146
|
let simple = this.isSimplePage();
|
|
@@ -135,14 +152,11 @@ class _Layouts extends React.Component {
|
|
|
135
152
|
return <PageLoading message='加载登录信息...'/>
|
|
136
153
|
}
|
|
137
154
|
|
|
138
|
-
|
|
139
155
|
return <AdminLayout path={this.state.path} logo={this.props.logo}/>
|
|
140
156
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
157
|
}
|
|
145
158
|
|
|
159
|
+
|
|
146
160
|
export const Layouts = withRouter(_Layouts);
|
|
147
161
|
export default Layouts
|
|
148
162
|
export * from './PageRender'
|