From 0d5b157e57519d66591460122654f3f935423c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Wed, 22 May 2019 02:25:22 +0800 Subject: [PATCH] fix local error --- config/router.config.js | 297 ------------------------------------ package.json | 18 ++- router.config.js | 297 ------------------------------------ scripts/fetch-block.js | 6 +- scripts/router.config.js | 124 +++++++-------- src/layouts/BasicLayout.tsx | 7 +- src/locales/en-US/menu.ts | 2 +- src/locales/pt-BR/menu.ts | 2 +- src/locales/zh-CN/menu.ts | 2 +- src/locales/zh-TW/menu.ts | 2 +- 10 files changed, 86 insertions(+), 671 deletions(-) delete mode 100644 config/router.config.js delete mode 100644 router.config.js diff --git a/config/router.config.js b/config/router.config.js deleted file mode 100644 index cdff38e0..00000000 --- a/config/router.config.js +++ /dev/null @@ -1,297 +0,0 @@ -export default [ - // user - { - path: '/user', - component: '../layouts/UserLayout', - routes: [ - { path: '/user', redirect: '/user/login' }, - { path: '/user/login', name: 'login', component: './User/Login' }, - { path: '/user/register', name: 'register', component: './User/Register' }, - { - path: '/user/register-result', - name: 'register.result', - component: './User/RegisterResult', - }, - { - component: '404', - }, - ], - }, - // app - { - path: '/', - component: '../layouts/BasicLayout', - Routes: ['src/pages/Authorized'], - routes: [ - // dashboard - { path: '/', redirect: '/dashboard/analysis', authority: ['admin', 'user'] }, - { - path: '/dashboard', - name: 'dashboard', - icon: 'dashboard', - routes: [ - { - path: '/dashboard/analysis', - name: 'analysis', - component: './Dashboard/Analysis', - }, - { - path: '/dashboard/monitor', - name: 'monitor', - component: './Dashboard/Monitor', - }, - { - path: '/dashboard/workplace', - name: 'workplace', - component: './Dashboard/Workplace', - }, - ], - }, - // forms - { - path: '/form', - icon: 'form', - name: 'form', - routes: [ - { - path: '/form/basic-form', - name: 'basicform', - component: './Forms/BasicForm', - }, - { - path: '/form/step-form', - name: 'stepform', - component: './Forms/StepForm', - hideChildrenInMenu: true, - routes: [ - { - path: '/form/step-form', - redirect: '/form/step-form/info', - }, - { - path: '/form/step-form/info', - name: 'info', - component: './Forms/StepForm/Step1', - }, - { - path: '/form/step-form/confirm', - name: 'confirm', - component: './Forms/StepForm/Step2', - }, - { - path: '/form/step-form/result', - name: 'result', - component: './Forms/StepForm/Step3', - }, - ], - }, - { - path: '/form/advanced-form', - name: 'advancedform', - authority: ['admin'], - component: './Forms/AdvancedForm', - }, - ], - }, - // list - { - path: '/list', - icon: 'table', - name: 'list', - routes: [ - { - path: '/list/table-list', - name: 'searchtable', - component: './List/TableList', - }, - { - path: '/list/basic-list', - name: 'basiclist', - component: './List/BasicList', - }, - { - path: '/list/card-list', - name: 'cardlist', - component: './List/CardList', - }, - { - path: '/list/search', - name: 'searchlist', - component: './List/List', - routes: [ - { - path: '/list/search', - redirect: '/list/search/articles', - }, - { - path: '/list/search/articles', - name: 'articles', - component: './List/Articles', - }, - { - path: '/list/search/projects', - name: 'projects', - component: './List/Projects', - }, - { - path: '/list/search/applications', - name: 'applications', - component: './List/Applications', - }, - ], - }, - ], - }, - { - path: '/profile', - name: 'profile', - icon: 'profile', - routes: [ - // profile - { - path: '/profile/basic', - name: 'basic', - component: './Profile/BasicProfile', - }, - { - path: '/profile/basic/:id', - hideInMenu: true, - component: './Profile/BasicProfile', - }, - { - path: '/profile/advanced', - name: 'advanced', - authority: ['admin'], - component: './Profile/AdvancedProfile', - }, - ], - }, - { - name: 'result', - icon: 'check-circle-o', - path: '/result', - routes: [ - // result - { - path: '/result/success', - name: 'success', - component: './Result/Success', - }, - { path: '/result/fail', name: 'fail', component: './Result/Error' }, - ], - }, - { - name: 'exception', - icon: 'warning', - path: '/exception', - routes: [ - // exception - { - path: '/exception/403', - name: 'not-permission', - component: './Exception/403', - }, - { - path: '/exception/404', - name: 'not-find', - component: './Exception/404', - }, - { - path: '/exception/500', - name: 'server-error', - component: './Exception/500', - }, - { - path: '/exception/trigger', - name: 'trigger', - hideInMenu: true, - component: './Exception/TriggerException', - }, - ], - }, - { - name: 'account', - icon: 'user', - path: '/account', - routes: [ - { - path: '/account/center', - name: 'center', - component: './Account/Center/Center', - routes: [ - { - path: '/account/center', - redirect: '/account/center/articles', - }, - { - path: '/account/center/articles', - component: './Account/Center/Articles', - }, - { - path: '/account/center/applications', - component: './Account/Center/Applications', - }, - { - path: '/account/center/projects', - component: './Account/Center/Projects', - }, - ], - }, - { - path: '/account/settings', - name: 'settings', - component: './Account/Settings/Info', - routes: [ - { - path: '/account/settings', - redirect: '/account/settings/base', - }, - { - path: '/account/settings/base', - component: './Account/Settings/BaseView', - }, - { - path: '/account/settings/security', - component: './Account/Settings/SecurityView', - }, - { - path: '/account/settings/binding', - component: './Account/Settings/BindingView', - }, - { - path: '/account/settings/notification', - component: './Account/Settings/NotificationView', - }, - ], - }, - ], - }, - // editor - { - name: 'editor', - icon: 'highlight', - path: '/editor', - routes: [ - { - path: '/editor/flow', - name: 'flow', - component: './Editor/GGEditor/Flow', - }, - { - path: '/editor/mind', - name: 'mind', - component: './Editor/GGEditor/Mind', - }, - { - path: '/editor/koni', - name: 'koni', - component: './Editor/GGEditor/Koni', - }, - ], - }, - { - component: '404', - }, - ], - }, -]; diff --git a/package.json b/package.json index be4b875a..f62c913b 100644 --- a/package.json +++ b/package.json @@ -61,14 +61,18 @@ "bizcharts-plugin-slider": "^2.1.1-beta.1", "classnames": "^2.2.6", "dva": "^2.4.0", + "hash.js": "^1.1.7", "lodash": "^4.17.10", "lodash-decorators": "^6.0.0", "memoize-one": "^5.0.0", "moment": "^2.22.2", "numeral": "^2.0.6", + "nzh": "^1.0.4", "omit.js": "^1.0.0", "path-to-regexp": "^2.4.0", + "prop-types": "^15.7.2", "qs": "^6.7.0", + "query-string": "^6.5.0", "rc-animate": "^2.4.4", "react": "^16.8.5", "react-container-query": "^0.11.0", @@ -78,6 +82,11 @@ "react-fittext": "^1.0.0", "react-media": "^1.9.2", "react-media-hook2": "^1.0.2", + "umi": "^2.7.0-beta.2", + "umi-plugin-ga": "^1.1.3", + "umi-plugin-locale": "^2.8.0-beta.1", + "umi-plugin-pro-block": "^1.3.0", + "umi-plugin-react": "^1.8.0-beta.1", "umi-request": "^1.0.7" }, "devDependencies": { @@ -127,12 +136,7 @@ "tslint": "^5.12.1", "tslint-config-prettier": "^1.17.0", "tslint-eslint-rules": "^5.4.0", - "tslint-react": "^3.6.0", - "umi": "^2.7.0-beta.2", - "umi-plugin-ga": "^1.1.3", - "umi-plugin-pro-block": "^1.3.0", - "umi-plugin-react": "^1.8.0-beta.1", - "umi-request": "^1.0.0" + "tslint-react": "^3.6.0" }, "optionalDependencies": { "puppeteer": "^1.12.1" @@ -147,4 +151,4 @@ "config/**/*.js*", "scripts/**/*.js" ] -} \ No newline at end of file +} diff --git a/router.config.js b/router.config.js deleted file mode 100644 index cdff38e0..00000000 --- a/router.config.js +++ /dev/null @@ -1,297 +0,0 @@ -export default [ - // user - { - path: '/user', - component: '../layouts/UserLayout', - routes: [ - { path: '/user', redirect: '/user/login' }, - { path: '/user/login', name: 'login', component: './User/Login' }, - { path: '/user/register', name: 'register', component: './User/Register' }, - { - path: '/user/register-result', - name: 'register.result', - component: './User/RegisterResult', - }, - { - component: '404', - }, - ], - }, - // app - { - path: '/', - component: '../layouts/BasicLayout', - Routes: ['src/pages/Authorized'], - routes: [ - // dashboard - { path: '/', redirect: '/dashboard/analysis', authority: ['admin', 'user'] }, - { - path: '/dashboard', - name: 'dashboard', - icon: 'dashboard', - routes: [ - { - path: '/dashboard/analysis', - name: 'analysis', - component: './Dashboard/Analysis', - }, - { - path: '/dashboard/monitor', - name: 'monitor', - component: './Dashboard/Monitor', - }, - { - path: '/dashboard/workplace', - name: 'workplace', - component: './Dashboard/Workplace', - }, - ], - }, - // forms - { - path: '/form', - icon: 'form', - name: 'form', - routes: [ - { - path: '/form/basic-form', - name: 'basicform', - component: './Forms/BasicForm', - }, - { - path: '/form/step-form', - name: 'stepform', - component: './Forms/StepForm', - hideChildrenInMenu: true, - routes: [ - { - path: '/form/step-form', - redirect: '/form/step-form/info', - }, - { - path: '/form/step-form/info', - name: 'info', - component: './Forms/StepForm/Step1', - }, - { - path: '/form/step-form/confirm', - name: 'confirm', - component: './Forms/StepForm/Step2', - }, - { - path: '/form/step-form/result', - name: 'result', - component: './Forms/StepForm/Step3', - }, - ], - }, - { - path: '/form/advanced-form', - name: 'advancedform', - authority: ['admin'], - component: './Forms/AdvancedForm', - }, - ], - }, - // list - { - path: '/list', - icon: 'table', - name: 'list', - routes: [ - { - path: '/list/table-list', - name: 'searchtable', - component: './List/TableList', - }, - { - path: '/list/basic-list', - name: 'basiclist', - component: './List/BasicList', - }, - { - path: '/list/card-list', - name: 'cardlist', - component: './List/CardList', - }, - { - path: '/list/search', - name: 'searchlist', - component: './List/List', - routes: [ - { - path: '/list/search', - redirect: '/list/search/articles', - }, - { - path: '/list/search/articles', - name: 'articles', - component: './List/Articles', - }, - { - path: '/list/search/projects', - name: 'projects', - component: './List/Projects', - }, - { - path: '/list/search/applications', - name: 'applications', - component: './List/Applications', - }, - ], - }, - ], - }, - { - path: '/profile', - name: 'profile', - icon: 'profile', - routes: [ - // profile - { - path: '/profile/basic', - name: 'basic', - component: './Profile/BasicProfile', - }, - { - path: '/profile/basic/:id', - hideInMenu: true, - component: './Profile/BasicProfile', - }, - { - path: '/profile/advanced', - name: 'advanced', - authority: ['admin'], - component: './Profile/AdvancedProfile', - }, - ], - }, - { - name: 'result', - icon: 'check-circle-o', - path: '/result', - routes: [ - // result - { - path: '/result/success', - name: 'success', - component: './Result/Success', - }, - { path: '/result/fail', name: 'fail', component: './Result/Error' }, - ], - }, - { - name: 'exception', - icon: 'warning', - path: '/exception', - routes: [ - // exception - { - path: '/exception/403', - name: 'not-permission', - component: './Exception/403', - }, - { - path: '/exception/404', - name: 'not-find', - component: './Exception/404', - }, - { - path: '/exception/500', - name: 'server-error', - component: './Exception/500', - }, - { - path: '/exception/trigger', - name: 'trigger', - hideInMenu: true, - component: './Exception/TriggerException', - }, - ], - }, - { - name: 'account', - icon: 'user', - path: '/account', - routes: [ - { - path: '/account/center', - name: 'center', - component: './Account/Center/Center', - routes: [ - { - path: '/account/center', - redirect: '/account/center/articles', - }, - { - path: '/account/center/articles', - component: './Account/Center/Articles', - }, - { - path: '/account/center/applications', - component: './Account/Center/Applications', - }, - { - path: '/account/center/projects', - component: './Account/Center/Projects', - }, - ], - }, - { - path: '/account/settings', - name: 'settings', - component: './Account/Settings/Info', - routes: [ - { - path: '/account/settings', - redirect: '/account/settings/base', - }, - { - path: '/account/settings/base', - component: './Account/Settings/BaseView', - }, - { - path: '/account/settings/security', - component: './Account/Settings/SecurityView', - }, - { - path: '/account/settings/binding', - component: './Account/Settings/BindingView', - }, - { - path: '/account/settings/notification', - component: './Account/Settings/NotificationView', - }, - ], - }, - ], - }, - // editor - { - name: 'editor', - icon: 'highlight', - path: '/editor', - routes: [ - { - path: '/editor/flow', - name: 'flow', - component: './Editor/GGEditor/Flow', - }, - { - path: '/editor/mind', - name: 'mind', - component: './Editor/GGEditor/Mind', - }, - { - path: '/editor/koni', - name: 'koni', - component: './Editor/GGEditor/Koni', - }, - ], - }, - { - component: '404', - }, - ], - }, -]; diff --git a/scripts/fetch-block.js b/scripts/fetch-block.js index 43cbf9cd..b6414fa8 100644 --- a/scripts/fetch-block.js +++ b/scripts/fetch-block.js @@ -120,6 +120,7 @@ const installRouters = findAllInstallRouter(router); let i = 0; const firstUpperCase = pathString => { return pathString + .replace('.', '') .split(/\/|\-/) .map(s => s.toLowerCase().replace(/( |^)[a-z]/g, L => L.toUpperCase())) .filter(s => s) @@ -132,12 +133,13 @@ const installBlock = () => { return; } console.log('install ' + item.name + ' to: ' + item.component); - const cmd = `umi block add https://github.com/ant-design/pro-blocks/tree/master/${firstUpperCase( item.path, - )} --npm-client=cnpm --path=${item.path}`; + )} --npm-client=cnpm --path=${item.path}`; + console.log(cmd); exec(cmd, { encoding: 'utf8' }, (error, statusbar) => { if (error) console.log(error); + console.log(statusbar); i += 1; installBlock(); }); diff --git a/scripts/router.config.js b/scripts/router.config.js index 5ab3a325..eb280bc0 100644 --- a/scripts/router.config.js +++ b/scripts/router.config.js @@ -64,27 +64,27 @@ module.exports = [ name: 'stepform', component: './Forms/StepForm', hideChildrenInMenu: true, - routes: [ - { - path: '/form/step-form', - redirect: '/form/step-form/info', - }, - { - path: '/form/step-form/info', - name: 'info', - component: './Forms/StepForm/Step1', - }, - { - path: '/form/step-form/confirm', - name: 'confirm', - component: './Forms/StepForm/Step2', - }, - { - path: '/form/step-form/result', - name: 'result', - component: './Forms/StepForm/Step3', - }, - ], + // routes: [ + // { + // path: '/form/step-form', + // redirect: '/form/step-form/info', + // }, + // { + // path: '/form/step-form/info', + // name: 'info', + // component: './Forms/StepForm/Step1', + // }, + // { + // path: '/form/step-form/confirm', + // name: 'confirm', + // component: './Forms/StepForm/Step2', + // }, + // { + // path: '/form/step-form/result', + // name: 'result', + // component: './Forms/StepForm/Step3', + // }, + // ], }, { path: '/form/advanced-form', @@ -117,7 +117,7 @@ module.exports = [ }, { path: '/list/search', - name: 'searchlist', + name: 'search-list', component: './List/List', routes: [ { @@ -219,51 +219,51 @@ module.exports = [ path: '/account/center', name: 'center', component: './Account/Center/Center', - routes: [ - { - path: '/account/center', - redirect: '/account/center/articles', - }, - { - path: '/account/center/articles', - component: './Account/Center/Articles', - }, - { - path: '/account/center/applications', - component: './Account/Center/Applications', - }, - { - path: '/account/center/projects', - component: './Account/Center/Projects', - }, - ], + // routes: [ + // { + // path: '/account/center', + // redirect: '/account/center/articles', + // }, + // { + // path: '/account/center/articles', + // component: './Account/Center/Articles', + // }, + // { + // path: '/account/center/applications', + // component: './Account/Center/Applications', + // }, + // { + // path: '/account/center/projects', + // component: './Account/Center/Projects', + // }, + // ], }, { path: '/account/settings', name: 'settings', component: './Account/Settings/Info', - routes: [ - { - path: '/account/settings', - redirect: '/account/settings/base', - }, - { - path: '/account/settings/base', - component: './Account/Settings/BaseView', - }, - { - path: '/account/settings/security', - component: './Account/Settings/SecurityView', - }, - { - path: '/account/settings/binding', - component: './Account/Settings/BindingView', - }, - { - path: '/account/settings/notification', - component: './Account/Settings/NotificationView', - }, - ], + // routes: [ + // { + // path: '/account/settings', + // redirect: '/account/settings/base', + // }, + // { + // path: '/account/settings/base', + // component: './Account/Settings/BaseView', + // }, + // { + // path: '/account/settings/security', + // component: './Account/Settings/SecurityView', + // }, + // { + // path: '/account/settings/binding', + // component: './Account/Settings/BindingView', + // }, + // { + // path: '/account/settings/notification', + // component: './Account/Settings/NotificationView', + // }, + // ], }, ], }, diff --git a/src/layouts/BasicLayout.tsx b/src/layouts/BasicLayout.tsx index 29ac49c9..f4a4bce9 100644 --- a/src/layouts/BasicLayout.tsx +++ b/src/layouts/BasicLayout.tsx @@ -26,11 +26,14 @@ export type BasicLayoutContext = { [K in 'location']: BasicLayoutProps[K] } & { /** * default menuLocal */ -const filterMenuData = (menuList: MenuDataItem[], locale: boolean) => { +const filterMenuData = (menuList: MenuDataItem[], locale: boolean): MenuDataItem[] => { return menuList.map(item => { const localItem = { ...item, - name: item.locale && locale ? formatMessage({ id: item.locale }) : item.name, + name: + item.locale && locale + ? formatMessage({ id: item.locale, defaultMessage: item.name }) + : item.name, children: item.children ? filterMenuData(item.children, locale) : [], }; diff --git a/src/locales/en-US/menu.ts b/src/locales/en-US/menu.ts index 27b07fee..fae9170f 100644 --- a/src/locales/en-US/menu.ts +++ b/src/locales/en-US/menu.ts @@ -17,7 +17,7 @@ export default { 'menu.form.step-form.result': 'Step Form(finished)', 'menu.form.advanced-form': 'Advanced Form', 'menu.list': 'List', - 'menu.list.search-table': 'Search Table', + 'menu.list.table-list': 'Search Table', 'menu.list.basic-list': 'Basic List', 'menu.list.card-list': 'Card List', 'menu.list.search-list': 'Search List', diff --git a/src/locales/pt-BR/menu.ts b/src/locales/pt-BR/menu.ts index ced1264d..6e641938 100644 --- a/src/locales/pt-BR/menu.ts +++ b/src/locales/pt-BR/menu.ts @@ -17,7 +17,7 @@ export default { 'menu.form.step-form.result': 'Formulário Assistido(finalizado)', 'menu.form.advanced-form': 'Formulário Avançado', 'menu.list': 'Lista', - 'menu.list.search-table': 'Tabela de Busca', + 'menu.list.table-list': 'Tabela de Busca', 'menu.list.basic-list': 'Lista Básica', 'menu.list.card-list': 'Lista de Card', 'menu.list.search-list': 'Lista de Busca', diff --git a/src/locales/zh-CN/menu.ts b/src/locales/zh-CN/menu.ts index 9462aa33..fd93cf33 100644 --- a/src/locales/zh-CN/menu.ts +++ b/src/locales/zh-CN/menu.ts @@ -17,7 +17,7 @@ export default { 'menu.form.step-form.result': '分步表单(完成)', 'menu.form.advanced-form': '高级表单', 'menu.list': '列表页', - 'menu.list.search-table': '查询表格', + 'menu.list.table-list': '查询表格', 'menu.list.basic-list': '标准列表', 'menu.list.card-list': '卡片列表', 'menu.list.search-list': '搜索列表', diff --git a/src/locales/zh-TW/menu.ts b/src/locales/zh-TW/menu.ts index 8d312c3e..6bc2964b 100644 --- a/src/locales/zh-TW/menu.ts +++ b/src/locales/zh-TW/menu.ts @@ -18,7 +18,7 @@ export default { 'menu.form.step-form.result': '分步表單(完成)', 'menu.form.advanced-form': '高級表單', 'menu.list': '列表頁', - 'menu.list.search-table': '查詢表格', + 'menu.list.table-list': '查詢表格', 'menu.list.basic-list': '標淮列表', 'menu.list.card-list': '卡片列表', 'menu.list.search-list': '搜索列表', -- GitLab