feat: 增加 sub_setting_nav 钩子

This commit is contained in:
苏文雄 2019-04-21 11:20:49 +08:00
parent 0fead80e49
commit bcbe34d53d
5 changed files with 42 additions and 2 deletions

View File

@ -8,6 +8,9 @@ import ProjectToken from './ProjectToken/ProjectToken';
import ProjectMock from './ProjectMock/index.js';
import { connect } from 'react-redux';
const TabPane = Tabs.TabPane;
const plugin = require('client/plugin.js');
const routers = {}
import './Setting.scss';
@ -23,7 +26,7 @@ class Setting extends Component {
};
render() {
const id = this.props.match.params.id;
plugin.emitHook('sub_setting_nav', routers);
return (
<div className="g-row">
<Tabs type="card" className="has-affix-footer tabs-large">
@ -44,6 +47,12 @@ class Setting extends Component {
<TabPane tab="全局mock脚本" key="5">
<ProjectMock projectId={+id} />
</TabPane>
{Object.keys(routers).map(key=>{
const C = routers[key].component;
return <TabPane tab={routers[key].name} key={routers[key].name}>
<C projectId={+id} />
</TabPane>
})}
</Tabs>
</div>
);

View File

@ -185,6 +185,19 @@ hooks = {
type: 'listener',
mulit: true,
listener: []
},
/*
* 添加项目设置 nav
* @param Object routers
*
* let routers = {
interface: { name: 'xxx', component: Xxx },
}
*/
sub_setting_nav:{
type: 'listener',
mulit: true,
listener: []
}
};

View File

@ -17,5 +17,9 @@ module.exports = {
name: 'import-yapi-json'
},{
name: 'wiki'
}]
}
// {
// name: 'test'
// }
]
}

View File

@ -0,0 +1,10 @@
function hander(routers) {
routers.test = {
name: 'test',
component: ()=> 'hello world.'
};
}
module.exports = function() {
this.bindHook('sub_setting_nav', hander);
};

View File

@ -0,0 +1,4 @@
module.exports = {
server: false,
client: true
}