mirror of
https://github.com/YMFE/yapi.git
synced 2025-03-07 14:16:52 +08:00
Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev
This commit is contained in:
commit
0665bdadfb
@ -1,6 +1,7 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true,
|
||||
"commonjs": true
|
||||
},
|
||||
"extends": [],
|
||||
|
@ -2,10 +2,12 @@ import LoginRedux from './reducer/Login/Login_redux.js'
|
||||
import login from './reducer/Login/login.js'
|
||||
import group from './reducer/group/group.js'
|
||||
import Interface from './reducer/Interface/InterfaceReducer.js'
|
||||
import news from './reducer/news/news.js'
|
||||
|
||||
export default {
|
||||
group,
|
||||
login,
|
||||
LoginRedux,
|
||||
Interface
|
||||
Interface,
|
||||
news
|
||||
}
|
||||
|
@ -1,29 +1,20 @@
|
||||
import {
|
||||
FETCH_GROUP_LIST,
|
||||
FETCH_CURR_GROUP
|
||||
SET_CURR_GROUP
|
||||
} from '../constants/action-types';
|
||||
import axios from 'axios';
|
||||
|
||||
export function fetchGroupList() {
|
||||
return {
|
||||
type: FETCH_GROUP_LIST,
|
||||
// payload 可以返回 Promise,异步请求使用 axios 即可
|
||||
payload: axios.get('/group/list')
|
||||
// payload: new Promise((resolve) => {
|
||||
// resolve({
|
||||
// data: ['Hotel', 'Vacation', 'Flight', 'Pay'],
|
||||
// res: true
|
||||
// })
|
||||
// })
|
||||
}
|
||||
}
|
||||
|
||||
export function fetchCurrGroup() {
|
||||
export function setCurrGroup(group) {
|
||||
return {
|
||||
type: FETCH_CURR_GROUP,
|
||||
payload: {
|
||||
data: 'MFE'
|
||||
}
|
||||
type: SET_CURR_GROUP,
|
||||
payload: group
|
||||
}
|
||||
}
|
||||
|
||||
|
66
client/actions/news.js
Normal file
66
client/actions/news.js
Normal file
@ -0,0 +1,66 @@
|
||||
import {
|
||||
FETCH_NEWS_DATA
|
||||
} from '../constants/action-types.js';
|
||||
|
||||
export function fetchNewsData () {
|
||||
const data = [{
|
||||
name: 'John Brown',
|
||||
date: '2015-11-11 13:00:15',
|
||||
desc: '创建服务现场'
|
||||
}, {
|
||||
name: 'John Brown1',
|
||||
date: '2015-11-11 13:00:15',
|
||||
desc: '技术测试异常'
|
||||
}, {
|
||||
name: 'John Brown2',
|
||||
date: '2015-11-11 13:00:15',
|
||||
desc: '网络异常正在修复'
|
||||
}]
|
||||
|
||||
return {
|
||||
type: FETCH_NEWS_DATA,
|
||||
payload: data
|
||||
};
|
||||
}
|
||||
|
||||
export function fetchViewedNews () {
|
||||
const data = [{
|
||||
name: 'John Brown21',
|
||||
date: '2015-11-11 13:00:15',
|
||||
desc: '创建服务现场'
|
||||
}, {
|
||||
name: 'John Brown12',
|
||||
date: '2015-11-11 13:00:15',
|
||||
desc: '技术测试异常'
|
||||
}, {
|
||||
name: 'John Brown22',
|
||||
date: '2015-11-11 13:00:15',
|
||||
desc: '网络异常正在修复'
|
||||
}]
|
||||
|
||||
return {
|
||||
type: FETCH_NEWS_DATA,
|
||||
payload: data
|
||||
}
|
||||
}
|
||||
|
||||
export function fetchNotVieweNews () {
|
||||
const data = [{
|
||||
name: 'John Brown22',
|
||||
date: '2015-11-11 13:00:15',
|
||||
desc: '创建服务现场'
|
||||
}, {
|
||||
name: 'John Brown12',
|
||||
date: '2015-11-11 13:00:15',
|
||||
desc: '技术测试异常'
|
||||
}, {
|
||||
name: 'John Brown22',
|
||||
date: '2015-11-11 13:00:15',
|
||||
desc: '网络异常正在修复'
|
||||
}]
|
||||
|
||||
return {
|
||||
type: FETCH_NEWS_DATA,
|
||||
payload: data
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ export const PROJECT_MEMBER_INTERFACE = 'PROJECT_MEMBER_INTERFACE'
|
||||
|
||||
// group
|
||||
export const FETCH_GROUP_LIST = 'FETCH_GROUP_LIST'
|
||||
export const FETCH_CURR_GROUP = 'FETCH_CURR_GROUP'
|
||||
export const SET_CURR_GROUP = 'SET_CURR_GROUP'
|
||||
|
||||
// project
|
||||
export const PROJECT_ADD = 'PROJECT_ADD'
|
||||
@ -16,3 +16,7 @@ export const REGISTER = 'REGISTER';
|
||||
|
||||
//header
|
||||
export const LOGIN_TYPE = 'LOGIN_TYPE';
|
||||
|
||||
// News
|
||||
export const FETCH_NEWS_DATA = 'FETCH_NEWS_DATA'
|
||||
|
||||
|
43
client/containers/News/News.js
Normal file
43
client/containers/News/News.js
Normal file
@ -0,0 +1,43 @@
|
||||
import './News.scss'
|
||||
import React, { Component } from 'react'
|
||||
import NewsTimeline from './NewsTimeline/NewsTimeline'
|
||||
import { connect } from 'react-redux'
|
||||
import PropTypes from 'prop-types'
|
||||
import NewsList from './NewsList/NewsList.js'
|
||||
import { fetchNewsData } from '../../actions/news.js'
|
||||
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
newsData: state.news.newsData?state.news.newsData:[]
|
||||
}
|
||||
},
|
||||
{
|
||||
fetchNewsData: fetchNewsData
|
||||
}
|
||||
)
|
||||
|
||||
class News extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
}
|
||||
static propTypes = {
|
||||
newsData: PropTypes.array,
|
||||
fetchNewsData: PropTypes.func
|
||||
}
|
||||
componentWillMount(){
|
||||
this.props.fetchNewsData()
|
||||
}
|
||||
render () {
|
||||
const data = this.props.newsData
|
||||
return (
|
||||
<section className="news-box">
|
||||
<NewsList />
|
||||
<NewsTimeline data = {data} />
|
||||
</section>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default News
|
81
client/containers/News/News.scss
Normal file
81
client/containers/News/News.scss
Normal file
@ -0,0 +1,81 @@
|
||||
/* .interface-box.css */
|
||||
.news-box {
|
||||
max-width: 11rem;
|
||||
display: -webkit-box;
|
||||
-webkit-box-flex: 1;
|
||||
margin: 15px auto 0 auto;
|
||||
font-size: 0.14rem;
|
||||
background: #FFF;
|
||||
|
||||
.news-list {
|
||||
width: 216px;
|
||||
line-height: 45px;
|
||||
background: #f9fafe;
|
||||
|
||||
li {
|
||||
padding: 0 0 0 30px;
|
||||
color: #344562;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover, &.active {
|
||||
background: #657289;
|
||||
color: #FFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.news-timeline{
|
||||
margin-left: 30px;
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.ant-timeline-item-content{
|
||||
background-color: #ececec;
|
||||
margin-left: 30px;
|
||||
border-radius: 4px;
|
||||
border-left:4px solid #ececec;
|
||||
min-width: 350px;
|
||||
max-width: 450px;
|
||||
padding: 10px;
|
||||
|
||||
.timelineDate{
|
||||
display: block;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.timelineName{
|
||||
float: right;
|
||||
}
|
||||
|
||||
p{
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div{
|
||||
overflow: hidden
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.ant-timeline-item-content:before{
|
||||
content:'';
|
||||
display: block;
|
||||
margin-left: -40px;
|
||||
width: 0px;
|
||||
height: 0px;
|
||||
float: left;
|
||||
border-width: 10px 13px;
|
||||
border-style: solid;
|
||||
border-color: transparent #ececec transparent transparent;
|
||||
}
|
||||
|
||||
.ant-timeline-item-tail{
|
||||
top: 16px;
|
||||
}
|
||||
|
||||
.ant-timeline-item-head{
|
||||
margin-top: 10px;
|
||||
}
|
77
client/containers/News/NewsList/NewsList.js
Normal file
77
client/containers/News/NewsList/NewsList.js
Normal file
@ -0,0 +1,77 @@
|
||||
import React, { Component } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import PropTypes from 'prop-types'
|
||||
import {
|
||||
fetchNewsData,
|
||||
fetchViewedNews,
|
||||
fetchNotVieweNews } from '../../../actions/news.js'
|
||||
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
newsData: state.news.newsData
|
||||
}
|
||||
},
|
||||
{
|
||||
fetchNewsData,
|
||||
fetchViewedNews,
|
||||
fetchNotVieweNews
|
||||
}
|
||||
)
|
||||
|
||||
class NewsList extends Component {
|
||||
|
||||
static propTypes = {
|
||||
fetchNewsData: PropTypes.func,
|
||||
fetchViewedNews: PropTypes.func,
|
||||
fetchNotVieweNews: PropTypes.func
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
}
|
||||
|
||||
|
||||
|
||||
fetchData(e){
|
||||
const mark = e.target.className;
|
||||
if(mark.indexOf('allnews')>-1){
|
||||
this.props.fetchNewsData()
|
||||
this.switchColor(mark.indexOf('allnews'),e.target)
|
||||
}else if(mark.indexOf('viewednews')>-1){
|
||||
this.props.fetchViewedNews();
|
||||
this.switchColor(mark.indexOf('viewednews'),e.target)
|
||||
}else if(mark.indexOf('notview')>-1){
|
||||
this.props.fetchNotVieweNews();
|
||||
this.switchColor(mark.indexOf('notview'),e.target)
|
||||
}
|
||||
|
||||
}
|
||||
switchColor(index,e){
|
||||
let childNodes = e.parentNode.childNodes;
|
||||
if(e.className.indexOf('active')> -1) return;
|
||||
for(let j = 0;j<childNodes.length;j++){
|
||||
const i = childNodes[j].className.indexOf('active');
|
||||
if(i> -1){
|
||||
// console.log( childNodes[i].className.splice);
|
||||
let className = childNodes[j].className;
|
||||
className = className.split('');
|
||||
className.splice(i,6);
|
||||
childNodes[j].className = className.join('');
|
||||
}
|
||||
}
|
||||
e.className = e.className + ' active';
|
||||
}
|
||||
render () {
|
||||
return (
|
||||
<ul onClick = {this.fetchData.bind(this)} className="news-list">
|
||||
<li className="active allnews">全部消息</li>
|
||||
<li className='viewednews'>已读消息</li>
|
||||
<li className='notview'>未读消息</li>
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default NewsList
|
38
client/containers/News/NewsTimeline/NewsTimeline.js
Normal file
38
client/containers/News/NewsTimeline/NewsTimeline.js
Normal file
@ -0,0 +1,38 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Timeline } from 'antd'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
class NewsTimeline extends Component {
|
||||
static propTypes = {
|
||||
data: PropTypes.array
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render () {
|
||||
const data = this.props.data;
|
||||
return (
|
||||
<section className="news-timeline">
|
||||
<Timeline pending={<a href="#">See more</a>}>
|
||||
{
|
||||
data.map(function(item,i){
|
||||
return (
|
||||
<Timeline.Item color = 'green' key = {i} >
|
||||
<div>
|
||||
<span className='timelineDate'>{item.date}</span>
|
||||
<span className='timelineName'>{item.name}</span>
|
||||
</div>
|
||||
<p>{item.desc}</p>
|
||||
</Timeline.Item>
|
||||
)
|
||||
})
|
||||
}
|
||||
</Timeline>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default NewsTimeline
|
@ -6,7 +6,7 @@ import { autobind } from 'core-decorators';
|
||||
|
||||
import {
|
||||
fetchGroupList,
|
||||
fetchCurrGroup,
|
||||
setCurrGroup,
|
||||
addGroup
|
||||
} from '../../../actions/group.js'
|
||||
|
||||
@ -19,7 +19,7 @@ import './GroupList.scss'
|
||||
}),
|
||||
{
|
||||
fetchGroupList,
|
||||
fetchCurrGroup,
|
||||
setCurrGroup,
|
||||
addGroup
|
||||
}
|
||||
)
|
||||
@ -27,9 +27,10 @@ export default class GroupList extends Component {
|
||||
|
||||
static propTypes = {
|
||||
groupList: PropTypes.array,
|
||||
currGroup: PropTypes.string,
|
||||
currGroup: PropTypes.object,
|
||||
addGroup: PropTypes.func,
|
||||
fetchGroupList: PropTypes.func
|
||||
fetchGroupList: PropTypes.func,
|
||||
setCurrGroup: PropTypes.func
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
@ -37,7 +38,10 @@ export default class GroupList extends Component {
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.props.fetchGroupList();
|
||||
this.props.fetchGroupList().then(() => {
|
||||
const currGroup = this.props.groupList[0] || { group_name: '' };
|
||||
this.props.setCurrGroup(currGroup)
|
||||
});
|
||||
}
|
||||
|
||||
@autobind
|
||||
@ -51,7 +55,7 @@ export default class GroupList extends Component {
|
||||
return (
|
||||
<Card title="Groups">
|
||||
<Button type="primary" onClick={this.addGroup}>添加分组</Button>
|
||||
<div>{currGroup}</div>
|
||||
<div>{currGroup.group_name}</div>
|
||||
{
|
||||
groupList.map((group, index) => (
|
||||
<div key={index}>{group.group_name}</div>
|
||||
|
54
client/containers/User/InterfaceTable/InterfaceTable.js
Normal file
54
client/containers/User/InterfaceTable/InterfaceTable.js
Normal file
@ -0,0 +1,54 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Table, Button } from 'antd'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
class InterfaceTable extends Component {
|
||||
static propTypes = {
|
||||
data: PropTypes.array
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
}
|
||||
|
||||
render () {
|
||||
const columns = [{
|
||||
title: '接口名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name'
|
||||
}, {
|
||||
title: '接口URL',
|
||||
dataIndex: 'age',
|
||||
key: 'age'
|
||||
}, {
|
||||
title: '操作者',
|
||||
dataIndex: 'address',
|
||||
key: 'address'
|
||||
}, {
|
||||
title: '更新日期',
|
||||
dataIndex: 'date',
|
||||
key: 'date'
|
||||
}, {
|
||||
title: '功能',
|
||||
'key': 'action',
|
||||
render: () => {
|
||||
return (
|
||||
<span>
|
||||
<Button type="primary">编辑</Button>
|
||||
<Button type="danger">删除</Button>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
}]
|
||||
|
||||
const data = this.props.data;
|
||||
|
||||
return (
|
||||
<section className="interface-table">
|
||||
<Table columns={columns} dataSource={data} />
|
||||
</section>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default InterfaceTable
|
62
client/containers/User/LeftMenu.js
Normal file
62
client/containers/User/LeftMenu.js
Normal file
@ -0,0 +1,62 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import {Input, Row, Col} from 'antd'
|
||||
|
||||
class LeftMenu extends Component {
|
||||
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
curitem: 'profile'
|
||||
}
|
||||
console.log(this.props)
|
||||
}
|
||||
|
||||
handleCurItem(curitem) {
|
||||
return () => {
|
||||
this.setState({
|
||||
curitem: curitem
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const menus = [{
|
||||
title: '个人资料',
|
||||
path: '/user/profile'
|
||||
}, {
|
||||
title: '用户管理',
|
||||
path: '/user/list'
|
||||
}
|
||||
]
|
||||
|
||||
let content = menus.map((menu, index) => {
|
||||
return (
|
||||
<li key={index} className={location.hash === '#' + menu.path ? 'active' : ''}>
|
||||
<Link to={menu.path} >{menu.title}</Link>
|
||||
</li>
|
||||
)
|
||||
})
|
||||
|
||||
const Search = Input.Search;
|
||||
|
||||
return (<div>
|
||||
<Row type="flex" justify="start" className="search">
|
||||
<Col span="24">
|
||||
<Search
|
||||
placeholder="搜索用户"
|
||||
onSearch={value => console.log(value)}
|
||||
/>
|
||||
</Col>
|
||||
|
||||
</Row>
|
||||
<ul className="user-list">
|
||||
{content}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default LeftMenu
|
64
client/containers/User/List.js
Executable file
64
client/containers/User/List.js
Executable file
@ -0,0 +1,64 @@
|
||||
import React, { Component } from 'react'
|
||||
//import PropTypes from 'prop-types'
|
||||
import {
|
||||
Table,
|
||||
Button
|
||||
} from 'antd'
|
||||
|
||||
|
||||
|
||||
class List extends Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
const columns = [{
|
||||
title: 'UID',
|
||||
dataIndex: 'uid',
|
||||
key: 'uid'
|
||||
}, {
|
||||
title: '用户名',
|
||||
dataIndex: 'username',
|
||||
key: 'username'
|
||||
}, {
|
||||
title: 'email',
|
||||
dataIndex: 'email',
|
||||
key: 'email'
|
||||
}, {
|
||||
title: '更新日期',
|
||||
dataIndex: 'up_time',
|
||||
key: 'up_time'
|
||||
}, {
|
||||
title: '功能',
|
||||
key: 'action',
|
||||
render: () => {
|
||||
return (
|
||||
<span>
|
||||
<Button type="primary">编辑</Button>
|
||||
<Button type="danger">删除</Button>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
}]
|
||||
|
||||
|
||||
const data = [
|
||||
{ uid: 1, username: 'admin', email: 'admin@admin.com', up_time: '2017.07.01', key: 1 },
|
||||
{ uid: 2, username: 'admin2', email: 'admin21113qq3ß@admin311.com', up_time: '2017.07.21', key: 2 }
|
||||
];
|
||||
|
||||
return (
|
||||
<section className="user-table">
|
||||
|
||||
<Table columns={columns} dataSource={data} />
|
||||
|
||||
</section>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default List
|
123
client/containers/User/Profile.js
Normal file
123
client/containers/User/Profile.js
Normal file
@ -0,0 +1,123 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Row, Col, Icon , Input, Button, Select} from 'antd'
|
||||
import axios from 'axios';
|
||||
|
||||
class Profile extends Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
usernameEdit: false,
|
||||
emailEdit: false,
|
||||
secureEdit: false,
|
||||
roleEdit: false
|
||||
}
|
||||
this.getUserInfo(101)
|
||||
}
|
||||
|
||||
handleEdit = (key, val) =>{
|
||||
var s = {};
|
||||
s[key] = val ;
|
||||
this.setState(s)
|
||||
}
|
||||
|
||||
getUserInfo = (id) => {
|
||||
axios.get('/user/find', {
|
||||
id: id
|
||||
}).then((res) =>{
|
||||
console.log(res)
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
let ButtonGroup = Button.Group;
|
||||
let userNameEditHtml, emailEditHtml,secureEditHtml, roleEditHtml;
|
||||
const Option = Select.Option;
|
||||
if(this.state.usernameEdit === false){
|
||||
userNameEditHtml = <div >
|
||||
<span className="text">xiaoming</span>
|
||||
<span className="text-button" onClick={() => {this.handleEdit( 'usernameEdit', true)}}><Icon type="edit"/>修改</span>
|
||||
</div>
|
||||
}else{
|
||||
userNameEditHtml = <div>
|
||||
<Input placeholder="用户名" />
|
||||
<ButtonGroup className="edit-buttons" >
|
||||
<Button className="edit-button" onClick={() => {this.handleEdit( 'usernameEdit', false)}} >Cancel</Button>
|
||||
<Button className="edit-button" type="primary">OK</Button>
|
||||
</ButtonGroup>
|
||||
</div>
|
||||
}
|
||||
|
||||
if(this.state.emailEdit === false){
|
||||
emailEditHtml = <div >
|
||||
<span className="text">abc@qq.com</span>
|
||||
<span className="text-button" onClick={() => {this.handleEdit( 'emailEdit', true)}} ><Icon type="edit"/>修改</span>
|
||||
</div>
|
||||
}else{
|
||||
emailEditHtml = <div>
|
||||
<Input placeholder="Email" />
|
||||
<ButtonGroup className="edit-buttons" >
|
||||
<Button className="edit-button" onClick={() => {this.handleEdit( 'emailEdit', false)}} >Cancel</Button>
|
||||
<Button className="edit-button" type="primary">OK</Button>
|
||||
</ButtonGroup>
|
||||
</div>
|
||||
}
|
||||
|
||||
if(this.state.roleEdit === true){
|
||||
roleEditHtml = <div>
|
||||
<span className="text">管理员</span>
|
||||
<span className="text-button" onClick={() => {this.handleEdit( 'roleEdit', true)}} ><Icon type="edit"/>修改</span>
|
||||
</div>
|
||||
}else{
|
||||
roleEditHtml = <Select defaultValue="admin" style={{ width: 150 }} >
|
||||
<Option value="admin">管理员</Option>
|
||||
<Option value="member">会员</Option>
|
||||
|
||||
</Select>
|
||||
}
|
||||
|
||||
if(this.state.secureEdit === false){
|
||||
secureEditHtml = <Button type="primary" onClick={() => {this.handleEdit( 'secureEdit', true)}}>密码修改</Button>
|
||||
}else{
|
||||
secureEditHtml = <div>
|
||||
<Input placeholder="旧的密码" />
|
||||
<Input placeholder="新的密码" />
|
||||
<ButtonGroup className="edit-buttons" >
|
||||
<Button className="edit-button" onClick={() => {this.handleEdit( 'secureEdit', false)}}>Cancel</Button>
|
||||
<Button className="edit-button" type="primary">OK</Button>
|
||||
</ButtonGroup>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
return <div className="user-profile">
|
||||
<Row className="user-item" type="flex" justify="start">
|
||||
<Col span={4}>用户名</Col>
|
||||
<Col span={12}>
|
||||
{userNameEditHtml}
|
||||
</Col>
|
||||
|
||||
</Row>
|
||||
<Row className="user-item" type="flex" justify="start">
|
||||
<Col span={4}>Email</Col>
|
||||
<Col span={12}>
|
||||
{emailEditHtml}
|
||||
</Col>
|
||||
</Row>
|
||||
<Row className="user-item" type="flex" justify="start">
|
||||
<Col span={4}>角色</Col>
|
||||
<Col span={12}>
|
||||
{roleEditHtml}
|
||||
</Col>
|
||||
</Row>
|
||||
<Row className="user-item" type="flex" justify="start">
|
||||
<Col span={4}>安全</Col>
|
||||
<Col span={12}>
|
||||
{secureEditHtml}
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
export default Profile
|
41
client/containers/User/User.js
Executable file
41
client/containers/User/User.js
Executable file
@ -0,0 +1,41 @@
|
||||
import './index.scss'
|
||||
import React, { Component } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import { Route} from 'react-router-dom'
|
||||
import LeftMenu from './LeftMenu.js'
|
||||
import List from './List.js'
|
||||
import PropTypes from 'prop-types'
|
||||
import Profile from './Profile.js'
|
||||
|
||||
@connect()
|
||||
class User extends Component {
|
||||
static propTypes = {
|
||||
match: PropTypes.object
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
console.log(this.props.match)
|
||||
}
|
||||
|
||||
render () {
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<section className="user-box">
|
||||
|
||||
<LeftMenu />
|
||||
|
||||
<Route path={this.props.match.path + '/list/:uid'} component={List} />
|
||||
<Route path={this.props.match.path + '/profile'} component={Profile} />
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default User
|
55
client/containers/User/index.js
Normal file
55
client/containers/User/index.js
Normal file
@ -0,0 +1,55 @@
|
||||
import './index.scss'
|
||||
import React, { Component } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import PropTypes from 'prop-types'
|
||||
import Header from '../../components/Header/Header.js'
|
||||
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
// fetchInterfaceData,
|
||||
// projectMember,
|
||||
// closeProjectMember
|
||||
}
|
||||
)
|
||||
|
||||
class user extends Component {
|
||||
static propTypes = {
|
||||
fetchInterfaceData: PropTypes.func,
|
||||
interfaceData: PropTypes.array,
|
||||
projectMember: PropTypes.func,
|
||||
closeProjectMember: PropTypes.func,
|
||||
modalVisible: PropTypes.bool
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
}
|
||||
|
||||
componentWillMount () {
|
||||
|
||||
}
|
||||
|
||||
render () {
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Header />
|
||||
|
||||
<section className="user-box">
|
||||
<InterfaceList projectMember={projectMember} />
|
||||
<InterfaceMode modalVisible={modalVisible} closeProjectMember={this.props.closeProjectMember} />
|
||||
<InterfaceTable data={interfaceData} />
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default Interface
|
95
client/containers/User/index.scss
Normal file
95
client/containers/User/index.scss
Normal file
@ -0,0 +1,95 @@
|
||||
/* .user-box.css */
|
||||
.user-box {
|
||||
max-width: 11rem;
|
||||
display: -webkit-box;
|
||||
-webkit-box-flex: 1;
|
||||
margin: 15px auto 0 auto;
|
||||
font-size: 0.14rem;
|
||||
background: #FFF;
|
||||
min-height:500px;
|
||||
|
||||
.search{
|
||||
height: 40px;
|
||||
padding: 5px;
|
||||
background: #f9f9f9;
|
||||
|
||||
input{
|
||||
background: #f9f9f9;
|
||||
line-height: 40px;
|
||||
height: 40px;
|
||||
border: 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
input:focus{
|
||||
outline:0;
|
||||
border-color:0;
|
||||
box-shadow: none
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
.user-list {
|
||||
width: 216px;
|
||||
line-height: 45px;
|
||||
background: #f9fafe;
|
||||
|
||||
li {
|
||||
padding: 0 0 0 30px;
|
||||
a{
|
||||
color: #344562;
|
||||
}
|
||||
|
||||
&.active,&.active a {
|
||||
background: #657289;
|
||||
color: #FFF;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.user-table {
|
||||
-webkit-box-flex: 1;
|
||||
margin: 0 0 0 20px;
|
||||
|
||||
.ant-table-wrapper table {
|
||||
font-size: .14rem;
|
||||
|
||||
button {
|
||||
margin: 0 10px 0 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.user-profile {
|
||||
-webkit-box-flex: 1;
|
||||
margin-top: 15px;
|
||||
margin-left: 15px;
|
||||
|
||||
.user-item {
|
||||
min-height:35px;
|
||||
line-height:35px;
|
||||
margin: 5px;
|
||||
margin-bottom:10px;
|
||||
|
||||
.text-button{
|
||||
font-size: 12px;
|
||||
color: #657289;
|
||||
cursor: pointer
|
||||
}
|
||||
|
||||
.edit-buttons{
|
||||
margin:10px;
|
||||
}
|
||||
|
||||
.edit-button{
|
||||
margin: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -2,10 +2,12 @@ import Home from './Home/Home.js'
|
||||
import Login from './Login/login-wrap.js'
|
||||
import ProjectGroups from './ProjectGroups/ProjectGroups.js'
|
||||
import Interface from './Interface/Interface.js'
|
||||
import News from './News/News.js'
|
||||
|
||||
export {
|
||||
Home,
|
||||
Login,
|
||||
ProjectGroups,
|
||||
Interface
|
||||
Interface,
|
||||
News
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
} from '../../constants/action-types';
|
||||
|
||||
const initialState = {
|
||||
isLogin: true,
|
||||
isLogin: false,
|
||||
userName: null,
|
||||
uid: null,
|
||||
loginWrapActiveKey:"1"
|
||||
|
@ -1,11 +1,11 @@
|
||||
import {
|
||||
FETCH_GROUP_LIST,
|
||||
FETCH_CURR_GROUP
|
||||
SET_CURR_GROUP
|
||||
} from '../../constants/action-types';
|
||||
|
||||
const initialState = {
|
||||
groupList: [],
|
||||
currGroup: 'MFE'
|
||||
currGroup: { group_name: '' }
|
||||
};
|
||||
|
||||
export default (state = initialState, action) => {
|
||||
@ -19,14 +19,11 @@ export default (state = initialState, action) => {
|
||||
}
|
||||
return state;
|
||||
}
|
||||
case FETCH_CURR_GROUP: {
|
||||
if (action.payload.res) {
|
||||
return {
|
||||
...state,
|
||||
currGroup: action.payload.data
|
||||
};
|
||||
}
|
||||
return state;
|
||||
case SET_CURR_GROUP: {
|
||||
return {
|
||||
...state,
|
||||
currGroup: action.payload
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
|
20
client/reducer/news/news.js
Normal file
20
client/reducer/news/news.js
Normal file
@ -0,0 +1,20 @@
|
||||
import {
|
||||
FETCH_NEWS_DATA
|
||||
} from '../../constants/action-types.js'
|
||||
|
||||
const initialState = {
|
||||
newsData: []
|
||||
}
|
||||
|
||||
export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case FETCH_NEWS_DATA: {
|
||||
return {
|
||||
...state,
|
||||
newsData: action.payload
|
||||
};
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
import React from 'react'
|
||||
|
||||
import { Route, HashRouter } from 'react-router-dom'
|
||||
import { Home, ProjectGroups, Interface } from './containers/index'
|
||||
import { Home, ProjectGroups, Interface, News } from './containers/index'
|
||||
import User from './containers/User/User.js'
|
||||
|
||||
import Header from './components/Header/Header'
|
||||
|
||||
export default () => {
|
||||
@ -11,7 +14,10 @@ export default () => {
|
||||
<Route path="/" component={ Home } exact />
|
||||
<Route path="/ProjectGroups" component={ ProjectGroups } />
|
||||
<Route path="/Interface" component={ Interface } />
|
||||
<Route path="/user" component={User} />
|
||||
<Route path="/News" component={ News } />
|
||||
</div>
|
||||
|
||||
</HashRouter>
|
||||
)
|
||||
}
|
||||
|
@ -26,6 +26,9 @@ ul {
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
&:active, &:hover, &:visited{
|
||||
text-decoration: none
|
||||
}
|
||||
}
|
||||
|
||||
a:hover {
|
||||
|
@ -3,9 +3,11 @@
|
||||
"webhost": "127.0.0.1",
|
||||
"adminAccount": "admin@admin.com",
|
||||
"db": {
|
||||
"servername": "192.168.237.71",
|
||||
"servername": "10.86.40.194",
|
||||
"DATABASE": "yapi",
|
||||
"port": 27017
|
||||
"port": 27017,
|
||||
"user": "test1",
|
||||
"pass": "test1"
|
||||
},
|
||||
"mail": {
|
||||
"host": "smtp.163.com",
|
||||
|
@ -22,6 +22,7 @@ function setupSql(){
|
||||
let userInst = yapi.getInst(userModel);
|
||||
let passsalt = yapi.commons.randStr();
|
||||
let result = userInst.save({
|
||||
username: yapi.WEBCONFIG.adminAccount.substr(0, yapi.WEBCONFIG.adminAccount.indexOf('@')),
|
||||
email: yapi.WEBCONFIG.adminAccount,
|
||||
password: yapi.commons.generatePassword('qunar.com', passsalt),
|
||||
passsalt: passsalt,
|
||||
|
@ -18,24 +18,23 @@ module.exports = async (ctx, next) => {
|
||||
return ctx.body = yapi.commons.resReturn(null, 403, e.message);
|
||||
}
|
||||
|
||||
let matchProject = [];
|
||||
let matchProject = false, maxBasepath = 0;
|
||||
for(let i=0, l = projects.length; i< l; i++){
|
||||
let project = projects[i];
|
||||
if(ctx.path && ctx.path.indexOf(project.basepath) === 0 && project.basepath[project.basepath.length -1] === '/'){
|
||||
matchProject.push(project);
|
||||
matchProject.push(project);
|
||||
if(project.basepath.length > maxBasepath){
|
||||
maxBasepath = project.basepath.length;
|
||||
matchProject = project;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(matchProject.length === 0){
|
||||
if(matchProject === false){
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '不存在的domain');
|
||||
}
|
||||
|
||||
if(matchProject.length > 1){
|
||||
return ctx.body = yapi.commons.resReturn(null, 401, '存在多个project,请检查数据库');
|
||||
}
|
||||
|
||||
let project = matchProject[0], interfaceData;
|
||||
let project = matchProject, interfaceData;
|
||||
let interfaceInst = yapi.getInst(interfaceModel);
|
||||
try{
|
||||
interfaceData = await interfaceInst.getByPath(project._id, ctx.path.substr(project.basepath.length));
|
||||
|
@ -38,7 +38,7 @@ createAction('group', 'del', 'post', 'del')
|
||||
createAction('user', 'login', 'post', 'login')
|
||||
createAction('user', 'reg', 'post', 'reg')
|
||||
createAction('user', 'list', 'get', 'list')
|
||||
createAction('user', 'find', 'post', 'findById')
|
||||
createAction('user', 'find', 'get', 'findById')
|
||||
createAction('user', 'update', 'post', 'update')
|
||||
createAction('user', 'del', 'post', 'del')
|
||||
createAction('user', 'status', 'get', 'getLoginStatus')
|
||||
|
@ -16,7 +16,10 @@ function connect(){
|
||||
mongoose.Promise = global.Promise;
|
||||
let config = yapi.WEBCONFIG;
|
||||
|
||||
let db = mongoose.connect(`mongodb://${config.db.servername}:${config.db.port}/${config.db.DATABASE}`);
|
||||
let db = mongoose.connect(`mongodb://${config.db.servername}:${config.db.port}/${config.db.DATABASE}`, {
|
||||
user: config.db.user,
|
||||
pass: config.db.pass
|
||||
});
|
||||
|
||||
db.then(function (res) {
|
||||
yapi.commons.log('mongodb load success...')
|
||||
|
@ -36,6 +36,7 @@ function setupSql() {
|
||||
var userInst = _yapi2.default.getInst(_user2.default);
|
||||
var passsalt = _yapi2.default.commons.randStr();
|
||||
var result = userInst.save({
|
||||
username: _yapi2.default.WEBCONFIG.adminAccount.substr(0, _yapi2.default.WEBCONFIG.adminAccount.indexOf('@')),
|
||||
email: _yapi2.default.WEBCONFIG.adminAccount,
|
||||
password: _yapi2.default.commons.generatePassword('qunar.com', passsalt),
|
||||
passsalt: passsalt,
|
||||
|
@ -28,7 +28,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
||||
|
||||
module.exports = function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx, next) {
|
||||
var hostname, config, projectInst, projects, matchProject, i, l, _project, project, interfaceData, interfaceInst;
|
||||
var hostname, config, projectInst, projects, matchProject, maxBasepath, i, l, _project, project, interfaceData, interfaceInst;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
@ -71,17 +71,21 @@ module.exports = function () {
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 403, _context.t0.message));
|
||||
|
||||
case 18:
|
||||
matchProject = [];
|
||||
matchProject = false, maxBasepath = 0;
|
||||
|
||||
for (i = 0, l = projects.length; i < l; i++) {
|
||||
_project = projects[i];
|
||||
|
||||
if (ctx.path && ctx.path.indexOf(_project.basepath) === 0 && _project.basepath[_project.basepath.length - 1] === '/') {
|
||||
matchProject.push(_project);
|
||||
if (_project.basepath.length > maxBasepath) {
|
||||
maxBasepath = _project.basepath.length;
|
||||
matchProject = _project;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!(matchProject.length === 0)) {
|
||||
if (!(matchProject === false)) {
|
||||
_context.next = 22;
|
||||
break;
|
||||
}
|
||||
@ -89,63 +93,55 @@ module.exports = function () {
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '不存在的domain'));
|
||||
|
||||
case 22:
|
||||
if (!(matchProject.length > 1)) {
|
||||
_context.next = 24;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '存在多个project,请检查数据库'));
|
||||
|
||||
case 24:
|
||||
project = matchProject[0], interfaceData = void 0;
|
||||
project = matchProject, interfaceData = void 0;
|
||||
interfaceInst = _yapi2.default.getInst(_interface2.default);
|
||||
_context.prev = 26;
|
||||
_context.next = 29;
|
||||
_context.prev = 24;
|
||||
_context.next = 27;
|
||||
return interfaceInst.getByPath(project._id, ctx.path.substr(project.basepath.length));
|
||||
|
||||
case 29:
|
||||
case 27:
|
||||
interfaceData = _context.sent;
|
||||
|
||||
if (!(!interfaceData || interfaceData.length === 0)) {
|
||||
_context.next = 32;
|
||||
_context.next = 30;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 404, '不存在的api'));
|
||||
|
||||
case 32:
|
||||
case 30:
|
||||
if (!(interfaceData.length > 1)) {
|
||||
_context.next = 34;
|
||||
_context.next = 32;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '存在多个api,请检查数据库'));
|
||||
|
||||
case 34:
|
||||
case 32:
|
||||
|
||||
interfaceData = interfaceData[0];
|
||||
|
||||
if (!(interfaceData.res_body_type === 'json')) {
|
||||
_context.next = 37;
|
||||
_context.next = 35;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _mockjs2.default.mock(_yapi2.default.commons.json_parse(interfaceData.res_body)));
|
||||
|
||||
case 37:
|
||||
case 35:
|
||||
return _context.abrupt('return', ctx.body = interfaceData.res_body);
|
||||
|
||||
case 40:
|
||||
_context.prev = 40;
|
||||
_context.t1 = _context['catch'](26);
|
||||
case 38:
|
||||
_context.prev = 38;
|
||||
_context.t1 = _context['catch'](24);
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 409, _context.t1.message));
|
||||
|
||||
case 43:
|
||||
case 41:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, undefined, [[9, 15], [26, 40]]);
|
||||
}, _callee, undefined, [[9, 15], [24, 38]]);
|
||||
}));
|
||||
|
||||
return function (_x, _x2) {
|
||||
|
@ -65,7 +65,7 @@ createAction('group', 'del', 'post', 'del');
|
||||
createAction('user', 'login', 'post', 'login');
|
||||
createAction('user', 'reg', 'post', 'reg');
|
||||
createAction('user', 'list', 'get', 'list');
|
||||
createAction('user', 'find', 'post', 'findById');
|
||||
createAction('user', 'find', 'get', 'findById');
|
||||
createAction('user', 'update', 'post', 'update');
|
||||
createAction('user', 'del', 'post', 'del');
|
||||
createAction('user', 'status', 'get', 'getLoginStatus');
|
||||
|
@ -27,7 +27,10 @@ function connect() {
|
||||
_mongoose2.default.Promise = global.Promise;
|
||||
var config = _yapi2.default.WEBCONFIG;
|
||||
|
||||
var db = _mongoose2.default.connect('mongodb://' + config.db.servername + ':' + config.db.port + '/' + config.db.DATABASE);
|
||||
var db = _mongoose2.default.connect('mongodb://' + config.db.servername + ':' + config.db.port + '/' + config.db.DATABASE, {
|
||||
user: config.db.user,
|
||||
pass: config.db.pass
|
||||
});
|
||||
|
||||
db.then(function (res) {
|
||||
_yapi2.default.commons.log('mongodb load success...');
|
||||
|
Loading…
Reference in New Issue
Block a user