mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-15 05:10:47 +08:00
Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev
This commit is contained in:
commit
5115f9d6e2
18
.tags
18
.tags
@ -344,11 +344,6 @@ regActions /Users/qitmac000445/Desktop/YAPI/yapi/client/reducer/modules/user.js
|
|||||||
const.username /Users/qitmac000445/Desktop/YAPI/yapi/client/reducer/modules/user.js /^ password,$/;" property line:106
|
const.username /Users/qitmac000445/Desktop/YAPI/yapi/client/reducer/modules/user.js /^ password,$/;" property line:106
|
||||||
logoutActions /Users/qitmac000445/Desktop/YAPI/yapi/client/reducer/modules/user.js /^export function logoutActions() {$/;" function line:115
|
logoutActions /Users/qitmac000445/Desktop/YAPI/yapi/client/reducer/modules/user.js /^export function logoutActions() {$/;" function line:115
|
||||||
loginTypeAction /Users/qitmac000445/Desktop/YAPI/yapi/client/reducer/modules/user.js /^export function loginTypeAction(index) {$/;" function line:122
|
loginTypeAction /Users/qitmac000445/Desktop/YAPI/yapi/client/reducer/modules/user.js /^export function loginTypeAction(index) {$/;" function line:122
|
||||||
constructor /Users/qitmac000445/Desktop/YAPI/yapi/client/Application.js /^ constructor(props) {$/;" function line:26
|
|
||||||
state.login /Users/qitmac000445/Desktop/YAPI/yapi/client/Application.js /^ this.state = {$/;" property line:28
|
|
||||||
static.checkLoginState /Users/qitmac000445/Desktop/YAPI/yapi/client/Application.js /^ static propTypes = {$/;" property line:33
|
|
||||||
componentDidMount /Users/qitmac000445/Desktop/YAPI/yapi/client/Application.js /^ componentDidMount() {$/;" function line:45
|
|
||||||
render /Users/qitmac000445/Desktop/YAPI/yapi/client/Application.js /^ render() {$/;" function line:78
|
|
||||||
const.height /Users/qitmac000445/Desktop/YAPI/yapi/client/components/Header/Header.js /^const headerStyle = {$/;" property line:13
|
const.height /Users/qitmac000445/Desktop/YAPI/yapi/client/components/Header/Header.js /^const headerStyle = {$/;" property line:13
|
||||||
const.lineHeight /Users/qitmac000445/Desktop/YAPI/yapi/client/components/Header/Header.js /^ 'height': '.56rem',$/;" property line:14
|
const.lineHeight /Users/qitmac000445/Desktop/YAPI/yapi/client/components/Header/Header.js /^ 'height': '.56rem',$/;" property line:14
|
||||||
const.padding /Users/qitmac000445/Desktop/YAPI/yapi/client/components/Header/Header.js /^ 'lineHeight': '.56rem',$/;" property line:15
|
const.padding /Users/qitmac000445/Desktop/YAPI/yapi/client/components/Header/Header.js /^ 'lineHeight': '.56rem',$/;" property line:15
|
||||||
@ -457,7 +452,12 @@ static.curUserRole /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/User/
|
|||||||
getUserList /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/User/List.js /^ getUserList() {$/;" function line:41
|
getUserList /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/User/List.js /^ getUserList() {$/;" function line:41
|
||||||
componentDidMount /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/User/List.js /^ componentDidMount() {$/;" function line:60
|
componentDidMount /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/User/List.js /^ componentDidMount() {$/;" function line:60
|
||||||
render /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/User/List.js /^ render() {$/;" function line:85
|
render /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/User/List.js /^ render() {$/;" function line:85
|
||||||
from.children /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/Project/Project.js /^ static propTypes = {$/;" property line:8
|
from.match /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/Project/Project.js /^ static propTypes = {$/;" property line:9
|
||||||
constructor /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/Project/Project.js /^ constructor(props) {$/;" function line:15
|
constructor /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/Project/Project.js /^ constructor(props) {$/;" function line:16
|
||||||
componentWillMount /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/Project/Project.js /^ componentWillMount() {$/;" function line:19
|
componentWillMount /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/Project/Project.js /^ componentWillMount() {$/;" function line:20
|
||||||
render /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/Project/Project.js /^ render () {$/;" function line:22
|
render /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/Project/Project.js /^ render () {$/;" function line:23
|
||||||
|
constructor /Users/qitmac000445/Desktop/YAPI/yapi/client/Application.js /^ constructor(props) {$/;" function line:26
|
||||||
|
state.login /Users/qitmac000445/Desktop/YAPI/yapi/client/Application.js /^ this.state = {$/;" property line:28
|
||||||
|
static.checkLoginState /Users/qitmac000445/Desktop/YAPI/yapi/client/Application.js /^ static propTypes = {$/;" property line:33
|
||||||
|
componentDidMount /Users/qitmac000445/Desktop/YAPI/yapi/client/Application.js /^ componentDidMount() {$/;" function line:45
|
||||||
|
render /Users/qitmac000445/Desktop/YAPI/yapi/client/Application.js /^ render() {$/;" function line:78
|
||||||
|
9
.tags1
9
.tags1
@ -4,7 +4,8 @@
|
|||||||
!_TAG_PROGRAM_NAME Exuberant Ctags //
|
!_TAG_PROGRAM_NAME Exuberant Ctags //
|
||||||
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
|
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
|
||||||
!_TAG_PROGRAM_VERSION 5.8 //
|
!_TAG_PROGRAM_VERSION 5.8 //
|
||||||
from.children /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/Project/Project.js /^ static propTypes = {$/;" property line:8
|
constructor /Users/qitmac000445/Desktop/YAPI/yapi/client/Application.js /^ constructor(props) {$/;" function line:26
|
||||||
constructor /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/Project/Project.js /^ constructor(props) {$/;" function line:15
|
state.login /Users/qitmac000445/Desktop/YAPI/yapi/client/Application.js /^ this.state = {$/;" property line:28
|
||||||
componentWillMount /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/Project/Project.js /^ componentWillMount() {$/;" function line:19
|
static.checkLoginState /Users/qitmac000445/Desktop/YAPI/yapi/client/Application.js /^ static propTypes = {$/;" property line:33
|
||||||
render /Users/qitmac000445/Desktop/YAPI/yapi/client/containers/Project/Project.js /^ render () {$/;" function line:22
|
componentDidMount /Users/qitmac000445/Desktop/YAPI/yapi/client/Application.js /^ componentDidMount() {$/;" function line:45
|
||||||
|
render /Users/qitmac000445/Desktop/YAPI/yapi/client/Application.js /^ render() {$/;" function line:78
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Route, HashRouter, Redirect, Switch } from 'react-router-dom';
|
import { Route, BrowserRouter as Router, Redirect, Switch } from 'react-router-dom';
|
||||||
import { Home, Group, Project, News, AddInterface, Follows, AddProject } from './containers/index';
|
import { Home, Group, Project, Follows, AddProject } from './containers/index';
|
||||||
import User from './containers/User/User.js';
|
import User from './containers/User/User.js';
|
||||||
import Header from './components/Header/Header';
|
import Header from './components/Header/Header';
|
||||||
import Footer from './components/Footer/Footer';
|
import Footer from './components/Footer/Footer';
|
||||||
@ -52,25 +52,24 @@ export default class App extends Component {
|
|||||||
return <Loading visible />;
|
return <Loading visible />;
|
||||||
} else {
|
} else {
|
||||||
r = (
|
r = (
|
||||||
<HashRouter>
|
<Router>
|
||||||
<div className="router-main">
|
<div className="router-main">
|
||||||
<Header />
|
<Header />
|
||||||
<div className="router-container">
|
<div className="router-container">
|
||||||
<Route path="/" component={Home} exact />
|
<Route path="/" component={Home} exact />
|
||||||
<Switch>
|
<Route path="/group/:id" component={requireAuthentication(Group)} />
|
||||||
<Redirect exact from='/group' to='/group/1' />
|
<Route path="/project/:id" component={requireAuthentication(Project)} />
|
||||||
<Route exact path="/group/:groupName" component={requireAuthentication(Group)} />
|
|
||||||
</Switch>
|
|
||||||
<Route path="/project" component={requireAuthentication(Project)} />
|
|
||||||
<Route path="/user" component={requireAuthentication(User)} />
|
<Route path="/user" component={requireAuthentication(User)} />
|
||||||
<Route path="/news" component={requireAuthentication(News)} />
|
|
||||||
<Route path="/add-interface" component={requireAuthentication(AddInterface)} />
|
|
||||||
<Route path="/follow" component={requireAuthentication(Follows)} />
|
<Route path="/follow" component={requireAuthentication(Follows)} />
|
||||||
<Route path="/add-project" component={requireAuthentication(AddProject)} />
|
<Route path="/add-project" component={requireAuthentication(AddProject)} />
|
||||||
|
{
|
||||||
|
// <Route path="/news" component={requireAuthentication(News)} />
|
||||||
|
// <Route path="/add-interface" component={requireAuthentication(AddInterface)} />
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<Footer />
|
<Footer />
|
||||||
</div>
|
</div>
|
||||||
</HashRouter>
|
</Router>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
|
@ -31,7 +31,7 @@ export default class BreadcrumbNavigation extends Component {
|
|||||||
type = 'project';
|
type = 'project';
|
||||||
}
|
}
|
||||||
const params = { type, id };
|
const params = { type, id };
|
||||||
axios.get('/user/nav', {params: params}).then( (res) => {
|
axios.get('/api/user/nav', {params: params}).then( (res) => {
|
||||||
const data = res.data.data;
|
const data = res.data.data;
|
||||||
// 依次填入group/projec/interface
|
// 依次填入group/projec/interface
|
||||||
if (data.group_name) {
|
if (data.group_name) {
|
||||||
|
@ -11,7 +11,7 @@ class Footer extends Component {
|
|||||||
}
|
}
|
||||||
render () {
|
render () {
|
||||||
const style = {
|
const style = {
|
||||||
'background': 'url(./image/footer-bac.jpg)'
|
'background': 'url(/image/footer-bac.jpg)'
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className = 'footer-wrapper'>
|
<div className = 'footer-wrapper'>
|
||||||
|
@ -53,7 +53,7 @@ const ToolUser = (props)=> (
|
|||||||
</Link>
|
</Link>
|
||||||
<Tooltip placement="bottom" title={'使用文档'}>
|
<Tooltip placement="bottom" title={'使用文档'}>
|
||||||
<li className="toolbar-li">
|
<li className="toolbar-li">
|
||||||
<a target="_blank" href="./doc/index.html"><Icon className="dropdown-link" style={{ fontSize: 16 }} type="question-circle" /></a>
|
<a target="_blank" href="/doc/index.html"><Icon className="dropdown-link" style={{ fontSize: 16 }} type="question-circle" /></a>
|
||||||
</li>
|
</li>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<li className="toolbar-li">
|
<li className="toolbar-li">
|
||||||
@ -69,7 +69,9 @@ const ToolUser = (props)=> (
|
|||||||
/>
|
/>
|
||||||
}>
|
}>
|
||||||
<a className="dropdown-link">
|
<a className="dropdown-link">
|
||||||
<img style={{width:24,height:24}} src="/user/avatar" /><span className="name">{props.user}</span>
|
|
||||||
|
<img style={{width:24,height:24}} src={`/api/user/avatar?uid=${props.uid}`} /><span className="name">{props.user}</span>
|
||||||
|
|
||||||
</a>
|
</a>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
</li>
|
</li>
|
||||||
@ -163,6 +165,9 @@ export default class HeaderCom extends Component {
|
|||||||
console.log(err);
|
console.log(err);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { login, user, msg, uid } = this.props;
|
const { login, user, msg, uid } = this.props;
|
||||||
return (
|
return (
|
||||||
@ -170,7 +175,7 @@ export default class HeaderCom extends Component {
|
|||||||
<div className="content g-row">
|
<div className="content g-row">
|
||||||
<div className="logo">
|
<div className="logo">
|
||||||
<Link to="/" onClick={this.relieveLink} className="href">
|
<Link to="/" onClick={this.relieveLink} className="href">
|
||||||
<img className="img" src="./image/logo_header@1x.png" /><span className="logo-name">YAPI<span className="ui-badge"></span></span>
|
<img className="img" src="/image/logo_header@1x.png" /><span className="logo-name">YAPI<span className="ui-badge"></span></span>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<div className="user-toolbar">
|
<div className="user-toolbar">
|
||||||
|
@ -49,7 +49,7 @@ export default class Srch extends Component{
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSearch = (value) => {
|
handleSearch = (value) => {
|
||||||
axios.get('/project/search?q='+value)
|
axios.get('/api/project/search?q='+value)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if(res.data && res.data.errcode === 0){
|
if(res.data && res.data.errcode === 0){
|
||||||
const dataSource = [];
|
const dataSource = [];
|
||||||
|
@ -147,7 +147,7 @@ class AddInterface extends Component {
|
|||||||
|
|
||||||
getMockURL (project_id, result) {
|
getMockURL (project_id, result) {
|
||||||
const params = {id: project_id}
|
const params = {id: project_id}
|
||||||
axios.get('/project/get', {params: params}).
|
axios.get('/api/project/get', {params: params}).
|
||||||
then( data => {
|
then( data => {
|
||||||
const { prd_host, basepath } = data.data.data
|
const { prd_host, basepath } = data.data.data
|
||||||
const mockURL = `http://${prd_host}${basepath}${result.path}`
|
const mockURL = `http://${prd_host}${basepath}${result.path}`
|
||||||
|
@ -106,7 +106,7 @@ export default class GroupList extends Component {
|
|||||||
@autobind
|
@autobind
|
||||||
async addGroup() {
|
async addGroup() {
|
||||||
const { newGroupName: group_name, newGroupDesc: group_desc } = this.state;
|
const { newGroupName: group_name, newGroupDesc: group_desc } = this.state;
|
||||||
const res = await axios.post('/group/add', { group_name, group_desc })
|
const res = await axios.post('/api/group/add', { group_name, group_desc })
|
||||||
if (!res.data.errcode) {
|
if (!res.data.errcode) {
|
||||||
this.setState({
|
this.setState({
|
||||||
addGroupModalVisible: false
|
addGroupModalVisible: false
|
||||||
@ -120,7 +120,7 @@ export default class GroupList extends Component {
|
|||||||
async editGroup() {
|
async editGroup() {
|
||||||
const { currGroupName: group_name, currGroupDesc: group_desc } = this.state;
|
const { currGroupName: group_name, currGroupDesc: group_desc } = this.state;
|
||||||
const id = this.props.currGroup._id;
|
const id = this.props.currGroup._id;
|
||||||
const res = axios.post('/group/up', { group_name, group_desc, id });
|
const res = axios.post('/api/group/up', { group_name, group_desc, id });
|
||||||
if (res.data.errcode) {
|
if (res.data.errcode) {
|
||||||
message.error(res.data.errmsg);
|
message.error(res.data.errmsg);
|
||||||
} else {
|
} else {
|
||||||
@ -159,7 +159,7 @@ export default class GroupList extends Component {
|
|||||||
async deleteGroup() {
|
async deleteGroup() {
|
||||||
const self = this;
|
const self = this;
|
||||||
const { currGroup } = self.props;
|
const { currGroup } = self.props;
|
||||||
const res = await axios.post('/group/del', {id: currGroup._id})
|
const res = await axios.post('/api/group/del', {id: currGroup._id})
|
||||||
if (res.data.errcode) {
|
if (res.data.errcode) {
|
||||||
message.error(res.data.errmsg);
|
message.error(res.data.errmsg);
|
||||||
} else {
|
} else {
|
||||||
|
@ -31,7 +31,7 @@ class InterfaceMode extends Component {
|
|||||||
const params = {
|
const params = {
|
||||||
id: this.getInterfaceId()
|
id: this.getInterfaceId()
|
||||||
}
|
}
|
||||||
axios.get('/project/get_member_list', { params })
|
axios.get('/api/project/get_member_list', { params })
|
||||||
.then(data => {
|
.then(data => {
|
||||||
this.setState({
|
this.setState({
|
||||||
'memberList': data.data.data
|
'memberList': data.data.data
|
||||||
@ -57,7 +57,7 @@ class InterfaceMode extends Component {
|
|||||||
id: this.getInterfaceId()
|
id: this.getInterfaceId()
|
||||||
}
|
}
|
||||||
|
|
||||||
axios.post('/project/del_member', params)
|
axios.post('/api/project/del_member', params)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.getMemberList()
|
this.getMemberList()
|
||||||
})
|
})
|
||||||
@ -70,11 +70,11 @@ class InterfaceMode extends Component {
|
|||||||
addNewUser () {
|
addNewUser () {
|
||||||
const { userName } = this.state
|
const { userName } = this.state
|
||||||
const params = { q: userName}
|
const params = { q: userName}
|
||||||
axios.get('/user/search', { params })
|
axios.get('/api/user/search', { params })
|
||||||
.then(data => {
|
.then(data => {
|
||||||
const member_uid = data.data.data[0].uid
|
const member_uid = data.data.data[0].uid
|
||||||
const params = {id: this.getInterfaceId(), member_uid}
|
const params = {id: this.getInterfaceId(), member_uid}
|
||||||
axios.post('/project/add_member', params)
|
axios.post('/api/project/add_member', params)
|
||||||
.then( () => {
|
.then( () => {
|
||||||
this.getMemberList()
|
this.getMemberList()
|
||||||
})
|
})
|
||||||
@ -94,7 +94,7 @@ class InterfaceMode extends Component {
|
|||||||
})
|
})
|
||||||
const params = { q: value}
|
const params = { q: value}
|
||||||
|
|
||||||
axios.get('/user/search', { params })
|
axios.get('/api/user/search', { params })
|
||||||
.then(data => {
|
.then(data => {
|
||||||
const userList = []
|
const userList = []
|
||||||
data = data.data.data
|
data = data.data.data
|
||||||
|
@ -51,7 +51,7 @@ class InterfaceTable extends Component {
|
|||||||
const params = {
|
const params = {
|
||||||
id: interfaceId
|
id: interfaceId
|
||||||
}
|
}
|
||||||
axios.post('/interface/del', params)
|
axios.post('/api/interface/del', params)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.deleteInterfaceData(interfaceId)
|
this.deleteInterfaceData(interfaceId)
|
||||||
})
|
})
|
||||||
|
0
client/containers/Project/Interface/Interface.js
Normal file
0
client/containers/Project/Interface/Interface.js
Normal file
@ -2,11 +2,12 @@ import React, { Component } from 'react'
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { Route, Switch, Redirect } from 'react-router-dom';
|
import { Route, Switch, Redirect } from 'react-router-dom';
|
||||||
import { Subnav } from '../../components/index'
|
import { Subnav } from '../../components/index'
|
||||||
|
import { Interface } from './Interface/Interface.js'
|
||||||
|
|
||||||
export default class GroupList extends Component {
|
export default class GroupList extends Component {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
children: PropTypes.element
|
match: PropTypes.object
|
||||||
}
|
}
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
@ -20,24 +21,25 @@ export default class GroupList extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
const { match } = this.props;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Subnav
|
<Subnav
|
||||||
default={'接口'}
|
default={'接口'}
|
||||||
data={[{
|
data={[{
|
||||||
name: '接口',
|
name: '接口',
|
||||||
path: '/project/:id/activity'
|
path: `/project/${match.params.id}/interface`
|
||||||
}, {
|
}, {
|
||||||
name: '设置',
|
name: '设置',
|
||||||
path: '/project/:id/setting'
|
path: `/project/${match.params.id}/setting`
|
||||||
}, {
|
}, {
|
||||||
name: '动态',
|
name: '动态',
|
||||||
path: '/project/:id/activity'
|
path: `/project/${match.params.id}/activity`
|
||||||
}]}/>
|
}]}/>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Redirect exact from='/project/:id' to='/project/:id/interface' />
|
<Redirect exact from='/project/:id' to={`/project/${match.params.id}/interface`} />
|
||||||
<Route path="/project/:id/activity" component={null} />
|
<Route path="/project/:id/activity" component={null} />
|
||||||
<Route path="/project/:id/interface" component={null} />
|
<Route path="/project/:id/interface" component={Interface} />
|
||||||
<Route path="/project/:id/setting" component={null} />
|
<Route path="/project/:id/setting" component={null} />
|
||||||
</Switch>
|
</Switch>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
import './index.scss'
|
|
||||||
import React, { Component } from 'react'
|
|
||||||
// import PropTypes from 'prop-types'
|
|
||||||
import { Upload, Icon, message } from 'antd'
|
|
||||||
class Avatar extends Component {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
imageUrl:""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
handleChange(info){
|
|
||||||
if (info.file.status === 'done') {
|
|
||||||
// Get this url from response in real world.
|
|
||||||
getBase64(info.file.originFileObj, imageUrl => this.setState({ imageUrl }));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
render() {
|
|
||||||
const imageUrl = this.state.imageUrl;
|
|
||||||
return <div className="avatar-box">
|
|
||||||
<Upload
|
|
||||||
className="avatar-uploader"
|
|
||||||
name="avatar"
|
|
||||||
showUploadList={true}
|
|
||||||
action="//jsonplaceholder.typicode.com/posts/"
|
|
||||||
beforeUpload={beforeUpload}
|
|
||||||
onChange={this.handleChange.bind(this)} >
|
|
||||||
{
|
|
||||||
imageUrl ?
|
|
||||||
<img src={imageUrl} alt="" className="avatar" /> :
|
|
||||||
<Icon type="plus" className="avatar-uploader-trigger" />
|
|
||||||
}
|
|
||||||
</Upload>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function beforeUpload(file) {
|
|
||||||
const isJPG = file.type === 'image/jpeg';
|
|
||||||
if (!isJPG) {
|
|
||||||
message.error('You can only upload JPG file!');
|
|
||||||
}
|
|
||||||
const isLt2M = file.size / 1024 / 1024 < 2;
|
|
||||||
if (!isLt2M) {
|
|
||||||
message.error('Image must smaller than 2MB!');
|
|
||||||
}
|
|
||||||
return isJPG && isLt2M;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getBase64(img, callback) {
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.addEventListener('load', () => callback(reader.result));
|
|
||||||
reader.readAsDataURL(img);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Avatar;
|
|
@ -42,7 +42,7 @@ class LeftMenu extends Component {
|
|||||||
this.interval = setInterval(() => {
|
this.interval = setInterval(() => {
|
||||||
if (this.searchSign === this._searchSign) {
|
if (this.searchSign === this._searchSign) {
|
||||||
this.interval = clearInterval(this.interval)
|
this.interval = clearInterval(this.interval)
|
||||||
axios.get('/user/search?q=' + value).then((res) => {
|
axios.get('/api/user/search?q=' + value).then((res) => {
|
||||||
if (res.data.errcode === 0) {
|
if (res.data.errcode === 0) {
|
||||||
this.setState({
|
this.setState({
|
||||||
dataSource: res.data.data
|
dataSource: res.data.data
|
||||||
|
@ -39,7 +39,7 @@ class List extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getUserList() {
|
getUserList() {
|
||||||
axios.get('/user/list?page=' + this.state.current).then((res) => {
|
axios.get('/api/user/list?page=' + this.state.current).then((res) => {
|
||||||
let result = res.data;
|
let result = res.data;
|
||||||
|
|
||||||
if (result.errcode === 0) {
|
if (result.errcode === 0) {
|
||||||
@ -62,7 +62,7 @@ class List extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
confirm = (uid) =>{
|
confirm = (uid) =>{
|
||||||
axios.post('/user/del', {
|
axios.post('/api/user/del', {
|
||||||
id: uid
|
id: uid
|
||||||
}).then( (res)=>{
|
}).then( (res)=>{
|
||||||
if(res.data.errcode === 0){
|
if(res.data.errcode === 0){
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { Row, Col, Input, Button, Select, message } from 'antd'
|
import { Row, Col, Input, Button, Select, message, Upload, Icon } from 'antd'
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import {formatTime} from '../../common.js'
|
import {formatTime} from '../../common.js'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
|
|
||||||
class Profile extends Component {
|
class Profile extends Component {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@ -38,7 +37,7 @@ class Profile extends Component {
|
|||||||
|
|
||||||
getUserInfo = (id) => {
|
getUserInfo = (id) => {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
axios.get('/user/find?id=' + id).then((res) => {
|
axios.get('/api/user/find?id=' + id).then((res) => {
|
||||||
_this.setState({
|
_this.setState({
|
||||||
userinfo: res.data.data,
|
userinfo: res.data.data,
|
||||||
_userinfo: res.data.data
|
_userinfo: res.data.data
|
||||||
@ -52,7 +51,7 @@ class Profile extends Component {
|
|||||||
let params = {uid: state.userinfo.uid}
|
let params = {uid: state.userinfo.uid}
|
||||||
params[name] = value;
|
params[name] = value;
|
||||||
|
|
||||||
axios.post('/user/update', params).then( (res)=>{
|
axios.post('/api/user/update', params).then( (res)=>{
|
||||||
let data = res.data;
|
let data = res.data;
|
||||||
if(data.errcode === 0){
|
if(data.errcode === 0){
|
||||||
let userinfo = this.state.userinfo;
|
let userinfo = this.state.userinfo;
|
||||||
@ -106,7 +105,7 @@ class Profile extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
axios.post('/user/change_password', params).then( (res)=>{
|
axios.post('/api/user/change_password', params).then( (res)=>{
|
||||||
let data = res.data;
|
let data = res.data;
|
||||||
if(data.errcode === 0){
|
if(data.errcode === 0){
|
||||||
this.handleEdit('secureEdit', false)
|
this.handleEdit('secureEdit', false)
|
||||||
@ -191,6 +190,7 @@ class Profile extends Component {
|
|||||||
|
|
||||||
return <div className="user-profile">
|
return <div className="user-profile">
|
||||||
<Row className="user-item" type="flex" justify="start">
|
<Row className="user-item" type="flex" justify="start">
|
||||||
|
<Col span={24}><Avatar uid={userinfo.uid}>点击上传头像</Avatar></Col>
|
||||||
<Col span={4}>用户id</Col>
|
<Col span={4}>用户id</Col>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
{userinfo.uid}
|
{userinfo.uid}
|
||||||
@ -237,4 +237,76 @@ class Profile extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Avatar extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
imageUrl:""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static propTypes = {
|
||||||
|
uid: PropTypes.number
|
||||||
|
}
|
||||||
|
uploadAvatar(basecode){
|
||||||
|
axios.post("/user/upload_avatar",{basecode: basecode}).then(()=>{
|
||||||
|
this.setState({ imageUrl: basecode })
|
||||||
|
}).catch((e)=>{
|
||||||
|
console.log(e);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
handleChange(info){
|
||||||
|
if (info.file.status === 'done') {
|
||||||
|
// Get this url from response in real world.
|
||||||
|
getBase64(info.file.originFileObj, basecode=>{this.uploadAvatar(basecode)});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
let imageUrl = "";
|
||||||
|
if(this.props.uid && !this.state.imageUrl){
|
||||||
|
imageUrl = `/user/avatar?uid=${this.props.uid}`;
|
||||||
|
}else{
|
||||||
|
imageUrl = this.state.imageUrl;
|
||||||
|
}
|
||||||
|
return <div className="avatar-box">
|
||||||
|
<Upload
|
||||||
|
className="avatar-uploader"
|
||||||
|
name="basecode"
|
||||||
|
showUploadList={true}
|
||||||
|
action="/user/upload_avatar"
|
||||||
|
beforeUpload={beforeUpload}
|
||||||
|
onChange={this.handleChange.bind(this)} >
|
||||||
|
{
|
||||||
|
imageUrl ?
|
||||||
|
<img src={imageUrl} alt="" className="avatar" /> :
|
||||||
|
<Icon type="plus" className="avatar-uploader-trigger" />
|
||||||
|
}
|
||||||
|
</Upload>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function beforeUpload(file) {
|
||||||
|
const isJPG = file.type === 'image/jpeg';
|
||||||
|
const isPNG = file.type === 'image/png';
|
||||||
|
if (!isJPG && !isPNG) {
|
||||||
|
message.error('图片的格式只能为 jpg、png!');
|
||||||
|
}
|
||||||
|
const isLt2M = file.size / 1024 / 1024 < 2;
|
||||||
|
if (!isLt2M) {
|
||||||
|
message.error('图片必须小于 200kb!');
|
||||||
|
}
|
||||||
|
|
||||||
|
return (isPNG||isJPG) && isLt2M;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBase64(img, callback) {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.addEventListener('load', () => callback(reader.result));
|
||||||
|
reader.readAsDataURL(img);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export default Profile
|
export default Profile
|
||||||
|
@ -2,12 +2,12 @@ import './index.scss'
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { Route } from 'react-router-dom'
|
import { Route } from 'react-router-dom'
|
||||||
import LeftMenu from './LeftMenu.js'
|
// import LeftMenu from './LeftMenu.js'
|
||||||
import List from './List.js'
|
import List from './List.js'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import Profile from './Profile.js'
|
import Profile from './Profile.js'
|
||||||
import { Row, Col } from 'antd';
|
import { Row } from 'antd';
|
||||||
|
import Subnav from '../../components/Subnav/Subnav.js';
|
||||||
@connect()
|
@connect()
|
||||||
class User extends Component {
|
class User extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@ -26,17 +26,23 @@ class User extends Component {
|
|||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div>
|
||||||
|
<Subnav
|
||||||
|
default={'我的关注'}
|
||||||
|
data={[{
|
||||||
|
name: '项目广场',
|
||||||
|
path: '/group'
|
||||||
|
}, {
|
||||||
|
name: '我的关注',
|
||||||
|
path: '/follow'
|
||||||
|
}]}/>
|
||||||
<div className="g-doc">
|
<div className="g-doc">
|
||||||
<Row gutter={16} className="user-box">
|
<Row gutter={16} className="user-box">
|
||||||
<Col span={6}>
|
|
||||||
<LeftMenu />
|
|
||||||
</Col>
|
|
||||||
<Col span={18}>
|
|
||||||
<Route path={this.props.match.path + '/list'} component={List} />
|
<Route path={this.props.match.path + '/list'} component={List} />
|
||||||
<Route path={this.props.match.path + '/profile/:uid'} component={Profile} />
|
<Route path={this.props.match.path + '/profile/:uid'} component={Profile} />
|
||||||
</Col>
|
|
||||||
</Row>
|
</Row>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ export function pushInterfaceMethod (value) {
|
|||||||
export function fetchInterfaceProject(id) {
|
export function fetchInterfaceProject(id) {
|
||||||
return {
|
return {
|
||||||
type: FETCH_INTERFACE_PROJECT,
|
type: FETCH_INTERFACE_PROJECT,
|
||||||
payload: axios.get('/project/get', { params: {id}})
|
payload: axios.get('/api/project/get', { params: {id}})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ export default (state = initialState, action) => {
|
|||||||
export function fetchGroupList() {
|
export function fetchGroupList() {
|
||||||
return {
|
return {
|
||||||
type: FETCH_GROUP_LIST,
|
type: FETCH_GROUP_LIST,
|
||||||
payload: axios.get('/group/list')
|
payload: axios.get('/api/group/list')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ export function fetchNewsData (typeid,page,limit) {
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
type: FETCH_NEWS_DATA,
|
type: FETCH_NEWS_DATA,
|
||||||
payload: axios.get('/log/list',{
|
payload: axios.get('/api/log/list',{
|
||||||
params: param
|
params: param
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
@ -56,7 +56,7 @@ export function getMockUrl(project_id){
|
|||||||
const params = {id: project_id};
|
const params = {id: project_id};
|
||||||
return {
|
return {
|
||||||
type:"",
|
type:"",
|
||||||
payload: axios.get('/project/get', {params: params})
|
payload: axios.get('/api/project/get', {params: params})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ export default (state = initialState, action) => {
|
|||||||
export function fetchProjectList(id, pageNum) {
|
export function fetchProjectList(id, pageNum) {
|
||||||
return {
|
return {
|
||||||
type: FETCH_PROJECT_LIST,
|
type: FETCH_PROJECT_LIST,
|
||||||
payload: axios.get('/project/list', {
|
payload: axios.get('/api/project/list', {
|
||||||
params: {
|
params: {
|
||||||
group_id: id,
|
group_id: id,
|
||||||
page: pageNum || 1,
|
page: pageNum || 1,
|
||||||
@ -95,7 +95,7 @@ export function addProject(data) {
|
|||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
type: PROJECT_ADD,
|
type: PROJECT_ADD,
|
||||||
payload: axios.post('/project/add', param)
|
payload: axios.post('/api/project/add', param)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ export function updateProject(data) {
|
|||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
type: PROJECT_UPDATE,
|
type: PROJECT_UPDATE,
|
||||||
payload: axios.post('/project/up', param)
|
payload: axios.post('/api/project/up', param)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,6 +120,6 @@ export function delProject(id) {
|
|||||||
const param = { id };
|
const param = { id };
|
||||||
return {
|
return {
|
||||||
type: PROJECT_DEL,
|
type: PROJECT_DEL,
|
||||||
payload: axios.post('/project/del', param)
|
payload: axios.post('/api/project/del', param)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ export default (state = initialState, action) => {
|
|||||||
// Action Creators
|
// Action Creators
|
||||||
export function checkLoginState() {
|
export function checkLoginState() {
|
||||||
return(dispatch)=> {
|
return(dispatch)=> {
|
||||||
axios.get('/user/status').then((res) => {
|
axios.get('/api/user/status').then((res) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: GET_LOGIN_STATE,
|
type: GET_LOGIN_STATE,
|
||||||
payload: res
|
payload: res
|
||||||
@ -95,7 +95,7 @@ export function checkLoginState() {
|
|||||||
export function loginActions(data) {
|
export function loginActions(data) {
|
||||||
return {
|
return {
|
||||||
type: LOGIN,
|
type: LOGIN,
|
||||||
payload: axios.post('/user/login', data)
|
payload: axios.post('/api/user/login', data)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,14 +108,14 @@ export function regActions(data) {
|
|||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
type: REGISTER,
|
type: REGISTER,
|
||||||
payload: axios.post('/user/reg', param)
|
payload: axios.post('/api/user/reg', param)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logoutActions() {
|
export function logoutActions() {
|
||||||
return {
|
return {
|
||||||
type: LOGIN_OUT,
|
type: LOGIN_OUT,
|
||||||
payload: axios.get('./user/logout')
|
payload: axios.get('/api/user/logout')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ gulp.task('initialBuild', ['removeDist'], () => {
|
|||||||
output('success', '初始编译成功!');
|
output('success', '初始编译成功!');
|
||||||
waitingSpinner();
|
waitingSpinner();
|
||||||
|
|
||||||
excuteCmd('node_modules/.bin/nodemon', ['-q', 'server_dist/app.js'], {
|
excuteCmd('node_modules/.bin/nodemon', ['-q', 'server_dist/app.js', 'dev'], {
|
||||||
cwd: __dirname
|
cwd: __dirname
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build-server": "babel server -d server_dist",
|
"build-server": "babel server -d server_dist",
|
||||||
"dev-server": "nodemon server_dist/app.js -L",
|
"dev-server": "nodemon server_dist/app.js dev -L",
|
||||||
"install-server": "node server_dist/install.js",
|
"install-server": "node server_dist/install.js",
|
||||||
"dev": "gulp --silent",
|
"dev": "gulp --silent",
|
||||||
"build": "gulp build --silent",
|
"build": "gulp build --silent",
|
||||||
|
@ -10,13 +10,29 @@ import router from './router.js';
|
|||||||
|
|
||||||
yapi.connect = dbModule.connect();
|
yapi.connect = dbModule.connect();
|
||||||
const app = new Koa();
|
const app = new Koa();
|
||||||
|
let indexFile = process.argv[2] === 'dev' ? 'dev.html' : 'index.html';
|
||||||
|
|
||||||
|
|
||||||
app.use(mockServer);
|
app.use(mockServer);
|
||||||
app.use(bodyParser());
|
app.use(bodyParser());
|
||||||
app.use(router.routes());
|
app.use(router.routes());
|
||||||
app.use(router.allowedMethods());
|
app.use(router.allowedMethods());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
app.use( async (ctx, next) => {
|
||||||
|
if( /^\/(?!api)[a-zA-Z0-9\/\-]*$/.test(ctx.path) ){
|
||||||
|
ctx.path = "/"
|
||||||
|
await next()
|
||||||
|
}else{
|
||||||
|
await next()
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
app.use(koaStatic(
|
app.use(koaStatic(
|
||||||
yapi.path.join(yapi.WEBROOT, 'static')
|
yapi.path.join(yapi.WEBROOT, 'static'),
|
||||||
|
{index: indexFile}
|
||||||
));
|
));
|
||||||
|
|
||||||
app.listen(yapi.WEBCONFIG.port);
|
app.listen(yapi.WEBCONFIG.port);
|
||||||
commons.log(`the server is start at port ${yapi.WEBCONFIG.port}`);
|
commons.log(`the server is start at port ${yapi.WEBCONFIG.port}`);
|
@ -19,7 +19,6 @@ class baseController {
|
|||||||
|
|
||||||
async init(ctx) {
|
async init(ctx) {
|
||||||
this.$user = null;
|
this.$user = null;
|
||||||
console.log(111111)
|
|
||||||
let ignoreRouter = [
|
let ignoreRouter = [
|
||||||
'/user/login_by_token',
|
'/user/login_by_token',
|
||||||
'/user/login',
|
'/user/login',
|
||||||
|
@ -451,7 +451,9 @@ class userController extends baseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* 上传用户头像
|
||||||
|
* @interface /user/upload_avatar
|
||||||
|
* @method POST
|
||||||
* @param {*} basecode base64编码,通过h5 api传给后端
|
* @param {*} basecode base64编码,通过h5 api传给后端
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -488,11 +490,19 @@ class userController extends baseController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户uid头像
|
||||||
|
* @interface /user/avatar
|
||||||
|
* @method GET
|
||||||
|
* @param {*} uid
|
||||||
|
*/
|
||||||
|
|
||||||
async avatar(ctx) {
|
async avatar(ctx) {
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
let uid = ctx.query.uid ? ctx.query.uid: this.getUid();
|
||||||
let avatarInst = yapi.getInst(avatarModel);
|
let avatarInst = yapi.getInst(avatarModel);
|
||||||
let data = await avatarInst.get(this.getUid());
|
let data = await avatarInst.get(uid);
|
||||||
let dataBuffer, type;
|
let dataBuffer, type;
|
||||||
if(!data || !data.basecode){
|
if(!data || !data.basecode){
|
||||||
dataBuffer = yapi.fs.readFileSync(yapi.path.join(yapi.WEBROOT, 'static/image/avatar.png'));
|
dataBuffer = yapi.fs.readFileSync(yapi.path.join(yapi.WEBROOT, 'static/image/avatar.png'));
|
||||||
|
@ -312,7 +312,7 @@ for(let ctrl in routerConfig){
|
|||||||
* @param {*} action controller_action_name
|
* @param {*} action controller_action_name
|
||||||
*/
|
*/
|
||||||
function createAction(controller, action, path, method) {
|
function createAction(controller, action, path, method) {
|
||||||
router[method](INTERFACE_CONFIG[controller].prefix + path, async (ctx) => {
|
router[method]("/api" + INTERFACE_CONFIG[controller].prefix + path, async (ctx) => {
|
||||||
let inst = new INTERFACE_CONFIG[controller].controller(ctx);
|
let inst = new INTERFACE_CONFIG[controller].controller(ctx);
|
||||||
|
|
||||||
await inst.init(ctx);
|
await inst.init(ctx);
|
||||||
@ -325,4 +325,5 @@ function createAction(controller, action, path, method) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var _regenerator = require('babel-runtime/regenerator');
|
||||||
|
|
||||||
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
||||||
|
|
||||||
|
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
|
||||||
|
|
||||||
|
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
||||||
|
|
||||||
var _yapi = require('./yapi.js');
|
var _yapi = require('./yapi.js');
|
||||||
|
|
||||||
var _yapi2 = _interopRequireDefault(_yapi);
|
var _yapi2 = _interopRequireDefault(_yapi);
|
||||||
@ -39,11 +47,49 @@ _yapi2.default.commons = _commons2.default;
|
|||||||
|
|
||||||
_yapi2.default.connect = _db2.default.connect();
|
_yapi2.default.connect = _db2.default.connect();
|
||||||
var app = new _koa2.default();
|
var app = new _koa2.default();
|
||||||
|
var indexFile = process.argv[2] === 'dev' ? 'dev.html' : 'index.html';
|
||||||
|
|
||||||
app.use(_mockServer2.default);
|
app.use(_mockServer2.default);
|
||||||
app.use((0, _koaBodyparser2.default)());
|
app.use((0, _koaBodyparser2.default)());
|
||||||
app.use(_router2.default.routes());
|
app.use(_router2.default.routes());
|
||||||
app.use(_router2.default.allowedMethods());
|
app.use(_router2.default.allowedMethods());
|
||||||
app.use((0, _koaStatic2.default)(_yapi2.default.path.join(_yapi2.default.WEBROOT, 'static')));
|
|
||||||
|
app.use(function () {
|
||||||
|
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx, next) {
|
||||||
|
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||||
|
while (1) {
|
||||||
|
switch (_context.prev = _context.next) {
|
||||||
|
case 0:
|
||||||
|
if (!/^\/(?!api)[a-zA-Z0-9\/\-]*$/.test(ctx.path)) {
|
||||||
|
_context.next = 6;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.path = "/";
|
||||||
|
_context.next = 4;
|
||||||
|
return next();
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
_context.next = 8;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
_context.next = 8;
|
||||||
|
return next();
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
case 'end':
|
||||||
|
return _context.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, _callee, undefined);
|
||||||
|
}));
|
||||||
|
|
||||||
|
return function (_x, _x2) {
|
||||||
|
return _ref.apply(this, arguments);
|
||||||
|
};
|
||||||
|
}());
|
||||||
|
app.use((0, _koaStatic2.default)(_yapi2.default.path.join(_yapi2.default.WEBROOT, 'static'), { index: indexFile }));
|
||||||
|
|
||||||
app.listen(_yapi2.default.WEBCONFIG.port);
|
app.listen(_yapi2.default.WEBCONFIG.port);
|
||||||
_commons2.default.log('the server is start at port ' + _yapi2.default.WEBCONFIG.port);
|
_commons2.default.log('the server is start at port ' + _yapi2.default.WEBCONFIG.port);
|
@ -66,23 +66,22 @@ var baseController = function () {
|
|||||||
switch (_context.prev = _context.next) {
|
switch (_context.prev = _context.next) {
|
||||||
case 0:
|
case 0:
|
||||||
this.$user = null;
|
this.$user = null;
|
||||||
console.log(111111);
|
|
||||||
ignoreRouter = ['/user/login_by_token', '/user/login', '/user/reg', '/user/status', '/user/logout'];
|
ignoreRouter = ['/user/login_by_token', '/user/login', '/user/reg', '/user/status', '/user/logout'];
|
||||||
|
|
||||||
if (!(ignoreRouter.indexOf(ctx.path) > -1)) {
|
if (!(ignoreRouter.indexOf(ctx.path) > -1)) {
|
||||||
_context.next = 7;
|
_context.next = 6;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$auth = true;
|
this.$auth = true;
|
||||||
_context.next = 9;
|
_context.next = 8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 6:
|
||||||
_context.next = 9;
|
_context.next = 8;
|
||||||
return this.checkLogin(ctx);
|
return this.checkLogin(ctx);
|
||||||
|
|
||||||
case 9:
|
case 8:
|
||||||
case 'end':
|
case 'end':
|
||||||
return _context.stop();
|
return _context.stop();
|
||||||
}
|
}
|
||||||
|
@ -938,7 +938,9 @@ var userController = function (_baseController) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* 上传用户头像
|
||||||
|
* @interface /user/upload_avatar
|
||||||
|
* @method POST
|
||||||
* @param {*} basecode base64编码,通过h5 api传给后端
|
* @param {*} basecode base64编码,通过h5 api传给后端
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -1033,21 +1035,30 @@ var userController = function (_baseController) {
|
|||||||
|
|
||||||
return uploadAvatar;
|
return uploadAvatar;
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户uid头像
|
||||||
|
* @interface /user/avatar
|
||||||
|
* @method GET
|
||||||
|
* @param {*} uid
|
||||||
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: 'avatar',
|
key: 'avatar',
|
||||||
value: function () {
|
value: function () {
|
||||||
var _ref12 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee12(ctx) {
|
var _ref12 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee12(ctx) {
|
||||||
var avatarInst, data, dataBuffer, type;
|
var uid, avatarInst, data, dataBuffer, type;
|
||||||
return _regenerator2.default.wrap(function _callee12$(_context12) {
|
return _regenerator2.default.wrap(function _callee12$(_context12) {
|
||||||
while (1) {
|
while (1) {
|
||||||
switch (_context12.prev = _context12.next) {
|
switch (_context12.prev = _context12.next) {
|
||||||
case 0:
|
case 0:
|
||||||
_context12.prev = 0;
|
_context12.prev = 0;
|
||||||
|
uid = ctx.query.uid ? ctx.query.uid : this.getUid();
|
||||||
avatarInst = _yapi2.default.getInst(_avatar2.default);
|
avatarInst = _yapi2.default.getInst(_avatar2.default);
|
||||||
_context12.next = 4;
|
_context12.next = 5;
|
||||||
return avatarInst.get(this.getUid());
|
return avatarInst.get(uid);
|
||||||
|
|
||||||
case 4:
|
case 5:
|
||||||
data = _context12.sent;
|
data = _context12.sent;
|
||||||
dataBuffer = void 0, type = void 0;
|
dataBuffer = void 0, type = void 0;
|
||||||
|
|
||||||
@ -1061,21 +1072,21 @@ var userController = function (_baseController) {
|
|||||||
|
|
||||||
ctx.set('Content-type', type);
|
ctx.set('Content-type', type);
|
||||||
ctx.body = dataBuffer;
|
ctx.body = dataBuffer;
|
||||||
_context12.next = 14;
|
_context12.next = 15;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 11:
|
case 12:
|
||||||
_context12.prev = 11;
|
_context12.prev = 12;
|
||||||
_context12.t0 = _context12['catch'](0);
|
_context12.t0 = _context12['catch'](0);
|
||||||
|
|
||||||
ctx.body = 'error:' + _context12.t0.message;
|
ctx.body = 'error:' + _context12.t0.message;
|
||||||
|
|
||||||
case 14:
|
case 15:
|
||||||
case 'end':
|
case 'end':
|
||||||
return _context12.stop();
|
return _context12.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, _callee12, this, [[0, 11]]);
|
}, _callee12, this, [[0, 12]]);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function avatar(_x13) {
|
function avatar(_x13) {
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
var _regenerator = require("babel-runtime/regenerator");
|
|
||||||
|
|
||||||
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
||||||
|
|
||||||
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");
|
|
||||||
|
|
||||||
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
||||||
|
|
||||||
// const jwt = require('jsonwebtoken');
|
|
||||||
//检查token是否过期
|
|
||||||
|
|
||||||
module.exports = function () {
|
|
||||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx, next) {
|
|
||||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
||||||
while (1) {
|
|
||||||
switch (_context.prev = _context.next) {
|
|
||||||
case 0:
|
|
||||||
_context.next = 2;
|
|
||||||
return next();
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
case "end":
|
|
||||||
return _context.stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, _callee, undefined);
|
|
||||||
}));
|
|
||||||
|
|
||||||
return function (_x, _x2) {
|
|
||||||
return _ref.apply(this, arguments);
|
|
||||||
};
|
|
||||||
}();
|
|
@ -1,44 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
var _regenerator = require("babel-runtime/regenerator");
|
|
||||||
|
|
||||||
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
||||||
|
|
||||||
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");
|
|
||||||
|
|
||||||
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
||||||
|
|
||||||
module.exports = function () {
|
|
||||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx, next) {
|
|
||||||
var path;
|
|
||||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
||||||
while (1) {
|
|
||||||
switch (_context.prev = _context.next) {
|
|
||||||
case 0:
|
|
||||||
path = ctx.path;
|
|
||||||
|
|
||||||
console.log(path); // eslint-disable-line
|
|
||||||
console.log(ctx.hostname); // eslint-disable-line
|
|
||||||
|
|
||||||
if (!next) {
|
|
||||||
_context.next = 6;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
_context.next = 6;
|
|
||||||
return next();
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
case "end":
|
|
||||||
return _context.stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, _callee, undefined);
|
|
||||||
}));
|
|
||||||
|
|
||||||
return function (_x, _x2) {
|
|
||||||
return _ref.apply(this, arguments);
|
|
||||||
};
|
|
||||||
}();
|
|
@ -314,7 +314,7 @@ for (var ctrl in routerConfig) {
|
|||||||
function createAction(controller, action, path, method) {
|
function createAction(controller, action, path, method) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
router[method](INTERFACE_CONFIG[controller].prefix + path, function () {
|
router[method]("/api" + INTERFACE_CONFIG[controller].prefix + path, function () {
|
||||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||||
var inst;
|
var inst;
|
||||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 25 KiB |
@ -6,7 +6,6 @@
|
|||||||
<title>YAPI-高效、易用、功能强大的api管理平台</title>
|
<title>YAPI-高效、易用、功能强大的api管理平台</title>
|
||||||
<script>
|
<script>
|
||||||
document.write('<script src="prd/assets.js?v=' + Math.random() + '"><\/script>');
|
document.write('<script src="prd/assets.js?v=' + Math.random() + '"><\/script>');
|
||||||
console.log(window)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user