diff --git a/client/containers/Project/Interface/InterfaceList/View.js b/client/containers/Project/Interface/InterfaceList/View.js index ea8ec357..af83a31e 100644 --- a/client/containers/Project/Interface/InterfaceList/View.js +++ b/client/containers/Project/Interface/InterfaceList/View.js @@ -1,14 +1,23 @@ -<<<<<<< HEAD -import '../interface.scss' +import './View.scss' import React, { Component } from 'react' import { connect } from 'react-redux' import PropTypes from 'prop-types' -import { formatTime } from '../../../../common.js'; +import { Table } from 'antd' +const mockEditor = require('./mockEditor.js') +// import { formatTime } from '../../../../common.js'; // import { Card } from 'antd' // import { getMockUrl } from '../../reducer/modules/news.js' -@connect() +@connect(state=>{ + console.log(state); + return { + curData: state.inter.curdata + } +}) + + + class View extends Component { constructor(props) { @@ -18,98 +27,162 @@ class View extends Component { viewData: PropTypes.object } + + componentDidMount() { + let that = this; + mockEditor({ + container: 'req_body_json', + data: that.props.req_body_form, + onChange: function () {} + }) + mockEditor({ + container: 'res_body_json', + data: that.props.res_body, + onChange: function () {} + }) + mockEditor({ + container: 'req_query_json', + data: that.props.req_query, + onChange: function () {} + }) + } + render () { + + const dataSource = [{ + name: '1', + value: '胡彦斌', + desc: 32 + }, { + name: '2', + value: '胡彦斌', + desc: 32 + }]; + + const columns = [{ + title: '参数名称', + dataIndex: 'name', + key: 'name' + }, { + title: '参数值', + dataIndex: 'value', + key: 'value' + }, { + title: '备注', + dataIndex: 'desc', + key: 'desc', + width: '45%' + }]; + + + + return
{/**/} -
+
接口名: - {this.props.viewData.casename} -
-
- 添加时间: - {formatTime(this.props.viewData.add_time/1000)} -
-
- 更新时间: - {formatTime(this.props.viewData.up_time/1000)} -
-
- 测试环境: - {this.props.viewData.env} -
-
- 域名: - {this.props.viewData.domain} + {this.props.viewData.title}
- 路径: + 接口路径: {this.props.viewData.path}
-
- 请求方法: - {this.props.viewData.method} +
+ 状态: + {this.props.viewData.status}
+
+ Mock地址: + {this.props.viewData.mockUrl} +
+
+ 接口描述: + {this.props.viewData.desc} +
+
+ 请求Headers: + + +
+ Query: +
+
+
+ 请求Body: +
+
+
+ 响应Body: +
+
+ + + } } -View.defaultProps = { - viewData: { - casename:"caename", - uid: 107, - col_id: 211, - index: 0, - project_id: 112, - add_time: new Date().getTime(), - up_time: new Date().getTime(), - env: "测试环境", - domain: "域名", - path: "路径", - method: "GET", - req_query: [{ - name: "String", - value: "String" - }], - req_headers: [{ - name: "String", - value: "String" - }], - req_body_type: "json", - res_body_form: [{ - name: "String", - value: "String" - }], - res_body_other: "String" - } +let data = { + title: '', + path: '', + status: 'undone', + method: 'get', + req_query: [{ + name: '', + desc: '', + required: "1" + }], + req_body_type: 'form', + req_headers: [{ + name: '', + value: '', required: "1" + }], + req_body_form: [{ + name: '', + type: '', + required: '' + }], + res_body_type: 'json', + res_body: '{a:123}', + desc: 'FP的好处是没有OO的复杂仪式感,是沿着数据结构+算法的思路进行抽象和结构化。如果顶层设计做好,代码复用度极高,代码量少。比如要生成一颗树我用迭归算法直接生成', + res_body_mock: '', + mockUrl: "this.props.mockUrl" } +// { +// casename:"caename", +// uid: 107, +// col_id: 211, +// index: 0, +// project_id: 112, +// add_time: new Date().getTime(), +// up_time: new Date().getTime(), +// env: "测试环境", +// domain: "域名", +// path: "路径", +// method: "GET", +// req_query: [{ +// name: "String", +// value: "String", +// required: "1" +// }], +// req_headers: [{ +// name: "String", +// value: "String", +// required: "1" +// }], +// req_body_type: "json", +// res_body_form: [{ +// name: "String", +// value: "String", +// required: "1" +// }], +// res_body_other: "String" +// } +View.defaultProps = { + viewData: data +} + + export default View -======= -import React,{Component} from 'react' -import PropTypes from 'prop-types' -import { connect } from 'react-redux'; -@connect( - state => { - return { - curdata: state.inter.curdata - } - } -) - -class InterfaceView extends Component{ - static propTypes = { - curdata: PropTypes.object - } - - render(){ - console.log(this.props.curdata) - let view = JSON.stringify(this.props.curdata, null, " "); - return
-      {view}
-    
- } -} - -export default InterfaceView; ->>>>>>> fe76f992f0b0251fce75b3fb564ace43565ab8b4 diff --git a/client/containers/Project/Interface/InterfaceList/View.scss b/client/containers/Project/Interface/InterfaceList/View.scss new file mode 100644 index 00000000..c8657682 --- /dev/null +++ b/client/containers/Project/Interface/InterfaceList/View.scss @@ -0,0 +1,35 @@ +.caseContainer{ + padding: 24px; + font-size: 12px; + // display: flex; + overflow: hidden; + >div{ + margin: 8px 0px; + // background-color: #ececec; + padding: 16px; + width: 100%; + box-sizing: border-box; + float: left; + .colKey{ + font-weight: bolder; + margin-right: 16px; + } + } + .colName,.colPath,.colstatus,.colMock{ + width: 50%; + float: left; + padding: 8px 16px; + } + .colDesc{ + line-height: 1.5em; + .colKey{ + margin-right: 0px; + float: left; + margin-bottom: 8px; + } + .colValue{ + float: left; + text-indent: 2em; + } + } +} \ No newline at end of file diff --git a/client/containers/Project/Interface/interface.scss b/client/containers/Project/Interface/interface.scss index da438153..0b1b3898 100644 --- a/client/containers/Project/Interface/interface.scss +++ b/client/containers/Project/Interface/interface.scss @@ -65,19 +65,7 @@ } } } -.caseContainer{ - padding: 24px; - font-size: 12px; - >div{ - margin: 8px 0px; - padding: 12px; - background-color: #ececec; - .colKey{ - font-weight: bolder; - margin-right: 16px; - } - } -} + diff --git a/client/containers/User/Profile.js b/client/containers/User/Profile.js index 1c3c1189..5c59c9cd 100644 --- a/client/containers/User/Profile.js +++ b/client/containers/User/Profile.js @@ -152,7 +152,7 @@ class Profile extends Component { userNameEditHtml =
{userinfo.username}   {/* { this.handleEdit('usernameEdit', true) }}>修改*/} - {userType?:""} + {}
} else { userNameEditHtml =
diff --git a/client/containers/User/User.js b/client/containers/User/User.js index 54ffdfd8..a9bd05ba 100755 --- a/client/containers/User/User.js +++ b/client/containers/User/User.js @@ -9,7 +9,6 @@ import Profile from './Profile.js' import { Row } from 'antd'; import Subnav from '../../components/Subnav/Subnav.js'; @connect(state=>{ - console.log(state); return { curUid: state.user.uid, userType: state.user.type, @@ -31,7 +30,7 @@ class User extends Component { } componentDidMount () { - console.log(this.props.match) + // console.log(this.props.match) } render () { @@ -41,7 +40,7 @@ class User extends Component { }]; if(this.props.role === "admin"){ navData.push({ - name: '成员管理', + name: '用户管理', path: '/user/list' }) } diff --git a/client/reducer/modules/user.js b/client/reducer/modules/user.js index 8a438c98..5bab37fb 100644 --- a/client/reducer/modules/user.js +++ b/client/reducer/modules/user.js @@ -18,7 +18,8 @@ const initialState = { uid: null, email: '', loginState: LOADING_STATUS, - loginWrapActiveKey: "1" + loginWrapActiveKey: "1", + role: "" }; export default (state = initialState, action) => { @@ -40,7 +41,8 @@ export default (state = initialState, action) => { isLogin: true, loginState: MEMBER_STATUS, uid: action.payload.data.data.uid, - userName: action.payload.data.data.username + userName: action.payload.data.data.username, + role: action.payload.data.data.role }; } else { return state; @@ -52,7 +54,8 @@ export default (state = initialState, action) => { isLogin: false, loginState: GUEST_STATUS, userName: null, - uid: null + uid: null, + role: "" } } case LOGIN_TYPE: { @@ -79,6 +82,7 @@ export default (state = initialState, action) => { export function checkLoginState() { return(dispatch)=> { axios.get('/api/user/status').then((res) => { + console.log(res) dispatch({ type: GET_LOGIN_STATE, payload: res