umijs / plugins

🍣 The one-stop shop for official Umi plugins and presets.
348 stars 238 forks source link

[bug] @umijs/plugin-qiankun 新语法配置导致 vue 切换异常,老语法正常 #884

Open fengsx opened 2 years ago

fengsx commented 2 years ago

问题插件

@umijs/plugin-qiankun

版本

2.39.2

demo

这是基于 qiankun 的仓库做的复现 demo:https://github.com/fengsx/qiankun

步骤

yarn
yarn examples:install
yarn examples:start

1、 直接打开的 http://localhost:7099/template/react16 是 qiankun 的 demo,无问题。 2、打开基于 @umijs/plugin-qiankun 开发主应用 http://localhost:8000/template/react16 ,如果

fengsx commented 2 years ago

@kuitos

kuitos commented 2 years ago

跳转的链接都拼错了,其他应用自然匹配不到了

fengsx commented 2 years ago

@kuitos 问题就在这里。采用插件的新语法配置后,错误的从 vue3 子应用导航到错误的地址了。旧语法是好的。

app-old app-new 分别对应了不同的语法。

kuitos commented 2 years ago

语法肯定没问题的,可以看看 example https://github.com/umijs/plugins/blob/master/packages/plugin-qiankun/examples/master/app.js

看问题就是主应用提供的跳转链接没拼对,这个你要排查下原因

fengsx commented 2 years ago

配置没有问题的。在 vue3 子应用下,通过主应用传递的 history 实例跳转是 ok 的,但是用 window.history.pushState 就会跳到错误的地址上。

fengsx commented 2 years ago

你给的 plugin-qiankun examples,如果是采用了 vue-router 4 的 vue3 的子应用,通过 window.history.pushState 跳转也是有问题的。 比如从 vue3 子应用跳转到 vue2 子应用: vue 3 unmount vue 2 mount vue 2 unmout vue 3 mount

旧的语法看上去是使用 frameworkStartedDefer 做了延迟处理。

kuitos commented 2 years ago

根本原因是链接拼错了吧,看看是不是 window.history.pushState 被 vue3 复写了

fengsx commented 2 years ago

不是链接拼错了。是通过 history.pushState 跳转后,vue-router 4 执行了两次。 vue3 mount,地址是 /template/vue3 vue3 umount,地址是 /template/vue2 vue2 mount,地址是 /template/vue2 vue2 unmount,地址是 /template/vue3/template/vue2 vue3 mount,地址是 /template/vue3/template/vue2

是 signle-spa 重新了。。。vue3没有重写。