mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-24 13:14:16 +08:00
fix: 合并
This commit is contained in:
commit
502eec54b9
26
README.md
26
README.md
@ -27,31 +27,11 @@ YApi 是<strong>高效</strong>、<strong>易用</strong>、<strong>功能强大
|
||||
#### 更新
|
||||
cd {项目目录}
|
||||
yapi-cli ls //查看版本号列表
|
||||
yapi-cli update -v v1.1.0
|
||||
yapi-cli update //更新到最新版本
|
||||
yapi-cli update -v {Version} //更新到指定版本
|
||||
|
||||
#### 配置邮箱 (仅支持 SMTP)
|
||||
打开项目目录 config.json 文件,新增 mail 配置, 替换默认的邮箱配置
|
||||
```javascript
|
||||
|
||||
{
|
||||
"port": "*****",
|
||||
"adminAccount": "********",
|
||||
"db": {...},
|
||||
"mail": {
|
||||
"enable": true,
|
||||
"host": "smtp.163.com", //邮箱服务器
|
||||
"port": 465, //端口
|
||||
"from": "***@163.com", //发送人邮箱
|
||||
"auth": {
|
||||
"user": "***@163.com", //邮箱服务器账号
|
||||
"pass": "*****" //邮箱服务器密码
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### 在线demo
|
||||
### 在线 Demo
|
||||
<p><a target="_blank" href="http://yapi.demo.qunar.com">yapi.demo.qunar.com</a></p>
|
||||
|
||||
管理员账号
|
||||
|
@ -128,7 +128,7 @@ class TimeTree extends Component {
|
||||
<span className="logtype">{logType[item.type]}动态</span>
|
||||
<span className="logtime">{formatTime(item.add_time)}</span>
|
||||
</div>
|
||||
<span className="logcontent">{item.content}</span>
|
||||
<span className="logcontent" dangerouslySetInnerHTML={{__html: item.content}}></span>
|
||||
</Timeline.Item>);
|
||||
});
|
||||
} else {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Upload, Icon, message, Select, Tooltip } from 'antd';
|
||||
import { Upload, Icon, message, Select, Tooltip, Button } from 'antd';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import './ProjectData.scss';
|
||||
@ -11,7 +11,12 @@ const Option = Select.Option;
|
||||
const plugin = require('client/plugin.js');
|
||||
|
||||
const importDataModule = {};
|
||||
|
||||
const exportDataModule = {};
|
||||
// exportDataModule.pdf = {
|
||||
// name: 'Pdf',
|
||||
// route: '/api/interface/download_crx',
|
||||
// desc: '导出项目接口文档为 pdf 文件'
|
||||
// }
|
||||
@connect(
|
||||
state => {
|
||||
// console.log(state);
|
||||
@ -30,7 +35,8 @@ class ProjectData extends Component {
|
||||
this.state = {
|
||||
selectCatid: "",
|
||||
menuList: [],
|
||||
curImportType: null
|
||||
curImportType: null,
|
||||
curExportType: null
|
||||
}
|
||||
}
|
||||
static propTypes = {
|
||||
@ -46,7 +52,8 @@ class ProjectData extends Component {
|
||||
menuList: menuList
|
||||
})
|
||||
});
|
||||
plugin.emitHook('import_data', importDataModule, this.props);
|
||||
plugin.emitHook('import_data', importDataModule);
|
||||
plugin.emitHook('export_data', exportDataModule, this.props.match.params.id);
|
||||
}
|
||||
selectChange(value) {
|
||||
this.setState({
|
||||
@ -68,17 +75,17 @@ class ProjectData extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
async handleAddCat(cats){
|
||||
async handleAddCat(cats) {
|
||||
let menuList = this.state.menuList;
|
||||
let catsObj = {};
|
||||
if(cats && Array.isArray(cats)){
|
||||
for(let i=0; i< cats.length; i++){
|
||||
if (cats && Array.isArray(cats)) {
|
||||
for (let i = 0; i < cats.length; i++) {
|
||||
let cat = cats[i];
|
||||
let findCat =_.find(menuList, menu=>menu.name === cat.name)
|
||||
let findCat = _.find(menuList, menu => menu.name === cat.name)
|
||||
catsObj[cat.name] = cat;
|
||||
if(findCat){
|
||||
if (findCat) {
|
||||
cat.id = findCat._id;
|
||||
}else{
|
||||
} else {
|
||||
let result = await axios.post('/api/interface/add_cat', {
|
||||
name: cat.name,
|
||||
project_id: this.props.match.params.id,
|
||||
@ -100,7 +107,7 @@ class ProjectData extends Component {
|
||||
reader.readAsText(info.file);
|
||||
reader.onload = async res => {
|
||||
res = importDataModule[this.state.curImportType].run(res.target.result);
|
||||
const cats =await this.handleAddCat(res.cats);
|
||||
const cats = await this.handleAddCat(res.cats);
|
||||
|
||||
res = res.apis;
|
||||
let len = res.length;
|
||||
@ -115,7 +122,7 @@ class ProjectData extends Component {
|
||||
if (this.props.basePath) {
|
||||
data.path = data.path.indexOf(this.props.basePath) === 0 ? data.path.substr(this.props.basePath.length) : data.path;
|
||||
}
|
||||
if(data.catname && cats[data.catname].id){
|
||||
if (data.catname && cats[data.catname].id) {
|
||||
data.catid = cats[data.catname].id;
|
||||
}
|
||||
|
||||
@ -141,6 +148,12 @@ class ProjectData extends Component {
|
||||
})
|
||||
}
|
||||
|
||||
handleExportType = (val) => {
|
||||
this.setState({
|
||||
curExportType: val
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
@ -169,8 +182,6 @@ class ProjectData extends Component {
|
||||
{Object.keys(importDataModule).map((name) => {
|
||||
return <Option key={name} value={name}>{importDataModule[name].name}</Option>
|
||||
})}
|
||||
|
||||
|
||||
</Select>
|
||||
</div>
|
||||
<div className="catidSelect">
|
||||
@ -185,7 +196,6 @@ class ProjectData extends Component {
|
||||
{this.state.menuList.map((item, key) => {
|
||||
return <Option key={key} value={item._id + ""}>{item.name}</Option>;
|
||||
})}
|
||||
|
||||
</Select>
|
||||
</div>
|
||||
<div style={{ marginTop: 16, height: 180 }}>
|
||||
@ -198,6 +208,32 @@ class ProjectData extends Component {
|
||||
</Dragger>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="dataImportCon" style={{ marginLeft: '20px', display: Object.keys(exportDataModule).length > 0 ? '' : 'none' }}>
|
||||
<div ><h3>数据导出</h3></div>
|
||||
<div className="dataImportTile">
|
||||
<Select placeholder="请选择导出数据的方式" onChange={this.handleExportType}>
|
||||
{Object.keys(exportDataModule).map((name) => {
|
||||
return <Option key={name} value={name}>{exportDataModule[name].name}</Option>
|
||||
})}
|
||||
</Select>
|
||||
</div>
|
||||
<div className="export-content">
|
||||
{this.state.curExportType ?
|
||||
<div>
|
||||
<p className="export-desc">{exportDataModule[this.state.curExportType].desc}</p>
|
||||
<a target="_blank" href={this.state.curExportType && exportDataModule[this.state.curExportType] && exportDataModule[this.state.curExportType].route} >
|
||||
<Button className="export-button" type="primary" size="large"> 导出 </Button>
|
||||
|
||||
</a>
|
||||
</div>
|
||||
:
|
||||
<Button disabled className="export-button" type="primary" size="large"> 导出 </Button>
|
||||
}
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,19 +1,34 @@
|
||||
.dataImportCon{
|
||||
display: inline-block;
|
||||
background-color: #ececec;
|
||||
padding: 16px;
|
||||
border-radius: 4px;
|
||||
.ant-upload-drag{
|
||||
.postman-dataImport{
|
||||
display: flex;
|
||||
.dataImportCon{
|
||||
min-width: 274px;
|
||||
background-color: #ececec;
|
||||
padding: 16px;
|
||||
background-color: white;
|
||||
}
|
||||
.dataImportTile{
|
||||
color: #2395f1;
|
||||
padding: 16px 0px;
|
||||
font-weight: 500;
|
||||
width: 100%;
|
||||
.ant-select{
|
||||
border-radius: 4px;
|
||||
|
||||
.ant-upload-drag{
|
||||
padding: 16px;
|
||||
background-color: white;
|
||||
}
|
||||
.dataImportTile{
|
||||
color: #2395f1;
|
||||
padding: 16px 0px;
|
||||
font-weight: 500;
|
||||
width: 100%;
|
||||
.ant-select{
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.export-content{
|
||||
text-align: center;
|
||||
}
|
||||
.export-desc{
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
.export-button{
|
||||
width: 100px;
|
||||
height:35px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,21 +9,66 @@ let hooks, pluginModule;
|
||||
*/
|
||||
|
||||
hooks = {
|
||||
/**
|
||||
* 第三方登录 //可参考 yapi-plugin-qsso 插件
|
||||
*/
|
||||
third_login: {
|
||||
type: 'component',
|
||||
mulit: false,
|
||||
listener: null
|
||||
},
|
||||
add_interface: {
|
||||
type: 'listener',
|
||||
mulit: true,
|
||||
listener: []
|
||||
},
|
||||
/**
|
||||
* 导入数据
|
||||
* @param Object importDataModule
|
||||
*
|
||||
* @info
|
||||
* 可参考 vendors/exts/yapi-plugin-import-swagger插件
|
||||
* importDataModule = {};
|
||||
*
|
||||
*/
|
||||
import_data: {
|
||||
type: 'listener',
|
||||
mulit: true,
|
||||
listener: []
|
||||
},
|
||||
/**
|
||||
* 导出数据
|
||||
* @param Object exportDataModule
|
||||
* @param projectId
|
||||
* @info
|
||||
* exportDataModule = {};
|
||||
* exportDataModule.pdf = {
|
||||
* name: 'Pdf',
|
||||
* route: '/api/plugin/export/pdf',
|
||||
* desc: '导出项目接口文档为 pdf 文件'
|
||||
* }
|
||||
*/
|
||||
export_data: {
|
||||
type: 'listener',
|
||||
mulit: true,
|
||||
listener: []
|
||||
},
|
||||
/**
|
||||
* 接口页面 tab 钩子
|
||||
* @param InterfaceTabs
|
||||
*
|
||||
* @info
|
||||
* 可参考 vendors/exts/yapi-plugin-advanced-mock
|
||||
* let InterfaceTabs = {
|
||||
view: {
|
||||
component: View,
|
||||
name: '预览'
|
||||
},
|
||||
edit: {
|
||||
component: Edit,
|
||||
name: '编辑'
|
||||
},
|
||||
run: {
|
||||
component: Run,
|
||||
name: '运行'
|
||||
}
|
||||
}
|
||||
*/
|
||||
interface_tab: {
|
||||
type: 'listener',
|
||||
mulit: true,
|
||||
@ -73,14 +118,14 @@ pluginModule = {
|
||||
emitHook: emitHook
|
||||
}
|
||||
let pluginModuleList;
|
||||
try{
|
||||
try {
|
||||
pluginModuleList = require('./plugin-module.js');
|
||||
}catch(err){pluginModuleList = {}}
|
||||
} catch (err) { pluginModuleList = {} }
|
||||
|
||||
|
||||
Object.keys(pluginModuleList).forEach(plugin=>{
|
||||
Object.keys(pluginModuleList).forEach(plugin => {
|
||||
if (!pluginModuleList[plugin]) return null;
|
||||
if(pluginModuleList[plugin] && typeof pluginModuleList[plugin].module === 'function'){
|
||||
if (pluginModuleList[plugin] && typeof pluginModuleList[plugin].module === 'function') {
|
||||
pluginModuleList[plugin].module.call(pluginModule, pluginModuleList[plugin].options)
|
||||
}
|
||||
})
|
||||
|
@ -77,26 +77,32 @@ function improtData(importDataModule){
|
||||
api.res_body = handleResponse(data.responses);
|
||||
|
||||
//处理参数
|
||||
data.parameters.forEach(param=>{
|
||||
let defaultParam = {
|
||||
name: param.name,
|
||||
desc: param.description,
|
||||
required: param.required? "1" : "0"
|
||||
}
|
||||
switch(param.in){
|
||||
case 'path' : api.req_params.push(defaultParam); break;
|
||||
case 'query': api.req_query.push(defaultParam); break;
|
||||
case 'body' : api.req_body_other = handleSchema(param.schema); break;
|
||||
case 'formData' : defaultParam.type = param.type === 'file'? 'file' : 'text'; api.req_body_form.push(defaultParam); break;
|
||||
case 'header' : api.req_headers.push(defaultParam);break;
|
||||
}
|
||||
})
|
||||
if(data.parameters && Array.isArray(data.parameters)){
|
||||
data.parameters.forEach(param=>{
|
||||
let defaultParam = {
|
||||
name: param.name,
|
||||
desc: param.description,
|
||||
required: param.required? "1" : "0"
|
||||
}
|
||||
switch(param.in){
|
||||
case 'path' : api.req_params.push(defaultParam); break;
|
||||
case 'query': api.req_query.push(defaultParam); break;
|
||||
case 'body' : api.req_body_other = handleSchema(param.schema); break;
|
||||
case 'formData' : defaultParam.type = param.type === 'file'? 'file' : 'text'; api.req_body_form.push(defaultParam); break;
|
||||
case 'header' : api.req_headers.push(defaultParam);break;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
return api;
|
||||
}
|
||||
|
||||
function handleResponse(api){
|
||||
let res_body = '';
|
||||
if(!api || !Array.isArray(api)){
|
||||
return res_body;
|
||||
}
|
||||
_.each(api, (res, code)=>{
|
||||
if(code == 200 || code === 'default'){
|
||||
res_body = handleSchema(res.schema);
|
||||
|
@ -105,7 +105,7 @@ class groupController extends baseController {
|
||||
result = yapi.commons.fieldSelect(result, ['_id', 'group_name', 'group_desc', 'uid', 'members','type']);
|
||||
let username = this.getUsername();
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 新增了分组 "${params.group_name}"`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 新增了分组 "${params.group_name}"`,
|
||||
type: 'group',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
@ -201,8 +201,12 @@ class groupController extends baseController {
|
||||
guest: "访客"
|
||||
};
|
||||
if(add_members.length){
|
||||
let members = add_members.map((item)=>{
|
||||
return `<a href = "/user/profile/${item.uid}">${item.username}</a>`
|
||||
})
|
||||
members = members.join("、");
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 新增了分组成员 "${add_members.reduce((str, item) => (str ? str + '、' : '') + item.username, '')}" 为 "${rolename[params.role]}"`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 新增了分组成员 ${members} 为 ${rolename[params.role]}`,
|
||||
type: 'group',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
@ -262,7 +266,7 @@ class groupController extends baseController {
|
||||
};
|
||||
let groupUserdata = await this.getUserdata(params.member_uid, params.role);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 更改了分组成员 "${groupUserdata.username}" 的权限为 "${rolename[params.role]}"`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更改了分组成员 <a href="/user/profile/${params.member_uid}">${groupUserdata.username}</a> 的权限为 "${rolename[params.role]}"`,
|
||||
type: 'group',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
@ -338,7 +342,7 @@ class groupController extends baseController {
|
||||
};
|
||||
let groupUserdata = await this.getUserdata(params.member_uid, params.role);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 删除了分组成员 "${groupUserdata.username}"`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 删除了分组成员 <a href="/user/profile/${params.member_uid}">${groupUserdata.username}</a>`,
|
||||
type: 'group',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
@ -386,9 +390,14 @@ class groupController extends baseController {
|
||||
if(result[i].role !== 'member'){
|
||||
newResult.unshift(result[i]);
|
||||
}else{
|
||||
let publicCount = await projectInst.countWithPublic(result[i].id);
|
||||
let publicCount = await projectInst.countWithPublic(result[i]._id);
|
||||
if(publicCount > 0){
|
||||
newResult.push(result[i]);
|
||||
}else{
|
||||
let projectCountWithAuth = await projectInst.getProjectWithAuth(result[i]._id, this.getUid());
|
||||
if(projectCountWithAuth > 0){
|
||||
newResult.push(result[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -489,7 +498,7 @@ class groupController extends baseController {
|
||||
let result = await groupInst.up(id, data);
|
||||
let username = this.getUsername();
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 更新了 "${data.group_name}" 分组`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更新了 <a href="/group/${id}">${data.group_name}</a> 分组`,
|
||||
type: 'group',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
|
@ -158,7 +158,8 @@ class interfaceController extends baseController {
|
||||
yapi.emitHook('interface_add', result._id).then();
|
||||
this.catModel.get(params.catid).then((cate) => {
|
||||
let username = this.getUsername();
|
||||
let title = `用户 "${username}" 为分类 "${cate.name}" 添加了接口 "${data.title}"`
|
||||
let title = `<a href="/user/profile/${this.getUid()}">${username}</a> 为分类 <a href="/project/${params.project_id}/interface/api/cat_${params.catid}">${cate.name}</a> 添加了接口 <a href="/project/${params.project_id}/interface/api/${result._id}">${data.title}</a> `
|
||||
|
||||
yapi.commons.saveLog({
|
||||
content: title,
|
||||
type: 'project',
|
||||
@ -484,7 +485,7 @@ class interfaceController extends baseController {
|
||||
if (data.catid) {
|
||||
this.catModel.get(+data.catid).then((cate) => {
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 更新了分类 "${cate.name}" 下的接口 "${interfaceData.title}"`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更新了分类 <a href="/project/${cate.project_id}/interface/api/cat_${data.catid}">${cate.name}</a> 下的接口 <a href="project/${cate.project_id}/interface/api/${id}">${interfaceData.title}</a>`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
@ -496,7 +497,7 @@ class interfaceController extends baseController {
|
||||
let cateid = interfaceData.catid;
|
||||
this.catModel.get(cateid).then((cate) => {
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 更新了分类 "${cate.name}" 下的接口 "${interfaceData.title}"`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更新了分类 <a href="/project/${cate.project_id}/interface/api/cat_${cateid}">${cate.name}</a> 下的接口 <a href="project/${cate.project_id}/interface/api/${id}>${interfaceData.title}</a>`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
@ -562,7 +563,7 @@ class interfaceController extends baseController {
|
||||
let username = this.getUsername();
|
||||
this.catModel.get(inter.catid).then((cate) => {
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 删除了分类 "${cate.name}" 下的接口 "${inter.title}"`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 删除了分类 <a href="/project/${cate.project_id}/interface/api/cat_${inter.catid}">${cate.name}</a> 下的接口 "${inter.title}"`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
@ -639,7 +640,7 @@ class interfaceController extends baseController {
|
||||
|
||||
let username = this.getUsername();
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 添加了分类 "${params.name}"`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 添加了分类 <a href="/project/${params.project_id}/interface/api/cat_${result._id}">${params.name}</a>`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
@ -670,7 +671,7 @@ class interfaceController extends baseController {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 更新了分类 "${cate.name}"`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更新了分类 <a href="/project/${cate.project_id}/interface/api/cat_${params.catid}">${cate.name}</a>`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
@ -700,7 +701,7 @@ class interfaceController extends baseController {
|
||||
|
||||
let username = this.getUsername();
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 删除了分类 "${catData.name}" 及该分类下的接口`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 删除了分类 <a href="/project/${catData.project_id}/interface/api/cat_${id}">${catData.name}</a> 及该分类下的接口`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
|
@ -48,7 +48,7 @@ class logController extends baseController {
|
||||
projectLogList.forEach((item, index)=>{
|
||||
item = item.toObject();
|
||||
if(item.type === 'project'){
|
||||
item.content = `在 ${projectDatas[item.typeid].name} 项目: ` + item.content;
|
||||
item.content = `在 <a href="/group/${item.typeid}">${projectDatas[item.typeid].name}</a> 项目: ` + item.content;
|
||||
}
|
||||
projectLogList[index] = item;
|
||||
})
|
||||
|
@ -134,11 +134,11 @@ class projectController extends baseController {
|
||||
}
|
||||
let username = this.getUsername();
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 添加了项目 "${params.name}"`,
|
||||
type: 'group',
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 添加了项目 <a href="/project/${result._id}">${params.name}</a>`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.group_id
|
||||
typeid: result._id
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
@ -204,9 +204,13 @@ class projectController extends baseController {
|
||||
try {
|
||||
let result = await this.Model.addMember(params.id, add_members);
|
||||
if(add_members.length){
|
||||
let members = add_members.map((item)=>{
|
||||
return `<a href = "/user/profile/${item.uid}">${item.username}</a>`
|
||||
})
|
||||
members = members.join("、");
|
||||
let username = this.getUsername();
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 添加了项目成员 "${add_members.reduce((str, item) => (str ? str + '、' : '') + item.username, '')}"`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 添加了项目成员 ${members}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
@ -258,7 +262,7 @@ class projectController extends baseController {
|
||||
let username = this.getUsername();
|
||||
yapi.getInst(userModel).findById(params.member_uid).then((member)=>{
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 删除了项目中的成员 "${member.username}"`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 删除了项目中的成员 <a href="/user/profile/${params.member_uid}">${member.username}</a>`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
@ -469,14 +473,18 @@ class projectController extends baseController {
|
||||
}
|
||||
|
||||
params.role = ['owner', 'dev', 'guest'].find(v => v === params.role) || 'dev';
|
||||
|
||||
let rolename = {
|
||||
'owner': '组长',
|
||||
'dev': '开发者',
|
||||
'guest': '访客'
|
||||
};
|
||||
try {
|
||||
let result = await projectInst.changeMemberRole(params.id, params.member_uid, params.role);
|
||||
|
||||
let username = this.getUsername();
|
||||
yapi.getInst(userModel).findById(params.member_uid).then((member)=>{
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 修改了项目中的成员 "${member.username}" 的角色为 "${params.role}"`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 修改了项目中的成员 <a href="/user/profile/${params.member_uid}">${member.username}</a> 的角色为 "${rolename[params.role]}"`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
@ -522,7 +530,7 @@ class projectController extends baseController {
|
||||
this.followModel.updateById(this.getUid(), id, data).then(()=>{
|
||||
let username = this.getUsername();
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 修改了项目图标、颜色`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 修改了项目图标、颜色`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
@ -601,7 +609,7 @@ class projectController extends baseController {
|
||||
let result = await this.Model.up(id, data);
|
||||
let username = this.getUsername();
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 更新了项目 "${projectData.name}"`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更新了项目 <a href="/user/profile/${id}}">${projectData.name}</a> ""`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
@ -652,7 +660,7 @@ class projectController extends baseController {
|
||||
let result = await this.Model.up(id, data);
|
||||
let username = this.getUsername();
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 更新了项目 "${projectData.name}" 环境`,
|
||||
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更新了项目 <a href="/user/profile/${id}">${projectData.name}"</a> 环境`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
|
@ -51,6 +51,13 @@ class projectModel extends baseModel {
|
||||
}).exec();
|
||||
}
|
||||
|
||||
getProjectWithAuth(group_id, uid){
|
||||
return this.model.count({
|
||||
"group_id": group_id,
|
||||
"members.uid": uid
|
||||
})
|
||||
}
|
||||
|
||||
getBaseInfo(id){
|
||||
return this.model.findOne({
|
||||
_id: id
|
||||
|
@ -11,6 +11,7 @@ var hooks = {
|
||||
/**
|
||||
* 第三方sso登录钩子,暂只支持设置一个
|
||||
* @param ctx
|
||||
* @return 必需返回一个 promise 对象,resolve({username: '', email: ''})
|
||||
*/
|
||||
'third_login': {
|
||||
type: 'single',
|
||||
|
@ -1 +1,5 @@
|
||||
window.WEBPACK_ASSETS = {"index.js":{"js":"index@8a3568400b8e3dea6f1e.js","css":"index@8a3568400b8e3dea6f1e.css"},"lib":{"js":"lib@92e2c3937254a8f33f8a.js"},"lib2":{"js":"lib2@2e084b54b8a92fdaf766.js"},"manifest":{"js":"manifest@b67af9f8b578904e66c5.js"}}
|
||||
<<<<<<< HEAD
|
||||
window.WEBPACK_ASSETS = {"index.js":{"js":"index@8a3568400b8e3dea6f1e.js","css":"index@8a3568400b8e3dea6f1e.css"},"lib":{"js":"lib@92e2c3937254a8f33f8a.js"},"lib2":{"js":"lib2@2e084b54b8a92fdaf766.js"},"manifest":{"js":"manifest@b67af9f8b578904e66c5.js"}}
|
||||
=======
|
||||
window.WEBPACK_ASSETS = {"index.js":{"js":"index@d40cbb31e3ed41d757d9.js","css":"index@d40cbb31e3ed41d757d9.css"},"lib":{"js":"lib@3d6790748483412d111e.js"},"lib2":{"js":"lib2@34c977588e1eeac462a0.js"},"manifest":{"js":"manifest@b67af9f8b578904e66c5.js"}}
|
||||
>>>>>>> e27b666f67edebac832ca9a3c751d0d764680284
|
||||
|
1
static/prd/index@d40cbb31e3ed41d757d9.css
Normal file
1
static/prd/index@d40cbb31e3ed41d757d9.css
Normal file
File diff suppressed because one or more lines are too long
BIN
static/prd/index@d40cbb31e3ed41d757d9.css.gz
Normal file
BIN
static/prd/index@d40cbb31e3ed41d757d9.css.gz
Normal file
Binary file not shown.
1
static/prd/index@d40cbb31e3ed41d757d9.js
Normal file
1
static/prd/index@d40cbb31e3ed41d757d9.js
Normal file
File diff suppressed because one or more lines are too long
BIN
static/prd/index@d40cbb31e3ed41d757d9.js.gz
Normal file
BIN
static/prd/index@d40cbb31e3ed41d757d9.js.gz
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
static/prd/lib2@34c977588e1eeac462a0.js.gz
Normal file
BIN
static/prd/lib2@34c977588e1eeac462a0.js.gz
Normal file
Binary file not shown.
1
static/prd/lib@3d6790748483412d111e.js
Normal file
1
static/prd/lib@3d6790748483412d111e.js
Normal file
File diff suppressed because one or more lines are too long
BIN
static/prd/lib@3d6790748483412d111e.js.gz
Normal file
BIN
static/prd/lib@3d6790748483412d111e.js.gz
Normal file
Binary file not shown.
@ -1 +1 @@
|
||||
(function(e){function i(t){if(n[t])return n[t].exports;var r=n[t]={exports:{},id:t,loaded:false};e[t].call(r.exports,r,r.exports,i);r.loaded=true;return r.exports}var t=window["webpackJsonp"];window["webpackJsonp"]=function(o,u){var a,f,l=0,c=[];for(;l<o.length;l++){f=o[l];if(r[f])c.push.apply(c,r[f]);r[f]=0}for(a in u){e[a]=u[a]}if(t)t(o,u);while(c.length)c.shift().call(null,i);if(u[0]){n[0]=0;return i(0)}};var n={};var r={3:0};i.e=function(t,n){if(r[t]===0)return n.call(null,i);if(r[t]!==undefined){r[t].push(n)}else{r[t]=[n];var s=document.getElementsByTagName("head")[0];var o=document.createElement("script");o.type="text/javascript";o.charset="utf-8";o.async=true;o.src=i.p+""+t+".chunk.min.js";s.appendChild(o)}};i.m=e;i.c=n;i.p=""})([])
|
||||
!function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n=window.webpackJsonp;window.webpackJsonp=function(s,o){for(var u,f,l=0,c=[];l<s.length;l++)f=s[l],i[f]&&c.push.apply(c,i[f]),i[f]=0;for(u in o)e[u]=o[u];for(n&&n(s,o);c.length;)c.shift().call(null,t);if(o[0])return r[0]=0,t(0)};var r={},i={3:0};t.e=function(e,n){if(0===i[e])return n.call(null,t);if(void 0!==i[e])i[e].push(n);else{i[e]=[n];var r=document.getElementsByTagName("head")[0],s=document.createElement("script");s.type="text/javascript",s.charset="utf-8",s.async=!0,s.src=t.p+""+e+".chunk.min.js",r.appendChild(s)}},t.m=e,t.c=r,t.p=""}([])
|
@ -166,6 +166,11 @@ module.exports = {
|
||||
});
|
||||
|
||||
if (this.env == 'prd') {
|
||||
baseConfig.plugins.push(new this.webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
warnings: false
|
||||
}
|
||||
}))
|
||||
baseConfig.plugins.push(assetsPluginInstance)
|
||||
baseConfig.plugins.push(compressPlugin)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user