diff --git a/client/components/Header/Header.scss b/client/components/Header/Header.scss
index 4b8c7072..6a6d6e56 100644
--- a/client/components/Header/Header.scss
+++ b/client/components/Header/Header.scss
@@ -13,6 +13,9 @@ $color-black-light : #404040;
/* .header-box.css */
.header-box {
+ height: .56rem;
+ line-height: .56rem;
+ padding: 0;
.logo {
position: relative;
float: left;
@@ -46,6 +49,24 @@ $color-black-light : #404040;
from { background-position: 0px; }
to { background-position: -240px; }
}
+ &:before, &:after {
+ content: '';
+ display: block;
+ width: 2px;
+ height: .56rem;
+ background-color: #222;
+ border-left: 1px solid #575D67;
+ position: relative;
+ top: 0;
+ }
+ &:before {
+ float: left;
+ left: -.08rem;
+ }
+ &:after {
+ float: right;
+ right: -.27rem;
+ }
}
.nav-toolbar {
diff --git a/client/containers/Project/AddProject/AddProject.js b/client/containers/AddProject/AddProject.js
similarity index 68%
rename from client/containers/Project/AddProject/AddProject.js
rename to client/containers/AddProject/AddProject.js
index 3b43f6ef..672111e6 100644
--- a/client/containers/Project/AddProject/AddProject.js
+++ b/client/containers/AddProject/AddProject.js
@@ -2,10 +2,8 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Button, Form, Input, Icon, Tooltip, Select, message, Row, Col, Radio } from 'antd';
-import { addProject, fetchProjectList, delProject, changeUpdateModal, changeTableLoading } from '../../../reducer/modules/project';
-// import { Link } from 'react-router-dom'
-// import variable from '../../../constants/variable';
-// import common from '../../../common';
+import { addProject } from '../../reducer/modules/project.js';
+import { fetchGroupList } from '../../reducer/modules/group.js'
import { autobind } from 'core-decorators';
const { TextArea } = Input;
const FormItem = Form.Item;
@@ -30,77 +28,46 @@ const formItemLayout = {
@connect(
state => {
return {
- projectList: state.project.projectList,
- userInfo: state.project.userInfo,
- tableLoading: state.project.tableLoading,
- currGroup: state.group.currGroup,
- total: state.project.total,
- currPage: state.project.currPage
+ groupList: state.group.groupList
}
},
{
- fetchProjectList,
- addProject,
- delProject,
- changeUpdateModal,
- changeTableLoading
+ fetchGroupList,
+ addProject
}
)
+
class ProjectList extends Component {
constructor(props) {
super(props);
this.state = {
- visible: false,
protocol: 'http:\/\/',
- projectData: []
+ groupList: []
}
}
static propTypes = {
+ groupList: PropTypes.array,
form: PropTypes.object,
- fetchProjectList: PropTypes.func,
addProject: PropTypes.func,
- delProject: PropTypes.func,
- changeUpdateModal: PropTypes.func,
- changeTableLoading: PropTypes.func,
- projectList: PropTypes.array,
- userInfo: PropTypes.object,
- tableLoading: PropTypes.bool,
- currGroup: PropTypes.object,
- total: PropTypes.number,
- currPage: PropTypes.number
+ fetchGroupList: PropTypes.func
}
// 确认添加项目
@autobind
handleOk(e) {
- const { form, currGroup, changeTableLoading, addProject, fetchProjectList } = this.props;
- const that = this;
+ const { form, addProject } = this.props;
e.preventDefault();
form.validateFields((err, values) => {
- // console.log(values);
+ console.log(values);
if (!err) {
values.protocol = this.state.protocol.split(':')[0];
- // 获取当前分组id传入values
- values.group_id = currGroup._id;
- changeTableLoading(true);
addProject(values).then((res) => {
- // 添加项目成功后再次请求列表
if (res.payload.data.errcode == 0) {
- that.setState({
- visible: false
- });
form.resetFields();
message.success('创建成功! ');
- fetchProjectList(currGroup._id, this.props.currPage).then(() => {
- changeTableLoading(false);
- });
- } else {
- changeTableLoading(false);
- message.error(res.payload.data.errmsg);
}
}).catch(() => {
- changeTableLoading(false);
});
}
});
@@ -114,18 +81,9 @@ class ProjectList extends Component {
})
}
- componentWillReceiveProps(nextProps) {
- // 切换项目列表
- if (this.props.projectList !== nextProps.projectList) {
- // console.log(nextProps.projectList);
- const data = nextProps.projectList.map((item, index) => {
- item.key = index;
- return item;
- });
- this.setState({
- projectData: data
- });
- }
+ async componentWillMount() {
+ await this.props.fetchGroupList();
+ this.setState({groupList: this.props.groupList});
}
render() {
@@ -157,8 +115,7 @@ class ProjectList extends Component {
}]
})(
)}
@@ -227,18 +184,18 @@ class ProjectList extends Component {
{...formItemLayout}
label="权限"
>
- {getFieldDecorator('radio-group', {
+ {getFieldDecorator('project_type', {
rules: [{
required: true
}],
- initialValue: 1
+ initialValue: 'private'
})(
-
+
私有
只有组长和项目开发者可以索引并查看项目信息
-
+
公开
任何人都可以索引并查看项目信息
diff --git a/client/containers/Project/AddProject/Addproject.scss b/client/containers/AddProject/Addproject.scss
similarity index 90%
rename from client/containers/Project/AddProject/Addproject.scss
rename to client/containers/AddProject/Addproject.scss
index cf805cb7..0b3ede2a 100644
--- a/client/containers/Project/AddProject/Addproject.scss
+++ b/client/containers/AddProject/Addproject.scss
@@ -1,4 +1,4 @@
-@import '../../../styles/common.scss';
+@import '../../styles/common.scss';
.m-container {
margin: .24rem auto !important;
diff --git a/client/containers/Group/Group.js b/client/containers/Group/Group.js
index 0db97fb0..92ca6f07 100644
--- a/client/containers/Group/Group.js
+++ b/client/containers/Group/Group.js
@@ -2,6 +2,7 @@ import React, { Component } from 'react';
import GroupList from './GroupList/GroupList.js';
import ProjectList from './ProjectList/ProjectList.js';
import Subnav from '../../components/Subnav/Subnav.js';
+import { Route, Switch, Redirect } from 'react-router-dom';
import { Row, Col } from 'antd';
import './Group.scss'
@@ -12,6 +13,19 @@ export default class Group extends Component {
}
render () {
+
+ const GroupContent = (
+
+ )
return (
-
+
+
+ GroupContent} />
+
)
}
diff --git a/client/containers/Project/Activity/Activity.js b/client/containers/Project/Activity/Activity.js
new file mode 100644
index 00000000..e69de29b
diff --git a/client/containers/Project/Interface/InterfaceCol/InterfaceColContent.js b/client/containers/Project/Interface/InterfaceCol/InterfaceColContent.js
new file mode 100644
index 00000000..1b92a5c6
--- /dev/null
+++ b/client/containers/Project/Interface/InterfaceCol/InterfaceColContent.js
@@ -0,0 +1,4 @@
+import React from 'react'
+export default () => {
+ return
hello colContent
+}
\ No newline at end of file
diff --git a/client/containers/Project/Interface/InterfaceCol/InterfaceColMenu.js b/client/containers/Project/Interface/InterfaceCol/InterfaceColMenu.js
new file mode 100644
index 00000000..1b92a5c6
--- /dev/null
+++ b/client/containers/Project/Interface/InterfaceCol/InterfaceColMenu.js
@@ -0,0 +1,4 @@
+import React from 'react'
+export default () => {
+ return
hello colContent
+}
\ No newline at end of file
diff --git a/client/containers/Project/Interface/InterfaceList/Edit.js b/client/containers/Project/Interface/InterfaceList/Edit.js
new file mode 100644
index 00000000..79fbcc4d
--- /dev/null
+++ b/client/containers/Project/Interface/InterfaceList/Edit.js
@@ -0,0 +1,5 @@
+import React from 'react'
+
+export default () => {
+ return
接口Edit
+}
\ No newline at end of file
diff --git a/client/containers/Project/Interface/InterfaceList/InterfaceContent.js b/client/containers/Project/Interface/InterfaceList/InterfaceContent.js
new file mode 100644
index 00000000..bb9cb3b8
--- /dev/null
+++ b/client/containers/Project/Interface/InterfaceList/InterfaceContent.js
@@ -0,0 +1,25 @@
+import React from 'react'
+import { Tabs } from 'antd';
+import Edit from './Edit.js'
+import View from './View.js'
+import Run from './Run.js'
+
+const TabPane = Tabs.TabPane;
+
+const Content = () => {
+ return
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+export default Content
\ No newline at end of file
diff --git a/client/containers/Project/Interface/InterfaceList/InterfaceMenu.js b/client/containers/Project/Interface/InterfaceList/InterfaceMenu.js
new file mode 100644
index 00000000..8cfa59c5
--- /dev/null
+++ b/client/containers/Project/Interface/InterfaceList/InterfaceMenu.js
@@ -0,0 +1,17 @@
+import React from 'react'
+import { Menu, Button, Input, Icon, Tag } from 'antd';
+export default () => {
+ return
+
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/client/containers/Project/Interface/InterfaceList/Run.js b/client/containers/Project/Interface/InterfaceList/Run.js
new file mode 100644
index 00000000..3aa0a3ae
--- /dev/null
+++ b/client/containers/Project/Interface/InterfaceList/Run.js
@@ -0,0 +1,5 @@
+import React from 'react'
+
+export default () => {
+ return
接口Run
+}
\ No newline at end of file
diff --git a/client/containers/Project/Interface/InterfaceList/View.js b/client/containers/Project/Interface/InterfaceList/View.js
new file mode 100644
index 00000000..4fe8a1eb
--- /dev/null
+++ b/client/containers/Project/Interface/InterfaceList/View.js
@@ -0,0 +1,6 @@
+import React from 'react'
+
+export default () => {
+ return
接口预览
+}
+
diff --git a/client/containers/Project/Interface/interface.scss b/client/containers/Project/Interface/interface.scss
new file mode 100644
index 00000000..c2accb43
--- /dev/null
+++ b/client/containers/Project/Interface/interface.scss
@@ -0,0 +1,70 @@
+.web-content{
+ .left-menu{
+ min-height: 5rem;
+ box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
+ background: #FFF;
+ border-radius:4px;
+ margin: 3px;
+ .ant-tabs-bar{
+ border-bottom: none;
+ margin-bottom: 0
+
+ }
+ .ant-tabs-nav{
+ width:100%;
+ background-color: #ececec
+ }
+ .ant-tabs-tab{
+ min-width: 50%;
+ }
+ .ant-tabs.ant-tabs-card > .ant-tabs-bar .ant-tabs-tab{
+ background-color: #fff
+ }
+ .ant-tabs.ant-tabs-card > .ant-tabs-bar .ant-tabs-tab-active{
+ background-color: #efefef
+ }
+
+ .interface-filter{
+ padding-left: 10px;
+ height:45px;
+ line-height: 32px;
+ padding-top:7px;
+ background-color: #efefef
+ }
+ .interface-list{
+
+ .btn-http{
+ height: 23px;
+ font-size: 10px;
+ margin-right: 7px;
+ padding: 0 5px;
+ width: 40px;
+ }
+
+ .btn-http-get{
+ background-color: #00a854;
+ border-color: #00a854
+ }
+ }
+ }
+
+ .right-content{
+ margin:3px;
+ min-height: 5rem;
+ box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
+ background: #FFF;
+ border-radius:4px;
+ .interface-content{
+ .ant-tabs-nav{
+ width:100%
+ }
+ .ant-tabs-nav-wrap{
+ text-align: left;
+ }
+ }
+ }
+}
+
+
+
+
diff --git a/client/containers/Project/Project.js b/client/containers/Project/Project.js
index 699cc87c..f69827bb 100644
--- a/client/containers/Project/Project.js
+++ b/client/containers/Project/Project.js
@@ -3,8 +3,11 @@ import { connect } from 'react-redux';
import PropTypes from 'prop-types'
import { Route, Switch, Redirect } from 'react-router-dom';
import { Subnav } from '../../components/index'
-import Interface from './Interface/Interface.js'
import { getProject } from '../../reducer/modules/project';
+import { Interface } from './Interface/Interface.js'
+import { Activity } from './Activity/Activity.js'
+import { Setting } from './Setting/Setting.js'
+
@connect(
state => {
@@ -39,6 +42,7 @@ export default class Project extends Component {
render () {
const { match } = this.props;
+ console.log('project')
return (
-
-
+
+
-
+
)
diff --git a/client/containers/Project/Setting/Setting.js b/client/containers/Project/Setting/Setting.js
new file mode 100644
index 00000000..e69de29b
diff --git a/client/containers/User/Profile.js b/client/containers/User/Profile.js
index e6e04912..f755350c 100644
--- a/client/containers/User/Profile.js
+++ b/client/containers/User/Profile.js
@@ -3,11 +3,23 @@ import { Row, Col, Input, Button, Select, message, Upload, Icon } from 'antd'
import axios from 'axios';
import {formatTime} from '../../common.js'
import PropTypes from 'prop-types'
+import { connect } from 'react-redux'
+
+@connect(state=>{
+ return {
+ curUid: state.user.uid,
+ userType: state.user.type
+ }
+},{
+
+})
class Profile extends Component {
static propTypes = {
- match: PropTypes.object
+ match: PropTypes.object,
+ curUid: PropTypes.number,
+ userType: PropTypes.string
}
constructor(props) {
@@ -126,12 +138,21 @@ class Profile extends Component {
const Option = Select.Option;
let userinfo = this.state.userinfo;
let _userinfo = this.state._userinfo;
- let roles = { admin: '管理员', member: '会员' }
+ let roles = { admin: '管理员', member: '会员' };
+ let userType = "";
+ if(this.props.userType === "third"){
+ userType = false;
+ }else if(this.props.userType === "site"){
+ userType = true;
+ }else{
+ userType = false;
+ }
+
if (this.state.usernameEdit === false) {
userNameEditHtml =
{userinfo.username}
{/* { this.handleEdit('usernameEdit', true) }}>修改*/}
-
+ {userType?:""}
} else {
userNameEditHtml =
@@ -147,7 +168,7 @@ class Profile extends Component {
emailEditHtml =
{userinfo.email}
{/* { this.handleEdit('emailEdit', true) }} >修改*/}
-
+ {userType?:""}
} else {
emailEditHtml =
@@ -163,7 +184,7 @@ class Profile extends Component {
roleEditHtml =
{roles[userinfo.role]}
{/* { this.handleEdit('roleEdit', true) }} >修改*/}
-
+ {userType?:""}
} else {
roleEditHtml =
}
}
@@ -243,15 +264,16 @@ class Avatar extends Component {
constructor(props) {
super(props);
this.state = {
- imageUrl:""
+ imageUrl: ""
}
}
static propTypes = {
uid: PropTypes.number
}
uploadAvatar(basecode){
- axios.post("/user/upload_avatar",{basecode: basecode}).then(()=>{
- this.setState({ imageUrl: basecode })
+ axios.post("/api/user/upload_avatar",{basecode: basecode}).then(()=>{
+ this.setState({ imageUrl: basecode });
+
}).catch((e)=>{
console.log(e);
})
@@ -264,18 +286,13 @@ class Avatar extends Component {
}
render() {
- let imageUrl = "";
- if(this.props.uid && !this.state.imageUrl){
- imageUrl = `/user/avatar?uid=${this.props.uid}`;
- }else{
- imageUrl = this.state.imageUrl;
- }
+ let imageUrl = this.state.imageUrl?this.state.imageUrl:`/api/user/avatar?uid=${this.props.uid}`;
return
{
@@ -284,6 +301,7 @@ class Avatar extends Component {
}
+ 点击头像更换
}
}
@@ -294,7 +312,7 @@ function beforeUpload(file) {
if (!isJPG && !isPNG) {
message.error('图片的格式只能为 jpg、png!');
}
- const isLt2M = file.size / 1024 / 1024 < 2;
+ const isLt2M = file.size / 1024 / 1024 < 0.2;
if (!isLt2M) {
message.error('图片必须小于 200kb!');
}
diff --git a/client/containers/User/User.js b/client/containers/User/User.js
index 62395d65..54ffdfd8 100755
--- a/client/containers/User/User.js
+++ b/client/containers/User/User.js
@@ -8,10 +8,22 @@ import PropTypes from 'prop-types'
import Profile from './Profile.js'
import { Row } from 'antd';
import Subnav from '../../components/Subnav/Subnav.js';
-@connect()
+@connect(state=>{
+ console.log(state);
+ return {
+ curUid: state.user.uid,
+ userType: state.user.type,
+ role: state.user.role
+ }
+},{
+
+})
class User extends Component {
static propTypes = {
- match: PropTypes.object
+ match: PropTypes.object,
+ curUid: PropTypes.number,
+ userType: PropTypes.string,
+ role: PropTypes.string
}
constructor(props) {
@@ -23,19 +35,22 @@ class User extends Component {
}
render () {
-
+ let navData = [{
+ name: '个人资料',
+ path: `/user/profile/${this.props.curUid}`
+ }];
+ if(this.props.role === "admin"){
+ navData.push({
+ name: '成员管理',
+ path: '/user/list'
+ })
+ }
return (
+ default={'个人资料'}
+ data={navData}/>
diff --git a/client/containers/User/index.scss b/client/containers/User/index.scss
index 4450acf8..247c7531 100644
--- a/client/containers/User/index.scss
+++ b/client/containers/User/index.scss
@@ -109,22 +109,23 @@
border-bottom-left-radius: .04rem;
border-bottom-right-radius: .04rem;
}
+ .avatar-uploader{
+ border: none;
+ }
.avatar-uploader,
.avatar-uploader-trigger,
.avatar {
- width: 150px;
- height: 150px;
+ width: 100px;
+ height: 100px;
+ overflow: hidden;
+ border-radius: 50px;
+
+ img{
+ height: auto;
+ }
}
.avatar-uploader {
display: block;
- border: 1px dashed #d9d9d9;
- border-radius: 6px;
- cursor: pointer;
- }
- .avatar-uploader {
- display: block;
- border: 1px dashed #d9d9d9;
- border-radius: 6px;
cursor: pointer;
}
.avatar-uploader-trigger {
@@ -133,4 +134,10 @@
font-size: 28px;
color: #999;
}
+ .avatarChange{
+ display: block;
+ width: 100px;
+ text-align: center;
+ padding-bottom: 8px;
+ }
}
diff --git a/client/containers/index.js b/client/containers/index.js
index 1b9f7fe0..ab3a6fa0 100644
--- a/client/containers/index.js
+++ b/client/containers/index.js
@@ -8,7 +8,7 @@ import News from './News/News.js'
import AddInterface from './AddInterface/AddInterface.js'
import DevTools from './DevTools/DevTools.js'
import Follows from './Follows/Follows.js'
-import AddProject from './Project/AddProject/AddProject.js'
+import AddProject from './AddProject/AddProject.js'
export {
Header,
diff --git a/client/styles/common.scss b/client/styles/common.scss
index b25b779f..e529d07a 100644
--- a/client/styles/common.scss
+++ b/client/styles/common.scss
@@ -65,3 +65,7 @@ em {
margin: .24rem auto;
padding: .24rem;
}
+
+.ant-dropdown .user-menu {
+ box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
+}
diff --git a/static/doc/api.html b/static/doc/api.html
index fb2d2110..fca964f6 100644
--- a/static/doc/api.html
+++ b/static/doc/api.html
@@ -138,12 +138,20 @@
/user/update
+
+ /user/upload_avatar
+
+
+
+ /user/avatar
+
+
/user/search
- /user/nav
+ /user/project
@@ -1242,6 +1250,130 @@
+
+
+
+
+
+
+
+ 描述:
+ 上传用户头像
+
+
+
+ 源码位置:
+ ./server/controllers/user.js:452
+
+
+
+
+ 参数:
+
+
+
+
+
+
+
+
+
+
+
+ 参数名 |
+ 类型 |
+ 描述 |
+ 必选 |
+ 支持版本 |
+
+
+
+
+ basecode |
+ * |
+ base64编码,通过h5 api传给后端 |
+
+
+
+
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 描述:
+ 根据用户uid头像
+
+
+
+ 源码位置:
+ ./server/controllers/user.js:495
+
+
+
+
+ 参数:
+
+
+
+
+
+
+
+
+
+
+
+ 参数名 |
+ 类型 |
+ 描述 |
+ 必选 |
+ 支持版本 |
+
+
+
+
+ uid |
+ * |
+ |
+
+
+
+
+ |
+ |
+
+
+
+
+
+
+
@@ -1262,7 +1394,7 @@
源码位置:
- ./server/controllers/user.js:511
+ ./server/controllers/user.js:527
@@ -1324,23 +1456,23 @@
-
示例:
-
{
- "errcode": 0,
- "errmsg": "success",
- "data": {
- "interface_id": 2746,
- "interface_name": "/a/c",
- "project_id": 2481,
- "project_name": "www.xxx.com/api",
- "group_id": 181,
- "group_name": "YMFE"
- }
-}
-
diff --git a/static/doc/static/server/controllers/base.js.html b/static/doc/static/server/controllers/base.js.html
index e52fd60b..960f78ff 100644
--- a/static/doc/static/server/controllers/base.js.html
+++ b/static/doc/static/server/controllers/base.js.html
@@ -47,13 +47,13 @@ class baseController {
async init(ctx) {
this.$user = null;
let ignoreRouter = [
- '/user/login_by_token',
- '/user/login',
- '/user/reg',
- '/user/status',
- '/user/logout'
+ '/api/user/login_by_token',
+ '/api/user/login',
+ '/api/user/reg',
+ '/api/user/status',
+ '/api/user/logout'
];
- if (ignoreRouter.indexOf(ctx.path) > -1) {
+ if (ignoreRouter.indexOf(ctx.path) > -1) {
this.$auth = true;
} else {
await this.checkLogin(ctx);
@@ -88,10 +88,14 @@ class baseController {
}
}
+ /**
+ *
+ * @param {*} ctx
+ */
async getLoginStatus(ctx) {
if (await this.checkLogin(ctx) === true) {
- let result = yapi.commons.fieldSelect(this.$user, ['_id', 'username', 'email', 'up_time', 'add_time', 'role']);
+ let result = yapi.commons.fieldSelect(this.$user, ['_id', 'username', 'email', 'up_time', 'add_time', 'role', 'type']);
result.server_ip = yapi.WEBCONFIG.server_ip;
return ctx.body = yapi.commons.resReturn(result);
}
diff --git a/static/doc/static/server/controllers/project.js.html b/static/doc/static/server/controllers/project.js.html
index 4f2559c2..56916288 100644
--- a/static/doc/static/server/controllers/project.js.html
+++ b/static/doc/static/server/controllers/project.js.html
@@ -603,7 +603,7 @@ class projectController extends baseController {
}, 500);
});
}
- module.exports = run;`;
+ module.exports = run;`
.trim();
return ctx.body = res;
}
diff --git a/static/doc/static/server/controllers/user.js.html b/static/doc/static/server/controllers/user.js.html
index 6c0fe69c..bff02828 100644
--- a/static/doc/static/server/controllers/user.js.html
+++ b/static/doc/static/server/controllers/user.js.html
@@ -81,8 +81,8 @@ class userController extends baseController {
email: result.email,
add_time: result.add_time,
up_time: result.up_time,
- server_ip: yapi.WEBCONFIG.server_ip
-
+ server_ip: yapi.WEBCONFIG.server_ip,
+ type: 'site'
}, 0, 'logout success...');
} else {
return ctx.body = yapi.commons.resReturn(null, 405, '密码错误');
@@ -478,8 +478,13 @@ class userController extends baseController {
}
/**
- *
+ * 上传用户头像
+ * @interface /user/upload_avatar
+ * @method POST
* @param {*} basecode base64编码,通过h5 api传给后端
+ * @category user
+ * @returns {Object}
+ * @example
*/
async uploadAvatar(ctx) {
@@ -515,11 +520,22 @@ class userController extends baseController {
}
+ /**
+ * 根据用户uid头像
+ * @interface /user/avatar
+ * @method GET
+ * @param {*} uid
+ * @category user
+ * @returns {Object}
+ * @example
+ */
+
async avatar(ctx) {
try{
+ let uid = ctx.query.uid ? ctx.query.uid: this.getUid();
let avatarInst = yapi.getInst(avatarModel);
- let data = await avatarInst.get(this.getUid());
+ let data = await avatarInst.get(uid);
let dataBuffer, type;
if(!data || !data.basecode){
dataBuffer = yapi.fs.readFileSync(yapi.path.join(yapi.WEBROOT, 'static/image/avatar.png'));
@@ -582,26 +598,24 @@ class userController extends baseController {
}
/**
- * 根据路由id获取面包屑数据
- * @interface /user/nav
+ * 根据路由id初始化项目数据
+ * @interface /user/project
* @method GET
* @category user
* @foldnumber 10
* @param {String} type 可选group|interface|project
* @param {Number} id
* @return {Object}
- * @example ./api/user/nav.json
+ * @example
*/
- async nav(ctx) {
+ async project(ctx) {
let { id, type } = ctx.request.query;
let result = {};
try {
if (type === 'interface') {
let interfaceInst = yapi.getInst(interfaceModel);
let interfaceData = await interfaceInst.get(id)
- result["interface_id"] = interfaceData._id;
- result["interface_name"] = interfaceData.path;
-
+ result.interface = interfaceData;
type = 'project';
id = interfaceData.project_id;
}
@@ -609,17 +623,38 @@ class userController extends baseController {
if (type === 'project') {
let projectInst = yapi.getInst(projectModel);
let projectData = await projectInst.get(id);
- result["project_id"] = projectData._id;
- result["project_name"] = projectData.prd_host + projectData.basepath;
+ result.project = projectData.toObject();
+ let ownerAuth = await this.checkAuth(id, 'project', 'danger'), devAuth;
+ if(ownerAuth){
+ result.project.role = 'owner'
+ }else{
+ devAuth = await this.checkAuth(id, 'project', 'site');
+ if(devAuth){
+ result.project.role = 'dev'
+ }else{
+ result.project.role = 'member'
+ }
+ }
type = 'group';
- id = projectData.group_id
+ id = projectData.group_id;
}
if (type === 'group') {
let groupInst = yapi.getInst(groupModel);
let groupData = await groupInst.get(id);
- result["group_id"] = groupData._id;
- result["group_name"] = groupData.group_name;
+ result.group = groupData.toObject();
+ let ownerAuth = await this.checkAuth(id, 'group', 'danger'), devAuth;
+ if(ownerAuth){
+ result.group.role = 'owner'
+ }else{
+ devAuth = await this.checkAuth(id, 'group', 'site');
+ if(devAuth){
+ result.group.role = 'dev'
+ }else{
+ result.group.role = 'member'
+ }
+ }
+
}
return ctx.body = yapi.commons.resReturn(result)
diff --git a/ydoc.json b/ydoc.json
index fe8d4fdb..39bede36 100644
--- a/ydoc.json
+++ b/ydoc.json
@@ -73,7 +73,7 @@
"description": "高效、易用、功能强大、的api管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。"
},
"content": "./README/README-mock.md" // 内容(这里以markdown文件举例)
-
+
},{
"name": "api",
"title": "",
@@ -85,8 +85,8 @@
"options": {
"type": "interface", // 类型,可选 component 和 lib,默认 component
"source": true, // 是否生成源文件预览,默认 false
- "categories":["group","user","project", "interface"]
-
+ "categories":["group","user","project", "interface","follow"]
+
}
}]
}