From 9f259c1c12e3a65aad3eead000d3439792cbbb35 Mon Sep 17 00:00:00 2001 From: smallchill Date: Tue, 11 Feb 2020 16:31:54 +0800 Subject: [PATCH] =?UTF-8?q?:tada:=202.6.1.RELEASE,=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=99=BB=E9=99=86=E9=AA=8C=E8=AF=81=E7=A0=81,=E6=94=AF?= =?UTF-8?q?=E6=8C=81Seata1.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- package.json | 2 +- src/components/Login/LoginItem.js | 93 ++++++++++++++++++++++++------- src/components/Login/index.less | 8 +++ src/locales/en-US/login.js | 1 + src/locales/zh-CN/login.js | 1 + src/locales/zh-TW/login.js | 1 + src/pages/Dashboard/Workplace.js | 16 +++++- src/pages/Login/Login.js | 3 +- src/services/user.js | 12 ++++ src/utils/authority.js | 17 +++++- 11 files changed, 128 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 4416f56..49c3d1f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- Downloads + Downloads Build Status Build Status Coverage Status diff --git a/package.json b/package.json index 44aaef5..e3e159e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sword", - "version": "2.6.0", + "version": "2.6.1", "description": "An out-of-box UI solution for enterprise applications", "private": true, "scripts": { diff --git a/src/components/Login/LoginItem.js b/src/components/Login/LoginItem.js index b3cc4d4..6761f89 100644 --- a/src/components/Login/LoginItem.js +++ b/src/components/Login/LoginItem.js @@ -1,9 +1,12 @@ import React, { Component } from 'react'; import { Form, Input, Button, Row, Col } from 'antd'; +import { formatMessage } from 'umi/locale'; import omit from 'omit.js'; import styles from './index.less'; import ItemMap from './map'; import LoginContext from './loginContext'; +import { getCaptchaImage } from '../../services/user'; +import { setCaptchaKey } from '../../utils/authority'; const FormItem = Form.Item; @@ -17,9 +20,18 @@ class WrapFormItem extends Component { super(props); this.state = { count: 0, + // 默认白色背景 + image: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7', }; } + componentWillMount() { + const { mode, type } = this.props; + if (type === 'Captcha' && mode === 'image') { + this.refreshCaptcha(); + } + } + componentDidMount() { const { updateActive, name } = this.props; if (updateActive) { @@ -28,9 +40,21 @@ class WrapFormItem extends Component { } componentWillUnmount() { + // 清除计数器 clearInterval(this.interval); } + refreshCaptcha = () => { + // 获取验证码 + getCaptchaImage().then(resp => { + const {data} = resp; + if (data.key) { + this.setState({ image: data.image }); + setCaptchaKey(data.key); + } + }); + }; + onGetCaptcha = () => { const { onGetCaptcha } = this.props; const result = onGetCaptcha ? onGetCaptcha() : null; @@ -71,7 +95,7 @@ class WrapFormItem extends Component { }; render() { - const { count } = this.state; + const { count, image } = this.state; const { form: { getFieldDecorator }, @@ -84,6 +108,7 @@ class WrapFormItem extends Component { defaultValue, rules, name, + mode, getCaptchaButtonText, getCaptchaSecondText, updateActive, @@ -96,26 +121,52 @@ class WrapFormItem extends Component { const otherProps = restProps || {}; if (type === 'Captcha') { - const inputProps = omit(otherProps, ['onGetCaptcha', 'countDown']); - return ( - - - - {getFieldDecorator(name, options)()} - - - - - - - ); + if (mode === 'mobile') { + const inputProps = omit(otherProps, ['onGetCaptcha', 'countDown']); + return ( + + + + {getFieldDecorator(name, options)()} + + + + + + + ); + } + if (mode === 'image') { + return ( + + + + {getFieldDecorator(name, options)( + + )} + + + captcha + + + + ); + } } return ( diff --git a/src/components/Login/index.less b/src/components/Login/index.less index 242e067..8712ffd 100644 --- a/src/components/Login/index.less +++ b/src/components/Login/index.less @@ -18,6 +18,14 @@ width: 100%; } + .getImgCaptcha { + display: block; + width: 100%; + cursor: pointer; + height: 40px; + border-radius: 5px; + } + .icon { margin-left: 16px; color: rgba(0, 0, 0, 0.2); diff --git a/src/locales/en-US/login.js b/src/locales/en-US/login.js index ac476dc..d1b6029 100644 --- a/src/locales/en-US/login.js +++ b/src/locales/en-US/login.js @@ -24,6 +24,7 @@ export default { 'validation.userName.tenantId': 'Please enter your tenantId!', 'validation.userName.required': 'Please enter your userName!', 'validation.password.required': 'Please enter your password!', + 'validation.captcha.required': 'Please enter your captcha!', 'validation.password.twice': 'The passwords entered twice do not match!', 'validation.password.strength.msg': "Please enter at least 6 characters and don't use passwords that are easy to guess.", diff --git a/src/locales/zh-CN/login.js b/src/locales/zh-CN/login.js index 64b3887..aae59fe 100644 --- a/src/locales/zh-CN/login.js +++ b/src/locales/zh-CN/login.js @@ -24,6 +24,7 @@ export default { 'validation.tenantId.required': '请输入租户ID!', 'validation.userName.required': '请输入用户名!', 'validation.password.required': '请输入密码!', + 'validation.captcha.required': '请输入验证码!', 'validation.password.twice': '两次输入的密码不匹配!', 'validation.password.strength.msg': '请至少输入 6 个字符。请不要使用容易被猜到的密码。', 'validation.password.strength.strong': '强度:强', diff --git a/src/locales/zh-TW/login.js b/src/locales/zh-TW/login.js index 6c05cf9..1ccf9ca 100644 --- a/src/locales/zh-TW/login.js +++ b/src/locales/zh-TW/login.js @@ -24,6 +24,7 @@ export default { 'validation.tenantId.required': '請輸入租戶編號!', 'validation.userName.required': '請輸入賬戶!', 'validation.password.required': '請輸入密碼!', + 'validation.captcha.required': '請輸入驗證碼!', 'validation.password.twice': '兩次輸入的密碼不匹配!', 'validation.password.strength.msg': '請至少輸入 6 個字符。請不要使用容易被猜到的密碼。', 'validation.password.strength.strong': '強度:強', diff --git a/src/pages/Dashboard/Workplace.js b/src/pages/Dashboard/Workplace.js index c4281d2..3b87443 100644 --- a/src/pages/Dashboard/Workplace.js +++ b/src/pages/Dashboard/Workplace.js @@ -14,14 +14,14 @@ class Workplace extends PureComponent {

