mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-21 05:19:42 +08:00
opti: 完善插件机制
This commit is contained in:
parent
6047d4cf8c
commit
1ce0692c31
1
.gitignore
vendored
1
.gitignore
vendored
@ -41,3 +41,4 @@ dev/
|
||||
.tags
|
||||
.tags1
|
||||
tsconfig.json
|
||||
client/plugin-module.js
|
||||
|
@ -1 +1 @@
|
||||
module.exports = null
|
||||
module.exports = {qsso : require('plugins/yapi-plugin-qsso/client.js')}
|
@ -79,13 +79,20 @@ pluginModule = {
|
||||
bindHook: bindHook,
|
||||
emitHook: emitHook
|
||||
}
|
||||
let pluginModuleList;
|
||||
try{
|
||||
pluginModuleList = require('./plugin-module.js');
|
||||
}catch(err){pluginModuleList = {}}
|
||||
|
||||
|
||||
let pluginModuleList = require('./plugin-module.js');
|
||||
config.plugins.forEach(plugin=>{
|
||||
if (!plugin) return null;
|
||||
if (!plugin.enable) return null;
|
||||
if(plugin.client){
|
||||
pluginModuleList[plugin.name].call(pluginModule, plugin)
|
||||
if(pluginModuleList[plugin.name] && typeof pluginModuleList[plugin.name] === 'function'){
|
||||
pluginModuleList[plugin.name].call(pluginModule, plugin)
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
2
ykit.js
2
ykit.js
@ -27,7 +27,7 @@ function fileExist (filePath){
|
||||
|
||||
function initPlugins(){
|
||||
var scripts = [] ;
|
||||
if(config.plugins && Array.isArray(config.plugins)){
|
||||
if(config.plugins && Array.isArray(config.plugins) && config.plugins.length){
|
||||
config.plugins = config.plugins.filter(item=>{
|
||||
return fileExist(path.resolve(__dirname, 'node_modules/yapi-plugin-' + item + '/client.js'))
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user