Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(qiankun): 运行时同时支持insert路径写入,以及嵌套路径两种写入方式 (#751) #770

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jefferyssy
Copy link

[email protected] umijs#698
版本支持运行中 insert 路由,加载微应用

export const qiankun = {
  apps: [{
      name: 'demo',
      entry: "https://localhost:8001"
 }],
  routes: [
    {
      path: '/test/demo',
      microApp: 'demo',
      // 通过insert可以在运行时插入主系统的routes中
      insert: '/test'
    },
};

但是到了
[email protected] umijs#706

insert 只能插入路由,而不能加载微引用

插入路由是通过 加载嵌套路由的方式加载微应用

export const qiankun = {
  apps: [{
      name: 'demo',
      entry: "https://localhost:8001"
 }],
  routes: [
    { path: '/test',
        routes: [
           { path: '/test/demo', microApp: 'demo' }
        ] 
     },
  ]
};

目的:最好两种方式都能加载微应用,可以让用户自定义选择那种模式

个人理解的使用场景:

insert: 模式比较适合,主应用为主体,路由大部分在配置中,只有小部分做微应用的时候适合独立插入路由。

嵌套路由:模式比较舍和,主应用只是一个基础的载体,所有的业务功能都来自子应用。主应用的路由是通过动态加载的方式生成

@jefferyssy
Copy link
Author

理解偏差, 现有的的嵌套路由模式,它还是只能添加到根路径上,而不是一开始理解的merge路径。
这块希望也能调整下。

例如:
umirc.ts

routes: [
  {
        path:'/', 
        components:  '@/Layout',
        routes: [
            { path:'/app2', component: '@/app2.ts', routes[] }
        ]
    }
]

app.ts

routes: [
   { path: '/app1', microApp: 'app1' },
    { path: '/app2', 
         routes: [
               { path: '/app2/nest', microApp: 'app2' }
         ] 
    },
]

结果:
原以为路由做deepmerge操作,实际上没有

routes: [
  {
        path:'/', 
        components:  '@/Layout',
        routes: [
               { path: '/app1', microApp: 'app1' },
               { path: '/app2', component: '@/app2.ts',  routes: [  { path: '/app2/nest', microApp: 'app2' } ] },
       ]
    }
]

实际,只是做嵌套插入微服务,没有动态插入字段路由的功能,并且导致 insert方法无效

routes: [
  {
        path:'/', 
        components:  '@/Layout',
        routes: [
               { path: '/app1', microApp: 'app1' },
               { path: '/app2' ,routes: [{ path: '/app2/nest', microApp: 'app2' } ]},
               { path: '/app2',   component: '@/app2.ts',  routes: [] },
       ]
    }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant