diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json
index 8721746..d9f7efa 100644
--- a/src/locales/en/messages.json
+++ b/src/locales/en/messages.json
@@ -7,4 +7,4 @@
"Sign in": "Sign in",
"Switch Theme": "Switch Theme",
"Username": "Username"
-}
\ No newline at end of file
+}
diff --git a/src/pages/login/index.js b/src/pages/login/index.js
index 3f6c453..6964132 100644
--- a/src/pages/login/index.js
+++ b/src/pages/login/index.js
@@ -5,6 +5,7 @@ import { Button, Row, Form, Icon, Input } from 'antd'
import router from 'umi/router'
import { GlobalFooter } from 'ant-design-pro'
import { Trans, withI18n } from '@lingui/react'
+import { stringify } from 'qs'
import config from 'utils/config'
import styles from './index.less'
@@ -26,7 +27,7 @@ class Login extends PureComponent {
}
render() {
- const { loading, form, i18n } = this.props
+ const { loading, form, i18n, location } = this.props
const { getFieldDecorator } = form
const footerLinks = [
@@ -38,11 +39,19 @@ class Login extends PureComponent {
},
{
key: 'English',
- title: router.push('/en/login')}>English,
+ title: (
+ router.push(`/en/login${location.search}`)}>
+ English
+
+ ),
},
{
key: 'Chinese',
- title: router.push('/zh/login')}>中文,
+ title: (
+ router.push(`/zh/login${location.search}`)}>
+ 中文
+
+ ),
},
]
diff --git a/src/pages/login/model.js b/src/pages/login/model.js
index 79f07a6..e7b7a54 100644
--- a/src/pages/login/model.js
+++ b/src/pages/login/model.js
@@ -1,4 +1,4 @@
-import { router } from 'utils'
+import { router, pathMatchRegexp } from 'utils'
import { loginUser } from 'api'
export default {
@@ -13,7 +13,7 @@ export default {
if (data.success) {
const { from } = locationQuery
yield put({ type: 'app/query' })
- if (from && from !== '/login') {
+ if (!pathMatchRegexp('/login', from)) {
router.push(from)
} else {
router.push('/dashboard')
diff --git a/src/utils/index.js b/src/utils/index.js
index 5ad74d1..1f9bf5d 100644
--- a/src/utils/index.js
+++ b/src/utils/index.js
@@ -71,6 +71,7 @@ export const langFromPath = curry(
* @return {string} Return the queryed language.
*/
(languages, defaultLanguage, pathname) => {
+ console.log(pathname)
for (const item of languages) {
if (pathname.startsWith(`/${item}/`)) {
return item
@@ -101,15 +102,15 @@ export const deLangPrefix = curry(
}
)(languages)
-export const addLangPrefix = curry(
- /**
- * Add the language prefix in pathname.
- * @param {array} prefix Specify the language you need to add.
- * @param {string} pathname Add the language prefix in the pathname.
- * @return {string} Return the pathname after adding the language prefix.
- */
- (prefix, pathname) => `/${prefix}${deLangPrefix(pathname)}`
-)(langFromPath(window.location.pathname))
+/**
+ * Add the language prefix in pathname.
+ * @param {string} pathname Add the language prefix in the pathname.
+ * @return {string} Return the pathname after adding the language prefix.
+ */
+export const addLangPrefix = pathname => {
+ const prefix = langFromPath(window.location.pathname)
+ return `/${prefix}${deLangPrefix(pathname)}`
+}
const routerAddLangPrefix = params => {
if (isString(params)) {