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

feat: 约定式路由支持配置额外属性 #10527

Merged
merged 10 commits into from
Feb 23, 2023
Merged

Conversation

AdoKevin
Copy link
Contributor

@AdoKevin AdoKevin commented Feb 15, 2023

参看 #10423

增加约定式路由读取layout, title, 以及其他额外属性。

由于function 的name属性为保留值,将title 值映射到路由配置的name字段。

改动包括

  • 代码修改

  • 文档增加扩展路由属性

  • 增加单元测试

@vercel
Copy link

vercel bot commented Feb 15, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated
umi ⬜️ Ignored (Inspect) Feb 22, 2023 at 2:00PM (UTC)

@xierenyuan
Copy link
Member

xierenyuan commented Feb 16, 2023

跟莺辞老师意见一致 感觉导出类似 clientLoader 的实现更好。如果 icon 支持 组件配置就更好了 那样自定义的布局就不在需要 走 patchRoute 处理了

import { definePageConfig } from 'umi';

export default function SomePage() {
  return <div>SomePage</div>;
}


export const pageConfig = definePageConfig({
  name: 'hello',
  layout: false,
  icon: <Hello />
});

@AdoKevin AdoKevin reopened this Feb 18, 2023
@fz6m
Copy link
Contributor

fz6m commented Feb 22, 2023

@AdoKevin 感谢 PR ,我补了剩下的部分。

这个功能要不要默认开启?

给第一次进到 PR 的人简介,该功能是使用 routeProps 来配置约定式路由的 props :

import { useRouteProps } from 'umi';

export default function Page() {
  const routes: typeof routeProps = useRouteProps();

  return (
    <div>
      index, props: {routes.a}
    </div>
  );
}

// 注意这里 🟢
export const routeProps = {
  a: 1,
};

目前是配置 routeProps 才会开启,想听听大家的意见,要不要默认开启。

默认开启会使用 es-module-lexer 扫描所有路由文件,多扫描的成本。

召唤 @sorrycc @stormslowly @xierenyuan @xiaohuoni

这个 PR 还彻底解了 routes 修改不刷新 icon 的问题

已清除掉之前的逻辑

@codecov
Copy link

codecov bot commented Feb 22, 2023

Codecov Report

Base: 29.47% // Head: 29.01% // Decreases project coverage by -0.47% ⚠️

Coverage data is based on head (ae8143a) compared to base (e024b93).
Patch coverage: 8.88% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10527      +/-   ##
==========================================
- Coverage   29.47%   29.01%   -0.47%     
==========================================
  Files         447      452       +5     
  Lines       13104    13380     +276     
  Branches     3086     3147      +61     
==========================================
+ Hits         3863     3882      +19     
- Misses       8595     8837     +242     
- Partials      646      661      +15     
Impacted Files Coverage Δ
packages/preset-umi/src/commands/dev/dev.ts 0.00% <0.00%> (ø)
...ackages/preset-umi/src/features/appData/appData.ts 0.00% <ø> (ø)
...eset-umi/src/features/clientLoader/clientLoader.ts 0.00% <0.00%> (ø)
...et-umi/src/features/configPlugins/configPlugins.ts 0.00% <0.00%> (ø)
...s/preset-umi/src/features/routeProps/routeProps.ts 0.00% <0.00%> (ø)
...kages/preset-umi/src/features/tmpFiles/tmpFiles.ts 0.00% <0.00%> (ø)
packages/preset-umi/src/index.ts 0.00% <ø> (ø)
packages/preset-umi/src/types.ts 0.00% <ø> (ø)
...kages/preset-umi/src/utils/routeExportExtractor.ts 0.00% <0.00%> (ø)
packages/renderer-react/src/index.ts 0.00% <0.00%> (ø)
... and 19 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sorrycc
Copy link
Member

sorrycc commented Feb 23, 2023

启用时机改成「约定式路由的时候默认开启」。这个 pr 改动比较大,我先合了,然后手动调整下启用时机。因为今天是发布日,需要早点发 canary 跑 checker 来验项目。

@sorrycc sorrycc merged commit deedf45 into umijs:master Feb 23, 2023
@github-actions
Copy link

感谢 PR!如果有兴趣一起参与维护 Umi,可加入我们的 Umi Contributor 群。加入方式是先用钉钉扫下方二维码加我钉钉,记得注明 github id,然后我会拉你到群里。

@stormslowly
Copy link
Member

@AdoKevin 这个新的 feature 可以加一些 example 来示例 和 e2e 用例保护下

@xiaohuoni
Copy link
Member

似乎又看到了 yaml 哈哈哈哈

--- title: haha

@afc163
Copy link
Contributor

afc163 commented Feb 24, 2023

导致了一个 bug umijs/dumi#1503

@fz6m
Copy link
Contributor

fz6m commented Feb 24, 2023

dumi#1503 已在 #10592 解决。

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

Successfully merging this pull request may close these issues.

7 participants