Skip to content

Commit

Permalink
Merge pull request #153 from hightall/issue152
Browse files Browse the repository at this point in the history
improvement: upgrade umi version to 3.0
  • Loading branch information
litong01 authored May 21, 2020
2 parents c6ae7e7 + 50766f8 commit 754afa4
Show file tree
Hide file tree
Showing 42 changed files with 531 additions and 566 deletions.
2 changes: 1 addition & 1 deletion build_image/docker/common/dashboard/Dockerfile.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM circleci/node:latest-browsers
FROM node:14.2.0

WORKDIR /usr/src/app/
USER root
Expand Down
18 changes: 0 additions & 18 deletions netlify.toml

This file was deleted.

90 changes: 16 additions & 74 deletions src/dashboard/config/config.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,23 @@
// https://umijs.org/config/
import os from 'os';
import pageRoutes from './router.config';
import webpackPlugin from './plugin.config';
import defaultSettings from '../src/defaultSettings';
import slash from 'slash2';
import theme from './theme';

const { pwa, primaryColor } = defaultSettings;
// preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
const { TEST } = process.env;
const PROXY = process.env.PROXY || 'http://127.0.0.1/engine';

const plugins = [
[
'umi-plugin-react',
{
antd: true,
dva: {
hmr: true,
},
locale: {
enable: true, // default false
default: 'en-US', // default zh-CN
baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
},
dynamicImport: {
loadingComponent: './components/PageLoading/index',
webpackChunkName: true,
level: 3,
},
pwa: pwa
? {
workboxPluginMode: 'InjectManifest',
workboxOptions: {
importWorkboxFrom: 'local',
},
}
: false,
...(!TEST && os.platform() === 'darwin'
? {
dll: {
include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
exclude: ['@babel/runtime', 'netlify-lambda'],
},
hardSource: false,
}
: {}),
},
],
];

