-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat(vue): init vue ui binding #2775
Conversation
|
@linghaoSu is attempting to deploy a commit to a Personal Account owned by @umijs on Vercel. @umijs first needs to authorize it. |
5277679
to
cd3087b
Compare
@bravepg 可以一起 review 下 |
de440e0
to
1da18bf
Compare
好的,前几天忙着其他事忘记这个 pr 了😂,我看看 |
"dev": "father dev", | ||
"test": "cross-env NODE_ENV=test vitest" | ||
}, | ||
"author": "Bravepg", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
author 换成你吧~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
换了~
container: containerRef.current!, | ||
props: propsFromParams, | ||
mountMicroApp({ | ||
props: componentProps, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里有点怪,把 componentProps 这个全部属性都透传进去了,然后下面又传递了 propsFromParams
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
setLoading(loading); | ||
}, | ||
source: 'react', | ||
}) | ||
|
||
return noop; | ||
}, [useDeepCompare(propsFromParams)]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里有个风险,lifeCycles 是个函数数组,之前是解构出来了。现在被放进到 propsFromParams 里面,如果有户有个设置生命周期的操作,可能会造成无限更新,最好还是把初始化需要的一些变量给解构出来。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果会无限更新应该在 vue 中也会,统一做一次 omit 解构
setLoading: (loading) => { | ||
setLoading(loading); | ||
}, | ||
source: 'react', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source 换个名字吧,有点怪怪的。可以直接叫做 key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好主意,换了
props: componentProps, | ||
container: containerRef.current!, | ||
propsFromParams, | ||
setApp(app) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setApp getApp,换成 setMicroApp 和 getMicroApp 吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
props: { | ||
name: { | ||
type: String, | ||
required: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vue 里面的 props 类型得重新定义一遍么?有没有快捷的生成方式?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
watch( | ||
name, | ||
() => { | ||
const microApp = microAppRef.value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
初始化的时候,有必要判断 microApp 是否存在吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里是 watch 启动后,当 name 发生变化时,销毁之前的生成的 microApp 用的判断
examples/main-vue/src/App.vue
Outdated
</script> | ||
|
||
<template> | ||
<MicroApp :name="name" entry="//localhost:7102" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
examples 这么搞合适吗?未来可能有很多个案例,有规划怎么展示给用户吗?单独叫 main-vue 然后引入 MicroApp 是不是有点重了。
@kuitos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里只是为了验证 vue 组件的可用,加入的 实验 demo,如果后续不需要可以在合并之前删掉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kuitos 其他的我 ok 了,这块 examples 的形式你确认下?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不同单独搞一个仓库,参考现在的 main https://github.com/umijs/qiankun/blob/master/examples/main/render/VueRender.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@linghaoSu cc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
正在处理中,稍后提交更新
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kuitos 在处理 demo 的过程中,发现目前的做法仅兼容 vue3,是否需要兼容到 vue2?
目前正在尝试使用 vue-demi 来做兼容处理,但需要一点时间,我先标记为 Draft 了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kuitos fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
demi 应该也是只能兼容到2.7+吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
193b76c
to
6b82871
Compare
ci 需要修一下 |
@kuitos fixed |
resolve #2689
MicroApp 组件
直接通过 组件加载(或卸载)子应用,该组件提供了 loading 以及错误捕获相关的能力:
当启用子应用加载动画或错误捕获能力时,子应用接受一个额外的样式类 wrapperClassName,渲染的结果如下所示:
加载动画
启用此能力后,当子应用正在加载时,会自动显示加载动画。当子应用挂载完成变成 MOUNTED 状态时,加载状态结束,显示子应用内容。
直接将 autoSetLoading 作为参数传入即可:
自定义加载动画
如果您希望覆盖默认的加载动画样式时,可以通过 loader slot 来自定义加载组件 loader 作为子应用的加载动画。
其中,loading 为 boolean 类型参数,为 true 时表示仍在加载状态,为 false 时表示加载状态已结束。
错误捕获
启用此能力后,当子应用加载出现异常时,会自动显示错误信息。可以向子应用传入 autoCaptureError 属性以开启子应用错误捕获能力:
自定义错误捕获
如果您希望覆盖默认的错误捕获组件样式时,可以通过 errorBoundary slot 来自定义子应用的错误捕获组件: