Skip to content

Commit

Permalink
Merge branch 'yangbin1994-dva2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
zuiidea committed Sep 8, 2017
2 parents 39c377e + 1288853 commit 6d17b5b
Show file tree
Hide file tree
Showing 16 changed files with 148 additions and 173 deletions.
18 changes: 9 additions & 9 deletions .roadhogrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ const svgSpriteDirs = [
]

export default {
entry : 'src/index.js',
svgSpriteLoaderDirs : svgSpriteDirs,
theme : "./theme.config.js",
publicPath : `/${version}/`,
outputPath : `./dist/${version}`,
entry: 'src/index.js',
svgSpriteLoaderDirs: svgSpriteDirs,
theme: "./theme.config.js",
publicPath: `/${version}/`,
outputPath: `./dist/${version}`,
// 接口代理示例
proxy: {
"/api/v1/weather": {
"target": "https://api.seniverse.com/",
"changeOrigin": true,
"pathRewrite": { "^/api/v1/weather" : "/v3/weather" }
"pathRewrite": { "^/api/v1/weather": "/v3/weather" }
},
// "/api/v2": {
// "target": "http://192.168.0.110",
// "changeOrigin": true,
// "pathRewrite": { "^/api/v2" : "/api/v2" }
// }
},
env : {
env: {
development: {
extraBabelPlugins: [
"dva-hmr",
Expand All @@ -50,8 +50,8 @@ export default {
]
}
},
dllPlugin : {
exclude: ["babel-runtime"],
dllPlugin: {
exclude: ["babel-runtime", "roadhog", "cross-env"],
include: ["dva/router", "dva/saga", "dva/fetch"]
}
}
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
"axios": "^0.16.2",
"babel-polyfill": "^6.23.0",
"classnames": "^2.2.5",
"cross-env": "^5.0.5",
"d3-shape": "^1.2.0",
"draftjs-to-markdown": "^0.4.0",
"dva": "^1.2.0",
"dva": "^2.0.1",
"dva-loading": "^0.2.0",
"ejs-loader": "^0.3.0",
"history": "^4.7.2",
"js-beautify": "^1.6.14",
"jsonp": "^0.2.1",
"less-vars-to-js": "^1.1.2",
Expand All @@ -21,6 +23,7 @@
"path-to-regexp": "^1.7.0",
"prop-types": "^15.5.10",
"qs": "^6.5.0",
"query-string": "^5.0.0",
"rc-tween-one": "^1.3.1",
"react": "^15.6.1",
"react-countup": "^2.1.1",
Expand Down Expand Up @@ -48,11 +51,13 @@
"eslint-plugin-react": "^7.1.0",
"html-webpack-plugin": "^2.29.0",
"redbox-react": "^1.2.10",
"roadhog": "^1.2.1"
"roadhog": "^1.2.2"
},
"pre-commit": ["lint"],
"pre-commit": [
"lint"
],
"scripts": {
"dev": "set BROWSER=none&&set HOST=0.0.0.0&&roadhog server",
"dev": "cross-env BROWSER=none HOST=0.0.0.0 roadhog server",
"lint": "eslint --fix --ext .js src",
"build": "roadhog build",
"build:dll": "roadhog buildDll",
Expand Down
6 changes: 3 additions & 3 deletions src/components/Layout/Bread.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Breadcrumb, Icon } from 'antd'
import { Link } from 'dva/router'
import { LinkWrapper } from 'components'
import pathToRegexp from 'path-to-regexp'
import { queryArray } from 'utils'
import styles from './Bread.less'
Expand Down Expand Up @@ -48,9 +48,9 @@ const Bread = ({ menu, location }) => {
return (
<Breadcrumb.Item key={key}>
{((pathArray.length - 1) !== key)
? <Link to={item.route}>
? <LinkWrapper to={item.route}>
{content}
</Link>
</LinkWrapper>
: content}
</Breadcrumb.Item>
)
Expand Down
6 changes: 3 additions & 3 deletions src/components/Layout/Menu.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Menu, Icon } from 'antd'
import { Link } from 'dva/router'
import { LinkWrapper } from 'components'
import { arrayToTree, queryArray } from 'utils'
import pathToRegexp from 'path-to-regexp'

Expand Down Expand Up @@ -31,10 +31,10 @@ const Menus = ({ siderFold, darkTheme, handleClickNavMenu, navOpenKeys, changeOp
}
return (
<Menu.Item key={item.id}>
<Link to={item.route}>
<LinkWrapper to={item.route}>
{item.icon && <Icon type={item.icon} />}
{(!siderFoldN || !menuTree.includes(item)) && item.name}
</Link>
</LinkWrapper>
</Menu.Item>
)
})
Expand Down
10 changes: 10 additions & 0 deletions src/components/LinkWrapper/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Link } from 'react-router-dom'

