fork from bc4552c5a8
This commit is contained in:
39
exts/yapi-plugin-import-yapi-json/client.js
Normal file
39
exts/yapi-plugin-import-yapi-json/client.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import { message } from 'antd';
|
||||
|
||||
function importData(importDataModule) {
|
||||
async function run(res) {
|
||||
try {
|
||||
let interfaceData = { apis: [], cats: [] };
|
||||
res = JSON.parse(res);
|
||||
res.forEach(item => {
|
||||
interfaceData.cats.push({
|
||||
name: item.name,
|
||||
desc: item.desc
|
||||
});
|
||||
item.list.forEach(api => {
|
||||
api.catname = item.name;
|
||||
});
|
||||
interfaceData.apis = interfaceData.apis.concat(item.list);
|
||||
});
|
||||
return interfaceData;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
message.error('数据格式有误');
|
||||
}
|
||||
}
|
||||
|
||||
if (!importDataModule || typeof importDataModule !== 'object') {
|
||||
console.error('importDataModule 参数Must be Object Type');
|
||||
return null;
|
||||
}
|
||||
|
||||
importDataModule.json = {
|
||||
name: 'json',
|
||||
run: run,
|
||||
desc: 'YApi接口 json数据导入'
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = function() {
|
||||
this.bindHook('import_data', importData);
|
||||
};
|
||||
4
exts/yapi-plugin-import-yapi-json/index.js
Normal file
4
exts/yapi-plugin-import-yapi-json/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
server: false,
|
||||
client: true
|
||||
}
|
||||
Reference in New Issue
Block a user