mirror of
https://github.com/YMFE/yapi.git
synced 2025-03-07 14:16:52 +08:00
add: 登录与注册逻辑
This commit is contained in:
commit
c0e5d95ac1
@ -11,13 +11,15 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
"react"
|
||||
"react",
|
||||
"import"
|
||||
],
|
||||
rules: {
|
||||
"indent": ["error", 2, { "SwitchCase": 1 }],
|
||||
"react/display-name": ["off"],
|
||||
"react/jsx-indent": ["error", 2],
|
||||
"comma-dangle": ["error", "only-multiline"],
|
||||
"no-console": ["off"]
|
||||
"comma-dangle": ["error", "never"],
|
||||
"no-console": ["off"],
|
||||
"import/no-unresolved": ["error"]
|
||||
}
|
||||
}
|
||||
|
@ -7,5 +7,5 @@ export default {
|
||||
group,
|
||||
login,
|
||||
LoginRedux,
|
||||
Interface,
|
||||
Interface
|
||||
}
|
||||
|
@ -20,3 +20,18 @@ export function fetchCurrGroup() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function addGroup(groupName) {
|
||||
return function(dispatch, getState) {
|
||||
const group = getState().group;
|
||||
const groupList = group.groupList || [];
|
||||
const newGroupList = groupList.concat([groupName + groupList.length]);
|
||||
dispatch({
|
||||
type: FETCH_GROUP_LIST,
|
||||
payload: {
|
||||
data: newGroupList,
|
||||
res: true
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {
|
||||
FETCH_INTERFACE_DATA,
|
||||
} from '../actionTypes.js';
|
||||
FETCH_INTERFACE_DATA
|
||||
} from '../constants/action-types.js';
|
||||
|
||||
export function fetchAuditIcons () {
|
||||
const data = [{
|
||||
@ -9,25 +9,25 @@ export function fetchAuditIcons () {
|
||||
age: 32,
|
||||
address: 'New York No. 1 Lake Park',
|
||||
date: '2015-11-11 13:00:15',
|
||||
features: '3',
|
||||
features: '3'
|
||||
}, {
|
||||
key: '2',
|
||||
name: 'Jim Green',
|
||||
age: 42,
|
||||
address: 'London No. 1 Lake Park',
|
||||
date: '2015-11-11 13:00:15',
|
||||
features: '3',
|
||||
features: '3'
|
||||
}, {
|
||||
key: '3',
|
||||
name: 'Joe Black',
|
||||
age: 32,
|
||||
address: 'Sidney No. 1 Lake Park',
|
||||
date: '2015-11-11 13:00:15',
|
||||
features: '3',
|
||||
features: '3'
|
||||
}]
|
||||
|
||||
return {
|
||||
type: FETCH_INTERFACE_DATA,
|
||||
payload: data,
|
||||
payload: data
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import './styles/Home/home.scss'
|
||||
import React, { Component } from 'react'
|
||||
|
||||
export {
|
||||
React,
|
||||
Component,
|
||||
}
|
||||
Component
|
||||
}
|
||||
|
@ -1,3 +1,6 @@
|
||||
// Interface
|
||||
export const FETCH_INTERFACE_DATA = 'FETCH_INTERFACE_DATA';
|
||||
|
||||
// group
|
||||
export const FETCH_GROUP_LIST = 'FETCH_GROUP_LIST'
|
||||
export const FETCH_CURR_GROUP = 'FETCH_CURR_GROUP'
|
||||
|
@ -9,17 +9,17 @@ import { fetchAuditIcons } from '../../actions/interface.js'
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
interfaceData: state.data,
|
||||
interfaceData: state.data
|
||||
}
|
||||
},
|
||||
{
|
||||
fetchAuditIcons,
|
||||
fetchAuditIcons
|
||||
}
|
||||
)
|
||||
|
||||
//
|
||||
class Interface extends Component {
|
||||
static propTypes = {
|
||||
fetchAuditIcons: PropTypes.func,
|
||||
fetchAuditIcons: PropTypes.func
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
@ -42,4 +42,4 @@ class Interface extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
export default Interface
|
||||
export default Interface
|
||||
|
@ -5,6 +5,7 @@
|
||||
-webkit-box-flex: 1;
|
||||
margin: 15px auto 0 auto;
|
||||
font-size: 0.14rem;
|
||||
background: #FFF;
|
||||
|
||||
.interface-list {
|
||||
width: 216px;
|
||||
|
@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
|
||||
|
||||
class InterfaceTable extends Component {
|
||||
static propTypes = {
|
||||
data: PropTypes.array,
|
||||
data: PropTypes.array
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
@ -15,27 +15,27 @@ class InterfaceTable extends Component {
|
||||
const columns = [{
|
||||
title: '接口名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
key: 'name'
|
||||
}, {
|
||||
title: '接口URL',
|
||||
dataIndex: 'age',
|
||||
key: 'age',
|
||||
key: 'age'
|
||||
}, {
|
||||
title: '操作者',
|
||||
dataIndex: 'address',
|
||||
key: 'address',
|
||||
key: 'address'
|
||||
}, {
|
||||
title: '更新日期',
|
||||
dataIndex: 'date',
|
||||
key: 'date',
|
||||
key: 'date'
|
||||
}, {
|
||||
title: '功能',
|
||||
'key': 'action',
|
||||
render: () => {
|
||||
return (
|
||||
<span>
|
||||
<Button type="primary">Primary</Button>
|
||||
<Button type="primary">Primary</Button>
|
||||
<Button type="primary">编辑</Button>
|
||||
<Button type="danger">删除</Button>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@ -52,4 +52,4 @@ class InterfaceTable extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
export default InterfaceTable
|
||||
export default InterfaceTable
|
||||
|
@ -1,23 +1,26 @@
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux'
|
||||
import { Card } from 'antd'
|
||||
import { Card, Button } from 'antd'
|
||||
import { autobind } from 'core-decorators';
|
||||
|
||||
import {
|
||||
fetchGroupList,
|
||||
fetchCurrGroup
|
||||
} from '../../actions/group.js'
|
||||
fetchCurrGroup,
|
||||
addGroup
|
||||
} from '../../../actions/group.js'
|
||||
|
||||
import './GroupList.scss'
|
||||
|
||||
@connect(
|
||||
state => ({
|
||||
groupList: state.group.groupList,
|
||||
currGroup: state.group.currGroup,
|
||||
currGroup: state.group.currGroup
|
||||
}),
|
||||
{
|
||||
fetchGroupList,
|
||||
fetchCurrGroup
|
||||
fetchCurrGroup,
|
||||
addGroup
|
||||
}
|
||||
)
|
||||
export default class GroupList extends Component {
|
||||
@ -27,7 +30,13 @@ export default class GroupList extends Component {
|
||||
|
||||
static propTypes = {
|
||||
groupList: PropTypes.array,
|
||||
currGroup: PropTypes.string
|
||||
currGroup: PropTypes.string,
|
||||
addGroup: PropTypes.func
|
||||
}
|
||||
|
||||
@autobind
|
||||
addGroup() {
|
||||
this.props.addGroup('group');
|
||||
}
|
||||
|
||||
render () {
|
||||
@ -35,6 +44,7 @@ export default class GroupList extends Component {
|
||||
|
||||
return (
|
||||
<Card title="Groups">
|
||||
<Button type="primary" onClick={this.addGroup}>添加分组</Button>
|
||||
<div>{currGroup}</div>
|
||||
{
|
||||
groupList.map((group, index) => (
|
@ -1,5 +1,5 @@
|
||||
import React, { Component } from 'react';
|
||||
import GroupList from '../../components/GroupList/GroupList.js';
|
||||
import GroupList from './GroupList/GroupList.js';
|
||||
import ProjectList from './ProjectList';
|
||||
import { Row, Col } from 'antd';
|
||||
|
||||
|
@ -7,11 +7,11 @@ const columns = [{
|
||||
title: 'Name',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
render: text => <a href="#">{text}</a>,
|
||||
render: text => <a href="#">{text}</a>
|
||||
}, {
|
||||
title: 'Age',
|
||||
dataIndex: 'age',
|
||||
key: 'age',
|
||||
key: 'age'
|
||||
}, {
|
||||
title: 'Action',
|
||||
key: 'action',
|
||||
@ -21,7 +21,7 @@ const columns = [{
|
||||
<span className="ant-divider" />
|
||||
<a href="#">删除</a>
|
||||
</span>
|
||||
),
|
||||
)
|
||||
}];
|
||||
|
||||
const data = [{
|
||||
|
@ -7,5 +7,5 @@ export {
|
||||
Home,
|
||||
Login,
|
||||
ProjectGroups,
|
||||
Interface,
|
||||
Interface
|
||||
}
|
||||
|
@ -1,13 +1,18 @@
|
||||
import React from 'react'
|
||||
import 'babel-polyfill'
|
||||
import thunkMiddleware from 'redux-thunk'
|
||||
import promiseMiddleware from 'redux-promise';
|
||||
import ReactDOM from 'react-dom'
|
||||
import App from './App'
|
||||
import { createStore, combineReducers } from 'redux'
|
||||
import { createStore, combineReducers, applyMiddleware } from 'redux'
|
||||
import { Provider } from 'react-redux'
|
||||
import ReduxContainer from './ReduxContainer.js'
|
||||
|
||||
// 合并 redux 创建stroe
|
||||
const store = createStore(combineReducers( ReduxContainer ))
|
||||
const store = createStore(combineReducers( ReduxContainer ), applyMiddleware(
|
||||
thunkMiddleware.default,
|
||||
promiseMiddleware
|
||||
))
|
||||
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
|
@ -14,7 +14,7 @@ export default (state = initialState, action) => {
|
||||
if (action.payload.res) {
|
||||
return {
|
||||
...state,
|
||||
groupList: action.payload.data,
|
||||
groupList: action.payload.data
|
||||
};
|
||||
}
|
||||
return state;
|
||||
@ -23,7 +23,7 @@ export default (state = initialState, action) => {
|
||||
if (action.payload.res) {
|
||||
return {
|
||||
...state,
|
||||
currGroup: action.payload.data,
|
||||
currGroup: action.payload.data
|
||||
};
|
||||
}
|
||||
return state;
|
||||
|
@ -1,13 +1,13 @@
|
||||
import {
|
||||
FETCH_INTERFACE_DATA,
|
||||
} from '../../actionTypes.js'
|
||||
FETCH_INTERFACE_DATA
|
||||
} from '../../constants/action-types.js'
|
||||
|
||||
export default (state = 3333, action) => {
|
||||
switch (action.type) {
|
||||
case FETCH_INTERFACE_DATA: {
|
||||
return {
|
||||
...state,
|
||||
icons: action.payload.data,
|
||||
icons: action.payload.data
|
||||
};
|
||||
}
|
||||
default:
|
||||
|
8
exampleCode/api/interface/del.json
Normal file
8
exampleCode/api/interface/del.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "success",
|
||||
"data": {
|
||||
"n": 1,
|
||||
"ok": 1
|
||||
}
|
||||
}
|
9
exampleCode/api/interface/up.json
Normal file
9
exampleCode/api/interface/up.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "success",
|
||||
"data": {
|
||||
"n": 1,
|
||||
"nModified": 1,
|
||||
"ok": 1
|
||||
}
|
||||
}
|
8
exampleCode/api/user/del.json
Normal file
8
exampleCode/api/user/del.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "success",
|
||||
"data": {
|
||||
"n": 1,
|
||||
"ok": 1
|
||||
}
|
||||
}
|
5
exampleCode/api/user/logout.json
Normal file
5
exampleCode/api/user/logout.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "success",
|
||||
"data": "ok"
|
||||
}
|
11
exampleCode/api/user/reg.json
Normal file
11
exampleCode/api/user/reg.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "success",
|
||||
"data": {
|
||||
"uid": 139,
|
||||
"email": "18500803805@163.com",
|
||||
"add_time": 1499768413,
|
||||
"up_time": 1499768413,
|
||||
"role": "member"
|
||||
}
|
||||
}
|
9
exampleCode/api/user/up.json
Normal file
9
exampleCode/api/user/up.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "success",
|
||||
"data": {
|
||||
"n": 1,
|
||||
"nModified": 1,
|
||||
"ok": 1
|
||||
}
|
||||
}
|
@ -16,7 +16,9 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@qnpm/ykit-config-qunar": "^0.8.1",
|
||||
"axios": "^0.16.2",
|
||||
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
||||
"core-decorators": "^0.17.0",
|
||||
"fs-extra": "^3.0.1",
|
||||
"jsonwebtoken": "^7.4.1",
|
||||
"koa": "^2.0.0",
|
||||
@ -34,8 +36,9 @@
|
||||
"node-sass-china": "^4.5.0",
|
||||
"nodemailer": "^4.0.1",
|
||||
"prop-types": "^15.5.10",
|
||||
"sha1": "^1.1.1",
|
||||
"redux": "^3.7.1",
|
||||
"redux-promise": "^0.5.3",
|
||||
"redux-thunk": "^2.2.0",
|
||||
"sha1": "^1.1.1",
|
||||
"ykit-config-antd": "^0.1.3",
|
||||
"ykit-config-react": "^0.4.4"
|
||||
@ -58,6 +61,7 @@
|
||||
"buffer-shims": "^1.0.0",
|
||||
"css-loader": "^0.28.4",
|
||||
"eslint": "^3.19.0",
|
||||
"eslint-plugin-import": "^2.2.0",
|
||||
"eslint-plugin-react": "^7.1.0",
|
||||
"express": "^4.15.3",
|
||||
"extract-text-webpack-plugin": "^1.0.1",
|
||||
|
@ -158,8 +158,8 @@ class userController extends baseController{
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
* @interface /user/list
|
||||
* 根据用户个人信息
|
||||
* @interface /user/find
|
||||
* @method GET
|
||||
* @param id 用户uid
|
||||
* @category user
|
||||
@ -183,7 +183,7 @@ class userController extends baseController{
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户列表,只有admin用户才有此权限
|
||||
* 删除用户,只有admin用户才有此权限
|
||||
* @interface /user/del
|
||||
* @method POST
|
||||
* @param id 用户uid
|
||||
|
@ -38,7 +38,7 @@ createAction('group', 'del', 'post', 'del')
|
||||
createAction('user', 'login', 'post', 'login')
|
||||
createAction('user', 'reg', 'post', 'reg')
|
||||
createAction('user', 'list', 'get', 'list')
|
||||
createAction('user', 'findById', 'post', 'findById')
|
||||
createAction('user', 'find', 'post', 'findById')
|
||||
createAction('user', 'update', 'post', 'update')
|
||||
createAction('user', 'del', 'post', 'del')
|
||||
createAction('user', 'status', 'get', 'getLoginStatus')
|
||||
|
Loading…
Reference in New Issue
Block a user