-
-
-
-
Ant Design
-
+
+
+
+
+
+
+
+
+
+
+
Ant Design
+
+
+
Ant Design 是西湖区最具影响力的 Web 设计规范
-
Ant Design 是西湖区最具影响力的 Web 设计规范
+ {children}
- {children}
+
-
-
+
);
}
}
-export default UserLayout;
+export default connect(({ menu: menuModel }) => ({
+ menuData: menuModel.menuData,
+ breadcrumbNameMap: menuModel.breadcrumbNameMap,
+}))(UserLayout);
diff --git a/src/layouts/UserLayout.less b/src/layouts/UserLayout.less
index 5eb257a442..ba3d3235fd 100644
--- a/src/layouts/UserLayout.less
+++ b/src/layouts/UserLayout.less
@@ -9,18 +9,18 @@
}
.lang {
- text-align: right;
width: 100%;
height: 40px;
line-height: 44px;
+ text-align: right;
:global(.ant-dropdown-trigger) {
margin-right: 24px;
}
}
.content {
- padding: 32px 0;
flex: 1;
+ padding: 32px 0;
}
@media (min-width: @screen-md-min) {
@@ -50,22 +50,22 @@
.logo {
height: 44px;
- vertical-align: top;
margin-right: 16px;
+ vertical-align: top;
}
.title {
- font-size: 33px;
- color: @heading-color;
- font-family: Avenir, 'Helvetica Neue', Arial, Helvetica, sans-serif;
- font-weight: 600;
position: relative;
top: 2px;
+ color: @heading-color;
+ font-weight: 600;
+ font-size: 33px;
+ font-family: Avenir, 'Helvetica Neue', Arial, Helvetica, sans-serif;
}
.desc {
- font-size: @font-size-base;
- color: @text-color-secondary;
margin-top: 12px;
margin-bottom: 40px;
+ color: @text-color-secondary;
+ font-size: @font-size-base;
}
diff --git a/src/locales/en-US.js b/src/locales/en-US.js
index 7cc1138729..e8733e3b30 100644
--- a/src/locales/en-US.js
+++ b/src/locales/en-US.js
@@ -3,6 +3,7 @@ import menu from './en-US/menu';
import settingDrawer from './en-US/settingDrawer';
import settings from './en-US/settings';
import pwa from './en-US/pwa';
+import component from './en-US/component';
export default {
'navBar.lang': 'Languages',
@@ -15,4 +16,5 @@ export default {
...settingDrawer,
...settings,
...pwa,
+ ...component,
};
diff --git a/src/locales/en-US/component.js b/src/locales/en-US/component.js
new file mode 100644
index 0000000000..3ba7eeda69
--- /dev/null
+++ b/src/locales/en-US/component.js
@@ -0,0 +1,5 @@
+export default {
+ 'component.tagSelect.expand': 'Expand',
+ 'component.tagSelect.collapse': 'Collapse',
+ 'component.tagSelect.all': 'All',
+};
diff --git a/src/locales/en-US/globalHeader.js b/src/locales/en-US/globalHeader.js
index 29f21d7d26..60b6d4ec2d 100644
--- a/src/locales/en-US/globalHeader.js
+++ b/src/locales/en-US/globalHeader.js
@@ -13,6 +13,5 @@ export default {
'component.noticeIcon.clear': 'Clear',
'component.noticeIcon.cleared': 'Cleared',
'component.noticeIcon.empty': 'No notifications',
- 'component.noticeIcon.loaded': 'Loaded',
- 'component.noticeIcon.loading-more': 'Loading more',
+ 'component.noticeIcon.view-more': 'View more',
};
diff --git a/src/locales/en-US/settings.js b/src/locales/en-US/settings.js
index e0de686d0b..822dd003ca 100644
--- a/src/locales/en-US/settings.js
+++ b/src/locales/en-US/settings.js
@@ -25,14 +25,14 @@ export default {
'app.settings.security.medium': 'Medium',
'app.settings.security.weak': 'Weak',
'app.settings.security.password': 'Account Password',
- 'app.settings.security.password-description': 'Current password strength:',
+ 'app.settings.security.password-description': 'Current password strength',
'app.settings.security.phone': 'Security Phone',
- 'app.settings.security.phone-description': 'Bound phone:',
+ 'app.settings.security.phone-description': 'Bound phone',
'app.settings.security.question': 'Security Question',
'app.settings.security.question-description':
'The security question is not set, and the security policy can effectively protect the account security',
'app.settings.security.email': 'Backup Email',
- 'app.settings.security.email-description': 'Bound Email:',
+ 'app.settings.security.email-description': 'Bound Email',
'app.settings.security.mfa': 'MFA Device',
'app.settings.security.mfa-description':
'Unbound MFA device, after binding, can be confirmed twice',
diff --git a/src/locales/pt-BR.js b/src/locales/pt-BR.js
index b4c456f060..4e6ac9d4e9 100644
--- a/src/locales/pt-BR.js
+++ b/src/locales/pt-BR.js
@@ -3,6 +3,7 @@ import menu from './pt-BR/menu';
import settingDrawer from './pt-BR/settingDrawer';
import settings from './pt-BR/settings';
import pwa from './pt-BR/pwa';
+import component from './pt-BR/component';
export default {
'navBar.lang': 'Idiomas',
@@ -15,4 +16,5 @@ export default {
...settingDrawer,
...settings,
...pwa,
+ ...component,
};
diff --git a/src/locales/pt-BR/component.js b/src/locales/pt-BR/component.js
new file mode 100644
index 0000000000..7cf9999c3a
--- /dev/null
+++ b/src/locales/pt-BR/component.js
@@ -0,0 +1,5 @@
+export default {
+ 'component.tagSelect.expand': 'Expandir',
+ 'component.tagSelect.collapse': 'Diminuir',
+ 'component.tagSelect.all': 'Todas',
+};
diff --git a/src/locales/pt-BR/globalHeader.js b/src/locales/pt-BR/globalHeader.js
index eac034d50b..c927399192 100644
--- a/src/locales/pt-BR/globalHeader.js
+++ b/src/locales/pt-BR/globalHeader.js
@@ -14,5 +14,5 @@ export default {
'component.noticeIcon.cleared': 'Limpo',
'component.noticeIcon.empty': 'Sem notificações',
'component.noticeIcon.loaded': 'Carregado',
- 'component.noticeIcon.loading-more': 'Carregar mais',
+ 'component.noticeIcon.view-more': 'Veja mais',
};
diff --git a/src/locales/zh-CN.js b/src/locales/zh-CN.js
index 273a7f6a4e..ee669f3b19 100644
--- a/src/locales/zh-CN.js
+++ b/src/locales/zh-CN.js
@@ -3,6 +3,7 @@ import menu from './zh-CN/menu';
import settingDrawer from './zh-CN/settingDrawer';
import settings from './zh-CN/settings';
import pwa from './zh-CN/pwa';
+import component from './zh-CN/component';
export default {
'navBar.lang': '语言',
@@ -15,4 +16,5 @@ export default {
...settingDrawer,
...settings,
...pwa,
+ ...component,
};
diff --git a/src/locales/zh-CN/component.js b/src/locales/zh-CN/component.js
new file mode 100644
index 0000000000..1f1feadbf6
--- /dev/null
+++ b/src/locales/zh-CN/component.js
@@ -0,0 +1,5 @@
+export default {
+ 'component.tagSelect.expand': '展开',
+ 'component.tagSelect.collapse': '收起',
+ 'component.tagSelect.all': '全部',
+};
diff --git a/src/locales/zh-CN/globalHeader.js b/src/locales/zh-CN/globalHeader.js
index 204538294c..9fd66a5875 100644
--- a/src/locales/zh-CN/globalHeader.js
+++ b/src/locales/zh-CN/globalHeader.js
@@ -13,6 +13,5 @@ export default {
'component.noticeIcon.clear': '清空',
'component.noticeIcon.cleared': '清空了',
'component.noticeIcon.empty': '暂无数据',
- 'component.noticeIcon.loaded': '加载完毕',
- 'component.noticeIcon.loading-more': '加载更多',
+ 'component.noticeIcon.view-more': '查看更多',
};
diff --git a/src/locales/zh-CN/settings.js b/src/locales/zh-CN/settings.js
index f664d37b9b..df8af43462 100644
--- a/src/locales/zh-CN/settings.js
+++ b/src/locales/zh-CN/settings.js
@@ -25,13 +25,13 @@ export default {
'app.settings.security.medium': '中',
'app.settings.security.weak': '弱',
'app.settings.security.password': '账户密码',
- 'app.settings.security.password-description': '当前密码强度:',
+ 'app.settings.security.password-description': '当前密码强度',
'app.settings.security.phone': '密保手机',
- 'app.settings.security.phone-description': '已绑定手机:',
+ 'app.settings.security.phone-description': '已绑定手机',
'app.settings.security.question': '密保问题',
'app.settings.security.question-description': '未设置密保问题,密保问题可有效保护账户安全',
'app.settings.security.email': '备用邮箱',
- 'app.settings.security.email-description': '已绑定邮箱:',
+ 'app.settings.security.email-description': '已绑定邮箱',
'app.settings.security.mfa': 'MFA 设备',
'app.settings.security.mfa-description': '未绑定 MFA 设备,绑定后,可以进行二次确认',
'app.settings.security.modify': '修改',
diff --git a/src/locales/zh-TW.js b/src/locales/zh-TW.js
index 35d483401e..62471d910d 100644
--- a/src/locales/zh-TW.js
+++ b/src/locales/zh-TW.js
@@ -3,6 +3,7 @@ import menu from './zh-TW/menu';
import settingDrawer from './zh-TW/settingDrawer';
import settings from './zh-TW/settings';
import pwa from './zh-TW/pwa';
+import component from './zh-TW/component';
export default {
'navBar.lang': '語言',
@@ -18,4 +19,5 @@ export default {
...settingDrawer,
...settings,
...pwa,
+ ...component,
};
diff --git a/src/locales/zh-TW/component.js b/src/locales/zh-TW/component.js
new file mode 100644
index 0000000000..ba48e299a9
--- /dev/null
+++ b/src/locales/zh-TW/component.js
@@ -0,0 +1,5 @@
+export default {
+ 'component.tagSelect.expand': '展開',
+ 'component.tagSelect.collapse': '收起',
+ 'component.tagSelect.all': '全部',
+};
diff --git a/src/locales/zh-TW/globalHeader.js b/src/locales/zh-TW/globalHeader.js
index 0ab49d6277..ed5845185c 100644
--- a/src/locales/zh-TW/globalHeader.js
+++ b/src/locales/zh-TW/globalHeader.js
@@ -3,7 +3,7 @@ export default {
'component.globalHeader.search.example1': '搜索提示壹',
'component.globalHeader.search.example2': '搜索提示二',
'component.globalHeader.search.example3': '搜索提示三',
- 'component.globalHeader.help': '使用文檔',
+ 'component.globalHeader.help': '使用手冊',
'component.globalHeader.notification': '通知',
'component.globalHeader.notification.empty': '妳已查看所有通知',
'component.globalHeader.message': '消息',
@@ -12,7 +12,6 @@ export default {
'component.globalHeader.event.empty': '妳已完成所有待辦',
'component.noticeIcon.clear': '清空',
'component.noticeIcon.cleared': '清空了',
- 'component.noticeIcon.empty': '暫無數據',
- 'component.noticeIcon.loaded': '加載完畢',
- 'component.noticeIcon.loading-more': '加載更多',
+ 'component.noticeIcon.empty': '暫無資料',
+ 'component.noticeIcon.view-more': '查看更多',
};
diff --git a/src/locales/zh-TW/settings.js b/src/locales/zh-TW/settings.js
index 8a94de5c49..dd45151a8a 100644
--- a/src/locales/zh-TW/settings.js
+++ b/src/locales/zh-TW/settings.js
@@ -25,13 +25,13 @@ export default {
'app.settings.security.medium': '中',
'app.settings.security.weak': '弱',
'app.settings.security.password': '賬戶密碼',
- 'app.settings.security.password-description': '當前密碼強度:',
+ 'app.settings.security.password-description': '當前密碼強度',
'app.settings.security.phone': '密保手機',
- 'app.settings.security.phone-description': '已綁定手機:',
+ 'app.settings.security.phone-description': '已綁定手機',
'app.settings.security.question': '密保問題',
'app.settings.security.question-description': '未設置密保問題,密保問題可有效保護賬戶安全',
'app.settings.security.email': '備用郵箱',
- 'app.settings.security.email-description': '已綁定郵箱:',
+ 'app.settings.security.email-description': '已綁定郵箱',
'app.settings.security.mfa': 'MFA 設備',
'app.settings.security.mfa-description': '未綁定 MFA 設備,綁定後,可以進行二次確認',
'app.settings.security.modify': '修改',
diff --git a/src/models/global.js b/src/models/global.js
index a27ce5ac49..fdae083029 100644
--- a/src/models/global.js
+++ b/src/models/global.js
@@ -6,42 +6,14 @@ export default {
state: {
collapsed: false,
notices: [],
- loadedAllNotices: false,
},
effects: {
*fetchNotices(_, { call, put, select }) {
const data = yield call(queryNotices);
- const loadedAllNotices = data && data.length && data[data.length - 1] === null;
- yield put({
- type: 'setLoadedStatus',
- payload: loadedAllNotices,
- });
yield put({
type: 'saveNotices',
- payload: data.filter(item => item),
- });
- const unreadCount = yield select(
- state => state.global.notices.filter(item => !item.read).length
- );
- yield put({
- type: 'user/changeNotifyCount',
- payload: {
- totalCount: data.length,
- unreadCount,
- },
- });
- },
- *fetchMoreNotices({ payload }, { call, put, select }) {
- const data = yield call(queryNotices, payload);
- const loadedAllNotices = data && data.length && data[data.length - 1] === null;
- yield put({
- type: 'setLoadedStatus',
- payload: loadedAllNotices,
- });
- yield put({
- type: 'pushNotices',
- payload: data.filter(item => item),
+ payload: data,
});
const unreadCount = yield select(
state => state.global.notices.filter(item => !item.read).length
@@ -114,18 +86,6 @@ export default {
notices: state.notices.filter(item => item.type !== payload),
};
},
- pushNotices(state, { payload }) {
- return {
- ...state,
- notices: [...state.notices, ...payload],
- };
- },
- setLoadedStatus(state, { payload }) {
- return {
- ...state,
- loadedAllNotices: payload,
- };
- },
},
subscriptions: {
diff --git a/src/models/menu.js b/src/models/menu.js
index 9cc54fb5d0..55e7909c5b 100644
--- a/src/models/menu.js
+++ b/src/models/menu.js
@@ -2,6 +2,7 @@ import memoizeOne from 'memoize-one';
import isEqual from 'lodash/isEqual';
import { formatMessage } from 'umi/locale';
import Authorized from '@/utils/Authorized';
+import { menu } from '../defaultSettings';
const { check } = Authorized;
@@ -19,10 +20,14 @@ function formatter(data, parentAuthority, parentName) {
} else {
locale = `menu.${item.name}`;
}
-
+ // if enableMenuLocale use item.name,
+ // close menu international
+ const name = menu.disableLocal
+ ? item.name
+ : formatMessage({ id: locale, defaultMessage: item.name });
const result = {
...item,
- name: formatMessage({ id: locale, defaultMessage: item.name }),
+ name,
locale,
authority: item.authority || parentAuthority,
};
@@ -92,17 +97,19 @@ export default {
state: {
menuData: [],
+ routerData: [],
breadcrumbNameMap: {},
},
effects: {
*getMenuData({ payload }, { put }) {
const { routes, authority } = payload;
- const menuData = filterMenuData(memoizeOneFormatter(routes, authority));
- const breadcrumbNameMap = memoizeOneGetBreadcrumbNameMap(menuData);
+ const originalMenuData = memoizeOneFormatter(routes, authority);
+ const menuData = filterMenuData(originalMenuData);
+ const breadcrumbNameMap = memoizeOneGetBreadcrumbNameMap(originalMenuData);
yield put({
type: 'save',
- payload: { menuData, breadcrumbNameMap },
+ payload: { menuData, breadcrumbNameMap, routerData: routes },
});
},
},
diff --git a/src/pages/Authorized.js b/src/pages/Authorized.js
index 5c1b819925..7d0ab23ed8 100644
--- a/src/pages/Authorized.js
+++ b/src/pages/Authorized.js
@@ -1,13 +1,44 @@
import React from 'react';
-import RenderAuthorized from 'ant-design-pro/lib/Authorized';
-import { getAuthority } from '@/utils/authority';
import Redirect from 'umi/redirect';
+import pathToRegexp from 'path-to-regexp';
+import { connect } from 'dva';
+import Authorized from '@/utils/Authorized';
-const Authority = getAuthority();
-const Authorized = RenderAuthorized(Authority);
+function AuthComponent({ children, location, routerData, currentCuser }) {
+ const isLogin = currentCuser && currentCuser.name;
-export default ({ children }) => (
-
}>
- {children}
-
-);
+ const getRouteAuthority = (pathname, routeData) => {
+ const routes = routeData.slice(); // clone
+
+ const getAuthority = (routeDatas, path) => {
+ let authorities;
+ routeDatas.forEach(route => {
+ // check partial route
+ if (pathToRegexp(`${route.path}(.*)`).test(path)) {
+ if (route.authority) {
+ authorities = route.authority;
+ }
+ // is exact route?
+ if (!pathToRegexp(route.path).test(path) && route.routes) {
+ authorities = getAuthority(route.routes, path);
+ }
+ }
+ });
+ return authorities;
+ };
+
+ return getAuthority(routes, pathname);
+ };
+ return (
+
:
}
+ >
+ {children}
+
+ );
+}
+export default connect(({ menu: menuModel, user: userModel }) => ({
+ routerData: menuModel.routerData,
+ currentCuser: userModel.currentCuser,
+}))(AuthComponent);
diff --git a/src/pages/document.ejs b/src/pages/document.ejs
index 720928c198..cf09effa0b 100644
--- a/src/pages/document.ejs
+++ b/src/pages/document.ejs
@@ -1,15 +1,17 @@
-
-
-
-
-
Ant Design Pro
-
-
-
-
-
-
-
+
+
+
+
+
Ant Design Pro
+
+
+
+
+
+
diff --git a/src/utils/getPageTitle.js b/src/utils/getPageTitle.js
new file mode 100644
index 0000000000..0dd1e62078
--- /dev/null
+++ b/src/utils/getPageTitle.js
@@ -0,0 +1,27 @@
+import { formatMessage } from 'umi/locale';
+import pathToRegexp from 'path-to-regexp';
+import isEqual from 'lodash/isEqual';
+import memoizeOne from 'memoize-one';
+import { menu, title } from '../defaultSettings';
+
+export const matchParamsPath = (pathname, breadcrumbNameMap) => {
+ const pathKey = Object.keys(breadcrumbNameMap).find(key => pathToRegexp(key).test(pathname));
+ return breadcrumbNameMap[pathKey];
+};
+
+const getPageTitle = (pathname, breadcrumbNameMap) => {
+ const currRouterData = matchParamsPath(pathname, breadcrumbNameMap);
+ if (!currRouterData) {
+ return title;
+ }
+ const pageName = menu.disableLocal
+ ? currRouterData.name
+ : formatMessage({
+ id: currRouterData.locale || currRouterData.name,
+ defaultMessage: currRouterData.name,
+ });
+
+ return `${pageName} - ${title}`;
+};
+
+export default memoizeOne(getPageTitle, isEqual);
diff --git a/src/utils/utils.less b/src/utils/utils.less
index 7257922527..7be54ba58b 100644
--- a/src/utils/utils.less
+++ b/src/utils/utils.less
@@ -1,34 +1,34 @@
.textOverflow() {
overflow: hidden;
+ white-space: nowrap;
text-overflow: ellipsis;
word-break: break-all;
- white-space: nowrap;
}
.textOverflowMulti(@line: 3, @bg: #fff) {
- overflow: hidden;
position: relative;
- line-height: 1.5em;
max-height: @line * 1.5em;
- text-align: justify;
margin-right: -1em;
padding-right: 1em;
- &:before {
- background: @bg;
- content: '...';
- padding: 0 1px;
+ overflow: hidden;
+ line-height: 1.5em;
+ text-align: justify;
+ &::before {
position: absolute;
right: 14px;
bottom: 0;
+ padding: 0 1px;
+ background: @bg;
+ content: '...';
}
- &:after {
- background: white;
- content: '';
- margin-top: 0.2em;
+ &::after {
position: absolute;
right: 14px;
width: 1em;
height: 1em;
+ margin-top: 0.2em;
+ background: white;
+ content: '';
}
}
@@ -36,15 +36,15 @@
// ------------------------
.clearfix() {
zoom: 1;
- &:before,
- &:after {
+ &::before,
+ &::after {
content: ' ';
display: table;
}
- &:after {
+ &::after {
clear: both;
- visibility: hidden;
- font-size: 0;
height: 0;
+ font-size: 0;
+ visibility: hidden;
}
}
diff --git a/tests/run-tests.js b/tests/run-tests.js
index 02c42b08ad..5735ada464 100644
--- a/tests/run-tests.js
+++ b/tests/run-tests.js
@@ -24,7 +24,11 @@ startServer.on('exit', () => {
console.log('Starting development server for e2e tests...');
startServer.stdout.on('data', data => {
console.log(data.toString());
- if (!once && data.toString().indexOf('Compiled successfully') >= 0) {
+ // hack code , wait umi
+ if (
+ (!once && data.toString().indexOf('Compiled successfully') >= 0) ||
+ data.toString().indexOf('Theme generated successfully') >= 0
+ ) {
// eslint-disable-next-line
once = true;
console.log('Development server is started, ready to run tests.');