mock平台

client.js 939B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { message } from 'antd';
  2. function improtData(importDataModule) {
  3. async function run(res) {
  4. try {
  5. let interfaceData = { apis: [], cats: [] };
  6. res = JSON.parse(res);
  7. res.forEach(item => {
  8. interfaceData.cats.push({
  9. name: item.name,
  10. desc: item.desc
  11. });
  12. item.list.forEach(api => {
  13. api.catname = item.name;
  14. });
  15. interfaceData.apis = interfaceData.apis.concat(item.list);
  16. });
  17. return interfaceData;
  18. } catch (e) {
  19. console.error(e);
  20. message.error('数据格式有误');
  21. }
  22. }
  23. if (!importDataModule || typeof importDataModule !== 'object') {
  24. console.error('importDataModule 参数Must be Object Type');
  25. return null;
  26. }
  27. importDataModule.json = {
  28. name: 'json',
  29. run: run,
  30. desc: 'YApi接口 json数据导入'
  31. };
  32. }
  33. module.exports = function() {
  34. this.bindHook('import_data', improtData);
  35. };