mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-30 13:23:49 +00:00
😪 js-standard
This commit is contained in:
@@ -1,37 +1,37 @@
|
||||
import React, {PropTypes} from 'react'
|
||||
import {Icon,Table,Tag} from 'antd'
|
||||
import React, { PropTypes } from 'react'
|
||||
import { Table, Tag } from 'antd'
|
||||
import styles from './browser.less'
|
||||
import {classnames,color} from '../../utils'
|
||||
import { color } from '../../utils'
|
||||
|
||||
const status = {
|
||||
1:{
|
||||
color:color.green
|
||||
1: {
|
||||
color: color.green
|
||||
},
|
||||
2:{
|
||||
color:color.red
|
||||
2: {
|
||||
color: color.red
|
||||
},
|
||||
3:{
|
||||
color:color.blue
|
||||
},
|
||||
4:{
|
||||
color:color.yellow
|
||||
3: {
|
||||
color: color.blue
|
||||
},
|
||||
4: {
|
||||
color: color.yellow
|
||||
}
|
||||
}
|
||||
|
||||
function Browser(props) {
|
||||
function Browser (props) {
|
||||
const columns = [
|
||||
{
|
||||
title: 'name',
|
||||
dataIndex: 'name',
|
||||
className:styles.name,
|
||||
className: styles.name
|
||||
}, {
|
||||
title: 'percent',
|
||||
dataIndex: 'percent',
|
||||
className:styles.percent,
|
||||
render:(text,it) => <Tag color={status[it.status].color}>{text}%</Tag>,
|
||||
},
|
||||
className: styles.percent,
|
||||
render: (text, it) => <Tag color={status[it.status].color}>{text}%</Tag>
|
||||
}
|
||||
]
|
||||
return <Table pagination={false} showHeader={false} columns={columns} key={(record,key)=>key} dataSource={props.data}/>
|
||||
return <Table pagination={false} showHeader={false} columns={columns} key={(record, key) => key} dataSource={props.data} />
|
||||
}
|
||||
|
||||
Browser.propTypes = {
|
||||
|
||||
@@ -1,48 +1,47 @@
|
||||
import React, {PropTypes} from 'react'
|
||||
import {Icon,Table,Tag} from 'antd'
|
||||
import React from 'react'
|
||||
import { Table, Tag } from 'antd'
|
||||
import styles from './comments.less'
|
||||
import {classnames,color} from '../../utils'
|
||||
|
||||
import { color } from '../../utils'
|
||||
|
||||
const status = {
|
||||
1:{
|
||||
color:color.green,
|
||||
text:'APPROVED'
|
||||
1: {
|
||||
color: color.green,
|
||||
text: 'APPROVED'
|
||||
},
|
||||
2:{
|
||||
color:color.yellow,
|
||||
text:'PENDING'
|
||||
},
|
||||
3:{
|
||||
color:color.red,
|
||||
text:'REJECTED'
|
||||
2: {
|
||||
color: color.yellow,
|
||||
text: 'PENDING'
|
||||
},
|
||||
3: {
|
||||
color: color.red,
|
||||
text: 'REJECTED'
|
||||
}
|
||||
}
|
||||
|
||||
function Comments(props) {
|
||||
function Comments (props) {
|
||||
const columns = [
|
||||
{
|
||||
title: 'avatar',
|
||||
dataIndex: 'avatar',
|
||||
width:48,
|
||||
className:styles.avatarcolumn,
|
||||
render: text => <span style={{backgroundImage:`url(${text})`}} className={styles.avatar} ></span>,
|
||||
width: 48,
|
||||
className: styles.avatarcolumn,
|
||||
render: text => <span style={{backgroundImage: `url(${text})`}} className={styles.avatar} />
|
||||
}, {
|
||||
title: 'content',
|
||||
dataIndex: 'content',
|
||||
render:(text,it) => <div>
|
||||
render: (text, it) => <div>
|
||||
<h5 className={styles.name}>{it.name}</h5>
|
||||
<p className={styles.content}>{it.content}</p>
|
||||
<div className={styles.daterow}>
|
||||
<Tag color={status[it.status].color}>{status[it.status].text}</Tag>
|
||||
<span className={styles.date}>{it.date}</span>
|
||||
</div>
|
||||
</div>,
|
||||
},
|
||||
</div>
|
||||
}
|
||||
]
|
||||
return (
|
||||
<div className={styles.comments}>
|
||||
<Table pagination={false} showHeader={false} columns={columns} key={(record,key)=>key} dataSource={props.data.filter((item,key) => key<3)}/>
|
||||
<Table pagination={false} showHeader={false} columns={columns} key={(record, key) => key} dataSource={props.data.filter((item, key) => key < 3)} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,35 +1,34 @@
|
||||
import React, { PropTypes } from 'react'
|
||||
import { Icon } from 'antd'
|
||||
import React from 'react'
|
||||
import styles from './completed.less'
|
||||
import {color} from '../../utils'
|
||||
import {AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer} from 'recharts'
|
||||
|
||||
function Completed(props) {
|
||||
function Completed (props) {
|
||||
return (
|
||||
<div className={styles.sales}>
|
||||
<div className={styles.title}>TEAM TOTAL COMPLETED</div>
|
||||
<ResponsiveContainer minHeight={360}>
|
||||
<AreaChart data={props.data}>
|
||||
<Legend verticalAlign="top"
|
||||
content={props => {
|
||||
const { payload } = props
|
||||
return <ul className={styles.legend+' clearfix'}>
|
||||
{payload.map((item,key) => <li key={key}><span className={styles.radiusdot} style={{background:item.color}}></span>{item.value}</li>) }
|
||||
</ul>
|
||||
}}/>
|
||||
<XAxis dataKey="name" axisLine={{stroke:color.borderBase,strokeWidth:1}} tickLine={false}/>
|
||||
<YAxis axisLine={false} tickLine={false} />
|
||||
<CartesianGrid vertical={false} stroke={color.borderBase} strokeDasharray="3 3" />
|
||||
<Tooltip
|
||||
wrapperStyle={{border:'none',boxShadow:'4px 4px 40px rgba(0, 0, 0, 0.05)'}}
|
||||
content={content => {
|
||||
const list = content.payload.map((item,key) => <li key={key} className={styles.tipitem}><span className={styles.radiusdot} style={{background:item.color}}></span>{item.name+':'+item.value}</li>)
|
||||
return <div className={styles.tooltip}><p className={styles.tiptitle}>{content.label}</p><ul>{list}</ul></div>
|
||||
}}/>
|
||||
<Area type="monotone" dataKey="Task complete" stroke={color.grass} fill={color.grass} strokeWidth={2} dot={{fill:'#fff'}} activeDot={{r: 5,fill:'#fff',stroke:color.green}}/>
|
||||
<Area type="monotone" dataKey="Cards Complete" stroke={color.sky} fill={color.sky} strokeWidth={2} dot={{fill:'#fff'}} activeDot={{r: 5,fill:'#fff',stroke:color.blue}}/>
|
||||
</AreaChart>
|
||||
</ResponsiveContainer>
|
||||
<AreaChart data={props.data}>
|
||||
<Legend verticalAlign='top'
|
||||
content={props => {
|
||||
const { payload } = props
|
||||
return <ul className={styles.legend + ' clearfix'}>
|
||||
{payload.map((item, key) => <li key={key}><span className={styles.radiusdot} style={{background: item.color}} />{item.value}</li>) }
|
||||
</ul>
|
||||
}} />
|
||||
<XAxis dataKey='name' axisLine={{stroke: color.borderBase, strokeWidth: 1}} tickLine={false} />
|
||||
<YAxis axisLine={false} tickLine={false} />
|
||||
<CartesianGrid vertical={false} stroke={color.borderBase} strokeDasharray='3 3' />
|
||||
<Tooltip
|
||||
wrapperStyle={{border: 'none', boxShadow: '4px 4px 40px rgba(0, 0, 0, 0.05)'}}
|
||||
content={content => {
|
||||
const list = content.payload.map((item, key) => <li key={key} className={styles.tipitem}><span className={styles.radiusdot} style={{background: item.color}} />{item.name + ':' + item.value}</li>)
|
||||
return <div className={styles.tooltip}><p className={styles.tiptitle}>{content.label}</p><ul>{list}</ul></div>
|
||||
}} />
|
||||
<Area type='monotone' dataKey='Task complete' stroke={color.grass} fill={color.grass} strokeWidth={2} dot={{fill: '#fff'}} activeDot={{r: 5, fill: '#fff', stroke: color.green}} />
|
||||
<Area type='monotone' dataKey='Cards Complete' stroke={color.sky} fill={color.sky} strokeWidth={2} dot={{fill: '#fff'}} activeDot={{r: 5, fill: '#fff', stroke: color.blue}} />
|
||||
</AreaChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,53 +1,53 @@
|
||||
import React, {PropTypes} from 'react'
|
||||
import React, { PropTypes } from 'react'
|
||||
import styles from './cpu.less'
|
||||
import {classnames,color} from '../../utils'
|
||||
import { color } from '../../utils'
|
||||
import CountUp from 'react-countup'
|
||||
import {LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer} from 'recharts'
|
||||
import { LineChart, Line, XAxis, YAxis, CartesianGrid, ResponsiveContainer } from 'recharts'
|
||||
|
||||
const countUpProps = {
|
||||
start:0,
|
||||
duration:2.75,
|
||||
useEasing:true,
|
||||
useGrouping:true,
|
||||
separator:','
|
||||
start: 0,
|
||||
duration: 2.75,
|
||||
useEasing: true,
|
||||
useGrouping: true,
|
||||
separator: ','
|
||||
}
|
||||
|
||||
function Cpu(props) {
|
||||
function Cpu (props) {
|
||||
return <div className={styles.cpu}>
|
||||
<div className={styles.number}>
|
||||
<div className={styles.item}>
|
||||
<p>usage</p>
|
||||
<p><CountUp
|
||||
end={props.usage}
|
||||
suffix="GB"
|
||||
{...countUpProps}
|
||||
end={props.usage}
|
||||
suffix='GB'
|
||||
{...countUpProps}
|
||||
/></p>
|
||||
</div>
|
||||
<div className={styles.item}>
|
||||
<p>space</p>
|
||||
<p><CountUp
|
||||
end={props.space}
|
||||
suffix="GB"
|
||||
{...countUpProps}
|
||||
end={props.space}
|
||||
suffix='GB'
|
||||
{...countUpProps}
|
||||
/></p>
|
||||
</div>
|
||||
<div className={styles.item}>
|
||||
<p>cpu</p>
|
||||
<p><CountUp
|
||||
end={props.cpu}
|
||||
suffix="%"
|
||||
{...countUpProps}
|
||||
end={props.cpu}
|
||||
suffix='%'
|
||||
{...countUpProps}
|
||||
/></p>
|
||||
</div>
|
||||
</div>
|
||||
<ResponsiveContainer minHeight={300}>
|
||||
<LineChart data={props.data} margin={{left: -40}}>
|
||||
<XAxis dataKey="name" axisLine={{stroke:color.borderBase,strokeWidth:1}} tickLine={false}/>
|
||||
<XAxis dataKey='name' axisLine={{stroke: color.borderBase, strokeWidth: 1}} tickLine={false} />
|
||||
<YAxis axisLine={false} tickLine={false} />
|
||||
<CartesianGrid vertical={false} stroke={color.borderBase} strokeDasharray="3 3" />
|
||||
<Line type="monotone" connectNulls={true} dataKey="cpu" stroke={color.blue} fill={color.blue} />
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
<CartesianGrid vertical={false} stroke={color.borderBase} strokeDasharray='3 3' />
|
||||
<Line type='monotone' connectNulls dataKey='cpu' stroke={color.blue} fill={color.blue} />
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import React, { PropTypes } from 'react'
|
||||
import React from 'react'
|
||||
import { Icon, Card } from 'antd'
|
||||
import CountUp from 'react-countup'
|
||||
import styles from './numberCard.less'
|
||||
|
||||
function NumberCard(props) {
|
||||
function NumberCard (props) {
|
||||
const { icon, color, title, number } = props
|
||||
return (
|
||||
<Card className={styles.numberCard} bordered={false} bodyStyle={{padding:0}}>
|
||||
<Card className={styles.numberCard} bordered={false} bodyStyle={{padding: 0}}>
|
||||
<Icon className={styles.iconWarp} style={{ color }} type={icon} />
|
||||
<div className={styles.content}>
|
||||
<p className={styles.title}>{title || 'No Title'}</p>
|
||||
@@ -15,10 +15,10 @@ function NumberCard(props) {
|
||||
start={0}
|
||||
end={number}
|
||||
duration={2.75}
|
||||
useEasing={true}
|
||||
useGrouping={true}
|
||||
separator=","
|
||||
{...props.countUp||{}}
|
||||
useEasing
|
||||
useGrouping
|
||||
separator=','
|
||||
{...props.countUp || {}}
|
||||
/>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import React, { PropTypes } from 'react'
|
||||
import { Icon } from 'antd'
|
||||
import React from 'react'
|
||||
import styles from './quote.less'
|
||||
import {classnames} from '../../utils'
|
||||
|
||||
function Quote(props) {
|
||||
function Quote (props) {
|
||||
const { name, content, title, avatar } = props
|
||||
return (
|
||||
<div className={styles.quote}>
|
||||
@@ -15,7 +13,7 @@ function Quote(props) {
|
||||
<p>-{name}-</p>
|
||||
<p>{title}</p>
|
||||
</div>
|
||||
<div className={styles.avatar} style={{backgroundImage:`url(${avatar})`}}></div>
|
||||
<div className={styles.avatar} style={{backgroundImage: `url(${avatar})`}} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,50 +1,49 @@
|
||||
import React, {PropTypes} from 'react'
|
||||
import {Icon,Table,Tag} from 'antd'
|
||||
import React from 'react'
|
||||
import { Table, Tag } from 'antd'
|
||||
import styles from './recentSales.less'
|
||||
import {classnames,color} from '../../utils'
|
||||
|
||||
import { color } from '../../utils'
|
||||
|
||||
const status = {
|
||||
1:{
|
||||
color:color.green,
|
||||
text:'SALE'
|
||||
1: {
|
||||
color: color.green,
|
||||
text: 'SALE'
|
||||
},
|
||||
2:{
|
||||
color:color.yellow,
|
||||
text:'REJECT'
|
||||
2: {
|
||||
color: color.yellow,
|
||||
text: 'REJECT'
|
||||
},
|
||||
3:{
|
||||
color:color.red,
|
||||
text:'TAX'
|
||||
3: {
|
||||
color: color.red,
|
||||
text: 'TAX'
|
||||
},
|
||||
4:{
|
||||
color:color.blue,
|
||||
text:'EXTENDED'
|
||||
4: {
|
||||
color: color.blue,
|
||||
text: 'EXTENDED'
|
||||
}
|
||||
}
|
||||
|
||||
function RecentSales(props) {
|
||||
function RecentSales (props) {
|
||||
const columns = [
|
||||
{
|
||||
title: 'NAME',
|
||||
dataIndex: 'name',
|
||||
dataIndex: 'name'
|
||||
}, {
|
||||
title: 'STATUS',
|
||||
dataIndex: 'status',
|
||||
render:text => <Tag color={status[text].color}>{status[text].text}</Tag>,
|
||||
render: text => <Tag color={status[text].color}>{status[text].text}</Tag>
|
||||
}, {
|
||||
title: 'DATE',
|
||||
dataIndex: 'date',
|
||||
render:text => new Date(text).format('yyyy-MM-dd'),
|
||||
render: text => new Date(text).format('yyyy-MM-dd')
|
||||
}, {
|
||||
title: 'PRICE',
|
||||
dataIndex: 'price',
|
||||
render:(text,it) => <span style={{color:status[it.status].color}}>${text}</span>,
|
||||
render: (text, it) => <span style={{color: status[it.status].color}}>${text}</span>
|
||||
}
|
||||
]
|
||||
return (
|
||||
<div className={styles.recentsales}>
|
||||
<Table pagination={false} columns={columns} key={(record,key)=>key} dataSource={props.data.filter((item,key) => key<5)}/>
|
||||
<Table pagination={false} columns={columns} key={(record, key) => key} dataSource={props.data.filter((item, key) => key < 5)} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,36 +1,35 @@
|
||||
import React, { PropTypes } from 'react'
|
||||
import { Icon } from 'antd'
|
||||
import React from 'react'
|
||||
import styles from './sales.less'
|
||||
import {color} from '../../utils'
|
||||
import {LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer} from 'recharts'
|
||||
|
||||
function Sales(props) {
|
||||
function Sales (props) {
|
||||
return (
|
||||
<div className={styles.sales}>
|
||||
<div className={styles.title}>Yearly Sales</div>
|
||||
<ResponsiveContainer minHeight={360}>
|
||||
<LineChart data={props.data}>
|
||||
<Legend verticalAlign="top"
|
||||
content={props => {
|
||||
const { payload } = props
|
||||
return <ul className={styles.legend+' clearfix'}>
|
||||
{payload.map((item,key) => <li key={key}><span className={styles.radiusdot} style={{background:item.color}}></span>{item.value}</li>) }
|
||||
</ul>
|
||||
}}/>
|
||||
<XAxis dataKey="name" axisLine={{stroke:color.borderBase,strokeWidth:1}} tickLine={false}/>
|
||||
<YAxis axisLine={false} tickLine={false} />
|
||||
<CartesianGrid vertical={false} stroke={color.borderBase} strokeDasharray="3 3" />
|
||||
<Tooltip
|
||||
wrapperStyle={{border:'none',boxShadow:'4px 4px 40px rgba(0, 0, 0, 0.05)'}}
|
||||
content={content => {
|
||||
const list = content.payload.map((item,key) => <li key={key} className={styles.tipitem}><span className={styles.radiusdot} style={{background:item.color}}></span>{item.name+':'+item.value}</li>)
|
||||
return <div className={styles.tooltip}><p className={styles.tiptitle}>{content.label}</p><ul>{list}</ul></div>
|
||||
}}/>
|
||||
<Line type="monotone" dataKey="Food" stroke={color.purple} strokeWidth={3} dot={{fill:color.purple}} activeDot={{r: 5,strokeWidth:0}}/>
|
||||
<Line type="monotone" dataKey="Clothes" stroke={color.red} strokeWidth={3} dot={{fill:color.red}} activeDot={{r: 5,strokeWidth:0}}/>
|
||||
<Line type="monotone" dataKey="Electronics" stroke={color.green} strokeWidth={3} dot={{fill:color.green}} activeDot={{r: 5,strokeWidth:0}}/>
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
<LineChart data={props.data}>
|
||||
<Legend verticalAlign='top'
|
||||
content={props => {
|
||||
const { payload } = props
|
||||
return <ul className={styles.legend + ' clearfix'}>
|
||||
{payload.map((item, key) => <li key={key}><span className={styles.radiusdot} style={{background: item.color}} />{item.value}</li>) }
|
||||
</ul>
|
||||
}} />
|
||||
<XAxis dataKey='name' axisLine={{stroke: color.borderBase, strokeWidth: 1}} tickLine={false} />
|
||||
<YAxis axisLine={false} tickLine={false} />
|
||||
<CartesianGrid vertical={false} stroke={color.borderBase} strokeDasharray='3 3' />
|
||||
<Tooltip
|
||||
wrapperStyle={{border: 'none', boxShadow: '4px 4px 40px rgba(0, 0, 0, 0.05)'}}
|
||||
content={content => {
|
||||
const list = content.payload.map((item, key) => <li key={key} className={styles.tipitem}><span className={styles.radiusdot} style={{background: item.color}} />{item.name + ':' + item.value}</li>)
|
||||
return <div className={styles.tooltip}><p className={styles.tiptitle}>{content.label}</p><ul>{list}</ul></div>
|
||||
}} />
|
||||
<Line type='monotone' dataKey='Food' stroke={color.purple} strokeWidth={3} dot={{fill: color.purple}} activeDot={{r: 5, strokeWidth: 0}} />
|
||||
<Line type='monotone' dataKey='Clothes' stroke={color.red} strokeWidth={3} dot={{fill: color.red}} activeDot={{r: 5, strokeWidth: 0}} />
|
||||
<Line type='monotone' dataKey='Electronics' stroke={color.green} strokeWidth={3} dot={{fill: color.green}} activeDot={{r: 5, strokeWidth: 0}} />
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
import React, {PropTypes} from 'react'
|
||||
import {Button} from 'antd'
|
||||
import React, { PropTypes } from 'react'
|
||||
import { Button } from 'antd'
|
||||
import styles from './user.less'
|
||||
import CountUp from 'react-countup'
|
||||
import {classnames,color} from '../../utils'
|
||||
import { color } from '../../utils'
|
||||
const countUpProps = {
|
||||
start:0,
|
||||
duration:2.75,
|
||||
useEasing:true,
|
||||
useGrouping:true,
|
||||
separator:','
|
||||
start: 0,
|
||||
duration: 2.75,
|
||||
useEasing: true,
|
||||
useGrouping: true,
|
||||
separator: ','
|
||||
}
|
||||
|
||||
function User(props) {
|
||||
const {avatar,name,email}=props
|
||||
function User (props) {
|
||||
const {avatar, name, email} = props
|
||||
return <div className={styles.user}>
|
||||
<div className={styles.header}>
|
||||
<div className={styles.headerinner}>
|
||||
<div className={styles.avatar} style={{backgroundImage:`url(${avatar})`}}></div>
|
||||
<div className={styles.avatar} style={{backgroundImage: `url(${avatar})`}} />
|
||||
<h5 className={styles.name}>{name}</h5>
|
||||
<p>{email}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.number}>
|
||||
<div className={styles.item}>
|
||||
<p>EARNING SALES</p>
|
||||
<p style={{color:color.green}}><CountUp
|
||||
end={props.sales}
|
||||
prefix="$"
|
||||
{...countUpProps}
|
||||
<div className={styles.item}>
|
||||
<p>EARNING SALES</p>
|
||||
<p style={{color: color.green}}><CountUp
|
||||
end={props.sales}
|
||||
prefix='$'
|
||||
{...countUpProps}
|
||||
/></p>
|
||||
</div>
|
||||
<div className={styles.item}>
|
||||
<p>ITEM SOLD</p>
|
||||
<p style={{color:color.blue}}><CountUp
|
||||
end={props.sold}
|
||||
{...countUpProps}
|
||||
</div>
|
||||
<div className={styles.item}>
|
||||
<p>ITEM SOLD</p>
|
||||
<p style={{color: color.blue}}><CountUp
|
||||
end={props.sold}
|
||||
{...countUpProps}
|
||||
/></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.footer}>
|
||||
<Button type="ghost" size="large">View Profile</Button>
|
||||
<Button type='ghost' size='large'>View Profile</Button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import React, {PropTypes} from 'react'
|
||||
import {Icon} from 'antd'
|
||||
import React from 'react'
|
||||
import styles from './weather.less'
|
||||
|
||||
function Weather(props) {
|
||||
function Weather (props) {
|
||||
const {city, icon, dateTime, temperature, name} = props
|
||||
return <div className={styles.weather}>
|
||||
<div className={styles.left}>
|
||||
<div className={styles.icon} style={{
|
||||
backgroundImage: `url(${icon})`
|
||||
}}></div>
|
||||
}} />
|
||||
<p>{name}</p>
|
||||
</div>
|
||||
<div className={styles.right}>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { PropTypes } from 'react'
|
||||
import { Breadcrumb, Icon } from 'antd'
|
||||
import styles from './main.less'
|
||||
import { config, menu } from '../../utils'
|
||||
import { menu } from '../../utils'
|
||||
|
||||
let pathSet = []
|
||||
const getPathSet = function (menuArray, parentPath) {
|
||||
@@ -11,16 +11,16 @@ const getPathSet = function (menuArray, parentPath) {
|
||||
path: parentPath + item.key,
|
||||
name: item.name,
|
||||
icon: item.icon || '',
|
||||
clickable:item.clickable==undefined?true:false
|
||||
clickable: item.clickable === undefined
|
||||
}
|
||||
if (!!item.child) {
|
||||
if (item.child) {
|
||||
getPathSet(item.child, parentPath + item.key + '/')
|
||||
}
|
||||
})
|
||||
}
|
||||
getPathSet(menu)
|
||||
|
||||
function Bread({ location }) {
|
||||
function Bread ({ location }) {
|
||||
let pathNames = []
|
||||
location.pathname.substr(1).split('/').map((item, key) => {
|
||||
if (key > 0) {
|
||||
@@ -30,11 +30,11 @@ function Bread({ location }) {
|
||||
}
|
||||
})
|
||||
const breads = pathNames.map((item, key) => {
|
||||
if(!(item in pathSet)){
|
||||
item='Dashboard'
|
||||
if (!(item in pathSet)) {
|
||||
item = 'Dashboard'
|
||||
}
|
||||
return (
|
||||
<Breadcrumb.Item key={key} {...((pathNames.length - 1 == key)||!pathSet[item].clickable)? '' : { href: '#' + pathSet[item].path }}>
|
||||
<Breadcrumb.Item key={key} {...((pathNames.length - 1 === key) || !pathSet[item].clickable) ? '' : { href: '#' + pathSet[item].path }}>
|
||||
{pathSet[item].icon
|
||||
? <Icon type={pathSet[item].icon} />
|
||||
: ''}
|
||||
@@ -46,7 +46,7 @@ function Bread({ location }) {
|
||||
return (
|
||||
<div className={styles.bread}>
|
||||
<Breadcrumb>
|
||||
<Breadcrumb.Item href="#/"><Icon type="home" />
|
||||
<Breadcrumb.Item href='#/'><Icon type='home' />
|
||||
<span>主页</span>
|
||||
</Breadcrumb.Item>
|
||||
{breads}
|
||||
@@ -56,7 +56,7 @@ function Bread({ location }) {
|
||||
}
|
||||
|
||||
Bread.propTypes = {
|
||||
location: PropTypes.object,
|
||||
location: PropTypes.object
|
||||
}
|
||||
|
||||
export default Bread
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { PropTypes } from 'react'
|
||||
import React from 'react'
|
||||
import styles from './main.less'
|
||||
import { config } from '../../utils'
|
||||
|
||||
@@ -1,37 +1,36 @@
|
||||
import React, {PropTypes} from 'react'
|
||||
import {Menu, Icon, Popover} from 'antd'
|
||||
import {Link} from 'dva/router'
|
||||
import React from 'react'
|
||||
import { Menu, Icon, Popover } from 'antd'
|
||||
import styles from './main.less'
|
||||
import Menus from './menu'
|
||||
|
||||
const SubMenu = Menu.SubMenu
|
||||
|
||||
function Header({user, logout, switchSider, siderFold, isNavbar ,location}) {
|
||||
function Header ({user, logout, switchSider, siderFold, isNavbar, location}) {
|
||||
let handleClickMenu = e => e.key === 'logout' && logout()
|
||||
const menusProps = {
|
||||
siderFold:false,
|
||||
darkTheme:false,
|
||||
siderFold: false,
|
||||
darkTheme: false,
|
||||
isNavbar,
|
||||
location
|
||||
}
|
||||
return (
|
||||
<div className={styles.header}>
|
||||
{isNavbar
|
||||
? <Popover placement="bottomLeft" overlayClassName={styles.popovermenu} trigger="click" content={<Menus {...menusProps}/>}>
|
||||
? <Popover placement='bottomLeft' overlayClassName={styles.popovermenu} trigger='click' content={<Menus {...menusProps} />}>
|
||||
<div className={styles.siderbutton}>
|
||||
<Icon type="bars"/>
|
||||
<Icon type='bars' />
|
||||
</div>
|
||||
</Popover>
|
||||
: <div className={styles.siderbutton} onClick={switchSider}>
|
||||
<Icon type={siderFold? 'menu-unfold': 'menu-fold'}/>
|
||||
<Icon type={siderFold ? 'menu-unfold' : 'menu-fold'} />
|
||||
</div>}
|
||||
|
||||
<Menu className="header-menu" mode="horizontal" onClick={handleClickMenu}>
|
||||
<Menu className='header-menu' mode='horizontal' onClick={handleClickMenu}>
|
||||
<SubMenu style={{
|
||||
float: 'right'
|
||||
}} title={< span > <Icon type="user"/>
|
||||
}} title={< span > <Icon type='user' />
|
||||
{user.name} < /span>}>
|
||||
<Menu.Item key="logout">
|
||||
<Menu.Item key='logout'>
|
||||
<a>注销</a>
|
||||
</Menu.Item>
|
||||
</SubMenu>
|
||||
@@ -1,18 +1,16 @@
|
||||
import React, { PropTypes } from 'react'
|
||||
import React from 'react'
|
||||
import { Menu, Icon } from 'antd'
|
||||
import { Link } from 'dva/router'
|
||||
import styles from './main.less'
|
||||
import { menu } from '../../utils'
|
||||
|
||||
|
||||
const topMenus = menu.map( item => item.key)
|
||||
const getMenus = function (menuArray,siderFold,parentPath) {
|
||||
const topMenus = menu.map(item => item.key)
|
||||
const getMenus = function (menuArray, siderFold, parentPath) {
|
||||
parentPath = parentPath || '/'
|
||||
return menuArray.map(item => {
|
||||
if (!!item.child) {
|
||||
if (item.child) {
|
||||
return (
|
||||
<Menu.SubMenu key={item.key} title={<span>{item.icon ? <Icon type={item.icon} /> : ''}{siderFold&&topMenus.indexOf(item.key)>=0 ? '' : item.name}</span>}>
|
||||
{getMenus(item.child,siderFold,parentPath + item.key + '/')}
|
||||
<Menu.SubMenu key={item.key} title={<span>{item.icon ? <Icon type={item.icon} /> : ''}{siderFold && topMenus.indexOf(item.key) >= 0 ? '' : item.name}</span>}>
|
||||
{getMenus(item.child, siderFold, parentPath + item.key + '/')}
|
||||
</Menu.SubMenu>
|
||||
)
|
||||
} else {
|
||||
@@ -20,7 +18,7 @@ const getMenus = function (menuArray,siderFold,parentPath) {
|
||||
<Menu.Item key={item.key}>
|
||||
<Link to={parentPath + item.key}>
|
||||
{item.icon ? <Icon type={item.icon} /> : ''}
|
||||
{siderFold&&topMenus.indexOf(item.key)>=0 ? '' : item.name}
|
||||
{siderFold && topMenus.indexOf(item.key) >= 0 ? '' : item.name}
|
||||
</Link>
|
||||
</Menu.Item>
|
||||
)
|
||||
@@ -28,16 +26,16 @@ const getMenus = function (menuArray,siderFold,parentPath) {
|
||||
})
|
||||
}
|
||||
|
||||
function Menus({ siderFold,darkTheme,location,isNavbar }) {
|
||||
const menuItems = getMenus(menu,siderFold)
|
||||
function Menus ({ siderFold, darkTheme, location, isNavbar }) {
|
||||
const menuItems = getMenus(menu, siderFold)
|
||||
return (
|
||||
<Menu
|
||||
mode={siderFold?"vertical":"inline"}
|
||||
theme={darkTheme?"dark":"light"}
|
||||
defaultOpenKeys={isNavbar?menuItems.map(item => item.key):[]}
|
||||
defaultSelectedKeys={[location.pathname.split('/')[location.pathname.split('/').length - 1]||'dashboard']}>
|
||||
{menuItems}
|
||||
</Menu>
|
||||
<Menu
|
||||
mode={siderFold ? 'vertical' : 'inline'}
|
||||
theme={darkTheme ? 'dark' : 'light'}
|
||||
defaultOpenKeys={isNavbar ? menuItems.map(item => item.key) : []}
|
||||
defaultSelectedKeys={[location.pathname.split('/')[location.pathname.split('/').length - 1] || 'dashboard']}>
|
||||
{menuItems}
|
||||
</Menu>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import React from 'react'
|
||||
import { Icon, Switch } from 'antd'
|
||||
import styles from './main.less'
|
||||
import { config } from '../../utils'
|
||||
import Menus from './menu'
|
||||
|
||||
function Sider ({ siderFold, darkTheme, location, changeTheme }) {
|
||||
const menusProps = {
|
||||
siderFold,
|
||||
darkTheme,
|
||||
location
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.logo}>
|
||||
<img src={config.logoSrc} />
|
||||
{siderFold ? '' : <span>{config.logoText}</span>}
|
||||
</div>
|
||||
<Menus {...menusProps} />
|
||||
{!siderFold ? <div className={styles.switchtheme}>
|
||||
<span><Icon type='bulb' />切换主题</span>
|
||||
<Switch onChange={changeTheme} defaultChecked={darkTheme} checkedChildren='黑' unCheckedChildren='白' />
|
||||
</div> : ''}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Sider
|
||||
@@ -1,29 +0,0 @@
|
||||
import React, { PropTypes } from 'react'
|
||||
import { Menu, Icon, Switch } from 'antd'
|
||||
import { Link } from 'dva/router'
|
||||
import styles from './main.less'
|
||||
import { config } from '../../utils'
|
||||
import Menus from './menu'
|
||||
|
||||
function Sider({ siderFold,darkTheme,location,changeTheme }) {
|
||||
const menusProps={
|
||||
siderFold,
|
||||
darkTheme,
|
||||
location
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.logo}>
|
||||
<img src={config.logoSrc} />
|
||||
{siderFold?'':<span>{config.logoText}</span>}
|
||||
</div>
|
||||
<Menus {...menusProps}/>
|
||||
{!siderFold?<div className={styles.switchtheme}>
|
||||
<span><Icon type="bulb" />切换主题</span>
|
||||
<Switch onChange={changeTheme} defaultChecked={darkTheme} checkedChildren="黑" unCheckedChildren="白" />
|
||||
</div>:''}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Sider
|
||||
@@ -1,8 +1,7 @@
|
||||
import React, {PropTypes} from 'react'
|
||||
import styles from './ico.less'
|
||||
import React from 'react'
|
||||
|
||||
const Ico = ({type}) => <span dangerouslySetInnerHTML={{
|
||||
__html: `<svg class="ico" aria-hidden="true"><use xlink:href="#anticon-${type}"></use></svg>`
|
||||
}}/>
|
||||
}} />
|
||||
|
||||
export default Ico
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import React, { PropTypes } from 'react'
|
||||
import { Table, Popconfirm, Pagination } from 'antd'
|
||||
import { Table, Popconfirm } from 'antd'
|
||||
import styles from './list.less'
|
||||
|
||||
function list({
|
||||
function list ({
|
||||
loading,
|
||||
dataSource,
|
||||
pagination,
|
||||
onPageChange,
|
||||
onDeleteItem,
|
||||
onEditItem,
|
||||
onEditItem
|
||||
}) {
|
||||
const columns = [
|
||||
{
|
||||
@@ -17,43 +17,43 @@ function list({
|
||||
key: 'avatar',
|
||||
width: 64,
|
||||
className: styles.avatar,
|
||||
render: (text) => <img width={24} src={text} />,
|
||||
render: (text) => <img width={24} src={text} />
|
||||
}, {
|
||||
title: '姓名',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
key: 'name'
|
||||
}, {
|
||||
title: '昵称',
|
||||
dataIndex: 'nickName',
|
||||
key: 'nickName',
|
||||
key: 'nickName'
|
||||
}, {
|
||||
title: '年龄',
|
||||
dataIndex: 'age',
|
||||
key: 'age',
|
||||
render: (text) => <span>{text}岁</span>,
|
||||
render: (text) => <span>{text}岁</span>
|
||||
}, {
|
||||
title: '性别',
|
||||
dataIndex: 'isMale',
|
||||
key: 'isMale',
|
||||
render: (text) => <span>{text
|
||||
? '男'
|
||||
: '女'}</span>,
|
||||
: '女'}</span>
|
||||
}, {
|
||||
title: '电话',
|
||||
dataIndex: 'phone',
|
||||
key: 'phone',
|
||||
key: 'phone'
|
||||
}, {
|
||||
title: '邮箱',
|
||||
dataIndex: 'email',
|
||||
key: 'email',
|
||||
key: 'email'
|
||||
}, {
|
||||
title: '住址',
|
||||
dataIndex: 'address',
|
||||
key: 'address',
|
||||
key: 'address'
|
||||
}, {
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
key: 'createTime'
|
||||
}, {
|
||||
title: '操作',
|
||||
key: 'operation',
|
||||
@@ -61,14 +61,14 @@ function list({
|
||||
render: (text, record) => (
|
||||
<p>
|
||||
<a onClick={() => onEditItem(record)} style={{
|
||||
marginRight: 4,
|
||||
marginRight: 4
|
||||
}}>编辑</a>
|
||||
<Popconfirm title="确定要删除吗?" onConfirm={() => onDeleteItem(record.id)}>
|
||||
<Popconfirm title='确定要删除吗?' onConfirm={() => onDeleteItem(record.id)}>
|
||||
<a>删除</a>
|
||||
</Popconfirm>
|
||||
</p>
|
||||
),
|
||||
},
|
||||
)
|
||||
}
|
||||
]
|
||||
|
||||
return (
|
||||
@@ -95,7 +95,7 @@ list.propTypes = {
|
||||
onEditItem: PropTypes.func,
|
||||
dataSource: PropTypes.array,
|
||||
loading: PropTypes.any,
|
||||
pagination: PropTypes.any,
|
||||
pagination: PropTypes.any
|
||||
}
|
||||
|
||||
export default list
|
||||
@@ -4,11 +4,11 @@ const FormItem = Form.Item
|
||||
|
||||
const formItemLayout = {
|
||||
labelCol: {
|
||||
span: 6,
|
||||
span: 6
|
||||
},
|
||||
wrapperCol: {
|
||||
span: 14,
|
||||
},
|
||||
span: 14
|
||||
}
|
||||
}
|
||||
|
||||
const modal = ({
|
||||
@@ -19,17 +19,17 @@ const modal = ({
|
||||
form: {
|
||||
getFieldDecorator,
|
||||
validateFields,
|
||||
getFieldsValue,
|
||||
},
|
||||
getFieldsValue
|
||||
}
|
||||
}) => {
|
||||
function handleOk() {
|
||||
function handleOk () {
|
||||
validateFields((errors) => {
|
||||
if (errors) {
|
||||
return
|
||||
}
|
||||
const data = {
|
||||
...getFieldsValue(),
|
||||
key: item.key,
|
||||
key: item.key
|
||||
}
|
||||
onOk(data)
|
||||
})
|
||||
@@ -40,44 +40,44 @@ const modal = ({
|
||||
visible,
|
||||
onOk: handleOk,
|
||||
onCancel,
|
||||
wrapClassName: 'vertical-center-modal',
|
||||
wrapClassName: 'vertical-center-modal'
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal {...modalOpts}>
|
||||
<Form horizontal>
|
||||
<FormItem label="姓名:" hasFeedback {...formItemLayout}>
|
||||
<FormItem label='姓名:' hasFeedback {...formItemLayout}>
|
||||
{getFieldDecorator('name', {
|
||||
initialValue: item.name,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '姓名未填写',
|
||||
},
|
||||
],
|
||||
message: '姓名未填写'
|
||||
}
|
||||
]
|
||||
})(<Input />)}
|
||||
</FormItem>
|
||||
<FormItem label="昵称:" hasFeedback {...formItemLayout}>
|
||||
<FormItem label='昵称:' hasFeedback {...formItemLayout}>
|
||||
{getFieldDecorator('nickName', {
|
||||
initialValue: item.nickName,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '昵称未填写',
|
||||
},
|
||||
],
|
||||
message: '昵称未填写'
|
||||
}
|
||||
]
|
||||
})(<Input />)}
|
||||
</FormItem>
|
||||
<FormItem label="性别" hasFeedback {...formItemLayout}>
|
||||
<FormItem label='性别' hasFeedback {...formItemLayout}>
|
||||
{getFieldDecorator('isMale', {
|
||||
initialValue: item.isMale,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
type: 'boolean',
|
||||
message: '请选择性别',
|
||||
},
|
||||
],
|
||||
message: '请选择性别'
|
||||
}
|
||||
]
|
||||
})(
|
||||
<Radio.Group>
|
||||
<Radio value>男</Radio>
|
||||
@@ -85,49 +85,49 @@ const modal = ({
|
||||
</Radio.Group>
|
||||
)}
|
||||
</FormItem>
|
||||
<FormItem label="年龄:" hasFeedback {...formItemLayout}>
|
||||
<FormItem label='年龄:' hasFeedback {...formItemLayout}>
|
||||
{getFieldDecorator('age', {
|
||||
initialValue: item.age,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '年龄未填写',
|
||||
},
|
||||
],
|
||||
message: '年龄未填写'
|
||||
}
|
||||
]
|
||||
})(<InputNumber min={18} max={100} />)}
|
||||
</FormItem>
|
||||
<FormItem label="电话:" hasFeedback {...formItemLayout}>
|
||||
<FormItem label='电话:' hasFeedback {...formItemLayout}>
|
||||
{getFieldDecorator('phone', {
|
||||
initialValue: item.phone,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '不能为空',
|
||||
},
|
||||
],
|
||||
message: '不能为空'
|
||||
}
|
||||
]
|
||||
})(<Input />)}
|
||||
</FormItem>
|
||||
<FormItem label="邮箱:" hasFeedback {...formItemLayout}>
|
||||
<FormItem label='邮箱:' hasFeedback {...formItemLayout}>
|
||||
{getFieldDecorator('email', {
|
||||
initialValue: item.email,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '不能为空',
|
||||
},
|
||||
],
|
||||
message: '不能为空'
|
||||
}
|
||||
]
|
||||
})(<Input />)}
|
||||
</FormItem>
|
||||
<FormItem label="住址:" hasFeedback {...formItemLayout}>
|
||||
<FormItem label='住址:' hasFeedback {...formItemLayout}>
|
||||
{getFieldDecorator('address', {
|
||||
initialValue: item.address,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '不能为空',
|
||||
},
|
||||
],
|
||||
message: '不能为空'
|
||||
}
|
||||
]
|
||||
})(<Input />)}
|
||||
</FormItem>
|
||||
</Form>
|
||||
@@ -140,7 +140,7 @@ modal.propTypes = {
|
||||
form: PropTypes.object,
|
||||
item: PropTypes.object,
|
||||
onOk: PropTypes.func,
|
||||
onCancel: PropTypes.func,
|
||||
onCancel: PropTypes.func
|
||||
}
|
||||
|
||||
export default Form.create()(modal)
|
||||
@@ -10,13 +10,13 @@ const search = ({
|
||||
form: {
|
||||
getFieldDecorator,
|
||||
validateFields,
|
||||
getFieldsValue,
|
||||
},
|
||||
getFieldsValue
|
||||
}
|
||||
}) => {
|
||||
function handleSubmit(e) {
|
||||
function handleSubmit (e) {
|
||||
e.preventDefault()
|
||||
validateFields((errors) => {
|
||||
if (!!errors) {
|
||||
if (errors) {
|
||||
return
|
||||
}
|
||||
onSearch(getFieldsValue())
|
||||
@@ -29,24 +29,24 @@ const search = ({
|
||||
<Form inline onSubmit={handleSubmit}>
|
||||
<Form.Item>
|
||||
{getFieldDecorator('field', {
|
||||
initialValue: field || 'name',
|
||||
initialValue: field || 'name'
|
||||
})(
|
||||
<Select>
|
||||
<Select.Option value="name">名字</Select.Option>
|
||||
<Select.Option value="address">地址</Select.Option>
|
||||
<Select.Option value='name'>名字</Select.Option>
|
||||
<Select.Option value='address'>地址</Select.Option>
|
||||
</Select>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item hasFeedback>
|
||||
{getFieldDecorator('keyword', {
|
||||
initialValue: keyword || '',
|
||||
initialValue: keyword || ''
|
||||
})(<Input />)}
|
||||
</Form.Item>
|
||||
<Button type="primary" htmlType="submit">搜索</Button>
|
||||
<Button type='primary' htmlType='submit'>搜索</Button>
|
||||
</Form>
|
||||
</div>
|
||||
<div className={styles.create}>
|
||||
<Button type="ghost" onClick={onAdd}>添加</Button>
|
||||
<Button type='ghost' onClick={onAdd}>添加</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
@@ -57,7 +57,7 @@ search.propTypes = {
|
||||
onSearch: PropTypes.func,
|
||||
onAdd: PropTypes.func,
|
||||
field: PropTypes.string,
|
||||
keyword: PropTypes.string,
|
||||
keyword: PropTypes.string
|
||||
}
|
||||
|
||||
export default Form.create()(search)
|
||||
+40
-38
@@ -1,45 +1,47 @@
|
||||
import {login, userInfo, logout} from '../services/app'
|
||||
import {parse} from 'qs'
|
||||
import Cookie from 'js-cookie'
|
||||
|
||||
export default {
|
||||
namespace : 'app',
|
||||
state : {
|
||||
namespace: 'app',
|
||||
state: {
|
||||
login: false,
|
||||
loading: false,
|
||||
user: {
|
||||
name: "吴彦祖"
|
||||
name: '吴彦祖'
|
||||
},
|
||||
loginButtonLoading: false,
|
||||
siderFold:localStorage.getItem("antdAdminSiderFold")==="true"?true:false,
|
||||
darkTheme:localStorage.getItem("antdAdminDarkTheme")==="false"?false:true,
|
||||
isNavbar:document.body.clientWidth<769?true:false,
|
||||
siderFold: localStorage.getItem('antdAdminSiderFold') === 'true',
|
||||
darkTheme: localStorage.getItem('antdAdminDarkTheme') !== 'false',
|
||||
isNavbar: document.body.clientWidth < 769
|
||||
},
|
||||
subscriptions : {
|
||||
setup({dispatch}) {
|
||||
subscriptions: {
|
||||
setup ({dispatch}) {
|
||||
dispatch({type: 'queryUser'})
|
||||
window.onresize = function(){
|
||||
window.onresize = function () {
|
||||
dispatch({type: 'changeNavbar'})
|
||||
}
|
||||
}
|
||||
},
|
||||
effects : {
|
||||
*login({
|
||||
effects: {
|
||||
*login ({
|
||||
payload
|
||||
}, {call, put}) {
|
||||
yield put({type: 'showLoginButtonLoading'})
|
||||
const data = yield call(login, parse(payload))
|
||||
if (data.success) {
|
||||
yield put({type: 'loginSuccess', payload: {
|
||||
yield put({
|
||||
type: 'loginSuccess',
|
||||
payload: {
|
||||
data
|
||||
}})
|
||||
} else {
|
||||
yield put({type: 'loginFail', payload: {
|
||||
data
|
||||
}})
|
||||
yield put({
|
||||
type: 'loginFail',
|
||||
payload: {data}
|
||||
})
|
||||
}
|
||||
},
|
||||
*queryUser({
|
||||
*queryUser ({
|
||||
payload
|
||||
}, {call, put}) {
|
||||
yield put({type: 'showLoading'})
|
||||
@@ -57,42 +59,42 @@ export default {
|
||||
yield put({type: 'hideLoading'})
|
||||
}
|
||||
},
|
||||
*logout({
|
||||
*logout ({
|
||||
payload
|
||||
}, {call, put}) {
|
||||
const data = yield call(logout, parse(payload))
|
||||
if(data.success){
|
||||
if (data.success) {
|
||||
yield put({
|
||||
type: 'logoutSuccess'
|
||||
})
|
||||
}
|
||||
},
|
||||
*switchSider({
|
||||
*switchSider ({
|
||||
payload
|
||||
}, {put}) {
|
||||
yield put({
|
||||
type: 'handleSwitchSider'
|
||||
})
|
||||
},
|
||||
*changeTheme({
|
||||
*changeTheme ({
|
||||
payload
|
||||
}, {put}) {
|
||||
yield put({
|
||||
type: 'handleChangeTheme'
|
||||
})
|
||||
},
|
||||
*changeNavbar({
|
||||
*changeNavbar ({
|
||||
payload
|
||||
}, {put}) {
|
||||
if(document.body.clientWidth<769){
|
||||
if (document.body.clientWidth < 769) {
|
||||
yield put({type: 'showNavbar'})
|
||||
}else {
|
||||
} else {
|
||||
yield put({type: 'hideNavbar'})
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
reducers : {
|
||||
loginSuccess(state, action) {
|
||||
reducers: {
|
||||
loginSuccess (state, action) {
|
||||
return {
|
||||
...state,
|
||||
...action.payload,
|
||||
@@ -100,58 +102,58 @@ export default {
|
||||
loginButtonLoading: false
|
||||
}
|
||||
},
|
||||
logoutSuccess(state){
|
||||
logoutSuccess (state) {
|
||||
return {
|
||||
...state,
|
||||
login: false
|
||||
}
|
||||
},
|
||||
loginFail(state) {
|
||||
loginFail (state) {
|
||||
return {
|
||||
...state,
|
||||
login: false,
|
||||
loginButtonLoading: false
|
||||
}
|
||||
},
|
||||
showLoginButtonLoading(state) {
|
||||
showLoginButtonLoading (state) {
|
||||
return {
|
||||
...state,
|
||||
loginButtonLoading: true
|
||||
}
|
||||
},
|
||||
showLoading(state) {
|
||||
showLoading (state) {
|
||||
return {
|
||||
...state,
|
||||
loading: true
|
||||
}
|
||||
},
|
||||
hideLoading(state) {
|
||||
hideLoading (state) {
|
||||
return {
|
||||
...state,
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
handleSwitchSider(state) {
|
||||
localStorage.setItem("antdAdminSiderFold",!state.darkTheme)
|
||||
handleSwitchSider (state) {
|
||||
localStorage.setItem('antdAdminSiderFold', !state.darkTheme)
|
||||
return {
|
||||
...state,
|
||||
siderFold: !state.siderFold
|
||||
}
|
||||
},
|
||||
handleChangeTheme(state) {
|
||||
localStorage.setItem("antdAdminDarkTheme",!state.darkTheme)
|
||||
handleChangeTheme (state) {
|
||||
localStorage.setItem('antdAdminDarkTheme', !state.darkTheme)
|
||||
return {
|
||||
...state,
|
||||
darkTheme: !state.darkTheme
|
||||
}
|
||||
},
|
||||
showNavbar(state) {
|
||||
showNavbar (state) {
|
||||
return {
|
||||
...state,
|
||||
isNavbar: true
|
||||
}
|
||||
},
|
||||
hideNavbar(state) {
|
||||
hideNavbar (state) {
|
||||
return {
|
||||
...state,
|
||||
isNavbar: false
|
||||
|
||||
+123
-123
@@ -1,11 +1,11 @@
|
||||
import {myCity, queryWeather , query} from '../services/dashboard'
|
||||
import {myCity, queryWeather, query} from '../services/dashboard'
|
||||
import {parse} from 'qs'
|
||||
|
||||
// zuimei 摘自 http://www.zuimeitianqi.com/res/js/index.js
|
||||
let zuimei = {
|
||||
ParseActualData: function (actual, air) {
|
||||
let weather = {
|
||||
icon: 'http://www.zuimeitianqi.com/res/icon/' + zuimei.GetIconName(actual.wea, "big"),
|
||||
icon: 'http://www.zuimeitianqi.com/res/icon/' + zuimei.GetIconName(actual.wea, 'big'),
|
||||
name: zuimei.GetWeatherName(actual.wea),
|
||||
temperature: actual.tmp,
|
||||
dateTime: new Date(actual.PTm).format('MM-dd hh:mm')
|
||||
@@ -17,28 +17,28 @@ let zuimei = {
|
||||
let myDate = new Date()
|
||||
let hour = myDate.getHours()
|
||||
let num = 0
|
||||
if (wea.indexOf("/") != -1) {
|
||||
let weas = wea.split("/")
|
||||
if (wea.indexOf('/') !== -1) {
|
||||
let weas = wea.split('/')
|
||||
if (hour < 12) {
|
||||
num = zuimei.ReplaceIcon(weas[0])
|
||||
if (num < 6) {
|
||||
num = num + "_" + flg + "_night.png"
|
||||
num = num + '_' + flg + '_night.png'
|
||||
} else {
|
||||
num = num + "_" + flg + ".png"
|
||||
num = num + '_' + flg + '.png'
|
||||
}
|
||||
} else if (12 <= hour) {
|
||||
} else if (hour >= 12) {
|
||||
num = zuimei.ReplaceIcon(weas[1])
|
||||
if (hour >= 18) {
|
||||
num = num + "_" + flg + "_night.png"
|
||||
num = num + '_' + flg + '_night.png'
|
||||
} else {
|
||||
num = num + "_" + flg + ".png"
|
||||
num = num + '_' + flg + '.png'
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((hour >= 18 && hour <= 23) || (hour >= 0 && hour <= 6)) {
|
||||
num = num + "_" + flg + "_night.png"
|
||||
num = num + '_' + flg + '_night.png'
|
||||
} else {
|
||||
num = num + "_" + flg + ".png"
|
||||
num = num + '_' + flg + '.png'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,21 +46,21 @@ let zuimei = {
|
||||
},
|
||||
|
||||
ReplaceIcon: function (num) {
|
||||
if (num == 21) {
|
||||
if (num === 21) {
|
||||
num = 7
|
||||
} else if (num == 22) {
|
||||
} else if (num === 22) {
|
||||
num = 8
|
||||
} else if (num == 10 || num == 11 || num == 12 || num == 23 || num == 24 || num == 25) {
|
||||
} else if (num === 10 || num === 11 || num === 12 || num === 23 || num === 24 || num === 25) {
|
||||
num = 9
|
||||
} else if (num == 13 || num == 15 || num == 26 || num == 27 || num == 34) {
|
||||
} else if (num === 13 || num === 15 || num === 26 || num === 27 || num === 34) {
|
||||
num = 14
|
||||
} else if (num == 17 || num == 28) {
|
||||
} else if (num === 17 || num === 28) {
|
||||
num = 16
|
||||
} else if (num == 35) {
|
||||
} else if (num === 35) {
|
||||
num = 18
|
||||
} else if (num == 31 || num == 32 || num == 33) {
|
||||
} else if (num === 31 || num === 32 || num === 33) {
|
||||
num = 20
|
||||
} else if (num == 30) {
|
||||
} else if (num === 30) {
|
||||
num = 29
|
||||
}
|
||||
|
||||
@@ -68,10 +68,10 @@ let zuimei = {
|
||||
},
|
||||
|
||||
GetWeatherName: function (wea) {
|
||||
let name = ""
|
||||
if (wea.indexOf("/") != -1) {
|
||||
let weas = wea.split("/")
|
||||
name = zuimei.GetWeatherByCode(weas[0]) + "转" + zuimei.GetWeatherByCode(weas[1])
|
||||
let name = ''
|
||||
if (wea.indexOf('/') !== -1) {
|
||||
let weas = wea.split('/')
|
||||
name = zuimei.GetWeatherByCode(weas[0]) + '转' + zuimei.GetWeatherByCode(weas[1])
|
||||
} else {
|
||||
name = zuimei.GetWeatherByCode(wea)
|
||||
}
|
||||
@@ -80,83 +80,83 @@ let zuimei = {
|
||||
},
|
||||
|
||||
GetWeatherByCode: function (num) {
|
||||
let wea = ""
|
||||
if (num == 0) {
|
||||
wea = "晴"
|
||||
} else if (num == 1) {
|
||||
wea = "多云"
|
||||
} else if (num == 2) {
|
||||
wea = "阴"
|
||||
} else if (num == 3) {
|
||||
wea = "阵雨"
|
||||
} else if (num == 4) {
|
||||
wea = "雷阵雨"
|
||||
} else if (num == 5) {
|
||||
wea = "雷阵雨并伴有冰雹"
|
||||
} else if (num == 6) {
|
||||
wea = "雨夹雪"
|
||||
} else if (num == 7) {
|
||||
wea = "小雨"
|
||||
} else if (num == 8) {
|
||||
wea = "中雨"
|
||||
} else if (num == 9) {
|
||||
wea = "大雨"
|
||||
} else if (num == 10) {
|
||||
wea = "暴雨"
|
||||
} else if (num == 11) {
|
||||
wea = "大暴雨"
|
||||
} else if (num == 12) {
|
||||
wea = "特大暴雨"
|
||||
} else if (num == 13) {
|
||||
wea = "阵雪"
|
||||
} else if (num == 14) {
|
||||
wea = "小雪"
|
||||
} else if (num == 15) {
|
||||
wea = "中雪"
|
||||
} else if (num == 16) {
|
||||
wea = "大雪"
|
||||
} else if (num == 17) {
|
||||
wea = "暴雪"
|
||||
} else if (num == 18) {
|
||||
wea = "雾"
|
||||
} else if (num == 19) {
|
||||
wea = "冻雨"
|
||||
} else if (num == 20) {
|
||||
wea = "沙尘暴"
|
||||
} else if (num == 21) {
|
||||
wea = "小雨-中雨"
|
||||
} else if (num == 22) {
|
||||
wea = "中雨-大雨"
|
||||
} else if (num == 23) {
|
||||
wea = "大雨-暴雨"
|
||||
} else if (num == 24) {
|
||||
wea = "暴雨-大暴雨"
|
||||
} else if (num == 25) {
|
||||
wea = "大暴雨-特大暴雨"
|
||||
} else if (num == 26) {
|
||||
wea = "小雪-中雪"
|
||||
} else if (num == 27) {
|
||||
wea = "中雪-大雪"
|
||||
} else if (num == 28) {
|
||||
wea = "大雪-暴雪"
|
||||
} else if (num == 29) {
|
||||
wea = "浮沉"
|
||||
} else if (num == 30) {
|
||||
wea = "扬沙"
|
||||
} else if (num == 31) {
|
||||
wea = "强沙尘暴"
|
||||
} else if (num == 32) {
|
||||
wea = "飑"
|
||||
} else if (num == 33) {
|
||||
wea = "龙卷风"
|
||||
} else if (num == 34) {
|
||||
wea = "若高吹雪"
|
||||
} else if (num == 35) {
|
||||
wea = "轻雾"
|
||||
} else if (num == 53) {
|
||||
wea = "霾"
|
||||
} else if (num == 99) {
|
||||
wea = "未知"
|
||||
let wea = ''
|
||||
if (num === 0) {
|
||||
wea = '晴'
|
||||
} else if (num === 1) {
|
||||
wea = '多云'
|
||||
} else if (num === 2) {
|
||||
wea = '阴'
|
||||
} else if (num === 3) {
|
||||
wea = '阵雨'
|
||||
} else if (num === 4) {
|
||||
wea = '雷阵雨'
|
||||
} else if (num === 5) {
|
||||
wea = '雷阵雨并伴有冰雹'
|
||||
} else if (num === 6) {
|
||||
wea = '雨夹雪'
|
||||
} else if (num === 7) {
|
||||
wea = '小雨'
|
||||
} else if (num === 8) {
|
||||
wea = '中雨'
|
||||
} else if (num === 9) {
|
||||
wea = '大雨'
|
||||
} else if (num === 10) {
|
||||
wea = '暴雨'
|
||||
} else if (num === 11) {
|
||||
wea = '大暴雨'
|
||||
} else if (num === 12) {
|
||||
wea = '特大暴雨'
|
||||
} else if (num === 13) {
|
||||
wea = '阵雪'
|
||||
} else if (num === 14) {
|
||||
wea = '小雪'
|
||||
} else if (num === 15) {
|
||||
wea = '中雪'
|
||||
} else if (num === 16) {
|
||||
wea = '大雪'
|
||||
} else if (num === 17) {
|
||||
wea = '暴雪'
|
||||
} else if (num === 18) {
|
||||
wea = '雾'
|
||||
} else if (num === 19) {
|
||||
wea = '冻雨'
|
||||
} else if (num === 20) {
|
||||
wea = '沙尘暴'
|
||||
} else if (num === 21) {
|
||||
wea = '小雨-中雨'
|
||||
} else if (num === 22) {
|
||||
wea = '中雨-大雨'
|
||||
} else if (num === 23) {
|
||||
wea = '大雨-暴雨'
|
||||
} else if (num === 24) {
|
||||
wea = '暴雨-大暴雨'
|
||||
} else if (num === 25) {
|
||||
wea = '大暴雨-特大暴雨'
|
||||
} else if (num === 26) {
|
||||
wea = '小雪-中雪'
|
||||
} else if (num === 27) {
|
||||
wea = '中雪-大雪'
|
||||
} else if (num === 28) {
|
||||
wea = '大雪-暴雪'
|
||||
} else if (num === 29) {
|
||||
wea = '浮沉'
|
||||
} else if (num === 30) {
|
||||
wea = '扬沙'
|
||||
} else if (num === 31) {
|
||||
wea = '强沙尘暴'
|
||||
} else if (num === 32) {
|
||||
wea = '飑'
|
||||
} else if (num === 33) {
|
||||
wea = '龙卷风'
|
||||
} else if (num === 34) {
|
||||
wea = '若高吹雪'
|
||||
} else if (num === 35) {
|
||||
wea = '轻雾'
|
||||
} else if (num === 53) {
|
||||
wea = '霾'
|
||||
} else if (num === 99) {
|
||||
wea = '未知'
|
||||
}
|
||||
|
||||
return wea
|
||||
@@ -164,8 +164,8 @@ let zuimei = {
|
||||
}
|
||||
|
||||
export default {
|
||||
namespace : 'dashboard',
|
||||
state : {
|
||||
namespace: 'dashboard',
|
||||
state: {
|
||||
weather: {
|
||||
city: '成都',
|
||||
temperature: '5',
|
||||
@@ -173,34 +173,34 @@ export default {
|
||||
icon: 'http://www.zuimeitianqi.com/res/icon/0_big.png',
|
||||
dateTime: new Date().format('MM-dd hh:mm')
|
||||
},
|
||||
sales:[],
|
||||
quote:{
|
||||
sales: [],
|
||||
quote: {
|
||||
avatar: 'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236'
|
||||
},
|
||||
numbers:[],
|
||||
recentSales:[],
|
||||
comments:[],
|
||||
completed:[],
|
||||
browser:[],
|
||||
cpu:{},
|
||||
user:{
|
||||
numbers: [],
|
||||
recentSales: [],
|
||||
comments: [],
|
||||
completed: [],
|
||||
browser: [],
|
||||
cpu: {},
|
||||
user: {
|
||||
avatar: 'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236'
|
||||
},
|
||||
}
|
||||
},
|
||||
subscriptions : {
|
||||
setup({dispatch}) {
|
||||
subscriptions: {
|
||||
setup ({dispatch}) {
|
||||
dispatch({type: 'queryWeather'})
|
||||
dispatch({type: 'query'})
|
||||
}
|
||||
},
|
||||
effects : {
|
||||
*query({
|
||||
effects: {
|
||||
*query ({
|
||||
payload
|
||||
}, {call, put}) {
|
||||
const data = yield call(query, parse(payload))
|
||||
yield put({type: 'queryWeather', payload: {...data}})
|
||||
},
|
||||
*queryWeather({
|
||||
*queryWeather ({
|
||||
payload
|
||||
}, {call, put}) {
|
||||
const myCityResult = yield call(myCity, {flg: 0})
|
||||
@@ -211,22 +211,22 @@ export default {
|
||||
weather.city = myCityData.selectCityName
|
||||
|
||||
yield put({type: 'queryWeatherSuccess', payload: {
|
||||
weather
|
||||
}})
|
||||
weather
|
||||
}})
|
||||
}
|
||||
},
|
||||
reducers : {
|
||||
queryWeatherSuccess(state, action) {
|
||||
reducers: {
|
||||
queryWeatherSuccess (state, action) {
|
||||
return {
|
||||
...state,
|
||||
...action.payload
|
||||
}
|
||||
},
|
||||
queryWeather(state, action) {
|
||||
queryWeather (state, action) {
|
||||
return {
|
||||
...state,
|
||||
...action.payload
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+29
-29
@@ -11,30 +11,30 @@ export default {
|
||||
currentItem: {},
|
||||
modalVisible: false,
|
||||
modalType: 'create',
|
||||
pagination:{
|
||||
pagination: {
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
showTotal: total => `共 ${total} 条`,
|
||||
current:1,
|
||||
total:null,
|
||||
current: 1,
|
||||
total: null
|
||||
}
|
||||
},
|
||||
|
||||
subscriptions: {
|
||||
setup({ dispatch, history }) {
|
||||
setup ({ dispatch, history }) {
|
||||
history.listen(location => {
|
||||
if (location.pathname === '/users') {
|
||||
dispatch({
|
||||
type: 'query',
|
||||
payload: location.query,
|
||||
payload: location.query
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
effects: {
|
||||
*query({ payload }, { call, put }) {
|
||||
*query ({ payload }, { call, put }) {
|
||||
yield put({ type: 'showLoading' })
|
||||
const data = yield call(query, parse(payload))
|
||||
if (data) {
|
||||
@@ -42,15 +42,15 @@ export default {
|
||||
type: 'querySuccess',
|
||||
payload: {
|
||||
list: data.data,
|
||||
pagination:{
|
||||
pagination: {
|
||||
total: data.page.total,
|
||||
current: data.page.current,
|
||||
current: data.page.current
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
*'delete'({ payload }, { call, put }) {
|
||||
*'delete' ({ payload }, { call, put }) {
|
||||
yield put({ type: 'showLoading' })
|
||||
const data = yield call(remove, { id: payload })
|
||||
if (data && data.success) {
|
||||
@@ -58,15 +58,15 @@ export default {
|
||||
type: 'querySuccess',
|
||||
payload: {
|
||||
list: data.data,
|
||||
pagination:{
|
||||
pagination: {
|
||||
total: data.page.total,
|
||||
current: data.page.current,
|
||||
current: data.page.current
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
*create({ payload }, { call, put }) {
|
||||
*create ({ payload }, { call, put }) {
|
||||
yield put({ type: 'hideModal' })
|
||||
yield put({ type: 'showLoading' })
|
||||
const data = yield call(create, payload)
|
||||
@@ -75,15 +75,15 @@ export default {
|
||||
type: 'querySuccess',
|
||||
payload: {
|
||||
list: data.data,
|
||||
pagination:{
|
||||
pagination: {
|
||||
total: data.page.total,
|
||||
current: data.page.current,
|
||||
current: data.page.current
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
*update({ payload }, { select, call, put }) {
|
||||
*update ({ payload }, { select, call, put }) {
|
||||
yield put({ type: 'hideModal' })
|
||||
yield put({ type: 'showLoading' })
|
||||
const id = yield select(({ users }) => users.currentItem.id)
|
||||
@@ -94,29 +94,29 @@ export default {
|
||||
type: 'querySuccess',
|
||||
payload: {
|
||||
list: data.data,
|
||||
pagination:{
|
||||
pagination: {
|
||||
total: data.page.total,
|
||||
current: data.page.current,
|
||||
current: data.page.current
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
reducers: {
|
||||
showLoading(state) {
|
||||
showLoading (state) {
|
||||
return { ...state, loading: true }
|
||||
},
|
||||
querySuccess(state, action) {
|
||||
querySuccess (state, action) {
|
||||
return { ...state, ...action.payload, loading: false }
|
||||
},
|
||||
showModal(state, action) {
|
||||
showModal (state, action) {
|
||||
return { ...state, ...action.payload, modalVisible: true }
|
||||
},
|
||||
hideModal(state) {
|
||||
hideModal (state) {
|
||||
return { ...state, modalVisible: false }
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-7
@@ -3,12 +3,11 @@ import {Router} from 'dva/router'
|
||||
import App from './routes/app'
|
||||
|
||||
export default function ({history, app}) {
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
component: App,
|
||||
getIndexRoute(nextState, cb) {
|
||||
getIndexRoute (nextState, cb) {
|
||||
require.ensure([], require => {
|
||||
app.model(require('./models/dashboard'))
|
||||
cb(null, {component: require('./routes/dashboard')})
|
||||
@@ -18,7 +17,7 @@ export default function ({history, app}) {
|
||||
{
|
||||
path: 'dashboard',
|
||||
name: 'dashboard',
|
||||
getComponent(nextState, cb) {
|
||||
getComponent (nextState, cb) {
|
||||
require.ensure([], require => {
|
||||
app.model(require('./models/dashboard'))
|
||||
cb(null, require('./routes/dashboard'))
|
||||
@@ -27,7 +26,7 @@ export default function ({history, app}) {
|
||||
}, {
|
||||
path: 'users',
|
||||
name: 'users',
|
||||
getComponent(nextState, cb) {
|
||||
getComponent (nextState, cb) {
|
||||
require.ensure([], require => {
|
||||
app.model(require('./models/users'))
|
||||
cb(null, require('./routes/users'))
|
||||
@@ -36,7 +35,7 @@ export default function ({history, app}) {
|
||||
}, {
|
||||
path: 'ui/ico',
|
||||
name: 'ui/ico',
|
||||
getComponent(nextState, cb) {
|
||||
getComponent (nextState, cb) {
|
||||
require.ensure([], require => {
|
||||
cb(null, require('./routes/ui/ico'))
|
||||
})
|
||||
@@ -44,7 +43,7 @@ export default function ({history, app}) {
|
||||
}, {
|
||||
path: '*',
|
||||
name: 'error',
|
||||
getComponent(nextState, cb) {
|
||||
getComponent (nextState, cb) {
|
||||
require.ensure([], require => {
|
||||
cb(null, require('./routes/error'))
|
||||
})
|
||||
@@ -54,5 +53,5 @@ export default function ({history, app}) {
|
||||
}
|
||||
]
|
||||
|
||||
return <Router history={history} routes={routes}/>
|
||||
return <Router history={history} routes={routes} />
|
||||
}
|
||||
|
||||
+24
-24
@@ -1,21 +1,21 @@
|
||||
import React, {PropTypes} from 'react'
|
||||
import {connect} from 'dva'
|
||||
import React, { PropTypes } from 'react'
|
||||
import { connect } from 'dva'
|
||||
import Login from './login'
|
||||
import Header from '../components/layout/header'
|
||||
import Bread from '../components/layout/bread'
|
||||
import Footer from '../components/layout/footer'
|
||||
import Sider from '../components/layout/sider'
|
||||
import styles from '../components/layout/main.less'
|
||||
import {Spin,message} from 'antd'
|
||||
import {classnames} from '../utils'
|
||||
import { Spin } from 'antd'
|
||||
import { classnames } from '../utils'
|
||||
import '../components/layout/common.less'
|
||||
|
||||
function App({children, location, dispatch, app}) {
|
||||
function App ({children, location, dispatch, app}) {
|
||||
const {login, loading, loginButtonLoading, user, siderFold, darkTheme, isNavbar} = app
|
||||
const loginProps = {
|
||||
loading,
|
||||
loginButtonLoading,
|
||||
onOk(data) {
|
||||
onOk (data) {
|
||||
dispatch({type: 'app/login', payload: data})
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,10 @@ function App({children, location, dispatch, app}) {
|
||||
siderFold,
|
||||
location,
|
||||
isNavbar,
|
||||
logout() {
|
||||
logout () {
|
||||
dispatch({type: 'app/logout'})
|
||||
},
|
||||
switchSider() {
|
||||
switchSider () {
|
||||
dispatch({type: 'app/switchSider'})
|
||||
}
|
||||
}
|
||||
@@ -37,29 +37,29 @@ function App({children, location, dispatch, app}) {
|
||||
siderFold,
|
||||
darkTheme,
|
||||
location,
|
||||
changeTheme(){
|
||||
changeTheme () {
|
||||
dispatch({type: 'app/changeTheme'})
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>{login
|
||||
? <div className={classnames(styles.layout,{[styles.fold]:isNavbar?false:siderFold},{[styles.withnavbar]:isNavbar})}>
|
||||
{!isNavbar?<aside className={classnames(styles.sider,{[styles.light]:!darkTheme})}>
|
||||
<Sider {...siderProps}/>
|
||||
</aside>:''}
|
||||
<div className={styles.main}>
|
||||
<Header {...headerProps}/>
|
||||
<Bread location={location}/>
|
||||
<div className={styles.container}>
|
||||
<div className={styles.content}>
|
||||
{children}
|
||||
</div>
|
||||
? <div className={classnames(styles.layout, {[styles.fold]: isNavbar ? false : siderFold}, {[styles.withnavbar]: isNavbar})}>
|
||||
{!isNavbar ? <aside className={classnames(styles.sider, {[styles.light]: !darkTheme})}>
|
||||
<Sider {...siderProps} />
|
||||
</aside> : ''}
|
||||
<div className={styles.main}>
|
||||
<Header {...headerProps} />
|
||||
<Bread location={location} />
|
||||
<div className={styles.container}>
|
||||
<div className={styles.content}>
|
||||
{children}
|
||||
</div>
|
||||
<Footer/>
|
||||
</div>
|
||||
<Footer />
|
||||
</div>
|
||||
: <div className={styles.spin}><Spin tip="加载用户信息..." spinning={loading} size="large"><Login {...loginProps}/></Spin></div>}</div>
|
||||
</div>
|
||||
: <div className={styles.spin}><Spin tip='加载用户信息...' spinning={loading} size='large'><Login {...loginProps} /></Spin></div>}</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ App.propTypes = {
|
||||
loginButtonLoading: PropTypes.bool,
|
||||
login: PropTypes.bool,
|
||||
user: PropTypes.object,
|
||||
siderFold:PropTypes.bool,
|
||||
darkTheme:PropTypes.bool,
|
||||
siderFold: PropTypes.bool,
|
||||
darkTheme: PropTypes.bool
|
||||
}
|
||||
|
||||
export default connect(({app}) => ({app}))(App)
|
||||
|
||||
+16
-18
@@ -1,7 +1,6 @@
|
||||
import React, {PropTypes} from 'react'
|
||||
import {connect} from 'dva'
|
||||
import {Link} from 'dva/router'
|
||||
import {Row, Col, Icon, Card} from 'antd'
|
||||
import {Row, Col, Card} from 'antd'
|
||||
import NumberCard from '../components/dashboard/numberCard'
|
||||
import Quote from '../components/dashboard/quote'
|
||||
import Sales from '../components/dashboard/sales'
|
||||
@@ -16,17 +15,16 @@ import styles from './dashboard.less'
|
||||
import {color} from '../utils'
|
||||
|
||||
const bodyStyle = {
|
||||
bodyStyle:{
|
||||
bodyStyle: {
|
||||
height: 432,
|
||||
background: '#fff',
|
||||
background: '#fff'
|
||||
}
|
||||
}
|
||||
|
||||
function Dashboard({dashboard,dispatch}) {
|
||||
|
||||
function Dashboard ({dashboard, dispatch}) {
|
||||
const {weather, sales, quote, numbers, recentSales, comments, completed, browser, cpu, user} = dashboard
|
||||
const numberCards = numbers.map((item, key) => <Col key={key} lg={6} md={12}>
|
||||
<NumberCard {...item}/>
|
||||
<NumberCard {...item} />
|
||||
</Col>)
|
||||
|
||||
return (
|
||||
@@ -36,7 +34,7 @@ function Dashboard({dashboard,dispatch}) {
|
||||
<Card bordered={false} bodyStyle={{
|
||||
padding: '24px 36px 24px 0'
|
||||
}}>
|
||||
<Sales data={sales}/>
|
||||
<Sales data={sales} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col lg={6} md={24}>
|
||||
@@ -47,7 +45,7 @@ function Dashboard({dashboard,dispatch}) {
|
||||
height: 204,
|
||||
background: color.blue
|
||||
}}>
|
||||
<Weather {...weather}/>
|
||||
<Weather {...weather} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col lg={24} md={12}>
|
||||
@@ -56,41 +54,41 @@ function Dashboard({dashboard,dispatch}) {
|
||||
height: 204,
|
||||
background: color.peach
|
||||
}}>
|
||||
<Quote {...quote}/>
|
||||
<Quote {...quote} />
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
</Col>
|
||||
<Col lg={12} md={24}>
|
||||
<Card bordered={false} {...bodyStyle}>
|
||||
<RecentSales data={recentSales}/>
|
||||
<RecentSales data={recentSales} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col lg={12} md={24}>
|
||||
<Card bordered={false} {...bodyStyle}>
|
||||
<Comments data={comments}/>
|
||||
<Comments data={comments} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col lg={24} md={24}>
|
||||
<Card bordered={false} bodyStyle={{
|
||||
padding: '24px 36px 24px 0'
|
||||
}}>
|
||||
<Completed data={completed}/>
|
||||
<Completed data={completed} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col lg={8} md={24}>
|
||||
<Card bordered={false} {...bodyStyle}>
|
||||
<Browser data={browser}/>
|
||||
<Browser data={browser} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col lg={8} md={24}>
|
||||
<Card bordered={false} {...bodyStyle}>
|
||||
<Cpu {...cpu}/>
|
||||
<Cpu {...cpu} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col lg={8} md={24}>
|
||||
<Card bordered={false} bodyStyle={{...bodyStyle.bodyStyle,padding:0}}>
|
||||
<User {...user}/>
|
||||
<Card bordered={false} bodyStyle={{...bodyStyle.bodyStyle, padding: 0}}>
|
||||
<User {...user} />
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
@@ -107,7 +105,7 @@ Dashboard.propTypes = {
|
||||
completed: PropTypes.array,
|
||||
browser: PropTypes.array,
|
||||
cpu: PropTypes.object,
|
||||
user: PropTypes.object,
|
||||
user: PropTypes.object
|
||||
}
|
||||
|
||||
export default connect(({dashboard}) => ({dashboard}))(Dashboard)
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@ import React from 'react'
|
||||
import {Icon} from 'antd'
|
||||
import styles from './error.less'
|
||||
|
||||
const Error = () => <div className="content-inner">
|
||||
const Error = () => <div className='content-inner'>
|
||||
<div className={styles.error}>
|
||||
<Icon type="frown-o"/>
|
||||
<Icon type='frown-o' />
|
||||
<h1>404 Not Found</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+9
-19
@@ -1,15 +1,6 @@
|
||||
import React, {PropTypes} from 'react'
|
||||
import {
|
||||
Icon,
|
||||
message,
|
||||
Button,
|
||||
Row,
|
||||
Col,
|
||||
Form,
|
||||
Input,
|
||||
Select
|
||||
} from 'antd'
|
||||
import {config} from '../utils'
|
||||
import { Button, Row, Form, Input } from 'antd'
|
||||
import { config } from '../utils'
|
||||
import styles from './login.less'
|
||||
|
||||
const FormItem = Form.Item
|
||||
@@ -22,8 +13,7 @@ const login = ({
|
||||
validateFieldsAndScroll
|
||||
}
|
||||
}) => {
|
||||
|
||||
function handleOk() {
|
||||
function handleOk () {
|
||||
validateFieldsAndScroll((errors, values) => {
|
||||
if (errors) {
|
||||
return
|
||||
@@ -32,12 +22,12 @@ const login = ({
|
||||
})
|
||||
}
|
||||
|
||||
document.onkeyup = e => e.keyCode===13 && handleOk()
|
||||
document.onkeyup = e => e.keyCode === 13 && handleOk()
|
||||
|
||||
return (
|
||||
<div className={styles.form}>
|
||||
<div className={styles.logo}>
|
||||
<img src={config.logoSrc}/>
|
||||
<img src={config.logoSrc} />
|
||||
<span>Ant Design</span>
|
||||
</div>
|
||||
<form>
|
||||
@@ -49,7 +39,7 @@ const login = ({
|
||||
message: '请填写用户名'
|
||||
}
|
||||
]
|
||||
})(<Input size="large" placeholder="用户名"/>)}
|
||||
})(<Input size='large' placeholder='用户名' />)}
|
||||
</FormItem>
|
||||
<FormItem hasFeedback>
|
||||
{getFieldDecorator('password', {
|
||||
@@ -59,10 +49,10 @@ const login = ({
|
||||
message: '请填写密码'
|
||||
}
|
||||
]
|
||||
})(<Input size="large" type="password" placeholder="密码"/>)}
|
||||
})(<Input size='large' type='password' placeholder='密码' />)}
|
||||
</FormItem>
|
||||
<Row>
|
||||
<Button type="primary" size="large" onClick={handleOk} loading={loginButtonLoading}>
|
||||
<Button type='primary' size='large' onClick={handleOk} loading={loginButtonLoading}>
|
||||
登录
|
||||
</Button>
|
||||
</Row>
|
||||
@@ -77,7 +67,7 @@ const login = ({
|
||||
|
||||
login.propTypes = {
|
||||
form: PropTypes.object,
|
||||
loginButtonLoading:PropTypes.bool,
|
||||
loginButtonLoading: PropTypes.bool,
|
||||
onOk: PropTypes.func
|
||||
}
|
||||
|
||||
|
||||
+35
-35
@@ -1,43 +1,43 @@
|
||||
import React, { PropTypes } from 'react'
|
||||
import {Ico} from '../../components/ui'
|
||||
import {Table} from 'antd'
|
||||
import React from 'react'
|
||||
import { Ico } from '../../components/ui'
|
||||
import { Table } from 'antd'
|
||||
import styles from './ico.less'
|
||||
|
||||
const iconlist = ['Cherry','Cheese','Bread','Beer','Beet','Bacon','Banana','Asparagus','Apple']
|
||||
const iconlist = ['Cherry', 'Cheese', 'Bread', 'Beer', 'Beet', 'Bacon', 'Banana', 'Asparagus', 'Apple']
|
||||
|
||||
const IcoPage = () => <div className="content-inner">
|
||||
const IcoPage = () => <div className='content-inner'>
|
||||
<ul className={styles.list}>
|
||||
{iconlist.map ( item =><li key={item}><Ico className={styles.icon} type={item} /><span className={styles.name}>{item}</span></li>)}
|
||||
{iconlist.map(item => <li key={item}><Ico className={styles.icon} type={item} /><span className={styles.name}>{item}</span></li>)}
|
||||
</ul>
|
||||
<h2 style={{margin:'16px 0'}}>Props</h2>
|
||||
<Table rowKey={(record,key) => key}
|
||||
pagination={false}
|
||||
bordered
|
||||
columns={[
|
||||
{
|
||||
title: '参数',
|
||||
dataIndex: 'props',
|
||||
},
|
||||
{
|
||||
title: '说明',
|
||||
dataIndex: 'desciption',
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
dataIndex: 'type',
|
||||
},
|
||||
{
|
||||
title: '默认值',
|
||||
dataIndex: 'default',
|
||||
}
|
||||
]}
|
||||
dataSource={[
|
||||
{
|
||||
props:'type',
|
||||
desciption:'图标类型',
|
||||
type:'string',
|
||||
default:'-'
|
||||
}]} />
|
||||
<h2 style={{margin: '16px 0'}}>Props</h2>
|
||||
<Table rowKey={(record, key) => key}
|
||||
pagination={false}
|
||||
bordered
|
||||
columns={[
|
||||
{
|
||||
title: '参数',
|
||||
dataIndex: 'props'
|
||||
},
|
||||
{
|
||||
title: '说明',
|
||||
dataIndex: 'desciption'
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
dataIndex: 'type'
|
||||
},
|
||||
{
|
||||
title: '默认值',
|
||||
dataIndex: 'default'
|
||||
}
|
||||
]}
|
||||
dataSource={[
|
||||
{
|
||||
props: 'type',
|
||||
desciption: '图标类型',
|
||||
type: 'string',
|
||||
default: '-'
|
||||
}]} />
|
||||
</div>
|
||||
|
||||
export default IcoPage
|
||||
|
||||
+27
-31
@@ -5,85 +5,81 @@ import UserList from '../components/users/list'
|
||||
import UserSearch from '../components/users/search'
|
||||
import UserModal from '../components/users/modal'
|
||||
|
||||
function Users({ location, dispatch, users }) {
|
||||
const {
|
||||
loading, list, total, current, pagination,
|
||||
currentItem, modalVisible, modalType,
|
||||
} = users
|
||||
|
||||
function Users ({ location, dispatch, users }) {
|
||||
const { loading, list, pagination, currentItem, modalVisible, modalType } = users
|
||||
const { field, keyword } = location.query
|
||||
|
||||
const userModalProps = {
|
||||
item: modalType === 'create' ? {} : currentItem,
|
||||
type: modalType,
|
||||
visible: modalVisible,
|
||||
onOk(data) {
|
||||
onOk (data) {
|
||||
dispatch({
|
||||
type: `users/${modalType}`,
|
||||
payload: data,
|
||||
payload: data
|
||||
})
|
||||
},
|
||||
onCancel() {
|
||||
onCancel () {
|
||||
dispatch({
|
||||
type: 'users/hideModal',
|
||||
type: 'users/hideModal'
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const userListProps = {
|
||||
dataSource: list,
|
||||
loading,
|
||||
pagination:pagination,
|
||||
onPageChange(page) {
|
||||
pagination: pagination,
|
||||
onPageChange (page) {
|
||||
dispatch(routerRedux.push({
|
||||
pathname: '/users',
|
||||
query: {
|
||||
page:page.current,
|
||||
pageSize:page.pageSize
|
||||
},
|
||||
page: page.current,
|
||||
pageSize: page.pageSize
|
||||
}
|
||||
}))
|
||||
},
|
||||
onDeleteItem(id) {
|
||||
onDeleteItem (id) {
|
||||
dispatch({
|
||||
type: 'users/delete',
|
||||
payload: id,
|
||||
payload: id
|
||||
})
|
||||
},
|
||||
onEditItem(item) {
|
||||
onEditItem (item) {
|
||||
dispatch({
|
||||
type: 'users/showModal',
|
||||
payload: {
|
||||
modalType: 'update',
|
||||
currentItem: item,
|
||||
},
|
||||
currentItem: item
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const userSearchProps = {
|
||||
field,
|
||||
keyword,
|
||||
onSearch(fieldsValue) {
|
||||
onSearch (fieldsValue) {
|
||||
dispatch({
|
||||
type: 'users/query',
|
||||
payload: fieldsValue,
|
||||
payload: fieldsValue
|
||||
})
|
||||
},
|
||||
onAdd() {
|
||||
onAdd () {
|
||||
dispatch({
|
||||
type: 'users/showModal',
|
||||
payload: {
|
||||
modalType: 'create',
|
||||
},
|
||||
modalType: 'create'
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const UserModalGen = () =>
|
||||
<UserModal {...userModalProps} />
|
||||
|
||||
return (
|
||||
<div className="content-inner">
|
||||
<div className='content-inner'>
|
||||
<UserSearch {...userSearchProps} />
|
||||
<UserList {...userListProps} />
|
||||
<UserModalGen />
|
||||
@@ -94,10 +90,10 @@ function Users({ location, dispatch, users }) {
|
||||
Users.propTypes = {
|
||||
users: PropTypes.object,
|
||||
location: PropTypes.object,
|
||||
dispatch: PropTypes.func,
|
||||
dispatch: PropTypes.func
|
||||
}
|
||||
|
||||
function mapStateToProps({ users }) {
|
||||
function mapStateToProps ({ users }) {
|
||||
return { users }
|
||||
}
|
||||
|
||||
|
||||
+6
-7
@@ -1,23 +1,22 @@
|
||||
import { request } from '../utils'
|
||||
import qs from 'qs'
|
||||
|
||||
export async function login(params) {
|
||||
export async function login (params) {
|
||||
return request('/api/login', {
|
||||
method: 'post',
|
||||
data:params,
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
export async function logout(params) {
|
||||
export async function logout (params) {
|
||||
return request('/api/logout', {
|
||||
method: 'post',
|
||||
data:params,
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
export async function userInfo(params) {
|
||||
export async function userInfo (params) {
|
||||
return request('/api/userInfo', {
|
||||
method: 'get',
|
||||
data:params,
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
import { request } from '../utils'
|
||||
import qs from 'qs'
|
||||
|
||||
export async function myCity(params) {
|
||||
export async function myCity (params) {
|
||||
return request('http://www.zuimeitianqi.com/zuimei/myCity', {
|
||||
method: 'get',
|
||||
cross:true,
|
||||
data:params,
|
||||
cross: true,
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
export async function queryWeather(params) {
|
||||
export async function queryWeather (params) {
|
||||
return request('http://www.zuimeitianqi.com/zuimei/queryWeather', {
|
||||
method: 'get',
|
||||
cross:true,
|
||||
data:params,
|
||||
cross: true,
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
export async function query(params) {
|
||||
export async function query (params) {
|
||||
return request('/api/dashboard', {
|
||||
method: 'get',
|
||||
data:params,
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,30 +1,29 @@
|
||||
import { request } from '../utils'
|
||||
import qs from 'qs'
|
||||
|
||||
export async function query(params) {
|
||||
export async function query (params) {
|
||||
return request('/api/users', {
|
||||
method: 'get',
|
||||
data:params,
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
export async function create(params) {
|
||||
export async function create (params) {
|
||||
return request('/api/users', {
|
||||
method: 'post',
|
||||
data:params,
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
export async function remove(params) {
|
||||
export async function remove (params) {
|
||||
return request('/api/users', {
|
||||
method: 'delete',
|
||||
data:params,
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
export async function update(params) {
|
||||
export async function update (params) {
|
||||
return request('/api/users', {
|
||||
method: 'put',
|
||||
data: params,
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,11 +1 @@
|
||||
import expect from 'expect';
|
||||
import example from '../../models/example';
|
||||
|
||||
describe('example', () => {
|
||||
|
||||
describe('reducer', () => {
|
||||
it('it should save', () => {
|
||||
expect(example.reducers['example/save']({}, { payload: { a: 1 }})).toEqual({ a: 1 });
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
+5
-5
@@ -4,8 +4,8 @@ module.exports = () => {
|
||||
'@border-radius-sm': '2px',
|
||||
'@shadow-color': 'rgba(0,0,0,0.05)',
|
||||
'@shadow-1-down': '4px 4px 40px @shadow-color',
|
||||
'@border-color-split':'#f4f4f4',
|
||||
'@border-color-base':'#e5e5e5',
|
||||
'@font-family':'monospace,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", SimSun, sans-serif'
|
||||
};
|
||||
};
|
||||
'@border-color-split': '#f4f4f4',
|
||||
'@border-color-base': '#e5e5e5',
|
||||
'@font-family': 'monospace,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", SimSun, sans-serif'
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
module.exports = {
|
||||
name: 'Ant Design Admin',
|
||||
prefix:'antdAdmin',
|
||||
prefix: 'antdAdmin',
|
||||
footerText: 'Ant Design Admin 版权所有 © 2016 由 zuiidea 支持',
|
||||
logoSrc:'https://t.alipayobjects.com/images/rmsweb/T1B9hfXcdvXXXXXXXX.svg',
|
||||
logoText:'Antd Admin',
|
||||
needLogin:true,
|
||||
};
|
||||
logoSrc: 'https://t.alipayobjects.com/images/rmsweb/T1B9hfXcdvXXXXXXXX.svg',
|
||||
logoText: 'Antd Admin',
|
||||
needLogin: true
|
||||
}
|
||||
|
||||
+15
-14
@@ -15,28 +15,29 @@ String.prototype.hyphenToHump = function () {
|
||||
|
||||
// 驼峰转连字符
|
||||
String.prototype.humpToHyphen = function () {
|
||||
return this.replace(/([A-Z])/g, "-$1").toLowerCase()
|
||||
return this.replace(/([A-Z])/g, '-$1').toLowerCase()
|
||||
}
|
||||
|
||||
// 日期格式化
|
||||
Date.prototype.format = function (format) {
|
||||
var o = {
|
||||
"M+": this.getMonth() + 1,
|
||||
"d+": this.getDate(),
|
||||
"h+": this.getHours(),
|
||||
'M+': this.getMonth() + 1,
|
||||
'd+': this.getDate(),
|
||||
'h+': this.getHours(),
|
||||
'H+': this.getHours(),
|
||||
"m+": this.getMinutes(),
|
||||
"s+": this.getSeconds(),
|
||||
"q+": Math.floor((this.getMonth() + 3) / 3),
|
||||
"S": this.getMilliseconds()
|
||||
'm+': this.getMinutes(),
|
||||
's+': this.getSeconds(),
|
||||
'q+': Math.floor((this.getMonth() + 3) / 3),
|
||||
'S': this.getMilliseconds()
|
||||
}
|
||||
if (/(y+)/.test(format))
|
||||
format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length))
|
||||
for (var k in o)
|
||||
if (new RegExp("(" + k + ")").test(format))
|
||||
format = format.replace(RegExp.$1, RegExp.$1.length == 1
|
||||
if (/(y+)/.test(format)) { format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)) }
|
||||
for (var k in o) {
|
||||
if (new RegExp('(' + k + ')').test(format)) {
|
||||
format = format.replace(RegExp.$1, RegExp.$1.length === 1
|
||||
? o[k]
|
||||
: ("00" + o[k]).substr(("" + o[k]).length))
|
||||
: ('00' + o[k]).substr(('' + o[k]).length))
|
||||
}
|
||||
}
|
||||
return format
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -7,18 +7,18 @@ module.exports = [
|
||||
{
|
||||
key: 'users',
|
||||
name: '用户管理',
|
||||
icon: 'user',
|
||||
icon: 'user'
|
||||
},
|
||||
{
|
||||
key: 'ui',
|
||||
name: 'UI组件',
|
||||
icon: 'camera-o',
|
||||
clickable:false,
|
||||
child:[
|
||||
clickable: false,
|
||||
child: [
|
||||
{
|
||||
key: 'ico',
|
||||
name: '业务图标',
|
||||
},
|
||||
name: '业务图标'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -28,7 +28,7 @@ module.exports = [
|
||||
child: [
|
||||
{
|
||||
key: 'navigation1',
|
||||
name: '二级导航1',
|
||||
name: '二级导航1'
|
||||
},
|
||||
{
|
||||
key: 'navigation2',
|
||||
@@ -36,14 +36,14 @@ module.exports = [
|
||||
child: [
|
||||
{
|
||||
key: 'navigation21',
|
||||
name: '三级导航1',
|
||||
name: '三级导航1'
|
||||
},
|
||||
{
|
||||
key: 'navigation22',
|
||||
name: '三级导航2',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
name: '三级导航2'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
+9
-9
@@ -1,22 +1,22 @@
|
||||
const Mock = require('mockjs')
|
||||
const mockData = [require("../../mock/users"), require("../../mock/app"), require("../../mock/dashboard")]
|
||||
const mockData = [require('../../mock/users'), require('../../mock/app'), require('../../mock/dashboard')]
|
||||
|
||||
function serialize(str) {
|
||||
let paramArray = str.split("&")
|
||||
function serialize (str) {
|
||||
let paramArray = str.split('&')
|
||||
let query = {}
|
||||
for (let i in paramArray) {
|
||||
query[paramArray[i].split("=")[0]] = paramArray[i].split("=")[1]
|
||||
query[paramArray[i].split('=')[0]] = paramArray[i].split('=')[1]
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
for (let i in mockData) {
|
||||
for (let key in mockData[i]) {
|
||||
Mock.mock(eval("/" + key.split(" ")[1].replace(/\//g, "\\\/") + "/"), key.split(" ")[0].toLowerCase(), function (options) {
|
||||
if (key.split(" ")[0].toLowerCase() == 'get') {
|
||||
options.query = !!options.url.split("?")[1]
|
||||
? serialize(options.url.split("?")[1])
|
||||
: (!!options.body
|
||||
Mock.mock(eval('/' + key.split(' ')[1].replace(/\//g, '\\\/') + '/'), key.split(' ')[0].toLowerCase(), function (options) {
|
||||
if (key.split(' ')[0].toLowerCase() == 'get') {
|
||||
options.query = options.url.split('?')[1]
|
||||
? serialize(options.url.split('?')[1])
|
||||
: (options.body
|
||||
? serialize(options.body)
|
||||
: {})
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
const Mock = require('mockjs')
|
||||
const Watch = require("watchjs")
|
||||
const Watch = require('watchjs')
|
||||
import config from './config'
|
||||
|
||||
export default function mockStorge(name, defaultValue) {
|
||||
export default function mockStorge (name, defaultValue) {
|
||||
let key = config.prefix + name
|
||||
global[key] = localStorage.getItem(key)
|
||||
? JSON.parse(localStorage.getItem(key))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const Ajax = require("robe-ajax")
|
||||
const Ajax = require('robe-ajax')
|
||||
|
||||
/**
|
||||
* Requests a URL, returning a promise.
|
||||
@@ -7,20 +7,18 @@ const Ajax = require("robe-ajax")
|
||||
* @param {object} [options] The options we want to pass to "fetch"
|
||||
* @return {object} An object containing either "data" or "err"
|
||||
*/
|
||||
export default function request(url, options) {
|
||||
export default function request (url, options) {
|
||||
if (options.cross) {
|
||||
return Ajax.getJSON("http://query.yahooapis.com/v1/public/yql", {
|
||||
q: "select * from json where url=\'"+url+"?"+Ajax.param(options.data)+"\'",
|
||||
format: "json"
|
||||
return Ajax.getJSON('http://query.yahooapis.com/v1/public/yql', {
|
||||
q: "select * from json where url='" + url + '?' + Ajax.param(options.data) + "'",
|
||||
format: 'json'
|
||||
})
|
||||
} else {
|
||||
return Ajax.ajax({
|
||||
url: url,
|
||||
method: options.method || 'get',
|
||||
data: options.data || {},
|
||||
processData: options.method == 'get'
|
||||
? true
|
||||
: false,
|
||||
processData: options.method === 'get',
|
||||
dataType: 'JSON'
|
||||
}).done((data) => {
|
||||
return data
|
||||
|
||||
+12
-12
@@ -1,14 +1,14 @@
|
||||
module.exports = {
|
||||
color:{
|
||||
green:'#64ea91',
|
||||
blue:'#8fc9fb',
|
||||
purple:'#d897eb',
|
||||
red:'#f69899',
|
||||
yellow:'#f8c82e',
|
||||
peach:'#f797d6',
|
||||
borderBase:'#e5e5e5',
|
||||
borderSplit:'#f4f4f4',
|
||||
grass:"#d6fbb5",
|
||||
sky:'#c1e0fc'
|
||||
color: {
|
||||
green: '#64ea91',
|
||||
blue: '#8fc9fb',
|
||||
purple: '#d897eb',
|
||||
red: '#f69899',
|
||||
yellow: '#f8c82e',
|
||||
peach: '#f797d6',
|
||||
borderBase: '#e5e5e5',
|
||||
borderSplit: '#f4f4f4',
|
||||
grass: '#d6fbb5',
|
||||
sky: '#c1e0fc'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user