apps.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. *微应用apps
  3. * @name: 微应用名称 - 具有唯一性
  4. * @entry: 微应用入口.必选 - 通过该地址加载微应用,
  5. * @container: 微应用挂载节点 - 微应用加载完成后将挂载在该节点上
  6. * @activeRule: 微应用触发的路由规则 - 触发路由规则后将加载该微应用
  7. */
  8. //子应用列表
  9. const _apps: object[] = [];
  10. for (const key in import.meta.env) {
  11. if (key === 'VITE_APP_SUB_APP') {
  12. const appList = JSON.parse(import.meta.env[key].replace(/'/g, '"'));
  13. appList.forEach((app) => {
  14. const name = app[0];
  15. const obj = {
  16. name,
  17. entry: app[1],
  18. container: '#content',
  19. activeRule: name,
  20. };
  21. _apps.push(obj);
  22. });
  23. }
  24. }
  25. console.log('子应用路由匹配规则', _apps);
  26. // const _apps: object[] = [
  27. // {
  28. // name: 'micro-need-air', // app name registered
  29. // entry: '//localhost:8099/',
  30. // container: '#content',
  31. // activeRule: 'micro-need-air',
  32. // },
  33. // {
  34. // name: 'micro-vent-3dModal', // app name registered
  35. // entry: '//localhost:8091/',
  36. // container: '#content',
  37. // activeRule: 'micro-vent-3dModal',
  38. // },
  39. // // {
  40. // // name: 'micro-vent-3dModal', // app name registered
  41. // // entry: '//localhost:8091/',
  42. // // container: '#content',
  43. // // activeRule: 'micro-vent-3dModal',
  44. // // },
  45. // ];
  46. export const apps = _apps;