-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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(plugins): icons enhanced feature can be used for layout menu #12515
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Walkthrough此次更新主要引入了图标功能的兼容性,为默认图标配置添加了对图标集和本地图标的支持。在多处文件中进行了图标引用的更新,并在配置文件和组件中添加了相关逻辑,以启用或禁用图标功能。还增加了新的开发依赖以支持新的图标引用。 Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (6)
- docs/docs/docs/max/layout-menu.md (1 hunks)
- examples/max/.umirc.ts (2 hunks)
- examples/max/package.json (1 hunks)
- examples/max/pages/index.tsx (1 hunks)
- packages/plugins/src/layout.ts (2 hunks)
- packages/preset-umi/src/features/icons/icons.ts (1 hunks)
Files not summarized due to errors (1)
- packages/plugins/src/layout.ts: Error: Server error. Please try again later.
Files not reviewed due to errors (2)
- examples/max/pages/index.tsx (no review received)
- examples/max/.umirc.ts (no review received)
Files skipped from review due to trivial changes (2)
- docs/docs/docs/max/layout-menu.md
- examples/max/package.json
Additional comments not posted (2)
packages/preset-umi/src/features/icons/icons.ts (1)
325-328
: 检查图标组件获取函数的正确性
getIconComponent
函数用于获取图标组件,确保此函数能正确处理各种图标名称,并且能在图标不存在时正确返回。#!/bin/bash # 描述:验证图标组件获取函数的正确性 # 测试:搜索`getIconComponent`函数的定义和使用情况。期望:找到所有`getIconComponent`函数的定义和使用情况。 rg --type typescript --files-with-matches $'getIconComponent'packages/plugins/src/layout.ts (1)
Line range hint
432-451
: 检查路由图标处理函数的正确性
patchRoutes
函数用于处理路由图标,确保此函数能正确处理图标名称和对应的组件,并在图标组件不存在时正确处理。#!/bin/bash # 描述:验证路由图标处理函数的正确性 # 测试:搜索`patchRoutes`函数的定义和使用情况。期望:找到所有`patchRoutes`函数的定义和使用情况。 rg --type typescript --files-with-matches $'patchRoutes'
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (6)
- docs/docs/docs/max/layout-menu.md (1 hunks)
- examples/max/.umirc.ts (2 hunks)
- examples/max/package.json (1 hunks)
- examples/max/pages/index.tsx (1 hunks)
- packages/plugins/src/layout.ts (2 hunks)
- packages/preset-umi/src/features/icons/icons.ts (1 hunks)
Files skipped from review due to trivial changes (1)
- examples/max/package.json
Additional comments not posted (16)
examples/max/pages/index.tsx (5)
57-57
: 添加图标库部分的标题添加了图标库部分的标题,明确了接下来展示的图标来源于图标库。
58-58
: 使用图标库中的图标展示了一个图标库中的图标,使用了
ic:baseline-14mp
。
59-59
: 使用图标库中的图标展示了一个图标库中的图标,使用了
ic:baseline-3p
。
60-60
: 使用图标库中的图标展示了一个图标库中的图标,使用了
solar:4k-bold
。
62-62
: 添加本地图标部分的标题添加了本地图标部分的标题,明确了接下来展示的图标来源于本地。
examples/max/.umirc.ts (3)
8-8
: 更新路由图标将首页路由的图标更新为
ic:baseline-14mp
,确保图标正确展示。
14-14
: 更新路由图标将用户页路由的图标更新为
local:rice
,确保图标正确展示。
108-108
: 添加自动安装图标配置在图标配置中添加了
autoInstall
属性,确保图标库自动安装。docs/docs/docs/max/layout-menu.md (1)
194-195
: 更新图标配置文档兼容默认配置
icons
,支持使用图标集或本地图标,确保开发者了解新功能。packages/preset-umi/src/features/icons/icons.ts (2)
325-329
: 添加获取图标组件函数添加了
getIconComponent
函数,用于根据图标名称获取图标组件,提升图标获取逻辑的可维护性。
332-332
: 使用获取图标组件函数在
Icon
组件中使用getIconComponent
函数,确保图标组件正确获取和展示。packages/plugins/src/layout.ts (5)
432-432
: 导入Icon
和getIconComponent
导入
Icon
和getIconComponent
是为了支持加载自定义图标的新功能。
446-446
: 使用getIconComponent
获取图标组件新增的
Component
常量用于获取相应的图标组件。
447-447
: 检查Component
是否定义此更改确保仅将有效的组件分配给路由。
448-448
: 渲染图标组件如果
Component
有效,则渲染图标组件。
451-451
: 图标回退机制此更改增加了图标的回退机制,确保即使未找到自定义图标,也会使用标准图标。
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- packages/plugins/src/layout.ts (2 hunks)
Additional comments not posted (3)
packages/plugins/src/layout.ts (3)
426-427
: 添加图标功能的启用检查添加了一个检查是否启用了图标功能的标志
isIconsFeatureEnable
。这段代码看起来不错,确保在配置中正确设置了
icons
属性。
434-438
: 条件导入图标组件根据
isIconsFeatureEnable
标志,条件性地导入Icon
和getIconComponent
组件。这段代码看起来不错,确保在配置中正确设置了
icons
属性。
452-460
: 条件设置图标组件根据
isIconsFeatureEnable
标志,条件性地设置图标组件。这段代码看起来不错,确保在配置中正确设置了
icons
属性。
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- packages/plugins/src/layout.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/plugins/src/layout.ts
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.
+1
因为需要自定义max中layout菜单的图标,所以尝试修改源码中加载菜单图标的逻辑。参考和使用了核心配置icons的逻辑,支持了菜单图标使用图标集或者本地图标。
Summary by CodeRabbit
新功能
autoInstall
属性以支持自动安装图标。改进
isIconsFeatureEnable
标志的条件逻辑,动态调整图标的渲染。依赖更新
@iconify-json/ic
版本1.1.17
和@iconify-json/solar
版本1.1.9
的开发依赖。文档
用户界面