8000 fix: fallback useRouteMeta logic and handle errors caused by custom routeMeta by Jinbao1001 · Pull Request #2137 · umijs/dumi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: fallback useRouteMeta logic and handle errors caused by custom routeMeta #2137

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

Merged
merged 8 commits into from
Jun 5, 2024

Conversation

Jinbao1001
Copy link
Member
@Jinbao1001 Jinbao1001 commented Jun 5, 2024

🤔 这个变动的性质是?/ What is the nature of this change?

  • 新特性提交 / New feature
  • bug 修复 / Fix bug
  • 样式优化 / Style optimization
  • 代码风格优化 / Code style optimization
  • 性能优化 / Performance optimization
  • 构建优化 / Build optimization
  • 网站、文档、Demo 改进 / Website, documentation, demo improvements
  • 重构代码或样式 / Refactor code or style
  • 测试相关 / Test related
  • 其他 / Other

🔗 相关 Issue / Related Issue

💡 需求背景和解决方案 / Background or solution

#2134 引入问题

  1. 所有路由都返回 routeMeta 会导致路由表错乱, 首页 redirect 到404 页面, 回滚变更, 不触发 useRouteMeta 的 merge 逻辑.
  2. 修复 ayncCache 遇到用户插件自定义 meta 导致的异常错误.

📝 更新日志 / Changelog

Language Changelog
🇺🇸 English fallback useRouteMeta logic and handle errors caused by custom routeMeta
🇨🇳 Chinese 回滚 useRouteMeta 变更 & 解决用户自定义 meta导致的异常

Copy link
vercel bot commented Jun 5, 2024

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

Name Status Preview Comments Updated (UTC)
dumi ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2024 9:43am

}
return meta;
};
const meta = merge(getRouteMetaById(route.id, { syncOnly: true }));
const proxyGetter = (target: any, prop: string) => {
if (ASYNC_META_PROPS.includes(prop)) {
if (!asyncCache.get(cacheKey)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不太对,原有逻辑有 2 条路径:

  1. 不存在 cache 时,创建 cache 并 throw
  2. 存在 cache 时直接 throw

新逻辑只有 1 条路径:

  1. 不存在 cache 且存在异步资源时,创建 cache 并 throw

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

捋了下应该要做两个调整,供参考:

  1. getRouteMetaById 要继续放进 cache 是否存在的 if 里面,否则会多调用函数
  2. throw 要挪回原位置,但判定一下 cache 存在时才 throw

@Jinbao1001 Jinbao1001 merged commit b2a6ed3 into master Jun 5, 2024
9 checks passed
@Jinbao1001 Jinbao1001 deleted the fix/repeat-route-merge 6860 branch June 5, 2024 10:00
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.

2 participants
0