mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-21 05:19:42 +08:00
opti: delete conflict file
This commit is contained in:
parent
c20c97d80b
commit
f4ff5e5418
@ -1,45 +0,0 @@
|
||||
const config = process.env.config;
|
||||
|
||||
/**
|
||||
* type single 只绑定一个监听函数,会返回处理结果
|
||||
* mulit 绑定多个监听函数
|
||||
*
|
||||
*/
|
||||
|
||||
var hooks = {
|
||||
'third_login': {
|
||||
type: 'single',
|
||||
listener: null
|
||||
},
|
||||
'add_interface': {
|
||||
type: 'mulit',
|
||||
listener: []
|
||||
}
|
||||
};
|
||||
|
||||
function bindHook(name, listener) {
|
||||
if (!name) throw new Error('缺少hookname');
|
||||
if (name in hooks === false) {
|
||||
throw new Error('不存在的hookname');
|
||||
}
|
||||
if (hooks[name].type === 'multi') {
|
||||
hooks[name].listener.push(listener);
|
||||
} else {
|
||||
hooks[name].listener = listener;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var yapi = {
|
||||
hooks: hooks,
|
||||
bindHook: bindHook
|
||||
}
|
||||
|
||||
if (config.plugins && Array.isArray(config.plugins)) {
|
||||
config.plugins.forEach(plugin => {
|
||||
let pluginModule = require(`plugins/yapi-plugin-${plugin}/client.js`);
|
||||
pluginModule.call(yapi) ;
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = hooks;
|
Loading…
Reference in New Issue
Block a user