-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.js
41 lines (37 loc) · 1.04 KB
/
client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { message } from 'antd';
import handleRepository from './client/rap2yapi.js';
function importData(importDataModule) {
async function run(res) {
try {
let resultStr = handleRepository(JSON.parse(res).data)
let interfaceData = { apis: [], cats: [] };
res = JSON.parse(resultStr);
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.rap2yapi = {
name: 'rap2yapi',
run: run,
desc: 'YApi接口 json数据导入1'
};
}
module.exports = function() {
this.bindHook('import_data', importData);
};