export default {
// add for transfer to umi
plugins,
treeShaking: true,
targets: {
ie: 11,
dva: {},
antd: {},
locale: {
default: 'en-US',
antd: false,
title: false,
baseNavigator: true,
baseSeparator: '-',
},
pwa: false,
lessLoader: { javascriptEnabled: true },
// devtool: false,
// 路由配置
routes: pageRoutes,
Expand All @@ -71,31 +32,8 @@ export default {
},
},
ignoreMomentLocale: true,
lessLoaderOptions: {
javascriptEnabled: true,
},
disableRedirectHoist: true,
cssLoaderOptions: {
modules: true,
getLocalIdent: (context, localIdentName, localName) => {
if (
context.resourcePath.includes('node_modules') ||
context.resourcePath.includes('ant.design.pro.less') ||
context.resourcePath.includes('global.less')
) {
return localName;
}
const match = context.resourcePath.match(/src(.*)/);
if (match && match[1]) {
const antdProPath = match[1].replace('.less', '');
const arr = slash(antdProPath)
.split('/')
.map(a => a.replace(/([A-Z])/g, '-$1'))
.map(a => a.toLowerCase());
return `cello${arr.join('-')}-${localName}`.replace(/--/g, '-');
}
return localName;
},
dynamicImport: {
loading: '@/components/PageLoading/index',
},
manifest: {
basePath: '/',
Expand All @@ -105,4 +43,8 @@ export default {
mock: {
exclude: ['mock/**/_*.js', 'mock/_*/**/*.js'],
},
hash: true,
history: {
type: 'hash',
},
};
128 changes: 67 additions & 61 deletions src/dashboard/config/router.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,83 +17,89 @@ export default [
// app
{
path: '/',
component: '../layouts/BasicLayout',
Routes: ['src/pages/Authorized'],
component: '../layouts/SecurityLayout',
routes: [
{ path: '/', redirect: '/overview', authority: ['operator', 'administrator', 'user'] },
{
path: '/overview',
name: 'overview',
icon: 'eye',
component: './Overview/Overview',
},
{
path: '/operator',
name: 'operator',
icon: 'dashboard',
authority: ['operator', 'administrator'],
path: '/',
component: '../layouts/BasicLayout',
authority: ['operator', 'administrator', 'user'],
routes: [
{ path: '/', redirect: '/overview' },
{
path: '/operator/overview',
path: '/overview',
name: 'overview',
component: './Operator/Overview',
},
{
path: '/operator/organization',
authority: ['operator'],
name: 'organization',
component: './Operator/Organization',
icon: 'eye',
component: './Overview/Overview',
},
{
path: '/operator/agent',
name: 'agent',
component: './Operator/Agent/Agent',
},
{
path: '/operator/agent/newAgent',
name: 'newAgent',
component: './Operator/Agent/newAgent',
hideInMenu: true,
},
{
path: '/operator/agent/editAgent',
name: 'editAgent',
component: './Operator/Agent/newAgent',
hideInMenu: true,
},
{
path: '/operator/node',
name: 'node',
component: './Operator/Node/Node',
},
{
path: '/operator/node/new',
name: 'newNode',
hideInMenu: true,
component: './Operator/Node/New/index',
path: '/operator',
name: 'operator',
icon: 'dashboard',
authority: ['operator', 'administrator'],
routes: [
{
path: '/operator/node/new',
redirect: '/operator/node/new/basic-info',
path: '/operator/overview',
name: 'overview',
component: './Operator/Overview',
},
{
path: '/operator/node/new/basic-info',
name: 'basicInfo',
component: './Operator/Node/New/basicInfo',
path: '/operator/organization',
authority: ['operator'],
name: 'organization',
component: './Operator/Organization',
},
{
path: '/operator/node/new/node-info',
name: 'nodeInfo',
component: './Operator/Node/New/nodeInfo',
path: '/operator/agent',
name: 'agent',
component: './Operator/Agent/Agent',
},
{
path: '/operator/agent/newAgent',
name: 'newAgent',
component: './Operator/Agent/newAgent',
hideInMenu: true,
},
{
path: '/operator/agent/editAgent',
name: 'editAgent',
component: './Operator/Agent/newAgent',
hideInMenu: true,
},
{
path: '/operator/node',
name: 'node',
component: './Operator/Node/Node',
},
{
path: '/operator/node/new',
name: 'newNode',
hideInMenu: true,
component: './Operator/Node/New/index',
routes: [
{
path: '/operator/node/new',
redirect: '/operator/node/new/basic-info',
},
{
path: '/operator/node/new/basic-info',
name: 'basicInfo',
component: './Operator/Node/New/basicInfo',
},
{
path: '/operator/node/new/node-info',
name: 'nodeInfo',
component: './Operator/Node/New/nodeInfo',
},
],
},
{
path: '/operator/userManagement',
name: 'userManagement',
component: './Operator/UserManagement',
},
],
},
{
path: '/operator/userManagement',
name: 'userManagement',
component: './Operator/UserManagement',
},
],
]
},
{
component: '404',
Expand Down
2 changes: 0 additions & 2 deletions src/dashboard/netlify.toml

This file was deleted.

19 changes: 7 additions & 12 deletions src/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"bizcharts": "3.5.2-beta.1",
"bizcharts-plugin-slider": "^2.1.1-beta.1",
"classnames": "^2.2.6",
"dva": "^2.4.1",
"enquire-js": "^0.2.1",
"express": "^4.16.4",
"gg-editor": "^2.0.2",
Expand All @@ -72,18 +71,17 @@
"prop-types": "^15.6.2",
"qs": "^6.6.0",
"rc-animate": "^2.6.0",
"react": "^16.7.0",
"react": "^16.8.0",
"react-container-query": "^0.11.0",
"react-copy-to-clipboard": "^5.0.1",
"react-document-title": "^2.0.3",
"react-dom": "^16.7.0",
"react-dom": "^16.8.0",
"react-fittext": "^1.0.0",
"react-media": "^1.9.2",
"resize-observer-polyfill": "^1.5.1",
"umi": "^2.13.13",
"umi-plugin-react": "^1.15.8",
"umi-request": "^1.2.19",
"cello-paginator": "^1.0.1",
"umi-request": "^1.2.19",
"@ant-design/pro-layout": "^5.0.0",
"validator": "^11.0.0"
},
"devDependencies": {
Expand Down Expand Up @@ -113,7 +111,6 @@
"jsdom-global": "^3.0.2",
"less": "^3.9.0",
"lint-staged": "^8.1.1",
"merge-umi-mock-data": "^1.0.4",
"mockjs": "^1.0.1-beta3",
"prettier": "^1.17.0",
"serverless-http": "^2.0.1",
Expand All @@ -128,11 +125,9 @@
"tslint": "^5.12.1",
"tslint-config-prettier": "^1.17.0",
"tslint-react": "^3.6.0",
"umi-plugin-ga": "^1.1.6",
"faker": "^4.1.0"
},
"optionalDependencies": {
"puppeteer": "^1.12.1"
"faker": "^4.1.0",
"umi": "^3.1.4",
"@umijs/preset-react": "^1.2.2"
},
"engines": {
"node": ">=10.0.0"
Expand Down
13 changes: 9 additions & 4 deletions src/dashboard/src/components/GlobalHeader/RightContent.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import React, { PureComponent } from 'react';
import { FormattedMessage } from 'umi-plugin-react/locale';
import { injectIntl } from 'umi';
import { Spin, Menu, Icon, Avatar } from 'antd';
import HeaderDropdown from '../HeaderDropdown';
import SelectLang from '../SelectLang';
import styles from './index.less';

export default class GlobalHeaderRight extends PureComponent {
class GlobalHeaderRight extends PureComponent {
render() {
const { currentUser, onMenuClick } = this.props;
const { currentUser, onMenuClick, intl } = this.props;
const menu = (
<Menu className={styles.menu} selectedKeys={[]} onClick={onMenuClick}>
<Menu.Item key="logout">
<Icon type="logout" />
<FormattedMessage id="menu.account.logout" defaultMessage="logout" />
{intl.formatMessage({
id: 'menu.account.logout',
defaultMessage: 'logout'
})}
</Menu.Item>
</Menu>
);
Expand All @@ -37,3 +40,5 @@ export default class GlobalHeaderRight extends PureComponent {
);
}
}

export default injectIntl(GlobalHeaderRight)
2 changes: 1 addition & 1 deletion src/dashboard/src/components/GlobalHeader/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import { Icon } from 'antd';
import Link from 'umi/link';
import { Link } from 'umi';
import Debounce from 'lodash-decorators/debounce';
import styles from './index.less';
import RightContent from './RightContent';
Expand Down
3 changes: 1 addition & 2 deletions src/dashboard/src/components/PageHeaderWrapper/breadcrumb.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import pathToRegexp from 'path-to-regexp';
import Link from 'umi/link';
import { formatMessage } from 'umi-plugin-react/locale';
import { Link, formatMessage } from 'umi';
import { urlToList } from '../_utils/pathTools';
import { menu } from '../../defaultSettings';

Expand Down
Loading

0 comments on commit 754afa4

Please sign in to comment.