opti: 优化首页交互

This commit is contained in:
suwenxiong 2019-01-08 14:55:12 +08:00
parent 620be327e8
commit 93341d9d58
4 changed files with 53 additions and 5 deletions

View File

@ -7,11 +7,16 @@ import GroupSetting from './GroupSetting/GroupSetting.js';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Route, Switch, Redirect } from 'react-router-dom';
import { Tabs, Layout } from 'antd';
import { Tabs, Layout, Spin } from 'antd';
const { Content, Sider } = Layout;
const TabPane = Tabs.TabPane;
import { fetchNewsData } from '../../reducer/modules/news.js';
import {
setCurrGroup
} from '../../reducer/modules/group';
import './Group.scss';
import axios from 'axios'
@connect(
state => {
return {
@ -22,19 +27,39 @@ import './Group.scss';
};
},
{
fetchNewsData: fetchNewsData
fetchNewsData: fetchNewsData,
setCurrGroup
}
)
export default class Group extends Component {
constructor(props) {
super(props);
this.state = {
groupId: -1
}
}
async componentDidMount(){
let r = await axios.get('/api/group/get_mygroup')
try{
let group = r.data.data;
this.setState({
groupId: group._id
})
this.props.setCurrGroup(group)
}catch(e){
console.error(e)
}
}
static propTypes = {
fetchNewsData: PropTypes.func,
curGroupId: PropTypes.number,
curUserRole: PropTypes.string,
currGroup: PropTypes.object,
curUserRoleInGroup: PropTypes.string
curUserRoleInGroup: PropTypes.string,
setCurrGroup: PropTypes.func
};
// onTabClick=(key)=> {
// // if (key == 3) {
@ -42,6 +67,7 @@ export default class Group extends Component {
// // }
// }
render() {
if(this.state.groupId === -1)return <Spin />
const GroupContent = (
<Layout style={{ minHeight: 'calc(100vh - 100px)', marginLeft: '24px', marginTop: '24px' }}>
<Sider style={{ height: '100%' }} width={300}>
@ -88,7 +114,7 @@ export default class Group extends Component {
return (
<div className="projectGround">
<Switch>
<Redirect exact from="/group" to="/group/0" />
<Redirect exact from="/group" to={"/group/" + this.state.groupId} />
<Route path="/group/:groupId" render={() => GroupContent} />
</Switch>
</div>

View File

@ -1,7 +1,7 @@
import React, { PureComponent as Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Icon, Modal, Input, message, Row, Menu, Col, Popover, Tooltip } from 'antd';
import { Icon, Modal, Input, message,Spin, Row, Menu, Col, Popover, Tooltip } from 'antd';
import { autobind } from 'core-decorators';
import axios from 'axios';
import { withRouter } from 'react-router-dom';
@ -240,6 +240,11 @@ export default class GroupList extends Component {
/>
</div>
</div>
{this.state.groupList.length === 0 && <Spin style={{
marginTop: 20,
display: 'flex',
justifyContent: 'center'
}} />}
<Menu
className="group-list"
mode="inline"

View File

@ -211,6 +211,16 @@ class groupController extends baseController {
};
}
async getMyGroup(ctx){
var groupInst = yapi.getInst(groupModel);
let privateGroup = await groupInst.getByPrivateUid(this.getUid());
if(privateGroup){
ctx.body = yapi.commons.resReturn(privateGroup)
}else{
ctx.body = yapi.commons.resReturn(null)
}
}
/**
* 添加项目分组成员
* @interface /group/add_member

View File

@ -55,6 +55,13 @@ let INTERFACE_CONFIG = {
let routerConfig = {
group: [
{
action: 'getMyGroup',
path: 'get_mygroup',
method: 'get'
},
{
action: 'list',
path: 'list',