- Downloads + Downloads Build Status Coverage Status Downloads @@ -206,7 +206,17 @@ class Workplace extends PureComponent { - + + +
1.升级SpringBoot 2.2.4.RELEASE
+
2.升级Alibaba Cloud 2.2.0.RELEASE
+
3.升级Mybatis-Plus 3.3.1
+
4.增加登陆验证码功能
+
5.增加验证码对应的CaptchaTokenGranter
+
6.增加RedisUtil,方便业务操作
+
7.增加Condition类getQueryWrapper自定义排除参数的入口
+
8.优化Seata封装,完美支持1.0.0版本
+
1.升级SpringCloud Hoxton.SR1
2.升级SpringBoot 2.2.2.RELEASE
diff --git a/src/pages/Login/Login.js b/src/pages/Login/Login.js index 43553ea..4715e4b 100644 --- a/src/pages/Login/Login.js +++ b/src/pages/Login/Login.js @@ -6,7 +6,7 @@ import Login from '../../components/Login'; import styles from './Login.less'; import { tenantMode } from '../../defaultSettings'; -const { Tab, TenantId, UserName, Password, Submit } = Login; +const { Tab, TenantId, UserName, Password, Captcha, Submit } = Login; @connect(({ login, loading }) => ({ login, @@ -117,6 +117,7 @@ class LoginPage extends Component { ]} onPressEnter={() => this.loginForm.validateFields(this.handleSubmit)} /> +
diff --git a/src/services/user.js b/src/services/user.js index 8a46591..d1ec2f7 100644 --- a/src/services/user.js +++ b/src/services/user.js @@ -1,11 +1,19 @@ import { stringify } from 'qs'; import request from '../utils/request'; import func from '../utils/Func'; +import { getCaptchaKey } from '../utils/authority'; // =====================用户=========================== export async function accountLogin(params) { + const values = params; + values.grantType = 'captcha'; + values.scope = 'all'; return request('/api/blade-auth/token', { + headers: { + 'Captcha-key': getCaptchaKey(), + 'Captcha-code': values.code, + }, method: 'POST', body: func.toFormData(params), }); @@ -72,3 +80,7 @@ export async function updatePassword(params) { body: func.toFormData(params), }); } + +export async function getCaptchaImage() { + return request('/api/blade-auth/captcha'); +} diff --git a/src/utils/authority.js b/src/utils/authority.js index 8743a69..27f59b7 100644 --- a/src/utils/authority.js +++ b/src/utils/authority.js @@ -17,7 +17,12 @@ export function getAuthority(str) { } export function setAuthority(authority) { - const proAuthority = typeof authority === 'string' ? authority.split(',') : (typeof authority === 'undefined' ? null : authority); + const proAuthority = + typeof authority === 'string' + ? authority.split(',') + : typeof authority === 'undefined' + ? null + : authority; return localStorage.setItem('sword-authority', JSON.stringify(proAuthority)); } @@ -63,10 +68,20 @@ export function setCurrentUser(account) { localStorage.setItem('sword-current-user', JSON.stringify(account)); } +export function setCaptchaKey(key) { + localStorage.removeItem('sword-captcha-key'); + localStorage.setItem('sword-captcha-key', key); +} + +export function getCaptchaKey() { + return localStorage.getItem('sword-captcha-key'); +} + export function removeAll() { localStorage.removeItem('sword-authority'); localStorage.removeItem('sword-token'); localStorage.removeItem('sword-routes'); localStorage.removeItem('sword-buttons'); localStorage.removeItem('sword-current-user'); + localStorage.removeItem('sword-captcha-key'); }