@jiangood/springboot-admin-starter 0.0.4 → 0.0.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 +1 -1
- package/src/framework/field-components/FieldTable.d.ts +2 -1
- package/src/framework/field-components/FieldTable.jsx +4 -7
- package/src/framework/index.ts +1 -0
- package/src/framework/pages/LoginPage.d.ts +11 -0
- package/src/framework/pages/LoginPage.jsx +136 -0
- package/src/{pages/login.less → framework/pages/LoginPage.less} +1 -1
- package/src/framework/pages/index.ts +1 -0
- package/src/layouts/admin/index.jsx +1 -1
- package/src/pages/login.jsx +4 -129
package/package.json
CHANGED
|
@@ -61,7 +61,7 @@ export class FieldTable extends React.Component {
|
|
|
61
61
|
let row = dataSource[index]
|
|
62
62
|
|
|
63
63
|
let v = e;
|
|
64
|
-
if (e != null &&e.hasOwnProperty('target')) {
|
|
64
|
+
if (e != null && e.hasOwnProperty('target')) {
|
|
65
65
|
v = e.target.value;
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -89,17 +89,14 @@ export class FieldTable extends React.Component {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
render() {
|
|
92
|
-
return <div className='edit-table'>
|
|
93
|
-
|
|
92
|
+
return <div className='edit-table' style={this.props.style}>
|
|
94
93
|
<Table columns={this.columns}
|
|
95
94
|
dataSource={this.state.dataSource}
|
|
96
95
|
size='small'
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
footer={() => <Button type='dashed' icon={<PlusOutlined/>}
|
|
96
|
+
footer={() => <Button type='dashed'
|
|
97
|
+
icon={<PlusOutlined/>}
|
|
100
98
|
onClick={this.add}>增加一行
|
|
101
99
|
</Button>}
|
|
102
|
-
|
|
103
100
|
pagination={false}
|
|
104
101
|
>
|
|
105
102
|
|
package/src/framework/index.ts
CHANGED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Button, Form, Input, message, Space} from 'antd';
|
|
3
|
+
import {LockOutlined, SafetyCertificateOutlined, UserOutlined, WarningOutlined} from '@ant-design/icons';
|
|
4
|
+
import "./LoginPage.less"
|
|
5
|
+
import {history} from 'umi';
|
|
6
|
+
import {HttpUtils, MessageUtils, PageUtils, SysUtils} from "../utils";
|
|
7
|
+
import {JSEncrypt} from "jsencrypt";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export class LoginPage extends React.Component {
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
state = {
|
|
14
|
+
logging: false,
|
|
15
|
+
|
|
16
|
+
siteInfo: {},
|
|
17
|
+
random: Math.random()
|
|
18
|
+
}
|
|
19
|
+
redirect = '/';
|
|
20
|
+
|
|
21
|
+
async componentDidMount() {
|
|
22
|
+
console.log('渲染登录页面')
|
|
23
|
+
const redirect = PageUtils.currentParams()['redirect']
|
|
24
|
+
if (redirect) {
|
|
25
|
+
console.log('重定向参数', redirect)
|
|
26
|
+
this.redirect = decodeURIComponent(redirect)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (localStorage.length === 0) {
|
|
30
|
+
MessageUtils.alert('站点数据缺失,刷新当前页面...')
|
|
31
|
+
window.location.reload()
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const siteInfo = SysUtils.getSiteInfo()
|
|
36
|
+
this.setState({siteInfo})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
submit = values => {
|
|
41
|
+
this.setState({logging: true})
|
|
42
|
+
|
|
43
|
+
const pubkey = this.state.siteInfo.rsaPublicKey;
|
|
44
|
+
if (!pubkey) {
|
|
45
|
+
message.error("未获取密钥,请刷新浏览器再试")
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
// 对密码加密
|
|
49
|
+
const crypt = new JSEncrypt();
|
|
50
|
+
crypt.setPublicKey(pubkey);
|
|
51
|
+
values.password = crypt.encrypt(values.password)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
HttpUtils.postForm('/admin/auth/login', values).then(rs => {
|
|
55
|
+
console.log('登录结果', rs)
|
|
56
|
+
history.push(this.redirect)
|
|
57
|
+
}).catch(e => {
|
|
58
|
+
console.log('登录错误', e)
|
|
59
|
+
})
|
|
60
|
+
.finally(() => {
|
|
61
|
+
this.setState({logging: false})
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
render() {
|
|
67
|
+
const {siteInfo} = this.state
|
|
68
|
+
|
|
69
|
+
const pageStyle = {}
|
|
70
|
+
if (siteInfo.loginBackground) {
|
|
71
|
+
let url = 'admin/sysFile/preview/' + siteInfo.loginBackground;
|
|
72
|
+
pageStyle.backgroundImage = 'url("' + url + '")'
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<section className='login-page' style={pageStyle}>
|
|
77
|
+
<div className="login-content">
|
|
78
|
+
<h1>{siteInfo.title}</h1>
|
|
79
|
+
<Form
|
|
80
|
+
name="normal_login"
|
|
81
|
+
className="login-form"
|
|
82
|
+
initialValues={{remember: true}}
|
|
83
|
+
onFinish={this.submit}
|
|
84
|
+
requiredMark={false}
|
|
85
|
+
colon={false}
|
|
86
|
+
>
|
|
87
|
+
|
|
88
|
+
<Form.Item name="username" rules={[{required: true, message: '请输入用户名!'}]}>
|
|
89
|
+
<Input size='large' prefix={<UserOutlined/>} placeholder="用户名" autoComplete="off"/>
|
|
90
|
+
</Form.Item>
|
|
91
|
+
<Form.Item name="password" rules={[{required: true, message: '请输入密码!'}]}>
|
|
92
|
+
<Input autoComplete="off" prefix={<LockOutlined/>} type="password" placeholder="密码"
|
|
93
|
+
size='large'
|
|
94
|
+
/>
|
|
95
|
+
</Form.Item>
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
{siteInfo.captcha && <Form.Item name='captchaCode' rules={[{required: true}]}>
|
|
99
|
+
<Space style={{alignItems: 'center'}}>
|
|
100
|
+
<Input size='large' placeholder='验证码' prefix={<SafetyCertificateOutlined/>}/>
|
|
101
|
+
<img height={36}
|
|
102
|
+
width={100}
|
|
103
|
+
src={"/admin/auth/captchaImage?_random=" + this.state.random}
|
|
104
|
+
onClick={() => {
|
|
105
|
+
this.setState({random: Math.random()})
|
|
106
|
+
}}></img>
|
|
107
|
+
</Space>
|
|
108
|
+
</Form.Item>}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
<Form.Item style={{marginTop: 10}}>
|
|
112
|
+
<Button loading={this.state.logging} type="primary" htmlType="submit"
|
|
113
|
+
block size='large'>
|
|
114
|
+
登录
|
|
115
|
+
</Button>
|
|
116
|
+
</Form.Item>
|
|
117
|
+
</Form>
|
|
118
|
+
|
|
119
|
+
{this.renderFormBottom()}
|
|
120
|
+
|
|
121
|
+
</div>
|
|
122
|
+
</section>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
renderFormBottom() {
|
|
128
|
+
let siteInfo = this.state.siteInfo;
|
|
129
|
+
if (siteInfo.loginBoxBottomTip) {
|
|
130
|
+
return <div style={{color: 'white', marginTop: 50, fontSize: '14px', textAlign: 'center'}}>
|
|
131
|
+
<WarningOutlined/> {siteInfo.loginBoxBottomTip}
|
|
132
|
+
</div>
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './LoginPage'
|
|
@@ -99,7 +99,7 @@ export default class extends React.Component {
|
|
|
99
99
|
<Header className='header'>
|
|
100
100
|
<div className='header-left'>
|
|
101
101
|
{siteInfo.logoUrl &&
|
|
102
|
-
<img className='logo-img' src=
|
|
102
|
+
<img className='logo-img' src='/admin/public/logo.jpg' onClick={() => history.push('/')} alt='logo'/>}
|
|
103
103
|
<h3 className='hide-on-mobile'>
|
|
104
104
|
<Link to="/" style={{color: ThemeUtils.getColor("primary-color")}}>{siteInfo.title} </Link>
|
|
105
105
|
</h3>
|
package/src/pages/login.jsx
CHANGED
|
@@ -1,144 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {Button, Form, Input, message, Space} from 'antd';
|
|
3
|
-
import {LockOutlined, SafetyCertificateOutlined, UserOutlined, WarningOutlined} from '@ant-design/icons';
|
|
4
|
-
import "./login.less"
|
|
5
|
-
import {history} from 'umi';
|
|
6
|
-
import {HttpUtils, MessageUtils, PageUtils, SysUtils} from "../framework";
|
|
7
|
-
import {JSEncrypt} from "jsencrypt";
|
|
8
2
|
|
|
3
|
+
import {LoginPage} from "../framework/pages/LoginPage";
|
|
9
4
|
|
|
10
|
-
export default class login extends React.Component {
|
|
11
5
|
|
|
6
|
+
export default class extends React.Component {
|
|
12
7
|
|
|
13
|
-
state = {
|
|
14
|
-
logging: false,
|
|
15
8
|
|
|
16
|
-
siteInfo: {},
|
|
17
|
-
random:Math.random()
|
|
18
|
-
}
|
|
19
|
-
redirect ='/';
|
|
20
|
-
|
|
21
|
-
async componentDidMount() {
|
|
22
|
-
console.log('渲染登录页面')
|
|
23
|
-
const redirect = PageUtils.currentParams()['redirect']
|
|
24
|
-
if(redirect){
|
|
25
|
-
console.log('重定向参数',redirect)
|
|
26
|
-
this.redirect = decodeURIComponent(redirect)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
{
|
|
31
|
-
// 内部系统登录
|
|
32
|
-
let token = PageUtils.currentParams().token
|
|
33
|
-
if (token) {
|
|
34
|
-
token = window.location.search
|
|
35
|
-
this.submit({token})
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (localStorage.length === 0) {
|
|
40
|
-
MessageUtils.alert('站点数据缺失,刷新当前页面...')
|
|
41
|
-
window.location.reload()
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const siteInfo = SysUtils.getSiteInfo()
|
|
46
|
-
this.setState({siteInfo})
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
submit = values => {
|
|
51
|
-
this.setState({logging: true})
|
|
52
|
-
|
|
53
|
-
const pubkey = this.state.siteInfo.rsaPublicKey;
|
|
54
|
-
if(!pubkey){
|
|
55
|
-
message.error("未获取密钥,请刷新浏览器再试")
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
// 对密码加密
|
|
59
|
-
const crypt = new JSEncrypt();
|
|
60
|
-
crypt.setPublicKey(pubkey);
|
|
61
|
-
values.password = crypt.encrypt(values.password)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
HttpUtils.postForm('/admin/auth/login', values).then(rs => {
|
|
65
|
-
console.log('登录结果', rs)
|
|
66
|
-
history.push(this.redirect)
|
|
67
|
-
}).catch(e=>{
|
|
68
|
-
console.log('登录错误', e)
|
|
69
|
-
})
|
|
70
|
-
.finally(() => {
|
|
71
|
-
this.setState({logging: false})
|
|
72
|
-
})
|
|
73
|
-
}
|
|
74
9
|
|
|
75
10
|
|
|
76
11
|
render() {
|
|
77
|
-
const {siteInfo} = this.state
|
|
78
|
-
|
|
79
|
-
const pageStyle = {}
|
|
80
|
-
if(siteInfo.loginBackground){
|
|
81
|
-
let url = 'admin/sysFile/preview/' + siteInfo.loginBackground;
|
|
82
|
-
pageStyle.backgroundImage = 'url("'+url+'")'
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<section className='login-page' style={pageStyle}>
|
|
87
|
-
<div className="login-content">
|
|
88
|
-
<h1>{siteInfo.title}</h1>
|
|
89
|
-
<Form
|
|
90
|
-
name="normal_login"
|
|
91
|
-
className="login-form"
|
|
92
|
-
initialValues={{remember: true}}
|
|
93
|
-
onFinish={this.submit}
|
|
94
|
-
requiredMark={false}
|
|
95
|
-
colon={false}
|
|
96
|
-
>
|
|
97
|
-
|
|
98
|
-
<Form.Item name="username" rules={[{required: true, message: '请输入用户名!'}]}>
|
|
99
|
-
<Input size='large' prefix={<UserOutlined/>} placeholder="用户名" autoComplete="off"/>
|
|
100
|
-
</Form.Item>
|
|
101
|
-
<Form.Item name="password" rules={[{required: true, message: '请输入密码!'}]}>
|
|
102
|
-
<Input autoComplete="off" prefix={<LockOutlined/>} type="password" placeholder="密码"
|
|
103
|
-
size='large'
|
|
104
|
-
/>
|
|
105
|
-
</Form.Item>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
{siteInfo.captcha && <Form.Item name='captchaCode' rules={[{required: true}]}>
|
|
109
|
-
<Space style={{alignItems: 'center'}}>
|
|
110
|
-
<Input size='large' placeholder='验证码' prefix={<SafetyCertificateOutlined/>}/>
|
|
111
|
-
<img height={36} width={100}
|
|
112
|
-
src={"/admin/auth/captchaImage?_random=" + this.state.random} onClick={() => {
|
|
113
|
-
this.setState({random: Math.random()})
|
|
114
|
-
}}></img>
|
|
115
|
-
</Space>
|
|
116
|
-
</Form.Item>}
|
|
117
12
|
|
|
118
|
-
|
|
119
|
-
<Form.Item style={{marginTop: 10}}>
|
|
120
|
-
<Button loading={this.state.logging} type="primary" htmlType="submit"
|
|
121
|
-
block size='large'>
|
|
122
|
-
登录
|
|
123
|
-
</Button>
|
|
124
|
-
</Form.Item>
|
|
125
|
-
</Form>
|
|
126
|
-
|
|
127
|
-
{this.renderFormBottom()}
|
|
128
|
-
|
|
129
|
-
</div>
|
|
130
|
-
</section>
|
|
131
|
-
);
|
|
13
|
+
return <LoginPage />
|
|
132
14
|
}
|
|
133
15
|
|
|
134
16
|
|
|
135
|
-
|
|
136
|
-
let siteInfo = this.state.siteInfo;
|
|
137
|
-
if (siteInfo.loginBoxBottomTip) {
|
|
138
|
-
return <div style={{color: 'white', marginTop: 50, fontSize: '14px', textAlign: 'center'}}>
|
|
139
|
-
<WarningOutlined/> {siteInfo.loginBoxBottomTip}
|
|
140
|
-
</div>
|
|
141
|
-
}
|
|
142
|
-
}
|
|
17
|
+
|
|
143
18
|
|
|
144
19
|
}
|