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

[Bug] 父应用无法感知子应用路由切换 #339

Closed
dream2023 opened this issue Mar 26, 2020 · 6 comments
Closed

[Bug] 父应用无法感知子应用路由切换 #339

dream2023 opened this issue Mar 26, 2020 · 6 comments

Comments

@dream2023
Copy link

#225 What happens?

主和子应用都是vue项目时,父应用的路由守卫,仅在初次渲染的时候触发,子应用内跳转无法触发

因为我们将权限等功能放到了父应用中,所以需要感知子应用路由的变化

最小可复现仓库

https://github.com/dream2023/qiankun_bug

复现步骤,错误日志以及相关配置

# 安装
cd master && yarn
cd ../app1 && yarn

# 启动
cd master && yarn serve
cd app1 && yarn serve

WX20200326-152625

从上图看到,主应用设置了路由后置守卫

test

除了初始化有一个 log信息外,当切换子应用路由时,并无信息输出

相关环境信息

  • qiankun 版本 1.4.5
  • *chrome
  • mac os
@kuitos
Copy link
Member

kuitos commented Mar 26, 2020

本身就是隔离的,主子应用 router 实例都不一样,自然不能互相监听

@dream2023
Copy link
Author

本身就是隔离的,主子应用 router 实例都不一样,自然不能互相监听

大佬见多识广,看看这个场景如何处理,或者你们的业务实践怎么处理

后台管理系统,菜单栏是后端获取,用户每次进入菜单,都要和vuex中menu列表对比,防止直接通过手输入url进入没有权限的页面

那这个校检我觉得是放到主应用比较合适,但由于没法感知子应用路由跳转导致有问题

@dream2023
Copy link
Author

本身就是隔离的,主子应用 router 实例都不一样,自然不能互相监听

不知道大佬理解了没有

@kuitos
Copy link
Member

kuitos commented Mar 26, 2020

放到子应用比较合适

@dream2023
Copy link
Author

dream2023 commented Mar 26, 2020

放到子应用比较合适

你是指嵌套的子应用,还是多匹配的子应用,还是指每个子应用都做这套逻辑

还有为什么子应用合适,这种全局的问题,不应该是放在父应用比较合适吗

@kuitos
Copy link
Member

kuitos commented Mar 26, 2020

架构上来讲这个属于子应用自己的职责范畴。
考虑两个场景就明白了

  1. 子应用需要单独打开
  2. 子应用需要嵌到另一个主应用里

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

No branches or pull requests

2 participants