-
-
-
-
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 5eb257a442db44cc5abfbecdb8db76f94d8d08d6..ba3d3235fd2b6fd17fd1403245cd2f025a6ea29a 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 7cc113872924fccae97d5df3840de6287634c242..e8733e3b30423f66517d205b8a932ab19ca6fca5 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 0000000000000000000000000000000000000000..3ba7eeda69c7cd6edc5fd8d205bd626531737a45
--- /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 29f21d7d264c280642637ee533d762dc92e64423..60b6d4ec2d4608a8daf42407b3b5e8afd414b205 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 e0de686d0bb11785fa065e54e0adbc63b74f4c4f..822dd003ca048a19eef66987ee10d10853fc15d7 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 b4c456f060a10036c484ae6282c9b1e3c7d27cdc..4e6ac9d4e91b0447b2936c7eeca31a215c9ea139 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 0000000000000000000000000000000000000000..7cf9999c3ab4296935f65eb6d270ec4c9126c485
--- /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 eac034d50bd65844b3d5246011344f7c3fdab008..c92739919227815c35d19e1ccf39949fdb8ba255 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 273a7f6a4e11596efc558ff8aad0495d94687ad7..ee669f3b19ad49203297b569de6f90ab8cc4ee64 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 0000000000000000000000000000000000000000..1f1feadbf6f1494e8da6a1e781a87399f1c46a8a
--- /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 204538294cedfe4d37dfa7436dadf9dc8f6b73ef..9fd66a5875f088d1071b48e87b1102c128663be8 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 f664d37b9bb5810f76b158bb9606a5ce099b6ae8..df8af4346207ece2c290d5988381fe0f7714cb1a 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 35d483401ec776afef19d702b9ea863e527363d5..62471d910d43c848868e015dd08ddb97a5e41fed 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 0000000000000000000000000000000000000000..ba48e299a91a29a64e2f9834cf5b0b1d3c080fb4
--- /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 0ab49d62770deb384787ddcda4a677efca46d6cd..ed5845185c9e040b43d7d79e914d5358175a7adb 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 8a94de5c499e5fe32ee63c0073cecdc8c4e2bd06..dd45151a8a47fcc9367704a3bb947cac24638cba 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 a27ce5ac496a16fba20ff7e7f0d0352e23847a32..fdae0830294b1c4798b5c7fbb75c81205f640ae4 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 9cc54fb5d0857d944176c86577b586a0a38b7737..55e7909c5b451bc3487f09c1252bd744954ddabf 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 5c1b819925522c4cd43bb745a2bf160d3337f475..7d0ab23ed8912e8a132b2a864662f8b46c3d74be 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 720928c198401283baa8bdd039d1fc499b1e1f14..cf09effa0beac18130d5b45dc56b5a4db4ab496d 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 0000000000000000000000000000000000000000..0dd1e6207858670ee08f256ff10e292717e6a078
--- /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 725792252787f49efba4f4e887301195a9818f3f..7be54ba58bca8f59650472bf77d1ae599165dda1 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 02c42b08ad46779b636edb5ca985d0cd0161e683..5735ada464787e0f44094c8fd608b10789c6109b 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.');