mirror of
https://github.com/zuiidea/antd-admin.git
synced 2024-04-21 12:32:14 +00:00
Added lint-staged and husky to unify code style.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": ["stylelint-config-standard", "stylelint-config-prettier"],
|
||||
"rules": {
|
||||
"declaration-empty-line-before": null,
|
||||
"no-descending-specificity": null,
|
||||
"selector-pseudo-class-no-unknown": null,
|
||||
"selector-pseudo-element-colon-notation": null
|
||||
}
|
||||
}
|
||||
+18
-10
@@ -34,10 +34,7 @@
|
||||
"react-draft-wysiwyg": "^1.12.13",
|
||||
"react-helmet": "^5.2.0",
|
||||
"react-highcharts": "^16.0.2",
|
||||
"recharts": "^1.1.0",
|
||||
"stylelint": "^9.5.0",
|
||||
"stylelint-config-prettier": "^4.0.0",
|
||||
"stylelint-config-standard": "^18.2.0"
|
||||
"recharts": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-plugin-dev-expression": "^0.2.1",
|
||||
@@ -48,23 +45,34 @@
|
||||
"eslint-plugin-import": "^2.6.0",
|
||||
"eslint-plugin-jsx-a11y": "^5.1.1",
|
||||
"eslint-plugin-react": "^7.1.0",
|
||||
"husky": "^0.14.3",
|
||||
"less-vars-to-js": "^1.3.0",
|
||||
"lint-staged": "^7.2.2",
|
||||
"mockjs": "^1.0.1-beta3",
|
||||
"prettier": "^1.14.2",
|
||||
"svg-sprite-loader": "^3.9.2",
|
||||
"stylelint": "^9.5.0",
|
||||
"stylelint-config-prettier": "^4.0.0",
|
||||
"stylelint-config-standard": "^18.2.0",
|
||||
"umi": "^2.0.0",
|
||||
"umi-plugin-react": "^1.0.0"
|
||||
},
|
||||
"pre-commit": [
|
||||
"lint"
|
||||
],
|
||||
"lint-staged": {
|
||||
"**/*.{js,less}": [
|
||||
"npm run prettier",
|
||||
"git add"
|
||||
],
|
||||
"**/*.js": "npm run lint",
|
||||
"**/*.less": "stylelint --syntax less"
|
||||
},
|
||||
"scripts": {
|
||||
"analyze": "cross-env ANALYZE=1 umi build",
|
||||
"build": "umi build",
|
||||
"lint": "eslint --fix --ext .js src",
|
||||
"lint:style": "stylelint 'src/**/*.less' --syntax less",
|
||||
"lint": "eslint --ext .js src",
|
||||
"lint:style": "stylelint \"src/**/*.less\" --syntax less",
|
||||
"start": "umi dev",
|
||||
"test": "umi test",
|
||||
"prettier": "prettier --write 'src/**/*'"
|
||||
"prettier": "prettier --write 'src/**/*'",
|
||||
"precommit": "lint-staged"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import Loader from '../Loader'
|
||||
import styles from './Page.less'
|
||||
|
||||
export default class Page extends Component {
|
||||
render () {
|
||||
render() {
|
||||
const { className, children, loading = false, inner = false } = this.props
|
||||
const loadingStyle = {
|
||||
height: 'calc(100vh - 184px)',
|
||||
|
||||
@@ -5,11 +5,4 @@ import Loader from './Loader'
|
||||
import * as MyLayout from './Layout/index.js'
|
||||
import Page from './Page'
|
||||
|
||||
export {
|
||||
MyLayout,
|
||||
Editor,
|
||||
FilterItem,
|
||||
DropOption,
|
||||
Loader,
|
||||
Page,
|
||||
}
|
||||
export { MyLayout, Editor, FilterItem, DropOption, Loader, Page }
|
||||
|
||||
+6
-6
@@ -58,16 +58,16 @@ const App = ({ children, dispatch, app, loading, location }) => {
|
||||
isNavbar,
|
||||
menuPopoverVisible,
|
||||
navOpenKeys,
|
||||
switchMenuPopover () {
|
||||
switchMenuPopover() {
|
||||
dispatch({ type: 'app/switchMenuPopver' })
|
||||
},
|
||||
logout () {
|
||||
logout() {
|
||||
dispatch({ type: 'app/logout' })
|
||||
},
|
||||
switchSider () {
|
||||
switchSider() {
|
||||
dispatch({ type: 'app/switchSider' })
|
||||
},
|
||||
changeOpenKeys (openKeys) {
|
||||
changeOpenKeys(openKeys) {
|
||||
dispatch({
|
||||
type: 'app/handleNavOpenKeys',
|
||||
payload: { navOpenKeys: openKeys },
|
||||
@@ -81,10 +81,10 @@ const App = ({ children, dispatch, app, loading, location }) => {
|
||||
siderFold,
|
||||
darkTheme,
|
||||
navOpenKeys,
|
||||
changeTheme () {
|
||||
changeTheme() {
|
||||
dispatch({ type: 'app/switchTheme' })
|
||||
},
|
||||
changeOpenKeys (openKeys) {
|
||||
changeOpenKeys(openKeys) {
|
||||
window.localStorage.setItem(
|
||||
`${prefix}navOpenKeys`,
|
||||
JSON.stringify(openKeys)
|
||||
|
||||
+11
-11
@@ -37,7 +37,7 @@ export default {
|
||||
locationQuery: {},
|
||||
},
|
||||
subscriptions: {
|
||||
setupHistory ({ dispatch, history }) {
|
||||
setupHistory({ dispatch, history }) {
|
||||
history.listen(location => {
|
||||
dispatch({
|
||||
type: 'updateState',
|
||||
@@ -49,7 +49,7 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
setup ({ dispatch }) {
|
||||
setup({ dispatch }) {
|
||||
dispatch({ type: 'query' })
|
||||
let tid
|
||||
window.onresize = () => {
|
||||
@@ -61,7 +61,7 @@ export default {
|
||||
},
|
||||
},
|
||||
effects: {
|
||||
*query ({ payload }, { call, put, select }) {
|
||||
*query({ payload }, { call, put, select }) {
|
||||
const { success, user } = yield call(query, payload)
|
||||
const { locationPathname } = yield select(_ => _.app)
|
||||
if (success && user) {
|
||||
@@ -115,7 +115,7 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
*logout ({ payload }, { call, put }) {
|
||||
*logout({ payload }, { call, put }) {
|
||||
const data = yield call(logout, parse(payload))
|
||||
if (data.success) {
|
||||
yield put({
|
||||
@@ -139,7 +139,7 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
*changeNavbar (action, { put, select }) {
|
||||
*changeNavbar(action, { put, select }) {
|
||||
const { app } = yield select(_ => _)
|
||||
const isNavbar = document.body.clientWidth < 769
|
||||
if (isNavbar !== app.isNavbar) {
|
||||
@@ -148,14 +148,14 @@ export default {
|
||||
},
|
||||
},
|
||||
reducers: {
|
||||
updateState (state, { payload }) {
|
||||
updateState(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
...payload,
|
||||
}
|
||||
},
|
||||
|
||||
switchSider (state) {
|
||||
switchSider(state) {
|
||||
window.localStorage.setItem(`${prefix}siderFold`, !state.siderFold)
|
||||
return {
|
||||
...state,
|
||||
@@ -163,7 +163,7 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
switchTheme (state) {
|
||||
switchTheme(state) {
|
||||
window.localStorage.setItem(`${prefix}darkTheme`, !state.darkTheme)
|
||||
return {
|
||||
...state,
|
||||
@@ -171,21 +171,21 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
switchMenuPopver (state) {
|
||||
switchMenuPopver(state) {
|
||||
return {
|
||||
...state,
|
||||
menuPopoverVisible: !state.menuPopoverVisible,
|
||||
}
|
||||
},
|
||||
|
||||
handleNavbar (state, { payload }) {
|
||||
handleNavbar(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
isNavbar: payload,
|
||||
}
|
||||
},
|
||||
|
||||
handleNavOpenKeys (state, { payload: navOpenKeys }) {
|
||||
handleNavOpenKeys(state, { payload: navOpenKeys }) {
|
||||
return {
|
||||
...state,
|
||||
...navOpenKeys,
|
||||
|
||||
@@ -6,7 +6,7 @@ import draftToHtml from 'draftjs-to-html'
|
||||
import draftToMarkdown from 'draftjs-to-markdown'
|
||||
|
||||
export default class EditorPage extends React.Component {
|
||||
constructor (props) {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
editorContent: null,
|
||||
@@ -17,7 +17,7 @@ export default class EditorPage extends React.Component {
|
||||
editorContent,
|
||||
})
|
||||
}
|
||||
render () {
|
||||
render() {
|
||||
const { editorContent } = this.state
|
||||
const colProps = {
|
||||
lg: 12,
|
||||
|
||||
@@ -163,7 +163,7 @@ const AirportCoordComponent = () => {
|
||||
let planePath =
|
||||
'path://M1705.06,1318.313v-89.254l-319.9-221.799l0.073-208.063c0.521-84.662-26.629-121.796-63.961-121.491c-37.332-0.305-64.482,36.829-63.961,121.491l0.073,208.063l-319.9,221.799v89.254l330.343-157.288l12.238,241.308l-134.449,92.931l0.531,42.034l175.125-42.917l175.125,42.917l0.531-42.034l-134.449-92.931l12.238-241.308L1705.06,1318.313z'
|
||||
|
||||
let convertData = function (data) {
|
||||
let convertData = function(data) {
|
||||
let res = []
|
||||
for (let i = 0; i < data.length; i += 1) {
|
||||
let dataItem = data[i]
|
||||
@@ -242,7 +242,7 @@ const AirportCoordComponent = () => {
|
||||
formatter: '{b}',
|
||||
},
|
||||
},
|
||||
symbolSize (val) {
|
||||
symbolSize(val) {
|
||||
return val[2] / 8
|
||||
},
|
||||
itemStyle: {
|
||||
|
||||
@@ -85,13 +85,13 @@ const option = {
|
||||
name: '1990',
|
||||
data: currentData[0],
|
||||
type: 'scatter',
|
||||
symbolSize (data) {
|
||||
symbolSize(data) {
|
||||
return Math.sqrt(data[2]) / 5e2
|
||||
},
|
||||
label: {
|
||||
emphasis: {
|
||||
show: true,
|
||||
formatter (param) {
|
||||
formatter(param) {
|
||||
return param.data[3]
|
||||
},
|
||||
position: 'top',
|
||||
@@ -119,13 +119,13 @@ const option = {
|
||||
name: '2015',
|
||||
data: currentData[1],
|
||||
type: 'scatter',
|
||||
symbolSize (data) {
|
||||
symbolSize(data) {
|
||||
return Math.sqrt(data[2]) / 5e2
|
||||
},
|
||||
label: {
|
||||
emphasis: {
|
||||
show: true,
|
||||
formatter (param) {
|
||||
formatter(param) {
|
||||
return param.data[3]
|
||||
},
|
||||
position: 'top',
|
||||
|
||||
@@ -153,7 +153,7 @@ const CalendarComponent = () => {
|
||||
type: 'effectScatter',
|
||||
coordinateSystem: 'calendar',
|
||||
calendarIndex: 1,
|
||||
symbolSize (val) {
|
||||
symbolSize(val) {
|
||||
return val[1] / 40
|
||||
},
|
||||
data: getVirtulData(2017),
|
||||
@@ -162,7 +162,7 @@ const CalendarComponent = () => {
|
||||
type: 'scatter',
|
||||
coordinateSystem: 'calendar',
|
||||
calendarIndex: 2,
|
||||
symbolSize (val) {
|
||||
symbolSize(val) {
|
||||
return val[1] / 60
|
||||
},
|
||||
data: getVirtulData(2017),
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react'
|
||||
import ReactEcharts from 'echarts-for-react'
|
||||
|
||||
class ChartAPIComponent extends React.Component {
|
||||
render () {
|
||||
render() {
|
||||
const option = {
|
||||
title: {
|
||||
text: '漏斗图',
|
||||
|
||||
@@ -2,22 +2,22 @@ import React from 'react'
|
||||
import ReactEcharts from 'echarts-for-react'
|
||||
|
||||
class ChartShowLoadingComponent extends React.Component {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super()
|
||||
this._t = null
|
||||
this.onChartReady = this.onChartReady.bind(this)
|
||||
}
|
||||
componentWillUnmount () {
|
||||
componentWillUnmount() {
|
||||
clearTimeout(this._t)
|
||||
}
|
||||
|
||||
onChartReady (chart) {
|
||||
onChartReady(chart) {
|
||||
this._t = setTimeout(() => {
|
||||
chart.hideLoading()
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
render () {
|
||||
render() {
|
||||
const getOtion = () => {
|
||||
const option = {
|
||||
title: {
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react'
|
||||
import ReactEcharts from 'echarts-for-react'
|
||||
|
||||
class DynamicChartComponent extends React.Component {
|
||||
constructor (props) {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.timeTicket = null
|
||||
this.count = 51
|
||||
@@ -68,7 +68,7 @@ class DynamicChartComponent extends React.Component {
|
||||
{
|
||||
type: 'category',
|
||||
boundaryGap: true,
|
||||
data: (function () {
|
||||
data: (function() {
|
||||
let now = new Date()
|
||||
let res = []
|
||||
let len = 50
|
||||
@@ -82,7 +82,7 @@ class DynamicChartComponent extends React.Component {
|
||||
{
|
||||
type: 'category',
|
||||
boundaryGap: true,
|
||||
data: (function () {
|
||||
data: (function() {
|
||||
let res = []
|
||||
let len = 50
|
||||
while (len--) {
|
||||
@@ -122,13 +122,13 @@ class DynamicChartComponent extends React.Component {
|
||||
},
|
||||
},
|
||||
animationEasing: 'elasticOut',
|
||||
animationDelay (idx) {
|
||||
animationDelay(idx) {
|
||||
return idx * 10
|
||||
},
|
||||
animationDelayUpdate (idx) {
|
||||
animationDelayUpdate(idx) {
|
||||
return idx * 10
|
||||
},
|
||||
data: (function () {
|
||||
data: (function() {
|
||||
let res = []
|
||||
let len = 50
|
||||
while (len--) {
|
||||
@@ -140,7 +140,7 @@ class DynamicChartComponent extends React.Component {
|
||||
{
|
||||
name: '最新成交价',
|
||||
type: 'line',
|
||||
data: (function () {
|
||||
data: (function() {
|
||||
let res = []
|
||||
let len = 0
|
||||
while (len < 50) {
|
||||
@@ -160,7 +160,7 @@ class DynamicChartComponent extends React.Component {
|
||||
this.fetchNewDate = this.fetchNewDate.bind(this)
|
||||
}
|
||||
|
||||
fetchNewDate () {
|
||||
fetchNewDate() {
|
||||
let axisData = new Date().toLocaleTimeString().replace(/^\D*/, '')
|
||||
let { option } = this.state
|
||||
option.title.text = `Hello Echarts-for-react.${new Date().getSeconds()}`
|
||||
@@ -178,20 +178,20 @@ class DynamicChartComponent extends React.Component {
|
||||
this.setState({ option })
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
componentDidMount() {
|
||||
if (this.timeTicket) {
|
||||
clearInterval(this.timeTicket)
|
||||
}
|
||||
this.timeTicket = setInterval(this.fetchNewDate, 1000)
|
||||
}
|
||||
|
||||
componentWillUnmount () {
|
||||
componentWillUnmount() {
|
||||
if (this.timeTicket) {
|
||||
clearInterval(this.timeTicket)
|
||||
}
|
||||
}
|
||||
|
||||
render () {
|
||||
render() {
|
||||
let code =
|
||||
"<ReactEcharts ref='echartsInstance' \n" +
|
||||
' option={this.state.option} />\n'
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react'
|
||||
import ReactEcharts from 'echarts-for-react'
|
||||
|
||||
class GaugeComponent extends React.Component {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super()
|
||||
const option = {
|
||||
backgroundColor: '#1b1b1b',
|
||||
@@ -218,7 +218,7 @@ class GaugeComponent extends React.Component {
|
||||
shadowColor: '#fff', // 默认透明
|
||||
shadowBlur: 10,
|
||||
},
|
||||
formatter (v) {
|
||||
formatter(v) {
|
||||
switch (`${v}`) {
|
||||
case '0':
|
||||
return 'E'
|
||||
@@ -287,7 +287,7 @@ class GaugeComponent extends React.Component {
|
||||
shadowColor: '#fff', // 默认透明
|
||||
shadowBlur: 10,
|
||||
},
|
||||
formatter (v) {
|
||||
formatter(v) {
|
||||
switch (`${v}`) {
|
||||
case '0':
|
||||
return 'H'
|
||||
@@ -331,7 +331,7 @@ class GaugeComponent extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
componentDidMount() {
|
||||
if (this.timeTicket) {
|
||||
clearInterval(this.timeTicket)
|
||||
}
|
||||
@@ -345,13 +345,13 @@ class GaugeComponent extends React.Component {
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
componentWillUnmount () {
|
||||
componentWillUnmount() {
|
||||
if (this.timeTicket) {
|
||||
clearInterval(this.timeTicket)
|
||||
}
|
||||
}
|
||||
|
||||
render () {
|
||||
render() {
|
||||
return (
|
||||
<div className="examples">
|
||||
<div className="parent">
|
||||
|
||||
@@ -381,7 +381,7 @@ const LunarCalendarComponent = () => {
|
||||
|
||||
const option = {
|
||||
tooltip: {
|
||||
formatter (params) {
|
||||
formatter(params) {
|
||||
return `降雨量: ${params.value[1].toFixed(2)}`
|
||||
},
|
||||
},
|
||||
@@ -432,7 +432,7 @@ const LunarCalendarComponent = () => {
|
||||
label: {
|
||||
normal: {
|
||||
show: true,
|
||||
formatter (params) {
|
||||
formatter(params) {
|
||||
let d = echarts.number.parseDate(params.value[0])
|
||||
return `${d.getDate()}\n\n${params.value[2]}\n\n`
|
||||
},
|
||||
@@ -450,7 +450,7 @@ const LunarCalendarComponent = () => {
|
||||
label: {
|
||||
normal: {
|
||||
show: true,
|
||||
formatter (params) {
|
||||
formatter(params) {
|
||||
return `\n\n\n${params.value[3] || ''}`
|
||||
},
|
||||
textStyle: {
|
||||
|
||||
@@ -4,7 +4,7 @@ import ReactEcharts from 'echarts-for-react'
|
||||
require('echarts/map/js/china.js')
|
||||
|
||||
class MapChartComponent extends React.Component {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super()
|
||||
this.timeTicket = null
|
||||
const randomData = () => {
|
||||
@@ -157,7 +157,7 @@ class MapChartComponent extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
componentDidMount() {
|
||||
if (this.timeTicket) {
|
||||
clearInterval(this.timeTicket)
|
||||
}
|
||||
@@ -171,13 +171,13 @@ class MapChartComponent extends React.Component {
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
componentWillUnmount () {
|
||||
componentWillUnmount() {
|
||||
if (this.timeTicket) {
|
||||
clearInterval(this.timeTicket)
|
||||
}
|
||||
}
|
||||
|
||||
render () {
|
||||
render() {
|
||||
let code =
|
||||
"require('echarts/map/js/china.js'); \n" +
|
||||
'<ReactEcharts \n' +
|
||||
|
||||
@@ -186,7 +186,7 @@ const TreemapComponent = () => {
|
||||
},
|
||||
]
|
||||
let formatUtil = echarts.format
|
||||
function getLevelOption () {
|
||||
function getLevelOption() {
|
||||
return [
|
||||
{
|
||||
itemStyle: {
|
||||
@@ -221,7 +221,7 @@ const TreemapComponent = () => {
|
||||
},
|
||||
|
||||
tooltip: {
|
||||
formatter (info) {
|
||||
formatter(info) {
|
||||
let { value, treePathInfo } = info
|
||||
let treePath = []
|
||||
|
||||
|
||||
@@ -82,19 +82,19 @@ const chartList = [
|
||||
]
|
||||
|
||||
class Chart extends React.Component {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super()
|
||||
this.state = {
|
||||
type: '',
|
||||
}
|
||||
this.handleRadioGroupChange = this.handleRadioGroupChange.bind(this)
|
||||
}
|
||||
handleRadioGroupChange (e) {
|
||||
handleRadioGroupChange(e) {
|
||||
this.setState({
|
||||
type: e.target.value,
|
||||
})
|
||||
}
|
||||
render () {
|
||||
render() {
|
||||
return (
|
||||
<Page inner id="EChartsMain">
|
||||
<RadioGroup
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* global define */
|
||||
;(function (root, factory) {
|
||||
;(function(root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// eslint-disable-line
|
||||
// AMD. Register as an anonymous module.
|
||||
@@ -15,7 +15,7 @@
|
||||
factory({}, root.echarts)
|
||||
}
|
||||
})(this, (exports, echarts) => {
|
||||
let log = function (msg) {
|
||||
let log = function(msg) {
|
||||
if (typeof console !== 'undefined') {
|
||||
console && console.error && console.error(msg)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* global define */
|
||||
;(function (root, factory) {
|
||||
;(function(root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// eslint-disable-line
|
||||
// AMD. Register as an anonymous module.
|
||||
@@ -15,7 +15,7 @@
|
||||
factory({}, root.echarts)
|
||||
}
|
||||
})(this, (exports, echarts) => {
|
||||
let log = function (msg) {
|
||||
let log = function(msg) {
|
||||
if (typeof console !== 'undefined') {
|
||||
console && console.error && console.error(msg)
|
||||
}
|
||||
|
||||
@@ -22,19 +22,19 @@ const chartList = [
|
||||
]
|
||||
|
||||
class Chart extends React.Component {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super()
|
||||
this.state = {
|
||||
type: '',
|
||||
}
|
||||
this.handleRadioGroupChange = this.handleRadioGroupChange.bind(this)
|
||||
}
|
||||
handleRadioGroupChange (e) {
|
||||
handleRadioGroupChange(e) {
|
||||
this.setState({
|
||||
type: e.target.value,
|
||||
})
|
||||
}
|
||||
render () {
|
||||
render() {
|
||||
return (
|
||||
<Page inner>
|
||||
<RadioGroup
|
||||
|
||||
@@ -22,19 +22,19 @@ const chartList = [
|
||||
]
|
||||
|
||||
class Chart extends React.Component {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super()
|
||||
this.state = {
|
||||
type: '',
|
||||
}
|
||||
this.handleRadioGroupChange = this.handleRadioGroupChange.bind(this)
|
||||
}
|
||||
handleRadioGroupChange (e) {
|
||||
handleRadioGroupChange(e) {
|
||||
this.setState({
|
||||
type: e.target.value,
|
||||
})
|
||||
}
|
||||
render () {
|
||||
render() {
|
||||
return (
|
||||
<Page inner>
|
||||
<RadioGroup
|
||||
|
||||
@@ -19,7 +19,7 @@ const status = {
|
||||
},
|
||||
}
|
||||
|
||||
function Browser ({ data }) {
|
||||
function Browser({ data }) {
|
||||
const columns = [
|
||||
{
|
||||
title: 'name',
|
||||
|
||||
@@ -19,7 +19,7 @@ const status = {
|
||||
},
|
||||
}
|
||||
|
||||
function Comments ({ data }) {
|
||||
function Comments({ data }) {
|
||||
const columns = [
|
||||
{
|
||||
title: 'avatar',
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
} from 'recharts'
|
||||
import styles from './completed.less'
|
||||
|
||||
function Completed ({ data }) {
|
||||
function Completed({ data }) {
|
||||
return (
|
||||
<div className={styles.sales}>
|
||||
<div className={styles.title}>TEAM TOTAL COMPLETED</div>
|
||||
|
||||
@@ -20,7 +20,7 @@ const countUpProps = {
|
||||
separator: ',',
|
||||
}
|
||||
|
||||
function Cpu ({ usage, space, cpu, data }) {
|
||||
function Cpu({ usage, space, cpu, data }) {
|
||||
return (
|
||||
<div className={styles.cpu}>
|
||||
<div className={styles.number}>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Icon, Card } from 'antd'
|
||||
import CountUp from 'react-countup'
|
||||
import styles from './numberCard.less'
|
||||
|
||||
function NumberCard ({ icon, color, title, number, countUp }) {
|
||||
function NumberCard({ icon, color, title, number, countUp }) {
|
||||
return (
|
||||
<Card
|
||||
className={styles.numberCard}
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import styles from './quote.less'
|
||||
|
||||
function Quote ({ name, content, title, avatar }) {
|
||||
function Quote({ name, content, title, avatar }) {
|
||||
return (
|
||||
<div className={styles.quote}>
|
||||
<div className={styles.inner}>{content}</div>
|
||||
|
||||
@@ -24,7 +24,7 @@ const status = {
|
||||
},
|
||||
}
|
||||
|
||||
function RecentSales ({ data }) {
|
||||
function RecentSales({ data }) {
|
||||
const columns = [
|
||||
{
|
||||
title: 'NAME',
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
} from 'recharts'
|
||||
import styles from './sales.less'
|
||||
|
||||
function Sales ({ data }) {
|
||||
function Sales({ data }) {
|
||||
return (
|
||||
<div className={styles.sales}>
|
||||
<div className={styles.title}>Yearly Sales</div>
|
||||
|
||||
@@ -13,7 +13,7 @@ const countUpProps = {
|
||||
separator: ',',
|
||||
}
|
||||
|
||||
function User ({ avatar, name, email, sales, sold }) {
|
||||
function User({ avatar, name, email, sales, sold }) {
|
||||
return (
|
||||
<div className={styles.user}>
|
||||
<div className={styles.header}>
|
||||
|
||||
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
|
||||
import { Spin } from 'antd'
|
||||
import styles from './weather.less'
|
||||
|
||||
function Weather ({ city, icon, dateTime, temperature, name, loading }) {
|
||||
function Weather({ city, icon, dateTime, temperature, name, loading }) {
|
||||
return (
|
||||
<Spin spinning={loading}>
|
||||
<div className={styles.weather}>
|
||||
|
||||
@@ -25,7 +25,7 @@ const bodyStyle = {
|
||||
},
|
||||
}
|
||||
|
||||
function Dashboard ({ dashboard, loading }) {
|
||||
function Dashboard({ dashboard, loading }) {
|
||||
const {
|
||||
weather,
|
||||
sales,
|
||||
|
||||
@@ -30,7 +30,7 @@ export default modelExtend(model, {
|
||||
},
|
||||
},
|
||||
subscriptions: {
|
||||
setup ({ dispatch, history }) {
|
||||
setup({ dispatch, history }) {
|
||||
history.listen(({ pathname }) => {
|
||||
if (pathname === '/dashboard' || pathname === '/') {
|
||||
dispatch({ type: 'query' })
|
||||
@@ -40,14 +40,14 @@ export default modelExtend(model, {
|
||||
},
|
||||
},
|
||||
effects: {
|
||||
*query ({ payload }, { call, put }) {
|
||||
*query({ payload }, { call, put }) {
|
||||
const data = yield call(query, parse(payload))
|
||||
yield put({
|
||||
type: 'updateState',
|
||||
payload: data,
|
||||
})
|
||||
},
|
||||
*queryWeather ({ payload = {} }, { call, put }) {
|
||||
*queryWeather({ payload = {} }, { call, put }) {
|
||||
payload.location = 'shenzhen'
|
||||
const result = yield call(weatherService.query, payload)
|
||||
const { success } = result
|
||||
|
||||
@@ -3,7 +3,7 @@ import { request, config } from 'utils'
|
||||
const { api } = config
|
||||
const { dashboard } = api
|
||||
|
||||
export function query (params) {
|
||||
export function query(params) {
|
||||
return request({
|
||||
url: dashboard,
|
||||
method: 'get',
|
||||
|
||||
@@ -2,7 +2,7 @@ import { request, config } from 'utils'
|
||||
|
||||
const { APIV1 } = config
|
||||
|
||||
export function query (params) {
|
||||
export function query(params) {
|
||||
params.key = 'i7sau1babuzwhycn'
|
||||
return request({
|
||||
url: `${APIV1}/weather/now.json`,
|
||||
|
||||
@@ -12,7 +12,7 @@ const Login = ({
|
||||
dispatch,
|
||||
form: { getFieldDecorator, validateFieldsAndScroll },
|
||||
}) => {
|
||||
function handleOk () {
|
||||
function handleOk() {
|
||||
validateFieldsAndScroll((errors, values) => {
|
||||
if (errors) {
|
||||
return
|
||||
|
||||
@@ -7,7 +7,7 @@ export default {
|
||||
state: {},
|
||||
|
||||
effects: {
|
||||
*login ({ payload }, { put, call, select }) {
|
||||
*login({ payload }, { put, call, select }) {
|
||||
const data = yield call(login, payload)
|
||||
const { locationQuery } = yield select(_ => _.app)
|
||||
if (data.success) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { request, config } from 'utils'
|
||||
const { api } = config
|
||||
const { userLogin } = api
|
||||
|
||||
export function login (data) {
|
||||
export function login(data) {
|
||||
return request({
|
||||
url: userLogin,
|
||||
method: 'post',
|
||||
|
||||
@@ -22,7 +22,7 @@ const Index = ({ post, dispatch, loading, location }) => {
|
||||
pagination,
|
||||
dataSource: list,
|
||||
loading: loading.effects['post/query'],
|
||||
onChange (page) {
|
||||
onChange(page) {
|
||||
dispatch(
|
||||
routerRedux.push({
|
||||
pathname,
|
||||
|
||||
@@ -6,7 +6,7 @@ export default modelExtend(pageModel, {
|
||||
namespace: 'post',
|
||||
|
||||
subscriptions: {
|
||||
setup ({ dispatch, history }) {
|
||||
setup({ dispatch, history }) {
|
||||
history.listen(location => {
|
||||
if (location.pathname === '/post') {
|
||||
dispatch({
|
||||
@@ -22,7 +22,7 @@ export default modelExtend(pageModel, {
|
||||
},
|
||||
|
||||
effects: {
|
||||
*query ({ payload }, { call, put }) {
|
||||
*query({ payload }, { call, put }) {
|
||||
const data = yield call(query, payload)
|
||||
if (data.success) {
|
||||
yield put({
|
||||
|
||||
@@ -3,7 +3,7 @@ import { request, config } from 'utils'
|
||||
const { api } = config
|
||||
const { posts } = api
|
||||
|
||||
export function query (params) {
|
||||
export function query(params) {
|
||||
return request({
|
||||
url: posts,
|
||||
method: 'get',
|
||||
|
||||
@@ -48,7 +48,7 @@ const requestOptions = [
|
||||
address: '@county(true)',
|
||||
isMale: '@boolean',
|
||||
email: '@email',
|
||||
avatar () {
|
||||
avatar() {
|
||||
return Mock.Random.image(
|
||||
'100x100',
|
||||
Mock.Random.color(),
|
||||
@@ -101,7 +101,7 @@ const requestOptions = [
|
||||
]
|
||||
|
||||
export default class RequestPage extends React.Component {
|
||||
constructor (props) {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
currntRequest: requestOptions[0],
|
||||
@@ -109,7 +109,7 @@ export default class RequestPage extends React.Component {
|
||||
result: '',
|
||||
}
|
||||
}
|
||||
componentDidMount () {
|
||||
componentDidMount() {
|
||||
this.handleRequest()
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ export default class RequestPage extends React.Component {
|
||||
this.setState(state)
|
||||
}
|
||||
|
||||
render () {
|
||||
render() {
|
||||
const colProps = {
|
||||
lg: 12,
|
||||
md: 24,
|
||||
|
||||
@@ -9,7 +9,7 @@ export default {
|
||||
},
|
||||
|
||||
subscriptions: {
|
||||
setup ({ dispatch, history }) {
|
||||
setup({ dispatch, history }) {
|
||||
history.listen(({ pathname }) => {
|
||||
const match = pathToRegexp('/user/:id').exec(pathname)
|
||||
if (match) {
|
||||
@@ -20,7 +20,7 @@ export default {
|
||||
},
|
||||
|
||||
effects: {
|
||||
*query ({ payload }, { call, put }) {
|
||||
*query({ payload }, { call, put }) {
|
||||
const data = yield call(query, payload)
|
||||
const { success, message, status, ...other } = data
|
||||
if (success) {
|
||||
@@ -37,7 +37,7 @@ export default {
|
||||
},
|
||||
|
||||
reducers: {
|
||||
querySuccess (state, { payload }) {
|
||||
querySuccess(state, { payload }) {
|
||||
const { data } = payload
|
||||
return {
|
||||
...state,
|
||||
|
||||
@@ -22,7 +22,7 @@ const List = ({
|
||||
} else if (e.key === '2') {
|
||||
confirm({
|
||||
title: 'Are you sure delete this record?',
|
||||
onOk () {
|
||||
onOk() {
|
||||
onDeleteItem(record.id)
|
||||
},
|
||||
})
|
||||
|
||||
@@ -40,7 +40,7 @@ const User = ({ location, dispatch, user, loading }) => {
|
||||
confirmLoading: loading.effects[`user/${modalType}`],
|
||||
title: `${modalType === 'create' ? 'Create User' : 'Update User'}`,
|
||||
wrapClassName: 'vertical-center-modal',
|
||||
onOk (data) {
|
||||
onOk(data) {
|
||||
dispatch({
|
||||
type: `user/${modalType}`,
|
||||
payload: data,
|
||||
@@ -48,7 +48,7 @@ const User = ({ location, dispatch, user, loading }) => {
|
||||
handleRefresh()
|
||||
})
|
||||
},
|
||||
onCancel () {
|
||||
onCancel() {
|
||||
dispatch({
|
||||
type: 'user/hideModal',
|
||||
})
|
||||
@@ -61,13 +61,13 @@ const User = ({ location, dispatch, user, loading }) => {
|
||||
pagination,
|
||||
location,
|
||||
isMotion,
|
||||
onChange (page) {
|
||||
onChange(page) {
|
||||
handleRefresh({
|
||||
page: page.current,
|
||||
pageSize: page.pageSize,
|
||||
})
|
||||
},
|
||||
onDeleteItem (id) {
|
||||
onDeleteItem(id) {
|
||||
dispatch({
|
||||
type: 'user/delete',
|
||||
payload: id,
|
||||
@@ -80,7 +80,7 @@ const User = ({ location, dispatch, user, loading }) => {
|
||||
})
|
||||
})
|
||||
},
|
||||
onEditItem (item) {
|
||||
onEditItem(item) {
|
||||
dispatch({
|
||||
type: 'user/showModal',
|
||||
payload: {
|
||||
@@ -107,13 +107,13 @@ const User = ({ location, dispatch, user, loading }) => {
|
||||
filter: {
|
||||
...query,
|
||||
},
|
||||
onFilterChange (value) {
|
||||
onFilterChange(value) {
|
||||
handleRefresh({
|
||||
...value,
|
||||
page: 1,
|
||||
})
|
||||
},
|
||||
onAdd () {
|
||||
onAdd() {
|
||||
dispatch({
|
||||
type: 'user/showModal',
|
||||
payload: {
|
||||
@@ -121,7 +121,7 @@ const User = ({ location, dispatch, user, loading }) => {
|
||||
},
|
||||
})
|
||||
},
|
||||
switchIsMotion () {
|
||||
switchIsMotion() {
|
||||
dispatch({ type: 'user/switchIsMotion' })
|
||||
},
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export default modelExtend(pageModel, {
|
||||
},
|
||||
|
||||
subscriptions: {
|
||||
setup ({ dispatch, history }) {
|
||||
setup({ dispatch, history }) {
|
||||
history.listen(location => {
|
||||
if (location.pathname === '/user') {
|
||||
const payload = location.query || { page: 1, pageSize: 10 }
|
||||
@@ -34,7 +34,7 @@ export default modelExtend(pageModel, {
|
||||
},
|
||||
|
||||
effects: {
|
||||
*query ({ payload = {} }, { call, put }) {
|
||||
*query({ payload = {} }, { call, put }) {
|
||||
const data = yield call(query, payload)
|
||||
if (data) {
|
||||
yield put({
|
||||
@@ -51,7 +51,7 @@ export default modelExtend(pageModel, {
|
||||
}
|
||||
},
|
||||
|
||||
*delete ({ payload }, { call, put, select }) {
|
||||
*delete({ payload }, { call, put, select }) {
|
||||
const data = yield call(remove, { id: payload })
|
||||
const { selectedRowKeys } = yield select(_ => _.user)
|
||||
if (data.success) {
|
||||
@@ -66,7 +66,7 @@ export default modelExtend(pageModel, {
|
||||
}
|
||||
},
|
||||
|
||||
*multiDelete ({ payload }, { call, put }) {
|
||||
*multiDelete({ payload }, { call, put }) {
|
||||
const data = yield call(usersService.remove, payload)
|
||||
if (data.success) {
|
||||
yield put({ type: 'updateState', payload: { selectedRowKeys: [] } })
|
||||
@@ -75,7 +75,7 @@ export default modelExtend(pageModel, {
|
||||
}
|
||||
},
|
||||
|
||||
*create ({ payload }, { call, put }) {
|
||||
*create({ payload }, { call, put }) {
|
||||
const data = yield call(create, payload)
|
||||
if (data.success) {
|
||||
yield put({ type: 'hideModal' })
|
||||
@@ -84,7 +84,7 @@ export default modelExtend(pageModel, {
|
||||
}
|
||||
},
|
||||
|
||||
*update ({ payload }, { select, call, put }) {
|
||||
*update({ payload }, { select, call, put }) {
|
||||
const id = yield select(({ user }) => user.currentItem.id)
|
||||
const newUser = { ...payload, id }
|
||||
const data = yield call(update, newUser)
|
||||
@@ -97,15 +97,15 @@ export default modelExtend(pageModel, {
|
||||
},
|
||||
|
||||
reducers: {
|
||||
showModal (state, { payload }) {
|
||||
showModal(state, { payload }) {
|
||||
return { ...state, ...payload, modalVisible: true }
|
||||
},
|
||||
|
||||
hideModal (state) {
|
||||
hideModal(state) {
|
||||
return { ...state, modalVisible: false }
|
||||
},
|
||||
|
||||
switchIsMotion (state) {
|
||||
switchIsMotion(state) {
|
||||
window.localStorage.setItem(`${prefix}userIsMotion`, !state.isMotion)
|
||||
return { ...state, isMotion: !state.isMotion }
|
||||
},
|
||||
|
||||
@@ -3,7 +3,7 @@ import { request, config } from 'utils'
|
||||
const { api } = config
|
||||
const { user } = api
|
||||
|
||||
export function query (params) {
|
||||
export function query(params) {
|
||||
return request({
|
||||
url: user,
|
||||
method: 'get',
|
||||
@@ -11,7 +11,7 @@ export function query (params) {
|
||||
})
|
||||
}
|
||||
|
||||
export function create (params) {
|
||||
export function create(params) {
|
||||
return request({
|
||||
url: user.replace('/:id', ''),
|
||||
method: 'post',
|
||||
@@ -19,7 +19,7 @@ export function create (params) {
|
||||
})
|
||||
}
|
||||
|
||||
export function remove (params) {
|
||||
export function remove(params) {
|
||||
return request({
|
||||
url: user,
|
||||
method: 'delete',
|
||||
@@ -27,7 +27,7 @@ export function remove (params) {
|
||||
})
|
||||
}
|
||||
|
||||
export function update (params) {
|
||||
export function update(params) {
|
||||
return request({
|
||||
url: user,
|
||||
method: 'patch',
|
||||
|
||||
@@ -3,7 +3,7 @@ import { request, config } from 'utils'
|
||||
const { api } = config
|
||||
const { users } = api
|
||||
|
||||
export function query (params) {
|
||||
export function query(params) {
|
||||
return request({
|
||||
url: users,
|
||||
method: 'get',
|
||||
@@ -11,7 +11,7 @@ export function query (params) {
|
||||
})
|
||||
}
|
||||
|
||||
export function remove (params) {
|
||||
export function remove(params) {
|
||||
return request({
|
||||
url: users + '/delete',
|
||||
method: 'post',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { message } from 'antd'
|
||||
|
||||
export default {
|
||||
onError (e) {
|
||||
onError(e) {
|
||||
e.preventDefault()
|
||||
message.error(e.message)
|
||||
},
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@ import { request, config } from 'utils'
|
||||
const { api } = config
|
||||
const { user, userLogout, userLogin } = api
|
||||
|
||||
export function login (params) {
|
||||
export function login(params) {
|
||||
return request({
|
||||
url: userLogin,
|
||||
method: 'post',
|
||||
@@ -11,7 +11,7 @@ export function login (params) {
|
||||
})
|
||||
}
|
||||
|
||||
export function logout (params) {
|
||||
export function logout(params) {
|
||||
return request({
|
||||
url: userLogout,
|
||||
method: 'get',
|
||||
@@ -19,7 +19,7 @@ export function logout (params) {
|
||||
})
|
||||
}
|
||||
|
||||
export function query (params) {
|
||||
export function query(params) {
|
||||
return request({
|
||||
url: user.replace('/:id', ''),
|
||||
method: 'get',
|
||||
|
||||
@@ -3,7 +3,7 @@ import { request, config } from 'utils'
|
||||
const { api } = config
|
||||
const { menus } = api
|
||||
|
||||
export function query (params) {
|
||||
export function query(params) {
|
||||
return request({
|
||||
url: menus,
|
||||
method: 'get',
|
||||
|
||||
+1
-1
@@ -4048,7 +4048,7 @@ const tree = list => {
|
||||
return result
|
||||
}
|
||||
|
||||
let DICT_FIXED = (function () {
|
||||
let DICT_FIXED = (function() {
|
||||
let fixed = []
|
||||
for (let id in DICT) {
|
||||
if ({}.hasOwnProperty.call(DICT, id)) {
|
||||
|
||||
+3
-3
@@ -10,7 +10,7 @@ export { color } from './theme'
|
||||
* @param name {String}
|
||||
* @return {String}
|
||||
*/
|
||||
export function queryURL (name) {
|
||||
export function queryURL(name) {
|
||||
let reg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`, 'i')
|
||||
let r = window.location.search.substr(1).match(reg)
|
||||
if (r != null) return decodeURI(r[2])
|
||||
@@ -24,7 +24,7 @@ export function queryURL (name) {
|
||||
* @param {String} keyAlias
|
||||
* @return {Array}
|
||||
*/
|
||||
export function queryArray (array, key, keyAlias = 'key') {
|
||||
export function queryArray(array, key, keyAlias = 'key') {
|
||||
if (!(array instanceof Array)) {
|
||||
return null
|
||||
}
|
||||
@@ -43,7 +43,7 @@ export function queryArray (array, key, keyAlias = 'key') {
|
||||
* @param {String} children
|
||||
* @return {Array}
|
||||
*/
|
||||
export function arrayToTree (
|
||||
export function arrayToTree(
|
||||
array,
|
||||
id = 'id',
|
||||
pid = 'pid',
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ import modelExtend from 'dva-model-extend'
|
||||
|
||||
export const model = {
|
||||
reducers: {
|
||||
updateState (state, { payload }) {
|
||||
updateState(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
...payload,
|
||||
@@ -25,7 +25,7 @@ export const pageModel = modelExtend(model, {
|
||||
},
|
||||
|
||||
reducers: {
|
||||
querySuccess (state, { payload }) {
|
||||
querySuccess(state, { payload }) {
|
||||
const { list, pagination } = payload
|
||||
return {
|
||||
...state,
|
||||
|
||||
@@ -74,7 +74,7 @@ const fetch = options => {
|
||||
}
|
||||
}
|
||||
|
||||
export default function request (options) {
|
||||
export default function request(options) {
|
||||
if (options.url && options.url.indexOf('//') > -1) {
|
||||
const origin = `${options.url.split('//')[0]}//${
|
||||
options.url.split('//')[1].split('/')[0]
|
||||
|
||||
Reference in New Issue
Block a user