router.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. 'use strict';
  2. /**
  3. * @param {Egg.Application} app - egg application
  4. */
  5. const os = require('os');
  6. function getIPAdress() {
  7. const interfaces = os.networkInterfaces();
  8. for (const devName in interfaces) {
  9. const iface = interfaces[devName];
  10. for (let i = 0; i < iface.length; i++) {
  11. const alias = iface[i];
  12. if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
  13. return alias.address;
  14. }
  15. }
  16. }
  17. }
  18. module.exports = app => {
  19. const { router, controller } = app;
  20. const { routePrefix, cluster } = app.config;
  21. const ipAddress = getIPAdress();
  22. console.log(`前缀:http://${ipAddress}:${cluster.listen.port}${routePrefix}`);
  23. router.get('/', controller.home.index);
  24. router.post('/courtAdmin/api/admin/login', controller.home.login);
  25. router.get('/courtAdmin/api/useradmin', controller.admin.index);
  26. require('./z_router/menu')(app); // 菜单
  27. require('./z_router/user')(app); // 用户
  28. require('./z_router/team')(app); // 团队
  29. require('./z_router/joinapply')(app); // 加入团队
  30. require('./z_router/dismissapply')(app); // 解散团队
  31. require('./z_router/match')(app); // 比赛管理
  32. require('./z_router/matchteam')(app); // 参赛团队
  33. require('./z_router/schedule')(app); // 赛程信息
  34. require('./z_router/notice')(app); // 通知通告
  35. require('./z_router/statistics')(app); // 统计
  36. };