export default (props) => {
const Component = props.to ? Link : 'a'
return (
<Component {...props}>
{props.children}
</Component>
)
}
8 changes: 6 additions & 2 deletions src/components/Loader/Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import PropTypes from 'prop-types'
import classNames from 'classnames'
import styles from './Loader.less'

const Loader = ({ spinning }) => {
return (<div className={classNames(styles.loader, { [styles.hidden]: !spinning })}>
const Loader = ({ spinning, fullScreen }) => {
return (<div className={classNames(styles.loader, {
[styles.hidden]: !spinning,
[styles.loader_fullScreen]: fullScreen,
})}>
<div className={styles.warpper}>
<div className={styles.inner} />
<div className={styles.text} >LOADING</div>
Expand All @@ -15,6 +18,7 @@ const Loader = ({ spinning }) => {

Loader.propTypes = {
spinning: PropTypes.bool,
fullScreen: PropTypes.bool,
}

export default Loader
6 changes: 5 additions & 1 deletion src/components/Loader/Loader.less
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
.loader_fullScreen {
position: fixed !important;
}

.loader {
display: block;
background-color: #fff;
width: 100%;
position: fixed;
position: absolute;
top: 0;
bottom: 0;
left: 0;
Expand Down
2 changes: 2 additions & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Editor from './Editor'
import FilterItem from './FilterItem'
import Loader from './Loader'
import * as Layout from './Layout/index.js'
import LinkWrapper from './LinkWrapper'

import layer from './layer'

Expand All @@ -19,4 +20,5 @@ export {
FilterItem,
Loader,
layer,
LinkWrapper,
}
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { message } from 'antd'
import dva from 'dva'
import createLoading from 'dva-loading'
import { browserHistory } from 'dva/router'
import createHistory from 'history/createBrowserHistory'
import 'babel-polyfill'

// 1. Initialize
const app = dva({
...createLoading({
effects: true,
}),
history: browserHistory,
history: createHistory(),
onError (error) {
message.error(error.message)
},
Expand Down
3 changes: 2 additions & 1 deletion src/models/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import config from 'config'
import { EnumRoleType } from 'enums'
import { query, logout } from 'services/app'
import * as menusService from 'services/menus'
import queryString from 'query-string'

const { prefix } = config

Expand Down Expand Up @@ -41,7 +42,7 @@ export default {
type: 'updateState',
payload: {
locationPathname: location.pathname,
locationQuery: location.query,
locationQuery: queryString.parse(location.search),
},
})
})
Expand Down
3 changes: 2 additions & 1 deletion src/models/post.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import modelExtend from 'dva-model-extend'
import { query } from 'services/posts'
import { pageModel } from 'models/common'
import queryString from 'query-string'

export default modelExtend(pageModel, {

Expand All @@ -13,7 +14,7 @@ export default modelExtend(pageModel, {
dispatch({ type: 'query',
payload: {
status: 2,
...location.query,
...queryString.parse(location.search),
} })
}
})
Expand Down
3 changes: 2 additions & 1 deletion src/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { config } from 'utils'
import { create, remove, update } from 'services/user'
import * as usersService from 'services/users'
import { pageModel } from './common'
import queryString from 'query-string'

const { query } = usersService
const { prefix } = config
Expand All @@ -25,7 +26,7 @@ export default modelExtend(pageModel, {
if (location.pathname === '/user') {
dispatch({
type: 'query',
payload: location.query,
payload: queryString.parse(location.search),
})
}
})
Expand Down
Loading

0 comments on commit 6d17b5b

Please sign in to comment.