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

[RFC] AppRoute、AppRouter 与 registerMicroApps 参数对齐 #299

Closed
maoxiaoke opened this issue May 14, 2021 · 4 comments · Fixed by #320
Closed

[RFC] AppRoute、AppRouter 与 registerMicroApps 参数对齐 #299

maoxiaoke opened this issue May 14, 2021 · 4 comments · Fixed by #320
Labels
Milestone

Comments

@maoxiaoke
Copy link
Collaborator

maoxiaoke commented May 14, 2021

概述

AppRoute、AppRouter 与 registerMicroApps 参数对齐

背景

目前 AppRoute、AppRouter 接收的参数通过 api 方式 有部分参数存在未对齐的地方,对用户的使用造成困扰。

方案设计

AppRouter 缺失的参数

  1. onLoadingApp
  2. onFinishLoading
  3. onError
    4. onActiveApps

以上参数均在 AppRouter 中新增

start 缺失的全局配置

  1. basename
    start 新增 basename 参数

AppRouteappConfig 不一致的参数

  1. path
    path 字段标记为 deprecated,推荐使用 activePath。activePath 的类型如下:
activePath?: string | string[] | PathData[] | MatchOptions[] | ActiveFn;

兼容模式下:

  • 若 activePath 不为函数,取 activePath 为应用 name (同以前的逻辑)
  • 若 activePath 为函数,则需明确提供 name 字段用于标记应用,否则 error 提示

在 activePath 存在匹配多个微应用的场景,兼容模式下:

  • 若微应用未提供 container 字段,则默认命中第一个匹配的应用

2. basename
标记为 deprecated,推荐使用 activePath: ActiveFn 实现。

<AppRoute
 // old way
  path=['/seller', '/watier']
  basename="ice"
 // new way
  activePath={ () => return ['/seller', '/watier'].addPrefix('ice') }
/>

build-plugin-icestark 使用

onLoadingApp、onFinishLoading、onError、onActiveApps 均可在 Framework 获取。

其他

相关 issue + 文档更新

#297
#209

@maoxiaoke maoxiaoke added the rfc label May 14, 2021
@ClarkXia
Copy link
Collaborator

部分 API 最好看下使用场景,比如 AppRouter 上提供 onActiveApps 是不是没必要,目前默认应该只会渲染一个 App,用 onAppEnter 的周期是否就可以满足

@maoxiaoke maoxiaoke mentioned this issue May 25, 2021
4 tasks
@maoxiaoke
Copy link
Collaborator Author

maoxiaoke commented May 25, 2021

  1. path 改成 activePath 需要还需要额外标记 key
  2. activePath 匹配多个微应用
  3. onError 是通过 ErrorComponent 的方式解决

@maoxiaoke
Copy link
Collaborator Author

activePath 匹配多个微应用与 AppRouter 单独提一个 rfc 来处理,现有逻辑保持不动

maoxiaoke added a commit that referenced this issue Jun 18, 2021
@maoxiaoke maoxiaoke added this to the v2.5.0 milestone Jul 29, 2021
@maoxiaoke
Copy link
Collaborator Author

更新:

  • AppConfig 应用 basename 为自定义向微应用传递的 Router 的 basename,该自定需要保留,并在 api 字段中新增

maoxiaoke added a commit that referenced this issue Aug 10, 2021
* feat: 🎸 consistent api

✅ Closes: #299, #297
maoxiaoke added a commit that referenced this issue Aug 13, 2021
Closes: #325

* feat: 🎸 consistent api (#324)

✅ Closes: #299, #297

* fix: 🐛 activePath is ignored (#357)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants