mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-21 05:19:42 +08:00
feat: 我的关注页面
This commit is contained in:
parent
f11970cf05
commit
71cd6c3b1b
@ -7,9 +7,6 @@ import PropTypes from 'prop-types';
|
||||
class ProjectCard extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
static propTypes = {
|
||||
@ -18,13 +15,12 @@ class ProjectCard extends Component {
|
||||
|
||||
render() {
|
||||
const { projectData } = this.props;
|
||||
console.log(projectData);
|
||||
return (
|
||||
<Link to={`/project/${projectData._id}`}>
|
||||
<Card bordered={false} bodyStyle={{padding: 16}} className="m-card">
|
||||
<div className="m-card-logo">
|
||||
<Icon type="area-chart" className="icon" />
|
||||
<p className="name">{projectData.name}</p>
|
||||
<p className="name">{projectData.name || projectData.projectname}</p>
|
||||
</div>
|
||||
<div className="m-card-btns" style={{display: 'none'}}>btns</div>
|
||||
</Card>
|
||||
|
@ -1,10 +1,48 @@
|
||||
import React, { Component } from 'react';
|
||||
import './Follows.scss';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { Row, Col } from 'antd';
|
||||
import { getFollowList } from '../../reducer/modules/follow';
|
||||
import Subnav from '../../components/Subnav/Subnav.js';
|
||||
import ProjectCard from '../../components/ProjectCard/ProjectCard.js';
|
||||
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
data: state.follow.data
|
||||
}
|
||||
},
|
||||
{
|
||||
getFollowList
|
||||
}
|
||||
)
|
||||
class Follows extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
data: []
|
||||
}
|
||||
}
|
||||
static propTypes = {
|
||||
getFollowList: PropTypes.func
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.getFollowList(107).then((res) => {
|
||||
console.log(res);
|
||||
if (res.payload.data.errcode === 0) {
|
||||
this.setState({
|
||||
data: res.payload.data.data.list
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
render () {
|
||||
const data = this.state.data;
|
||||
console.log(data);
|
||||
return (
|
||||
<div>
|
||||
<Subnav
|
||||
@ -17,14 +55,15 @@ class Follows extends Component {
|
||||
path: '/follow'
|
||||
}]}/>
|
||||
<div className="g-row">
|
||||
<div className="follow-box">
|
||||
<div className="follow-container">
|
||||
<ProjectCard />
|
||||
<ProjectCard />
|
||||
<ProjectCard />
|
||||
<ProjectCard />
|
||||
</div>
|
||||
</div>
|
||||
<Row gutter={16} className="follow-box">
|
||||
{data.map((item, index) => {
|
||||
console.log(item);
|
||||
return (
|
||||
<Col span={6} key={index}>
|
||||
<ProjectCard projectData={item} />
|
||||
</Col>);
|
||||
})}
|
||||
</Row>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
@ -3,10 +3,5 @@
|
||||
|
||||
.follow-box{
|
||||
padding: 24px;
|
||||
background-color: #FFF;
|
||||
.follow-container{
|
||||
display: flex;
|
||||
display: -webkit-flex;
|
||||
}
|
||||
|
||||
background-color: #fff;
|
||||
}
|
@ -6,7 +6,6 @@ class MemberList extends Component {
|
||||
render() {
|
||||
return (
|
||||
<div className="m-panel">
|
||||
chengyuan 列表 成员
|
||||
|
||||
</div>
|
||||
);
|
||||
|
@ -133,17 +133,17 @@ class ProjectList extends Component {
|
||||
})
|
||||
}
|
||||
|
||||
// 分页逻辑
|
||||
@autobind
|
||||
paginationChange(pageNum) {
|
||||
this.props.fetchProjectList(this.props.currGroup._id, pageNum).then((res) => {
|
||||
if (res.payload.data.errcode) {
|
||||
message.error(res.payload.data.errmsg);
|
||||
} else {
|
||||
this.props.changeTableLoading(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
// // 分页逻辑 取消分页
|
||||
// @autobind
|
||||
// paginationChange(pageNum) {
|
||||
// this.props.fetchProjectList(this.props.currGroup._id, pageNum).then((res) => {
|
||||
// if (res.payload.data.errcode) {
|
||||
// message.error(res.payload.data.errmsg);
|
||||
// } else {
|
||||
// this.props.changeTableLoading(false);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
// 切换分组
|
||||
|
34
client/reducer/modules/follow.js
Normal file
34
client/reducer/modules/follow.js
Normal file
@ -0,0 +1,34 @@
|
||||
import axios from 'axios';
|
||||
|
||||
// Actions
|
||||
const GET_FOLLOW_LIST = 'yapi/follow/GET_FOLLOW_LIST';
|
||||
|
||||
// Reducer
|
||||
const initialState = {
|
||||
data: []
|
||||
};
|
||||
|
||||
export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case GET_FOLLOW_LIST: {
|
||||
console.log(action);
|
||||
return {
|
||||
...state,
|
||||
data: action.payload.data.data
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
// Action Creators
|
||||
export function getFollowList(uid) {
|
||||
return {
|
||||
type: GET_FOLLOW_LIST,
|
||||
payload: axios.get('/api/follow/list', {
|
||||
params: { uid }
|
||||
})
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import inter from './interface.js'
|
||||
import news from './news.js'
|
||||
import addInterface from './addInterface.js'
|
||||
import menu from './menu.js'
|
||||
import follow from './follow.js'
|
||||
|
||||
export default combineReducers({
|
||||
group,
|
||||
@ -14,5 +15,6 @@ export default combineReducers({
|
||||
project,
|
||||
news,
|
||||
addInterface,
|
||||
menu
|
||||
menu,
|
||||
follow
|
||||
})
|
||||
|
@ -579,6 +579,7 @@ class projectController extends baseController {
|
||||
* @method GET
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @author wenbo.dong
|
||||
* @param {String} project_id
|
||||
*/
|
||||
async download(ctx) {
|
||||
|
@ -1284,6 +1284,7 @@ var projectController = function (_baseController) {
|
||||
* @method GET
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @author wenbo.dong
|
||||
* @param {String} project_id
|
||||
*/
|
||||
|
||||
|
@ -406,7 +406,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -443,7 +443,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
@ -541,7 +541,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -637,7 +637,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -725,7 +725,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"logout success..."</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -764,7 +764,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token string">"ok"</span>
|
||||
@ -855,7 +855,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" ><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" ><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -951,7 +951,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"logout success..."</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -1436,7 +1436,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"ok"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
@ -1549,7 +1549,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#37" target="_blank">./server/controllers/project.js:37</a>
|
||||
<a href="./static/server/controllers/project.js.html#39" target="_blank">./server/controllers/project.js:39</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1661,7 +1661,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -1702,7 +1702,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#127" target="_blank">./server/controllers/project.js:127</a>
|
||||
<a href="./static/server/controllers/project.js.html#137" target="_blank">./server/controllers/project.js:137</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1756,7 +1756,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -1786,7 +1786,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#170" target="_blank">./server/controllers/project.js:170</a>
|
||||
<a href="./static/server/controllers/project.js.html#188" target="_blank">./server/controllers/project.js:188</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1840,7 +1840,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -1870,7 +1870,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#223" target="_blank">./server/controllers/project.js:223</a>
|
||||
<a href="./static/server/controllers/project.js.html#254" target="_blank">./server/controllers/project.js:254</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1912,7 +1912,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
@ -1948,7 +1948,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#248" target="_blank">./server/controllers/project.js:248</a>
|
||||
<a href="./static/server/controllers/project.js.html#279" target="_blank">./server/controllers/project.js:279</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1990,7 +1990,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -2031,7 +2031,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#272" target="_blank">./server/controllers/project.js:272</a>
|
||||
<a href="./static/server/controllers/project.js.html#303" target="_blank">./server/controllers/project.js:303</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2073,7 +2073,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -2258,7 +2258,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#313" target="_blank">./server/controllers/project.js:313</a>
|
||||
<a href="./static/server/controllers/project.js.html#344" target="_blank">./server/controllers/project.js:344</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2300,7 +2300,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -2330,7 +2330,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#373" target="_blank">./server/controllers/project.js:373</a>
|
||||
<a href="./static/server/controllers/project.js.html#419" target="_blank">./server/controllers/project.js:419</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2448,7 +2448,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code">
|
||||
<span class="token comment" spellcheck="true">//请求示例</span>
|
||||
<span class="token punctuation">{</span>
|
||||
<span class="token string">"id"</span><span class="token punctuation">:</span> <span class="token number">8</span><span class="token punctuation">,</span>
|
||||
@ -2490,7 +2490,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#464" target="_blank">./server/controllers/project.js:464</a>
|
||||
<a href="./static/server/controllers/project.js.html#520" target="_blank">./server/controllers/project.js:520</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2532,7 +2532,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"ok"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -2585,7 +2585,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#519" target="_blank">./server/controllers/project.js:519</a>
|
||||
<a href="./static/server/controllers/project.js.html#575" target="_blank">./server/controllers/project.js:575</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2868,7 +2868,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code">
|
||||
<span class="token comment" spellcheck="true">//请求 /interface/add</span>
|
||||
<span class="token comment" spellcheck="true">//header Content-Type:application/json</span>
|
||||
|
||||
@ -3003,7 +3003,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">.</span><span class="token operator">/</span>api<span class="token operator">/</span><span class="token keyword">interface</span><span class="token operator">/</span><span class="token keyword">get</span><span class="token punctuation">.</span>json</code></pre>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">.</span><span class="token operator">/</span>api<span class="token operator">/</span><span class="token keyword">interface</span><span class="token operator">/</span><span class="token keyword">get</span><span class="token punctuation">.</span>json</code></pre>
|
||||
|
||||
|
||||
</div>
|
||||
@ -3068,7 +3068,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">.</span><span class="token operator">/</span>api<span class="token operator">/</span><span class="token keyword">interface</span><span class="token operator">/</span>list<span class="token punctuation">.</span>json</code></pre>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">.</span><span class="token operator">/</span>api<span class="token operator">/</span><span class="token keyword">interface</span><span class="token operator">/</span>list<span class="token punctuation">.</span>json</code></pre>
|
||||
|
||||
|
||||
</div>
|
||||
@ -3293,7 +3293,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -3366,7 +3366,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -3461,7 +3461,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token operator">/</span>follow<span class="token operator">/</span>list</code></pre>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token operator">/</span>follow<span class="token operator">/</span>list</code></pre>
|
||||
|
||||
|
||||
</div>
|
||||
@ -3526,7 +3526,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token operator">/</span>follow<span class="token operator">/</span>del</code></pre>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token operator">/</span>follow<span class="token operator">/</span>del</code></pre>
|
||||
|
||||
|
||||
</div>
|
||||
@ -3536,7 +3536,7 @@
|
||||
<h3 id="-follow-add" class="page-header subject">
|
||||
/follow/add
|
||||
|
||||
<span class="ui-badge">POST</span>
|
||||
<span class="ui-badge">GET</span>
|
||||
|
||||
|
||||
<a class="hashlink" href="#-follow-add">#</a>
|
||||
@ -3627,7 +3627,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token operator">/</span>follow<span class="token operator">/</span>add</code></pre>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token operator">/</span>follow<span class="token operator">/</span>add</code></pre>
|
||||
|
||||
|
||||
</div>
|
||||
@ -4344,9 +4344,9 @@
|
||||
</thead>
|
||||
|
||||
<tr>
|
||||
<td>uid</td>
|
||||
<td>typeid</td>
|
||||
<td>Number</td>
|
||||
<td>用户id, 不能为空</td>
|
||||
<td>动态类型id, 不能为空</td>
|
||||
<td>
|
||||
|
||||
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
|
||||
@ -4380,7 +4380,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token operator">/</span>log<span class="token operator">/</span>list</code></pre>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token operator">/</span>log<span class="token operator">/</span>list</code></pre>
|
||||
|
||||
|
||||
</div>
|
||||
@ -4435,8 +4435,8 @@
|
||||
var $this = $(this);
|
||||
$this.removeClass('extend').addClass('fold');
|
||||
$this.html('折叠代码');
|
||||
$this.prev().height('auto');
|
||||
$this.prev().parent().height('auto');
|
||||
$this.parent().children('.js-code').height('auto');
|
||||
$this.parent().height('auto');
|
||||
});
|
||||
$('.ydoc-example').delegate('.fold', 'click', function() {
|
||||
var $this = $(this);
|
||||
@ -4444,7 +4444,7 @@
|
||||
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
|
||||
$this.removeClass('fold').addClass('extend');
|
||||
$this.parent().height(EXAMPLE_MAX_HEIGHT); // pre
|
||||
$this.prev().height(EXAMPLE_MAX_HEIGHT); // code
|
||||
$this.parent().children('.js-code').height(EXAMPLE_MAX_HEIGHT); // code
|
||||
$this.html("展开更多……");
|
||||
});
|
||||
}
|
||||
|
@ -175,8 +175,8 @@
|
||||
var $this = $(this);
|
||||
$this.removeClass('extend').addClass('fold');
|
||||
$this.html('折叠代码');
|
||||
$this.prev().height('auto');
|
||||
$this.prev().parent().height('auto');
|
||||
$this.parent().children('.js-code').height('auto');
|
||||
$this.parent().height('auto');
|
||||
});
|
||||
$('.ydoc-example').delegate('.fold', 'click', function() {
|
||||
var $this = $(this);
|
||||
@ -184,7 +184,7 @@
|
||||
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
|
||||
$this.removeClass('fold').addClass('extend');
|
||||
$this.parent().height(EXAMPLE_MAX_HEIGHT); // pre
|
||||
$this.prev().height(EXAMPLE_MAX_HEIGHT); // code
|
||||
$this.parent().children('.js-code').height(EXAMPLE_MAX_HEIGHT); // code
|
||||
$this.html("展开更多……");
|
||||
});
|
||||
}
|
||||
|
@ -68,23 +68,23 @@
|
||||
<div class="ydoc-container-content " id="readme">
|
||||
|
||||
<article class="markdown-body">
|
||||
<h2 class="subject" id="快速开始">快速开始 <a class="hashlink" href="#快速开始">#</a></h2><h3 class="subject" id="1 接口管理架构">1 接口管理架构 <a class="hashlink" href="#1 接口管理架构">#</a></h3><p>平台以<strong>项目分组</strong> -> <strong>项目</strong> -> <strong>接口</strong>的划分进行接口组织管理。</p>
|
||||
<h2 class="subject" id="快速开始">快速开始 <a class="hashlink" href="#快速开始">#</a></h2><h3 class="subject" id="1_接口管理架构">1 接口管理架构 <a class="hashlink" href="#1_接口管理架构">#</a></h3><p>平台以<strong>项目分组</strong> -> <strong>项目</strong> -> <strong>接口</strong>的划分进行接口组织管理。</p>
|
||||
<p><img src="http://upload-images.jianshu.io/upload_images/842107-305ba49a60ee1ff5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
|
||||
<h4 class="subject" id="1.1 项目分组">1.1 项目分组 <a class="hashlink" href="#1.1 项目分组">#</a></h4><p>登录之后进到项目首页,左边侧边栏显示的即分组列表。</p>
|
||||
<h4 class="subject" id="1.1_项目分组">1.1 项目分组 <a class="hashlink" href="#1.1_项目分组">#</a></h4><p>登录之后进到项目首页,左边侧边栏显示的即分组列表。</p>
|
||||
<p><img src="http://upload-images.jianshu.io/upload_images/842107-d90ca4b3242fa760.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "200" style="margin-left:170px;display:block;" alt="图片名称" align=center /></p>
|
||||
<p>管理员有权限添加或删除分组。</p>
|
||||
<p><img src="http://upload-images.jianshu.io/upload_images/842107-a0d4d9a98003896a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "500" style="margin-left:170px;display:block;" alt="图片名称" align=center /></p>
|
||||
<blockquote>
|
||||
<p>分组名称具有唯一性</p>
|
||||
</blockquote>
|
||||
<h4 class="subject" id="1.2 项目">1.2 项目 <a class="hashlink" href="#1.2 项目">#</a></h4><p>选中不同的分组,右边会显示该分组下的项目列表。</p>
|
||||
<h4 class="subject" id="1.2_项目">1.2 项目 <a class="hashlink" href="#1.2_项目">#</a></h4><p>选中不同的分组,右边会显示该分组下的项目列表。</p>
|
||||
<p><img src="http://upload-images.jianshu.io/upload_images/842107-137bcae58b84715e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
|
||||
<p>创建项目需要填写项目名称,项目线上域名(添加完成后可配置项目其他环境域名),项目接口基本路径(接口路径前面相同的部分)以及项目描述。</p>
|
||||
<p><img src="http://upload-images.jianshu.io/upload_images/842107-360a50ddb746f73d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
|
||||
<blockquote>
|
||||
<p>项目『线上域名 + 基本路径』具有唯一性</p>
|
||||
</blockquote>
|
||||
<h4 class="subject" id="1.3 接口">1.3 接口 <a class="hashlink" href="#1.3 接口">#</a></h4><p>点击项目名称,进入该项目接口列表。</p>
|
||||
<h4 class="subject" id="1.3_接口">1.3 接口 <a class="hashlink" href="#1.3_接口">#</a></h4><p>点击项目名称,进入该项目接口列表。</p>
|
||||
<p><img src="http://upload-images.jianshu.io/upload_images/842107-e858005f714f4889.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
|
||||
<p>点击编辑,进入接口详情页(之后接口详情页和编辑也会分开),可以编辑接口或者请求测试真实接口。</p>
|
||||
<p><img src="http://upload-images.jianshu.io/upload_images/842107-78c0ea839619d068.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
|
||||
@ -134,8 +134,8 @@
|
||||
var $this = $(this);
|
||||
$this.removeClass('extend').addClass('fold');
|
||||
$this.html('折叠代码');
|
||||
$this.prev().height('auto');
|
||||
$this.prev().parent().height('auto');
|
||||
$this.parent().children('.js-code').height('auto');
|
||||
$this.parent().height('auto');
|
||||
});
|
||||
$('.ydoc-example').delegate('.fold', 'click', function() {
|
||||
var $this = $(this);
|
||||
@ -143,7 +143,7 @@
|
||||
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
|
||||
$this.removeClass('fold').addClass('extend');
|
||||
$this.parent().height(EXAMPLE_MAX_HEIGHT); // pre
|
||||
$this.prev().height(EXAMPLE_MAX_HEIGHT); // code
|
||||
$this.parent().children('.js-code').height(EXAMPLE_MAX_HEIGHT); // code
|
||||
$this.html("展开更多……");
|
||||
});
|
||||
}
|
||||
|
@ -70,7 +70,7 @@
|
||||
<article class="markdown-body">
|
||||
<h2 class="subject" id="Mock功能">Mock功能 <a class="hashlink" href="#Mock功能">#</a></h2> <p style='text-indent:2em;line-height:1.8em'>yapi的Mock功能可以根据用户的输入接口信息如协议、URL、接口名、请求头、请求参数、mock规则(<a href="#mock">点击到Mock规则</a>)生成Mock接口,这些接口会自动生成模拟数据,支持复杂的生成逻辑,创建者可以自由构造需要的数据。而且与常见的Mock方式如将Mock写在代码里和JS拦截等相比yapi的Mock在使用场景和效率和复杂度上是相差甚远的,正是由于yapi的Mock是一个第三方平台那么在 团队开发时任何人都可以权限许可下创建、修改接口信息等操作,这对于团队开发是很有好处的。</p>
|
||||
|
||||
<h3 class="subject" id="1 Mock步骤">1 Mock步骤 <a class="hashlink" href="#1 Mock步骤">#</a></h3><h4 class="subject" id="1.1 创建接口">1.1 创建接口 <a class="hashlink" href="#1.1 创建接口">#</a></h4><p>通过点击页面上的"+添加接口"</p>
|
||||
<h3 class="subject" id="1_Mock步骤">1 Mock步骤 <a class="hashlink" href="#1_Mock步骤">#</a></h3><h4 class="subject" id="1.1_创建接口">1.1 创建接口 <a class="hashlink" href="#1.1_创建接口">#</a></h4><p>通过点击页面上的"+添加接口"</p>
|
||||
<p><img src="http://note.youdao.com/yws/api/personal/file/WEB613bd4f29db038f2b41c03dcfceda2b6?method=download&shareKey=29bfc2b855f6f26ce0079baf567e54cc" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
|
||||
<p> 输入协议、URL、接口名、请求头、请求参数、Mock规则(<a href="#mock">点击到Mock规则</a>)等信息。</p>
|
||||
<p><img src="http://note.youdao.com/yws/api/personal/file/WEB680a37ba304768804b23cf2cf36ed40d?method=download&shareKey=0d750695dce3a4c7abf697fa58d24c57" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
|
||||
@ -84,14 +84,14 @@
|
||||
<p>取到上面的链接在浏览器中请求就可以得到如下结果。</p>
|
||||
<p><img src="http://note.youdao.com/yws/api/personal/file/WEB1d1f7dc7b83a8cd6f576953cf45e9719?method=download&shareKey=99b4af9baac527b969543dd0a909d2a1" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
|
||||
<p><span id = "mock"></span></p>
|
||||
<h3 class="subject" id="2.1 Mock语法规范">2.1 Mock语法规范 <a class="hashlink" href="#2.1 Mock语法规范">#</a></h3><blockquote>
|
||||
<h3 class="subject" id="2.1_Mock语法规范">2.1 Mock语法规范 <a class="hashlink" href="#2.1_Mock语法规范">#</a></h3><blockquote>
|
||||
<p>了解更多Mock详情:<a href="https://github.com/nuysoft/Mock/wiki/Syntax-Specification">Mock.js 官方文档</a></p>
|
||||
</blockquote>
|
||||
<p>Mock.js 的语法规范包括两部分:</p>
|
||||
<p><a href="#DTD">1. 数据模板定义规范(Data Template Definition,DTD)</a></p>
|
||||
<p><a href="#DPD">2. 数据占位符定义规范(Data Placeholder Definition,DPD)</a></p>
|
||||
<p><span id = "DTD"></span></p>
|
||||
<h3 class="subject" id="数据模板定义规范(Data Template Definition,DTD)">数据模板定义规范(Data Template Definition,DTD) <a class="hashlink" href="#数据模板定义规范(Data Template Definition,DTD)">#</a></h3><p>数据模板中的每个属性由 3 部分构成:属性名、生成规则、属性值:</p>
|
||||
<h3 class="subject" id="数据模板定义规范(Data_Template_Definition,DTD)">数据模板定义规范(Data Template Definition,DTD) <a class="hashlink" href="#数据模板定义规范(Data_Template_Definition,DTD)">#</a></h3><p>数据模板中的每个属性由 3 部分构成:属性名、生成规则、属性值:</p>
|
||||
<pre><code>// 属性名 name (与生成规则之间用 "|<span class="token string">" 隔开)
|
||||
// 生成规则 rule(生成规则有7种详见下面的生成规则)
|
||||
// 属性值 value(可以含有 "</span>@占位符" 同时也指定了最终值的初始值和类型)
|
||||
@ -107,14 +107,14 @@
|
||||
'name|count.dcount'<span class="token operator">:</span> value
|
||||
'name|+step'<span class="token operator">:</span> value
|
||||
</code></pre><p>下面提供了6种生成规则以及示例包括 String、Number、Boolean、Object、Array:</p>
|
||||
<h4 class="subject" id="1. 属性值是字符串 String">1. 属性值是字符串 String <a class="hashlink" href="#1. 属性值是字符串 String">#</a></h4><pre><code><span class="token number">1</span>. 'name|min-max'<span class="token operator">:</span> string
|
||||
<h4 class="subject" id="1._属性值是字符串_String">1. 属性值是字符串 String <a class="hashlink" href="#1._属性值是字符串_String">#</a></h4><pre><code><span class="token number">1</span>. 'name|min-max'<span class="token operator">:</span> string
|
||||
|
||||
通过重复 string 生成一个字符串,重复次数大于等于 min,小于等于 max。
|
||||
|
||||
<span class="token number">2</span>. 'name|count'<span class="token operator">:</span> string
|
||||
|
||||
通过重复 string 生成一个字符串,重复次数等于 count。
|
||||
</code></pre><h4 class="subject" id="2. 属性值是数字 Number">2. 属性值是数字 Number <a class="hashlink" href="#2. 属性值是数字 Number">#</a></h4><pre><code><span class="token number">1</span>. 'name|+<span class="token number">1</span>'<span class="token operator">:</span> number
|
||||
</code></pre><h4 class="subject" id="2._属性值是数字_Number">2. 属性值是数字 Number <a class="hashlink" href="#2._属性值是数字_Number">#</a></h4><pre><code><span class="token number">1</span>. 'name|+<span class="token number">1</span>'<span class="token operator">:</span> number
|
||||
|
||||
属性值自动加 <span class="token number">1</span>,初始值为 number。
|
||||
|
||||
@ -140,21 +140,21 @@ Mock.mock(<span class="token punctuation">{</span>
|
||||
<span class="token property">"number3"</span><span class="token operator">:</span> <span class="token number">123.777</span><span class="token punctuation">,</span>
|
||||
<span class="token property">"number4"</span><span class="token operator">:</span> <span class="token number">123.1231091814</span>
|
||||
<span class="token punctuation">}</span>
|
||||
</code></pre><h4 class="subject" id="3. 属性值是布尔型 Boolean">3. 属性值是布尔型 Boolean <a class="hashlink" href="#3. 属性值是布尔型 Boolean">#</a></h4><pre><code><span class="token number">1</span>. 'name|<span class="token number">1</span>'<span class="token operator">:</span> boolean
|
||||
</code></pre><h4 class="subject" id="3._属性值是布尔型_Boolean">3. 属性值是布尔型 Boolean <a class="hashlink" href="#3._属性值是布尔型_Boolean">#</a></h4><pre><code><span class="token number">1</span>. 'name|<span class="token number">1</span>'<span class="token operator">:</span> boolean
|
||||
|
||||
随机生成一个布尔值,值为 <span class="token boolean">true</span> 的概率是 <span class="token number">1</span>/<span class="token number">2</span>,值为 <span class="token boolean">false</span> 的概率同样是 <span class="token number">1</span>/<span class="token number">2</span>。
|
||||
|
||||
<span class="token number">2</span>. 'name|min-max'<span class="token operator">:</span> value
|
||||
|
||||
随机生成一个布尔值,值为 value 的概率是 min / (min + max<span class="token punctuation">)</span>,值为 !value 的概率是 max / (min + max<span class="token punctuation">)</span>。
|
||||
</code></pre><h4 class="subject" id="4. 属性值是对象 Object">4. 属性值是对象 Object <a class="hashlink" href="#4. 属性值是对象 Object">#</a></h4><pre><code><span class="token number">1</span>. 'name|count'<span class="token operator">:</span> object
|
||||
</code></pre><h4 class="subject" id="4._属性值是对象_Object">4. 属性值是对象 Object <a class="hashlink" href="#4._属性值是对象_Object">#</a></h4><pre><code><span class="token number">1</span>. 'name|count'<span class="token operator">:</span> object
|
||||
|
||||
从属性值 object 中随机选取 count 个属性。
|
||||
|
||||
<span class="token number">2</span>. 'name|min-max'<span class="token operator">:</span> object
|
||||
|
||||
从属性值 object 中随机选取 min 到 max 个属性。
|
||||
</code></pre><h4 class="subject" id="5. 属性值是数组 Array">5. 属性值是数组 Array <a class="hashlink" href="#5. 属性值是数组 Array">#</a></h4><pre><code><span class="token number">1</span>. 'name|<span class="token number">1</span>'<span class="token operator">:</span> array
|
||||
</code></pre><h4 class="subject" id="5._属性值是数组_Array">5. 属性值是数组 Array <a class="hashlink" href="#5._属性值是数组_Array">#</a></h4><pre><code><span class="token number">1</span>. 'name|<span class="token number">1</span>'<span class="token operator">:</span> array
|
||||
|
||||
从属性值 array 中随机选取 <span class="token number">1</span> 个元素,作为最终值。
|
||||
|
||||
@ -170,7 +170,7 @@ Mock.mock(<span class="token punctuation">{</span>
|
||||
|
||||
通过重复属性值 array 生成一个新数组,重复次数为 count。
|
||||
</code></pre><p><span id = "DPD"></span></p>
|
||||
<h3 class="subject" id="数据占位符定义规范(Data Placeholder Definition,DPD)">数据占位符定义规范(Data Placeholder Definition,DPD) <a class="hashlink" href="#数据占位符定义规范(Data Placeholder Definition,DPD)">#</a></h3><pre><code>占位符 只是在属性值字符串中占个位置,并不出现在最终的属性值中。
|
||||
<h3 class="subject" id="数据占位符定义规范(Data_Placeholder_Definition,DPD)">数据占位符定义规范(Data Placeholder Definition,DPD) <a class="hashlink" href="#数据占位符定义规范(Data_Placeholder_Definition,DPD)">#</a></h3><pre><code>占位符 只是在属性值字符串中占个位置,并不出现在最终的属性值中。
|
||||
|
||||
占位符 的格式为:
|
||||
|
||||
@ -240,8 +240,8 @@ name<span class="token operator">:</span> <span class="token punctuation">{</spa
|
||||
var $this = $(this);
|
||||
$this.removeClass('extend').addClass('fold');
|
||||
$this.html('折叠代码');
|
||||
$this.prev().height('auto');
|
||||
$this.prev().parent().height('auto');
|
||||
$this.parent().children('.js-code').height('auto');
|
||||
$this.parent().height('auto');
|
||||
});
|
||||
$('.ydoc-example').delegate('.fold', 'click', function() {
|
||||
var $this = $(this);
|
||||
@ -249,7 +249,7 @@ name<span class="token operator">:</span> <span class="token punctuation">{</spa
|
||||
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
|
||||
$this.removeClass('fold').addClass('extend');
|
||||
$this.parent().height(EXAMPLE_MAX_HEIGHT); // pre
|
||||
$this.prev().height(EXAMPLE_MAX_HEIGHT); // code
|
||||
$this.parent().children('.js-code').height(EXAMPLE_MAX_HEIGHT); // code
|
||||
$this.html("展开更多……");
|
||||
});
|
||||
}
|
||||
|
@ -129,7 +129,8 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
$('.markdown-body pre').map(function(i, item) {
|
||||
$(item).addClass('ydoc-example');
|
||||
$(item).addClass('ydoc-example').append('<div class="ui-copy js-copy" data-clipboard-action="copy" data-clipboard-target=".js-code-' + i + '" data-copy-number="' + i + '">copy</div><div class="copy-tip copy-tip-' + i + '">已复制</div>');
|
||||
$(item).children('code').addClass('js-code-'+i);
|
||||
});
|
||||
|
||||
var winHeight = $(window).height() - 44,
|
||||
@ -213,4 +214,17 @@ $(document).ready(function() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 代码复制功能
|
||||
var clipboard = new Clipboard('.js-copy');
|
||||
|
||||
clipboard.on('success', function(e) {
|
||||
var copyNumber = $(e.trigger).attr('data-copy-number');
|
||||
$('.copy-tip-'+copyNumber).show();
|
||||
setTimeout(function() {
|
||||
$('.copy-tip-'+copyNumber).hide();
|
||||
}, 1000);
|
||||
e.clearSelection();
|
||||
});
|
||||
|
||||
});
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -106,6 +106,9 @@ class baseController {
|
||||
return this.$user.role;
|
||||
}
|
||||
|
||||
getUsername() {
|
||||
return this.$user.username;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {*} id type对应的id
|
||||
|
@ -114,7 +114,7 @@ class followController extends baseController {
|
||||
/**
|
||||
* 添加关注
|
||||
* @interface /follow/add
|
||||
* @method POST
|
||||
* @method GET
|
||||
* @category follow
|
||||
* @foldnumber 10
|
||||
* @param {Number} uid 用户id
|
||||
@ -131,7 +131,8 @@ class followController extends baseController {
|
||||
uid: 'number',
|
||||
projectid: 'number',
|
||||
projectname: 'string',
|
||||
icon: 'string'
|
||||
icon: 'string',
|
||||
color: 'string'
|
||||
});
|
||||
|
||||
if (!params.uid) {
|
||||
@ -153,17 +154,22 @@ class followController extends baseController {
|
||||
if (!params.icon) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目图标标志不能为空');
|
||||
}
|
||||
if (!params.color) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目颜色不能为空');
|
||||
}
|
||||
|
||||
let data = {
|
||||
uid: params.uid,
|
||||
projectid: params.projectid,
|
||||
projectname: params.projectname,
|
||||
icon: params.icon
|
||||
icon: params.icon,
|
||||
color: params.color
|
||||
|
||||
};
|
||||
|
||||
try {
|
||||
let result = await this.Model.save(data);
|
||||
result = yapi.commons.fieldSelect(result, ['_id', 'uid', 'projectid', 'projectname', 'icon']);
|
||||
result = yapi.commons.fieldSelect(result, ['_id', 'uid', 'projectid', 'projectname', 'icon', 'color']);
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
|
14
static/doc/static/server/controllers/log.js.html
vendored
14
static/doc/static/server/controllers/log.js.html
vendored
@ -59,7 +59,7 @@ class logController extends baseController {
|
||||
* @method GET
|
||||
* @category log
|
||||
* @foldnumber 10
|
||||
* @param {Number} uid 用户id, 不能为空
|
||||
* @param {Number} typeid 动态类型id, 不能为空
|
||||
* @param {Number} [page] 分页页码
|
||||
* @param {Number} [limit] 分页大小
|
||||
* @returns {Object}
|
||||
@ -69,15 +69,17 @@ class logController extends baseController {
|
||||
async list(ctx) {
|
||||
let typeid = ctx.request.query.typeid,
|
||||
page = ctx.request.query.page || 1,
|
||||
limit = ctx.request.query.limit || 10;
|
||||
|
||||
limit = ctx.request.query.limit || 10,
|
||||
type = ctx.request.query.type;
|
||||
if (!typeid) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, 'typeid不能为空');
|
||||
}
|
||||
|
||||
if(!type) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, 'type不能为空');
|
||||
}
|
||||
try {
|
||||
let result = await this.Model.listWithPaging(typeid, page, limit);
|
||||
let count = await this.Model.listCount(typeid);
|
||||
let result = await this.Model.listWithPaging(typeid,type, page, limit);
|
||||
let count = await this.Model.listCount(typeid,type);
|
||||
|
||||
ctx.body = yapi.commons.resReturn({
|
||||
total: Math.ceil(count / limit),
|
||||
|
@ -32,6 +32,7 @@ import interfaceModel from '../models/interface.js';
|
||||
import groupModel from '../models/group';
|
||||
import commons from '../utils/commons.js';
|
||||
import userModel from '../models/user.js';
|
||||
import logModel from '../models/log.js';
|
||||
import Mock from 'mockjs';
|
||||
const send = require('koa-send');
|
||||
|
||||
@ -41,6 +42,7 @@ class projectController extends baseController {
|
||||
super(ctx);
|
||||
this.Model = yapi.getInst(projectModel);
|
||||
this.groupModel = yapi.getInst(groupModel);
|
||||
this.logModel = yapi.getInst(logModel);
|
||||
}
|
||||
|
||||
handleBasepath(basepath) {
|
||||
@ -146,6 +148,14 @@ class projectController extends baseController {
|
||||
|
||||
try {
|
||||
let result = await this.Model.save(data);
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
content: `用户${username}添加了项目${params.name}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.group_id
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -189,6 +199,14 @@ class projectController extends baseController {
|
||||
|
||||
try {
|
||||
let result = await this.Model.addMember(params.id, userdata);
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
content: `用户${username}添加了项目成员${userdata.username}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -226,6 +244,19 @@ class projectController extends baseController {
|
||||
|
||||
try {
|
||||
let result = await this.Model.delMember(params.id, params.member_uid);
|
||||
let username = this.getUsername();
|
||||
let project = await this.Model.get(params.id);
|
||||
for(let i in project.members){
|
||||
if(i.uid === params.member_uid){
|
||||
await this.logModel.save({
|
||||
content: `用户${username}删除了项目${project.name}中的成员${i.username}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
});
|
||||
}
|
||||
}
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -392,6 +423,21 @@ class projectController extends baseController {
|
||||
|
||||
try {
|
||||
let result = await groupInst.changeMemberRole(params.id, params.member_uid, params.role);
|
||||
|
||||
let username = this.getUsername();
|
||||
let project = await this.Model.get(params.id);
|
||||
for(let i in project.members){
|
||||
if(i.uid === params.member_uid){
|
||||
await this.logModel.save({
|
||||
content: `用户${username}修改了项目${project.name}中成员${i.username}的角色为${params.role}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -483,6 +529,16 @@ class projectController extends baseController {
|
||||
if (params.env) data.env = params.env;
|
||||
|
||||
let result = await this.Model.up(id, data);
|
||||
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
content: `用户${username}更新了项目${params.name}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: id
|
||||
});
|
||||
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -550,6 +606,7 @@ class projectController extends baseController {
|
||||
* @method GET
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @author wenbo.dong
|
||||
* @param {String} project_id
|
||||
*/
|
||||
async download(ctx) {
|
||||
|
Loading…
Reference in New Issue
Block a user