提交 d22c8c31 authored 作者: vipcxj's avatar vipcxj

1.update roadhog to 3.x

2.update dva to 2.x 3.update react to 16.x 4.update some other library
上级 abb66e6a
...@@ -25,7 +25,16 @@ ...@@ -25,7 +25,16 @@
"require-yield": [1], "require-yield": [1],
"no-plusplus": "off", "no-plusplus": "off",
"no-mixed-operators": "off", "no-mixed-operators": "off",
"max-len": [0, 120] "max-len": [0, 120],
"object-curly-newline": "off",
"padded-blocks": "off",
"function-paren-newline": "off",
"jsx-a11y/anchor-is-valid": "off",
"no-multi-assign": "off",
"no-await-in-loop": "off",
"prefer-destructuring": "off",
"react/require-default-props": "off",
"react/no-array-index-key": "off"
}, },
"parserOptions": { "parserOptions": {
"ecmaFeatures": { "ecmaFeatures": {
......
const oldRequire = require.extensions['.js'];
const babelRegister = require('./babel-register');
const babelRequire = require.extensions['.js'];
require.extensions = (m, filename) => {
oldRequire(m, filename);
delete require.cache[filename];
return babelRequire(m, filename);
};
module.exports = require('./mock'); module.exports = require('./mock');
babelRegister.unregister();
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */ /* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
import 'babel-polyfill'; import '@babel/polyfill';
import { configure } from '@storybook/react'; import { configure } from '@storybook/react';
function loadStories() { import('../stories').then((stories) => {
require('../stories'); configure(stories, module);
} });
configure(loadStories, module);
...@@ -4,7 +4,7 @@ const createProxy = require('http-proxy-middleware'); ...@@ -4,7 +4,7 @@ const createProxy = require('http-proxy-middleware');
const _ = require('lodash'); const _ = require('lodash');
const assert = require('assert'); const assert = require('assert');
const roadhog = require('../.roadhogrc'); const roadhog = require('../.webpackrc');
const mock = require('../.roadhogrc.mock'); const mock = require('../.roadhogrc.mock');
function parseKey(key) { function parseKey(key) {
......
const genDefaultConfig = require('@storybook/react/dist/server/config/defaults/webpack.config.js'); const genDefaultConfig = require('@storybook/react/dist/server/config/defaults/webpack.config.js').default;
const path = require('path'); const path = require('path').default;
module.exports = (baseConfig, env) => { module.exports = (baseConfig, env) => {
const config = genDefaultConfig(baseConfig, env); const config = genDefaultConfig(baseConfig, env);
......
...@@ -16,6 +16,9 @@ const resource_proxy = { ...@@ -16,6 +16,9 @@ const resource_proxy = {
module.exports = { module.exports = {
"entry": "src/index.js", "entry": "src/index.js",
"html": {
"template": "src/index.ejs",
},
"theme": { "theme": {
"layout-header-height": "48px", "layout-header-height": "48px",
"layout-header-background": "#fff", "layout-header-background": "#fff",
...@@ -24,13 +27,16 @@ module.exports = { ...@@ -24,13 +27,16 @@ module.exports = {
'menu-dark-bg': '#404040', 'menu-dark-bg': '#404040',
"layout-header-padding": "0", "layout-header-padding": "0",
}, },
"ignoreMomentLocale": true,
"hash": true,
"env": { "env": {
"development": { "development": {
publicPath: "/",
"extraBabelPlugins": [ "extraBabelPlugins": [
"dva-hmr", "dva-hmr",
"transform-runtime",
["import", { "libraryName": "antd", "style": true }] ["import", { "libraryName": "antd", "style": true }]
], ],
"devtool": "cheap-module-eval-source-map",
"proxy": { "proxy": {
"/api": proxy, "/api": proxy,
"/resource": resource_proxy, "/resource": resource_proxy,
...@@ -43,9 +49,9 @@ module.exports = { ...@@ -43,9 +49,9 @@ module.exports = {
apiContextPath: "/bm" apiContextPath: "/bm"
}, },
"extraBabelPlugins": [ "extraBabelPlugins": [
"transform-runtime",
["import", { "libraryName": "antd", "style": true }] ["import", { "libraryName": "antd", "style": true }]
] ],
"devtool": "hidden-source-map"
} }
} }
}; };
...@@ -7,17 +7,6 @@ import toFilters from './src/mock/filter'; ...@@ -7,17 +7,6 @@ import toFilters from './src/mock/filter';
const modules = genModules(); const modules = genModules();
const tasks = getTasks(); const tasks = getTasks();
const users = [
{
userId: 1,
userName: 'cxj',
tokenId: '12345-65432-abcdef',
expire: -1,
},
];
let currentUser = users[0];
const domains = [ const domains = [
{ {
id: 1, id: 1,
...@@ -47,8 +36,7 @@ const getDomain = (id) => { ...@@ -47,8 +36,7 @@ const getDomain = (id) => {
}; };
const dealWithData = (req) => { const dealWithData = (req) => {
const sort = req.query.sort; const { sort, order } = req.query;
const order = req.query.order;
const filters = []; const filters = [];
for (const queryKey in req.query) { for (const queryKey in req.query) {
if (queryKey.indexOf('f-') === 0) { if (queryKey.indexOf('f-') === 0) {
...@@ -114,7 +102,7 @@ module.exports = { ...@@ -114,7 +102,7 @@ module.exports = {
}, },
'/api/domain/all': wrapResponse(domains), '/api/domain/all': wrapResponse(domains),
'/api/domain/switch': (req, res) => { '/api/domain/switch': (req, res) => {
const domainId = req.query.domainId; const { domainId } = req.query;
const intDomainId = parseInt(domainId, 10); const intDomainId = parseInt(domainId, 10);
const domainIds = domains.map(domain => domain.id); const domainIds = domains.map(domain => domain.id);
if (domainIds.indexOf(intDomainId) !== -1) { if (domainIds.indexOf(intDomainId) !== -1) {
...@@ -136,7 +124,7 @@ module.exports = { ...@@ -136,7 +124,7 @@ module.exports = {
}, },
'/api/module/all/info': (req, res) => { '/api/module/all/info': (req, res) => {
console.log('/api/module/all/info'); console.log('/api/module/all/info');
const all = modules.all; const { all } = modules;
const publics = modules.public; const publics = modules.public;
const findModule = id => all.filter(m => m.id === id).pop(); const findModule = id => all.filter(m => m.id === id).pop();
const fetchParent = (module) => { const fetchParent = (module) => {
......
{ {
"private": true, "private": true,
"scripts": { "scripts": {
"start": "roadhog server", "start": "roadhog dev",
"build": "roadhog build", "build": "cross-env ANALYZE=true roadhog build",
"test": "roadhog test --require ./test_setup.js", "test": "roadhog test --require ./test_setup.js",
"lint": "eslint --ext .js src test", "lint": "eslint --ext .js src test",
"precommit": "npm run lint", "precommit": "npm run lint",
...@@ -13,22 +13,20 @@ ...@@ -13,22 +13,20 @@
"install-node": "6.9.2" "install-node": "6.9.2"
}, },
"dependencies": { "dependencies": {
"antd": "^2.13.0", "antd": "^2.13.11",
"axo": "0.0.2", "axo": "0.0.2",
"babel-plugin-import": "^1.2.1",
"babel-runtime": "^6.9.2",
"bowser": "^1.8.1", "bowser": "^1.8.1",
"bundle-loader": "^0.5.5", "dva": "^2.2.0-beta.2",
"dva": "^1.2.1", "dva-react-router-3": "^1.0.2",
"dva-loading": "^0.2.1", "dva-loading": "^1.0.4",
"fastjson_ref_resolver": "latest", "fastjson_ref_resolver": "latest",
"fingerprintjs": "^0.5.3", "fingerprintjs": "^0.5.3",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"lowdb": "^1.0.0", "lowdb": "^1.0.0",
"moment": "^2.18.1", "moment": "^2.18.1",
"prop-types": "^15.5.10", "prop-types": "^15.6.1",
"react": "^15.6.1", "react": "^16.2.0",
"react-dom": "^15.6.1", "react-dom": "^16.2.0",
"react-json-view": "^1.11.4", "react-json-view": "^1.11.4",
"react-sizeme": "^2.3.4", "react-sizeme": "^2.3.4",
"resolve-pathname": "^2.1.0", "resolve-pathname": "^2.1.0",
...@@ -38,31 +36,23 @@ ...@@ -38,31 +36,23 @@
}, },
"devDependencies": { "devDependencies": {
"@storybook/react": "^3.2.8", "@storybook/react": "^3.2.8",
"babel-eslint": "^7.1.1", "babel-plugin-dva-hmr": "^0.4.1",
"babel-plugin-dva-hmr": "^0.3.2", "babel-plugin-import": "^1.6.5",
"babel-plugin-transform-runtime": "^6.9.0", "babel-register": "^7.0.0-beta.3",
"babel-preset-es2016": "^6.24.1", "bundle-loader": "^0.5.6",
"babel-preset-es2017": "^6.24.1",
"babel-register": "^6.24.1",
"chai": "^4.0.2", "chai": "^4.0.2",
"cross-env": "^5.0.1", "cross-env": "^5.1.3",
"ejs-loader": "^0.3.0", "ejs-loader": "^0.3.1",
"enzyme": "^2.9.1", "enzyme": "^3.3.0",
"eslint": "^3.12.2", "eslint-config-airbnb": "^16.1.0",
"eslint-config-airbnb": "^13.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.8.0",
"expect": "^1.20.2",
"http-proxy-middleware": "^0.17.4", "http-proxy-middleware": "^0.17.4",
"husky": "^0.12.0",
"jsdom": "^11.0.0", "jsdom": "^11.0.0",
"less": "^2.7.2", "less": "^2.7.2",
"less-loader": "^4.0.0", "less-loader": "^4.0.0",
"mockjs": "^1.0.1-beta3", "mockjs": "^1.0.1-beta3",
"path": "^0.12.7", "path": "^0.12.7",
"react-test-renderer": "^15.6.1", "react-test-renderer": "^16.2.0",
"redbox-react": "^1.3.2", "redbox-react": "^1.5.0",
"roadhog": "^1.2.2" "roadhog": "^2.3.0-beta.1"
} }
} }
...@@ -59,20 +59,21 @@ class TableInput extends Component { ...@@ -59,20 +59,21 @@ class TableInput extends Component {
const { items, form, children } = this.props; const { items, form, children } = this.props;
if (this.state.editing) { if (this.state.editing) {
const fields = _.castArray(children) const fields = _.castArray(children)
.map((child, i) => { .map(
const item = items[i]; (child, i) => {
return ( const item = items[i];
<Form.Item {...item}> return (
{ <Form.Item {...item}>
form.getFieldDecorator(item.name, item)( {
child, form.getFieldDecorator(item.name, item)(
) child,
} )
</Form.Item> }
); </Form.Item>
}, );
this, },
); this,
);
return ( return (
<div> <div>
{[ {[
......
...@@ -46,7 +46,7 @@ const combineMenus = (menus1, menus2) => { ...@@ -46,7 +46,7 @@ const combineMenus = (menus1, menus2) => {
export const getMenus = async () => { export const getMenus = async () => {
if (!data.flags.menus) { if (!data.flags.menus) {
const context = require.context('../register/modules', true, /^.*\.(js|jsx|json)/); const context = require.context('../register/modules', true, /^.*\.(js|jsx|json)/);
const staticMenus = flatMap(context.keys(), context); const staticMenus = flatMap(context.keys(), k => context(k).default);
const dynamicMenus = await fetchMenus(); const dynamicMenus = await fetchMenus();
data.menus = combineMenus(staticMenus, dynamicMenus); data.menus = combineMenus(staticMenus, dynamicMenus);
data.flags.menus = true; data.flags.menus = true;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dva Demo</title> <title>Dva Demo</title>
<script src="https://cdn.bootcss.com/babel-polyfill/6.26.0/polyfill.min.js"></script> <script src="https://cdn.bootcss.com/babel-polyfill/7.0.0-beta.3/polyfill.min.js"></script>
<!--<link rel="stylesheet" href="/index.css" />--> <!--<link rel="stylesheet" href="/index.css" />-->
</head> </head>
<body> <body>
......
...@@ -14,7 +14,7 @@ moment.locale('zh-cn'); ...@@ -14,7 +14,7 @@ moment.locale('zh-cn');
const app = dva({ const app = dva({
history, history,
onError(error) { onError(error) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
processError(error); processError(error);
}, },
}); });
......
import { routerRedux } from 'dva/router'; import { routerRedux } from 'dva-react-router-3/router';
import { authorize, login, userInfo } from '../services/login'; import { authorize, login, userInfo } from '../services/login';
import { validate as passValidate } from '../services/login/password'; import { validate as passValidate } from '../services/login/password';
import { requestCode, validate as ucaValidate } from '../services/login/uca'; import { requestCode, validate as ucaValidate } from '../services/login/uca';
......
import { routerRedux } from 'dva/router'; import { routerRedux } from 'dva-react-router-3/router';
import { isString } from 'lodash'; import { isString } from 'lodash';
import { logout } from '../../services/main'; import { logout } from '../../services/main';
import { fetchDomains, switchDomain, currentDomain } from '../../services/domain'; import { fetchDomains, switchDomain, currentDomain } from '../../services/domain';
......
/* eslint-disable */
export default [/* { export default [/* {
name: 'test-menu', name: 'test-menu',
showName: '测试', showName: '测试',
......
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Router } from 'dva/router'; import { Router } from 'dva-react-router-3/router';
import _ from 'lodash'; import { isString } from 'lodash';
import config from './utils/config'; import config from './utils/config';
import { isAuthed, hasDomain, histories } from './utils/auth'; import { isAuthed, hasDomain, histories } from './utils/auth';
import { fullPath, makePromise0 } from './utils/helper'; import { fullPath, makePromise0 } from './utils/helper';
...@@ -75,7 +75,7 @@ const createRoutes = async (app, modules, groups, basePath) => { ...@@ -75,7 +75,7 @@ const createRoutes = async (app, modules, groups, basePath) => {
for (const module of modules) { for (const module of modules) {
let info; let info;
let layout; let layout;
if (_.isString(module)) { if (isString(module)) {
info = await getModuleInfo(module); info = await getModuleInfo(module);
layout = await getModuleLayout(module); layout = await getModuleLayout(module);
} else { } else {
...@@ -89,13 +89,15 @@ const createRoutes = async (app, modules, groups, basePath) => { ...@@ -89,13 +89,15 @@ const createRoutes = async (app, modules, groups, basePath) => {
name: showName, name: showName,
}; };
if (layout.route) { if (layout.route) {
const modelBundle = await makePromise0(require('bundle!./models/main/modules/' + layout.route + '/index.js')); // eslint-disable-line import/no-dynamic-require, prefer-template, global-require const modelBundle = await makePromise0(require('bundle-loader!./models/main/modules/' + layout.route + '/index.js').default); // eslint-disable-line import/no-dynamic-require, prefer-template, global-require
registerModel(app, modelBundle); registerModel(app, modelBundle);
const routeBundle = await makePromise0(require('bundle!./routes/main/modules/' + layout.route + '/index.js')); // eslint-disable-line import/no-dynamic-require, prefer-template, global-require const routeBundle = await makePromise0(require('bundle-loader!./routes/main/modules/' + layout.route + '/index.js').default); // eslint-disable-line import/no-dynamic-require, prefer-template, global-require
route.component = routeBundle; route.component = routeBundle;
if (routeBundle.route) { if (routeBundle.route) {
for (const key in routeBundle.route) { for (const key in routeBundle.route) {
// noinspection JSUnfilteredForInLoop
if ({}.hasOwnProperty.call(routeBundle.route, key)) { if ({}.hasOwnProperty.call(routeBundle.route, key)) {
// noinspection JSUnfilteredForInLoop
route[key] = routeBundle.route[key]; route[key] = routeBundle.route[key];
} }
} }
...@@ -176,8 +178,8 @@ function RouterConfig({ history, app }) { ...@@ -176,8 +178,8 @@ function RouterConfig({ history, app }) {
path: 'login', path: 'login',
getComponent(ignored, cb) { getComponent(ignored, cb) {
require.ensure([], (require) => { require.ensure([], (require) => {
registerModel(app, require('./models/login')); registerModel(app, require('./models/login').default);
cb(null, require('./routes/login')); cb(null, require('./routes/login').default);
}, 'login'); }, 'login');
}, },
}, },
...@@ -188,8 +190,8 @@ function RouterConfig({ history, app }) { ...@@ -188,8 +190,8 @@ function RouterConfig({ history, app }) {
}, },
getComponent(ignored, cb) { getComponent(ignored, cb) {
require.ensure([], (require) => { require.ensure([], (require) => {
registerModel(app, require('./models/domain')); registerModel(app, require('./models/domain').default);
cb(null, require('./routes/domain')); cb(null, require('./routes/domain').default);
}, 'domain'); }, 'domain');
}, },
}, },
...@@ -200,8 +202,8 @@ function RouterConfig({ history, app }) { ...@@ -200,8 +202,8 @@ function RouterConfig({ history, app }) {
}, },
getComponent(ignored, cb) { getComponent(ignored, cb) {
require.ensure([], (require) => { require.ensure([], (require) => {
registerModel(app, require('./models/main')); registerModel(app, require('./models/main').default);
cb(null, require('./routes/main')); cb(null, require('./routes/main').default);
}, 'main'); }, 'main');
}, },
getChildRoutes: (nextState, cb) => { getChildRoutes: (nextState, cb) => {
...@@ -231,8 +233,8 @@ function RouterConfig({ history, app }) { ...@@ -231,8 +233,8 @@ function RouterConfig({ history, app }) {
}, },
getComponent(ignored, cb) { getComponent(ignored, cb) {
require.ensure([], (require) => { require.ensure([], (require) => {
registerModel(app, require('./models/main/modules/' + config.fastNavigationPage)); // eslint-disable-line import/no-dynamic-require, prefer-template registerModel(app, require('./models/main/modules/' + config.fastNavigationPage).default); // eslint-disable-line import/no-dynamic-require, prefer-template
cb(null, require('./routes/main/modules/' + config.fastNavigationPage)); // eslint-disable-line import/no-dynamic-require, prefer-template cb(null, require('./routes/main/modules/' + config.fastNavigationPage).default); // eslint-disable-line import/no-dynamic-require, prefer-template
}, 'fastNav'); }, 'fastNav');
}, },
}); });
...@@ -243,8 +245,8 @@ function RouterConfig({ history, app }) { ...@@ -243,8 +245,8 @@ function RouterConfig({ history, app }) {
} }
RouterConfig.propTypes = { RouterConfig.propTypes = {
history: PropTypes.object, history: PropTypes.object.isRequired,
app: PropTypes.object, app: PropTypes.object.isRequired,
}; };
export default RouterConfig; export default RouterConfig;
...@@ -115,7 +115,7 @@ class LoginForm extends React.Component { ...@@ -115,7 +115,7 @@ class LoginForm extends React.Component {
render() { render() {
const { getFieldDecorator } = this.props.form; const { getFieldDecorator } = this.props.form;
const loading = this.props.loading; const { loading } = this.props;
return ( return (
<div className={styles.canvas}> <div className={styles.canvas}>
<div className={styles.container}> <div className={styles.container}>
......
...@@ -2,7 +2,7 @@ import React from 'react'; ...@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Menu, Breadcrumb, Icon } from 'antd'; import { Menu, Breadcrumb, Icon } from 'antd';
import { connect } from 'dva'; import { connect } from 'dva';
import { Link } from 'dva/router'; import { Link } from 'dva-react-router-3/router';
import styles from './header.less'; import styles from './header.less';
const SubMenu = Menu.SubMenu; const SubMenu = Menu.SubMenu;
......
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { connect } from 'dva'; import { connect } from 'dva';
import { withRouter } from 'dva/router'; import { withRouter } from 'dva-react-router-3/router';
import { Layout } from 'antd'; import { Layout } from 'antd';
import SiderLogo from '../../components/layout/sider/SiderLogo'; import SiderLogo from '../../components/layout/sider/SiderLogo';
import SiderMenu from '../../components/layout/sider/SiderMenu'; import SiderMenu from '../../components/layout/sider/SiderMenu';
...@@ -76,7 +76,7 @@ class Main extends React.Component { ...@@ -76,7 +76,7 @@ class Main extends React.Component {
Main.propTypes = { Main.propTypes = {
children: PropTypes.element, children: PropTypes.element,
main: PropTypes.object.isRequired, main: PropTypes.object,
}; };
export default connect(({ main }) => ({ main }))(withRouter(Main)); export default connect(({ main }) => ({ main }))(withRouter(Main));
import { connect } from 'dva'; import { connect } from 'dva';
import { withRouter } from 'dva/router'; import { withRouter } from 'dva-react-router-3/router';
import List from './list'; import List from './list';
import Detail from './detail'; import Detail from './detail';
import route from '../../../../components/hoc/routes'; import route from '../../../../components/hoc/routes';
......
import { browserHistory } from 'dva/router'; import { browserHistory } from 'dva-react-router-3/router';
import resolvePathname from 'resolve-pathname'; import resolvePathname from 'resolve-pathname';
import { isString } from 'lodash'; import { isString } from 'lodash';
import config from '../utils/config'; import config from '../utils/config';
......
...@@ -88,7 +88,7 @@ export function encrypt(text) { ...@@ -88,7 +88,7 @@ export function encrypt(text) {
*/ */
export function queryURL(name) { export function queryURL(name) {
const reg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`, 'i'); const reg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`, 'i');
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const r = window ? window.location.search.substr(1).match(reg) : null; const r = window ? window.location.search.substr(1).match(reg) : null;
if (r !== null) return decodeURI(r[2]); if (r !== null) return decodeURI(r[2]);
return null; return null;
...@@ -101,7 +101,7 @@ export function padDigits(number, digits) { ...@@ -101,7 +101,7 @@ export function padDigits(number, digits) {
export function is(obj, type) { export function is(obj, type) {
return (type === 'Null' && obj === null) || return (type === 'Null' && obj === null) ||
(type === 'Undefined' && obj === void 0) || // eslint-disable-line no-void (type === 'Undefined' && obj === void 0) || // eslint-disable-line no-void
(type === 'Number' && isFinite(obj)) || (type === 'Number' && Number.isFinite(obj)) ||
Object.prototype.toString.call(obj).slice(8, -1) === type; Object.prototype.toString.call(obj).slice(8, -1) === type;
} }
......
/* eslint-disable */ /* eslint-disable */
export const fetch = require('dva/fetch'); export const fetch = require('dva/fetch');
module.exports = function (config) { module.exports = function webpack(config) {
config.module.rules.push({ config.module.rules.push({
test: /\.ejs$/, test: /\.ejs$/,
loader: 'ejs-loader', loader: 'ejs-loader',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论