mirror of
https://github.com/zuiidea/antd-admin
synced 2026-11-05 23:54:58 +00:00
Merge branch 'develop'
This commit is contained in:
@@ -85,7 +85,7 @@ class Header extends PureComponent {
|
||||
trigger="click"
|
||||
key="notifications"
|
||||
overlayClassName={styles.notificationPopover}
|
||||
getPopupContainer={() => document.querySelector('#layoutHeader')}
|
||||
getPopupContainer={() => document.querySelector('#primaryLayout')}
|
||||
content={
|
||||
<div className={styles.notification}>
|
||||
<List
|
||||
|
||||
@@ -26,7 +26,7 @@ class Layout extends Component {
|
||||
componentDidMount() {
|
||||
const language = langFromPath(this.props.location.pathname)
|
||||
this.language = language
|
||||
this.loadCatalog(language)
|
||||
language && this.loadCatalog(language)
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
@@ -35,7 +35,7 @@ class Layout extends Component {
|
||||
const { catalogs } = nextState
|
||||
|
||||
if (preLanguage !== language && !catalogs[language]) {
|
||||
this.loadCatalog(language)
|
||||
language && this.loadCatalog(language)
|
||||
this.language = language
|
||||
return false
|
||||
}
|
||||
|
||||
+13
-6
@@ -11,6 +11,14 @@ import config from 'config'
|
||||
|
||||
const { queryRouteList, logoutUser, queryUserInfo } = api
|
||||
|
||||
const goDashboard = () => {
|
||||
if (pathMatchRegexp(['/', '/login'], window.location.pathname)) {
|
||||
router.push({
|
||||
pathname: '/dashboard',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
namespace: 'app',
|
||||
state: {
|
||||
@@ -71,7 +79,10 @@ export default {
|
||||
*query({ payload }, { call, put, select }) {
|
||||
// store isInit to prevent query trigger by refresh
|
||||
const isInit = store.get('isInit')
|
||||
if (isInit) return
|
||||
if (isInit) {
|
||||
goDashboard()
|
||||
return
|
||||
}
|
||||
const { locationPathname } = yield select(_ => _.app)
|
||||
const { success, user } = yield call(queryUserInfo, payload)
|
||||
if (success && user) {
|
||||
@@ -99,11 +110,7 @@ export default {
|
||||
store.set('permissions', permissions)
|
||||
store.set('user', user)
|
||||
store.set('isInit', true)
|
||||
if (pathMatchRegexp(['/', '/login'], window.location.pathname)) {
|
||||
router.push({
|
||||
pathname: '/dashboard',
|
||||
})
|
||||
}
|
||||
goDashboard()
|
||||
} else if (queryLayout(config.layouts, locationPathname) !== 'public') {
|
||||
router.push({
|
||||
pathname: '/login',
|
||||
|
||||
@@ -73,7 +73,7 @@ function Completed({ data }) {
|
||||
return (
|
||||
<div className={styles.tooltip}>
|
||||
<p className={styles.tiptitle}>{content.label}</p>
|
||||
<ul>{list}</ul>
|
||||
{content.payload && <ul>{list}</ul>}
|
||||
</div>
|
||||
)
|
||||
}}
|
||||
|
||||
@@ -73,7 +73,7 @@ function Sales({ data }) {
|
||||
return (
|
||||
<div className={styles.tooltip}>
|
||||
<p className={styles.tiptitle}>{content.label}</p>
|
||||
<ul>{list}</ul>
|
||||
{content.payload && <ul>{list}</ul>}
|
||||
</div>
|
||||
)
|
||||
}}
|
||||
|
||||
@@ -86,6 +86,10 @@ body {
|
||||
a:focus {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.ant-table-layout-fixed table {
|
||||
table-layout: auto;
|
||||
}
|
||||
}
|
||||
@media (min-width: 1600px) {
|
||||
:global {
|
||||
|
||||
+35
-17
@@ -10,8 +10,10 @@ export config from './config'
|
||||
export request from './request'
|
||||
export { Color } from './theme'
|
||||
|
||||
export const { defaultLanguage } = i18n
|
||||
export const languages = i18n.languages.map(item => item.key)
|
||||
// export const { defaultLanguage } = i18n
|
||||
// export const languages = i18n.languages.map(item => item.key)
|
||||
export const languages = i18n ? i18n.languages.map(item => item.key) : []
|
||||
export const defaultLanguage = i18n ? i18n.defaultLanguage : ''
|
||||
|
||||
/**
|
||||
* Query objects that specify keys and values in an array where all values are objects.
|
||||
@@ -61,23 +63,32 @@ export function arrayToTree(
|
||||
return result
|
||||
}
|
||||
|
||||
export const langFromPath = curry(
|
||||
/**
|
||||
* Query language from pathname.
|
||||
* @param {array} languages Specify which languages are currently available.
|
||||
* @param {string} defaultLanguage Specify the default language.
|
||||
* @param {string} pathname Pathname to be queried.
|
||||
* @return {string} Return the queryed language.
|
||||
*/
|
||||
(languages, defaultLanguage, pathname) => {
|
||||
for (const item of languages) {
|
||||
if (pathname.startsWith(`/${item}/`)) {
|
||||
return item
|
||||
}
|
||||
// export const langFromPath = curry(
|
||||
// /**
|
||||
// * Query language from pathname.
|
||||
// * @param {array} languages Specify which languages are currently available.
|
||||
// * @param {string} defaultLanguage Specify the default language.
|
||||
// * @param {string} pathname Pathname to be queried.
|
||||
// * @return {string} Return the queryed language.
|
||||
// */
|
||||
// (languages, defaultLanguage, pathname) => {
|
||||
// for (const item of languages) {
|
||||
// if (pathname.startsWith(`/${item}/`)) {
|
||||
// return item
|
||||
// }
|
||||
// }
|
||||
// return defaultLanguage
|
||||
// }
|
||||
// )(languages)(defaultLanguage)
|
||||
|
||||
export const langFromPath = pathname => {
|
||||
for (const item of languages) {
|
||||
if (pathname.startsWith(`/${item}/`)) {
|
||||
return item
|
||||
}
|
||||
return defaultLanguage
|
||||
}
|
||||
)(languages)(defaultLanguage)
|
||||
return defaultLanguage
|
||||
}
|
||||
|
||||
export const deLangPrefix = curry(
|
||||
/**
|
||||
@@ -106,11 +117,18 @@ export const deLangPrefix = curry(
|
||||
* @return {string} Return the pathname after adding the language prefix.
|
||||
*/
|
||||
export function addLangPrefix(pathname) {
|
||||
if (!i18n) {
|
||||
return pathname
|
||||
}
|
||||
|
||||
const prefix = langFromPath(window.location.pathname)
|
||||
return `/${prefix}${deLangPrefix(pathname)}`
|
||||
}
|
||||
|
||||
const routerAddLangPrefix = params => {
|
||||
if (!i18n) {
|
||||
return params
|
||||
}
|
||||
if (isString(params)) {
|
||||
params = addLangPrefix(params)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user