diff --git a/README.md b/README.md index 7588e8053..4d06e1810 100755 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ +# Why fork YApi ? What I did ? +yapi 目前尚不支持接口多级分类,因此按照[社区项目](https://github.com/herenwei/yapi)的[方式](https://github.com/herenwei/yapi/commit/448a6486110858326b2756b9f85bceafcd158446#)进行了二次开发。在该项目的基础上,我调整了拖拽接口功能(分类不支持拖拽,但可以设置排序值来决定顺序),支持接口可拖拽排序或拖入到别的分类下(该项目仅支持同级目录下的接口排序)。 + +除了以上不同点外,yapi本身的导入导出`json`数据也要配套的进行调整,否则多级目录导出的数据导入到别的项目将导致不直接包含接口的目录丢失。 + +由于业务需要,对 [RAP1](https://github.com/thx/RAP) 导出的接口数据也做了导入支持,在插件 [rap1平台数据导入](https://github.com/wxxcarl/yapi-plugin-import-rap) 基础上按照多级目录适配做了调整,发布在 [这里](https://github.com/zeyongTsai/yapi-plugin-import-rap)。 + +postman 也是支持多级目录的,只有这样改才能更好的适配,目前还没对 postman 的数据做适配,欢迎大家一起开发。 + +# 增加的特性 +1. 多级接口分类 +2. 对接RAP1的多级接口分类 +3. 分组项目分类 + +---- +以下是官方原文档: + + ## YApi 可视化接口管理平台 体验地址: diff --git a/client/containers/AddProject/AddProject.js b/client/containers/AddProject/AddProject.js index 9be8ca415..b62277409 100755 --- a/client/containers/AddProject/AddProject.js +++ b/client/containers/AddProject/AddProject.js @@ -4,6 +4,7 @@ import { connect } from 'react-redux'; import { Button, Form, Input, Icon, Tooltip, Select, message, Row, Col, Radio } from 'antd'; import { addProject } from '../../reducer/modules/project.js'; import { fetchGroupList } from '../../reducer/modules/group.js'; +import { fetchSubGroupList } from '../../reducer/modules/subGroup.js' import { autobind } from 'core-decorators'; import { setBreadcrumb } from '../../reducer/modules/user'; const { TextArea } = Input; @@ -33,13 +34,15 @@ const formItemLayout = { state => { return { groupList: state.group.groupList, + subGroupList: state.subGroup.subGroupList, currGroup: state.group.currGroup }; }, { fetchGroupList, addProject, - setBreadcrumb + setBreadcrumb, + fetchSubGroupList } ) @withRouter @@ -48,17 +51,20 @@ class ProjectList extends Component { super(props); this.state = { groupList: [], + subGroupList: [], currGroupId: null }; } static propTypes = { groupList: PropTypes.array, + subGroupList: PropTypes.array, form: PropTypes.object, currGroup: PropTypes.object, addProject: PropTypes.func, history: PropTypes.object, setBreadcrumb: PropTypes.func, - fetchGroupList: PropTypes.func + fetchGroupList: PropTypes.func, + fetchSubGroupList: PropTypes.func }; handlePath = e => { @@ -67,6 +73,12 @@ class ProjectList extends Component { basepath: handlePath(val) }); }; + handleGroupSelect = async (value) => { + await this.props.fetchSubGroupList(value) + this.setState({ + subGroupList: this.props.subGroupList + }) + }; // 确认添加项目 @autobind @@ -78,6 +90,7 @@ class ProjectList extends Component { values.group_id = values.group; values.icon = constants.PROJECT_ICON[0]; values.color = pickRandomProperty(constants.PROJECT_COLOR); + values.sub_group_id = values.subGroup || 0 addProject(values).then(res => { if (res.payload.data.errcode == 0) { form.resetFields(); @@ -99,6 +112,13 @@ class ProjectList extends Component { } this.setState({ currGroupId: this.props.currGroup._id ? this.props.currGroup._id : this.props.groupList[0]._id + }, async () => { + if (this.state.currGroupId) { + await this.props.fetchSubGroupList(this.state.currGroupId) + this.setState({ + subGroupList: this.props.subGroupList + }) + } }); this.setState({ groupList: this.props.groupList }); } @@ -125,7 +145,7 @@ class ProjectList extends Component { } ] })( - {this.state.groupList.map((item, index) => (