hashHistory to browserHistory

This commit is contained in:
pmg1989
2017-02-25 15:19:27 +08:00
parent a07b2a6b0e
commit e03316423f
5 changed files with 33 additions and 11 deletions
+7 -6
View File
@@ -23,10 +23,11 @@
"babel-plugin-import": "^1.0.1",
"babel-plugin-transform-runtime": "^6.9.0",
"babel-runtime": "^6.9.2",
"dora": "0.3.x",
"dora-plugin-proxy": "^0.7.0",
"dora-plugin-webpack": "0.6.x",
"dora-plugin-webpack-hmr": "^0.1.0",
"dora": "^0.4.3",
"dora-plugin-browser-history": "^0.2.0",
"dora-plugin-proxy": "^0.8.5",
"dora-plugin-webpack": "^0.8.1",
"dora-plugin-webpack-hmr": "^0.2.1",
"eslint": "^2.13.1",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.8.1",
@@ -40,8 +41,8 @@
"watchjs": "^0.0.0"
},
"scripts": {
"start": "dora --plugins \"proxy,webpack,webpack-hmr\"",
"dev": "dora --plugins \"webpack,webpack-hmr\"",
"start": "dora --plugins \"proxy,webpack,webpack-hmr,browser-history?index=/src/index.html\"",
"dev": "dora --plugins \"webpack,webpack-hmr,browser-history?index=/src/index.html\"",
"lint": "eslint --fix --ext .js,.jsx src/components/layout",
"build": "atool-build"
},
+2 -2
View File
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Ant Design Admin</title>
<link rel="stylesheet" href="index.css" />
<link rel="stylesheet" href="/index.css" />
<link rel="icon" href="https://t.alipayobjects.com/images/T1QUBfXo4fXXXXXXXX.png" type="image/x-icon">
<!--[if lte IE 10]>
<script
@@ -16,7 +16,7 @@
<div id="root"></div>
<script src="index.js"></script>
<script src="/index.js"></script>
<script src="//at.alicdn.com/t/font_c4y7asse3q1cq5mi.js"></script>
</body>
+7 -3
View File
@@ -1,14 +1,18 @@
import './index.html'
import dva from 'dva'
import { browserHistory } from 'dva/router'
// 1. Initialize
const app = dva()
const app = dva({
history: browserHistory,
onError(error) {
console.error("app onError -- ", error)
}
})
// 2. Model
app.model(require('./models/app'))
app.model(require('./models/dashboard'))
app.model(require('./models/users'))
// 3. Router
app.router(require('./router'))
+10
View File
@@ -2,6 +2,14 @@ import React from 'react'
import {Router} from 'dva/router'
import App from './routes/app'
const cached = {};
function registerModel(app, model) {
if (!cached[model.namespace]) {
app.model(model)
cached[model.namespace] = 1
}
}
export default function ({history, app}) {
const routes = [
{
@@ -18,6 +26,7 @@ export default function ({history, app}) {
name: 'dashboard',
getComponent (nextState, cb) {
require.ensure([], require => {
registerModel(app, require('./models/dashboard'))
cb(null, require('./routes/dashboard'))
})
}
@@ -26,6 +35,7 @@ export default function ({history, app}) {
name: 'users',
getComponent (nextState, cb) {
require.ensure([], require => {
registerModel(app, require('./models/users'))
cb(null, require('./routes/users'))
})
}
+7
View File
@@ -1,4 +1,5 @@
const webpack = require('atool-build/lib/webpack')
const path = require('path')
module.exports = function (webpackConfig, env) {
webpackConfig.babel.plugins.push('transform-runtime')
@@ -19,6 +20,12 @@ module.exports = function (webpackConfig, env) {
webpackConfig.babel.plugins.push('dev-expression')
}
webpackConfig.output = {
path: path.join(__dirname, '../dist'),
filename: '[name].js',
publicPath: '/'
}
// Don't extract common.js and common.css
webpackConfig.plugins = webpackConfig.plugins.filter(function (plugin) {
return !(plugin instanceof webpack.optimize.CommonsChunkPlugin)