Commit c589b9f6 authored by nano's avatar nano

init

parent 91e80f3a
This diff is collapsed.
...@@ -35,9 +35,6 @@ export default { ...@@ -35,9 +35,6 @@ export default {
subscriptions: { subscriptions: {
setup({dispatch, history}) { setup({dispatch, history}) {
if (location.pathname != '/loginCallback') {
dispatch({type: 'init'})
}
return history.listen(({pathname, query}) => { return history.listen(({pathname, query}) => {
if (pathname === '/login') { if (pathname === '/login') {
let params = new URLSearchParams() let params = new URLSearchParams()
......
import React from 'react'; import React from "react";
import { connect } from 'dva'; import {connect} from "dva";
import styles from './Apps.less'; import styles from "./Apps.less";
import { Link } from 'dva/router'; import {Link} from "dva/router";
import { Button, Affix, Icon, Table, Tag } from 'antd' import {Affix, Button, Icon, Table} from "antd";
import Create from '../components/App/Create' import Create from "../components/App/Create";
const columns = [ const columns = [
...@@ -18,20 +18,20 @@ const columns = [ ...@@ -18,20 +18,20 @@ const columns = [
dataIndex: 'name', dataIndex: 'name',
render: name => name && name["zh-CN"], render: name => name && name["zh-CN"],
width: '10%', width: '10%',
},{ }, {
title: "author", title: "author",
dataIndex: 'author', dataIndex: 'author',
width: '10%', width: '10%',
},{ }, {
title: "category", title: "category",
dataIndex: 'category', dataIndex: 'category',
width: '10%', width: '10%',
},{ }, {
title: "homepage", title: "homepage",
dataIndex: 'homepage', dataIndex: 'homepage',
render: homepage => <a href={homepage} target="_blank">{homepage}</a>, render: homepage => <a href={homepage} target="_blank">{homepage}</a>,
width: '10%', width: '10%',
},{ }, {
title: "released_at", title: "released_at",
dataIndex: 'released_at', dataIndex: 'released_at',
sorter: true, sorter: true,
...@@ -44,50 +44,59 @@ const columns = [ ...@@ -44,50 +44,59 @@ const columns = [
}, },
] ]
function Apps({children, dispatch, isCreate, isSubmit, apps}) { class Apps extends React.Component {
const CreateProps = { componentWillMount() {
visible: isCreate, const {dispatch} = this.props
isLoading: isSubmit, console.log(this.props)
onCancel: () => dispatch({ type: 'App/onCancel'}),
onCreate: () => dispatch({ type: 'App/onCreate'}),
onSubmit: (payload) => dispatch({ type: 'App/create', payload}),
} }
const CreateButtonProps = { render() {
onClick: () => dispatch({ type: 'App/onCreate'}), const {children, dispatch, isCreate, isSubmit, apps} = this.props
className: styles.CreateBtn,
shape: "circle",
type: "primary",
size: "large",
}
const TableProps = { const CreateProps = {
rowKey: row => row.id, visible: isCreate,
columns, isLoading: isSubmit,
dataSource: Object.values(apps) onCancel: () => dispatch({type: 'App/onCancel'}),
} onCreate: () => dispatch({type: 'App/onCreate'}),
onSubmit: (payload) => dispatch({type: 'App/create', payload}),
}
const CreateButtonProps = {
onClick: () => dispatch({type: 'App/onCreate'}),
className: styles.CreateBtn,
shape: "circle",
type: "primary",
size: "large",
}
return ( const TableProps = {
<div className={styles.normal}> rowKey: row => row.id,
columns,
dataSource: Object.values(apps)
}
<Table {...TableProps}/> return (
<div className={styles.normal}>
<Affix style={{ position: 'absolute', bottom: 50, right: 50}}> <Table {...TableProps}/>
<Button {...CreateButtonProps} >
<Icon type="plus" />
</Button>
</Affix>
<Create {...CreateProps}/> <Affix style={{position: 'absolute', bottom: 50, right: 50}}>
</div> <Button {...CreateButtonProps} >
); <Icon type="plus"/>
</Button>
</Affix>
<Create {...CreateProps}/>
</div>
);
}
} }
function mapStateToProps(state) { function mapStateToProps(state) {
const { const {
Apps: { apps }, Apps: {apps},
App: { isCreate, isSubmit }, App: {isCreate, isSubmit},
} = state } = state
return { return {
apps, apps,
......
import React from 'react'; import React from "react";
import { connect } from 'dva'; import {connect} from "dva";
import Nav from '../components/Common/Nav' import Nav from "../components/Common/Nav";
import {Layout} from 'antd' import {Layout} from "antd";
function Entry({ children}) { class Entry extends React.Component {
return (
<Layout style={{ flexDirection: 'row', minHeight: '100%'}}> componentWillMount() {
<Nav /> const {dispatch, location:{pathname}} = this.props
<Layout style={{ minHeight: '400px'}}> if(pathname !== 'loginCallback') {
{children} dispatch({type: 'Common/init'})
}
}
render() {
const {children} = this.props
return (
<Layout style={{flexDirection: 'row', minHeight: '100%'}}>
<Nav />
<Layout style={{minHeight: '400px'}}>
{children}
</Layout>
</Layout> </Layout>
</Layout> );
); }
} }
function mapStateToProps(state) { function mapStateToProps(state) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment