feat: user style

This commit is contained in:
suxiaoxin 2017-07-20 16:44:41 +08:00
parent 689e4d2081
commit d80dfea9aa
6 changed files with 150 additions and 79 deletions

View File

@ -1,7 +1,7 @@
import './index.scss'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { Route} from 'react-router-dom'
import { Route, Redirect} from 'react-router-dom'
import LeftMenu from './LeftMenu.js'
import List from './List.js'
import PropTypes from 'prop-types'
@ -29,7 +29,7 @@ class User extends Component {
<section className="user-box">
<LeftMenu />
<Redirect from={this.props.match.path} to={this.props.match.path + '/list'} />
<Route path={this.props.match.path + '/list'} component={List} />
<Route path={this.props.match.path + '/profile/:uid'} component={Profile} />
</section>

View File

@ -5,23 +5,30 @@
-webkit-box-flex: 1;
margin: .88rem auto 0 auto;
font-size: 0.14rem;
background: #FFF;
min-height:500px;
margin-top: 84px;
ul{border:none}
.user-list {
width: 216px;
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
background: #FFF;
border-radius:5px;
.search{
margin: 5px;
}
ul{border:none}
}
.user-table {
-webkit-box-flex: 1;
padding-right: 15px;
padding: 15px;
margin-left: 15px;
border-radius:5px;
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
background: #FFF;
.ant-table-wrapper table {
font-size: .14rem;
@ -35,7 +42,9 @@
-webkit-box-flex: 1;
margin-top: 15px;
margin-left: 15px;
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
background: #FFF;
border-radius:5px;
.user-item {
min-height:35px;
line-height:35px;

View File

@ -61,6 +61,7 @@ var interfaceController = function (_baseController) {
* @category interface
* @foldnumber 10
* @param {Number} project_id 项目id不能为空
* @param {String} title 接口标题不能为空
* @param {String} path 接口请求路径不能为空
* @param {String} method 请求方式
* @param {Array} [req_headers] 请求的header信息
@ -141,30 +142,31 @@ var interfaceController = function (_baseController) {
};
if (data.req_params_type === 'form') data.req_params_form = params.req_params;else data.req_params_other = params.req_params;
if (params.req_params_form) data.req_params_form = params.req_params_form;
if (params.req_params_other) data.req_params_other = params.req_params_other;
_context.next = 17;
_context.next = 18;
return this.Model.save(data);
case 17:
case 18:
result = _context.sent;
ctx.body = _yapi2.default.commons.resReturn(result);
_context.next = 24;
_context.next = 25;
break;
case 21:
_context.prev = 21;
case 22:
_context.prev = 22;
_context.t0 = _context['catch'](12);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
case 24:
case 25:
case 'end':
return _context.stop();
}
}
}, _callee, this, [[12, 21]]);
}, _callee, this, [[12, 22]]);
}));
function add(_x) {
@ -371,39 +373,41 @@ var interfaceController = function (_baseController) {
if (params.path) data.path = params.path;
if (params.title) data.title = params.title;
if (params.desc) data.desc = params.desc;
if (params.method) data.method = params.method;
if (params.req_headers) data.req_headers = params.req_headers;
if (params.req_params_type === 'form') data.req_params_form = params.req_params;else data.req_params_other = params.req_params;
if (params.req_params_form) data.req_params_form = params.req_params_form;
if (params.req_params_other) data.req_params_other = params.req_params_other;
if (params.res_body_type) data.res_body_type = params.res_body_type;
if (params.res_body) data.res_body = params.res_body;
_context4.prev = 19;
_context4.next = 22;
_context4.prev = 21;
_context4.next = 24;
return this.Model.up(id, data);
case 22:
case 24:
result = _context4.sent;
ctx.body = _yapi2.default.commons.resReturn(result);
_context4.next = 29;
_context4.next = 31;
break;
case 26:
_context4.prev = 26;
_context4.t0 = _context4['catch'](19);
case 28:
_context4.prev = 28;
_context4.t0 = _context4['catch'](21);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context4.t0.message);
case 29:
case 31:
case 'end':
return _context4.stop();
}
}
}, _callee4, this, [[19, 26]]);
}, _callee4, this, [[21, 28]]);
}));
function up(_x4) {

View File

@ -71,6 +71,36 @@ var projectController = function (_baseController) {
return _this;
}
(0, _createClass3.default)(projectController, [{
key: 'handleBasepath',
value: function handleBasepath(basepath) {
if (!basepath) return false;
if (basepath[0] !== '/') basepath = '/' + basepath;
if (basepath[basepath.length - 1] === '/') basepath = basepath.substr(0, basepath.length - 1);
if (!this.verifyPath(basepath)) {
return false;
}
return basepath;
}
}, {
key: 'verifyPath',
value: function verifyPath(path) {
if (/^[a-zA-Z0-9\-\/_:]+$/.test(basepath)) {
return true;
} else {
return false;
}
}
}, {
key: 'verifyDomain',
value: function verifyDomain(domain) {
if (!domain) return false;
if (/^[a-zA-Z0-9\-_\.]+[a-zA-Z]{2,6}$/.test(domain)) {
return true;
}
return false;
}
/**
* 添加项目分组
* @interface /project/add
@ -87,8 +117,7 @@ var projectController = function (_baseController) {
* @example ./api/project/add.json
*/
(0, _createClass3.default)(projectController, [{
}, {
key: 'add',
value: function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
@ -145,20 +174,36 @@ var projectController = function (_baseController) {
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目domain不能为空'));
case 14:
if (!(params.basepath = this.handleBasepath(params.basepath) === false)) {
_context.next = 16;
return this.Model.checkDomainRepeat(params.prd_host, params.basepath);
break;
}
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, 'basepath格式有误'));
case 16:
if (this.verifyDomain(params.prd_host)) {
_context.next = 18;
break;
}
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '线上域名格式有误'));
case 18:
_context.next = 20;
return this.Model.checkDomainRepeat(params.prd_host, params.basepath);
case 20:
checkRepeatDomain = _context.sent;
if (!(checkRepeatDomain > 0)) {
_context.next = 19;
_context.next = 23;
break;
}
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '已存在domain和basepath'));
case 19:
case 23:
data = {
name: params.name,
desc: params.desc,
@ -171,29 +216,29 @@ var projectController = function (_baseController) {
add_time: _yapi2.default.commons.time(),
up_time: _yapi2.default.commons.time()
};
_context.prev = 20;
_context.next = 23;
_context.prev = 24;
_context.next = 27;
return this.Model.save(data);
case 23:
case 27:
result = _context.sent;
ctx.body = _yapi2.default.commons.resReturn(result);
_context.next = 30;
_context.next = 34;
break;
case 27:
_context.prev = 27;
_context.t0 = _context['catch'](20);
case 31:
_context.prev = 31;
_context.t0 = _context['catch'](24);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
case 30:
case 34:
case 'end':
return _context.stop();
}
}
}, _callee, this, [[20, 27]]);
}, _callee, this, [[24, 31]]);
}));
function add(_x) {
@ -743,6 +788,23 @@ var projectController = function (_baseController) {
case 12:
projectData = _context8.sent;
if (!(params.basepath = this.handleBasepath(params.basepath) === false)) {
_context8.next = 15;
break;
}
return _context8.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, 'basepath格式有误'));
case 15:
if (this.verifyDomain(params.prd_host)) {
_context8.next = 17;
break;
}
return _context8.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '线上域名格式有误'));
case 17:
if (projectData.name === params.name) {
delete params.name;
}
@ -752,43 +814,43 @@ var projectController = function (_baseController) {
}
if (!params.name) {
_context8.next = 21;
_context8.next = 25;
break;
}
_context8.next = 18;
_context8.next = 22;
return this.Model.checkNameRepeat(params.name);
case 18:
case 22:
checkRepeat = _context8.sent;
if (!(checkRepeat > 0)) {
_context8.next = 21;
_context8.next = 25;
break;
}
return _context8.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '已存在的项目名'));
case 21:
case 25:
if (!(params.basepath && params.prd_host)) {
_context8.next = 27;
_context8.next = 31;
break;
}
_context8.next = 24;
_context8.next = 28;
return this.Model.checkDomainRepeat(params.prd_host, params.basepath);
case 24:
case 28:
checkRepeatDomain = _context8.sent;
if (!(checkRepeatDomain > 0)) {
_context8.next = 27;
_context8.next = 31;
break;
}
return _context8.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '已存在domain和basepath'));
case 27:
case 31:
data = {
uid: this.getUid(),
up_time: _yapi2.default.commons.time()
@ -804,28 +866,28 @@ var projectController = function (_baseController) {
if (params.protocol) data.protocol = params.protocol;
if (params.env) data.env = params.env;
_context8.next = 35;
_context8.next = 39;
return this.Model.up(id, data);
case 35:
case 39:
result = _context8.sent;
ctx.body = _yapi2.default.commons.resReturn(result);
_context8.next = 42;
_context8.next = 46;
break;
case 39:
_context8.prev = 39;
case 43:
_context8.prev = 43;
_context8.t1 = _context8['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context8.t1.message);
case 42:
case 46:
case 'end':
return _context8.stop();
}
}
}, _callee8, this, [[0, 39]]);
}, _callee8, this, [[0, 43]]);
}));
function up(_x8) {

View File

@ -47,13 +47,9 @@ var interfaceModel = function (_baseModel) {
key: 'getSchema',
value: function getSchema() {
return {
title: { type: String, required: true },
uid: { type: Number, required: true },
path: { type: String, required: true, validate: {
validator: function validator(v) {
return v && v[0] !== '/';
},
message: '接口路径第一位不能是/'
} },
path: { type: String, required: true },
method: { type: String, required: true },
project_id: { type: Number, required: true },
desc: String,

View File

@ -51,9 +51,9 @@ var projectModel = function (_baseModel) {
name: { type: String, required: true },
basepath: { type: String, required: true, validate: {
validator: function validator(v) {
return v && v[v.length - 1] === '/';
return v && v[0] === '/';
},
message: 'basepath字符串结尾必须是/'
message: 'basepath必须是/开头'
} },
desc: String,
group_id: { type: Number, required: true },