Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

route-manifest 是否有必要通过 plugin context 传下去? #380

Open
luhc228 opened this issue Jul 21, 2022 · 3 comments
Open

route-manifest 是否有必要通过 plugin context 传下去? #380

luhc228 opened this issue Jul 21, 2022 · 3 comments
Assignees

Comments

@luhc228
Copy link
Member

luhc228 commented Jul 21, 2022

目前在插件中要拿到路由信息,是通过 fse.readJSONSync(path.join(rootDir, '.ice', 'route-manifest.json')) 读取的

@luhc228 luhc228 self-assigned this Jul 21, 2022
@CYJB
Copy link

CYJB commented Oct 20, 2022

这里实际上是需要从 js 文件名反查页面路径。

例如存在以下路由配置时,生成的 js 文件名为 main-index.js,需要能够反查到页面路径(/main)。

defineRoutes: (route) => {
      route('/main', 'Main/index.jsx');
}

@CYJB
Copy link

CYJB commented Oct 20, 2022

另外,用于生成 __ICE_APP_CONTEXT__ 的相关属性也都是需要的,一些数据看起来也是比较难直接拿到的

appData,
routesData,
routesConfig,
routePath,
downgrade,

@luhc228
Copy link
Member Author

luhc228 commented Oct 31, 2022

appData,
routesData,
routesConfig,
routePath,
downgrade,

插件提供一个 api ( getRouteMainfest() )获取路由信息,如果在 dev 场景下路由变化时拿到最新的路由信息,需要自行 addWatchEvent() 并在回调中调用 getRouteMainfest()

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

No branches or pull requests

2 participants