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

fix(): fix accessing images of v2 micro-apps in v3 container, and vice versa #1481

Merged
merged 2 commits into from
Jan 20, 2025

Conversation

weareoutman
Copy link
Member

@weareoutman weareoutman commented Jan 17, 2025

依赖检查

组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。

请勾选以下两组选项其中之一:

  • 本次 MR 没有使用上游组件(例如框架、后台组件等)的较新版本提供的特性。

或者:

  • 本次 MR 使用了上游组件(例如框架、后台组件等)的较新版本提供的特性。
  • 在对应的文件中更新了该上游组件的依赖版本(或确认了当前声明的依赖版本已包含本次 MR 使用的新特性)。

提交信息检查

Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。

破坏性变更是针对于下游使用者而言,可以通过本次改动对下游使用者的影响来识别变更类型:

  • 下游使用者不做任何改动,仍可以正常工作时,那么它属于普通变更。
  • 反之,下游使用者不做改动就无法正常工作时,那么它属于破坏性变更。

例如,构件修改了一个属性名,小产品 Storyboard 中需要使用新属性名才能工作,那么它就是破坏性变更。
又例如,构件还没有任何下游使用者,那么它的任何变更都是普通变更。

破坏性变更:

  • ⚠️ 本次 MR 包含破坏性变更的提交,请继续确认以下所有选项:
  • 没有更好的兼容方案,必须做破坏性变更。
  • 使用了 feat 作为提交类型。
  • 标注了 BREAKING CHANGE: 你的变更说明
  • 同时更新了本仓库中所有下游使用者的调用。
  • 同时更新了本仓库中所有下游使用者对该子包的依赖为即将发布的 major 版本。
  • 同时为其它仓库的 Migrating 做好了准备,例如文档或批量改动的方法。
  • 手动验证过破坏性变更在 Migrate 后可以正常工作。
  • 破坏性变更所在的提交没有意外携带其它子包的改动。

新特性:

  • 本次 MR 包含新特性的提交,且该提交不带有破坏性变更,并使用了 feat 作为提交类型。
  • 给新特性添加了单元测试。
  • 手动验证过新特性可以正常工作。

问题修复:

  • 本次 MR 包含问题修复的提交,且该提交不带有新特性或破坏性变更,并使用了 fix 作为提交类型。
  • 给问题修复添加了单元测试。
  • 手动验证过问题修复得到解决。

杂项工作:

即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:

  • 本次 MR 包含杂项工作的提交,且该提交不带有问题修复、新特性或破坏性变更,并使用了 chore, docs, test 等作为提交类型。

Summary by CodeRabbit

  • 新功能

    • 改进了图标解析和获取的错误处理机制
    • 添加了对微应用版本号 URL 的特殊处理逻辑
  • Bug 修复

    • 优化了图标加载失败时的处理流程
    • 支持自动切换微应用版本号以获取正确的图标资源
  • 测试

    • 新增测试用例,验证图标加载的不同场景
    • 完善了对图标获取错误情况的测试覆盖
  • 依赖更新

    • 新增依赖 @next-core/easyops-runtime,版本为 ^0.13.3
  • 类型导出

    • 更新了多个类型的导出方式,增强了类型安全性和清晰度

Copy link

coderabbitai bot commented Jan 17, 2025

总览

变更概述

此次变更主要涉及图标处理逻辑的增强,特别是在处理微应用版本相关的图标URL时。在SvgCache.ts中引入了新的正则表达式和改进的错误处理机制,以支持在不同版本的微应用间自动切换图标URL。同时,测试文件中增强了模拟的fetch函数,增加了对不同URL响应的处理,并新增了相关测试用例。此外,部分类型导出声明进行了调整,以增强类型安全性。

变更

文件 变更摘要
bricks/icons/src/shared/SvgCache.ts - 新增正则表达式REGEX_MICRO_APPS_WITH_VERSION
- 修改resolveIcon函数签名,增加isFix参数
- 优化错误处理逻辑,支持在v2和v3版本间切换URL
bricks/icons/src/svg-icon/index.spec.ts - 增强模拟的fetch函数,支持不同URL场景
- 新增两个测试用例:fix urlfail url
- 验证图标组件在不同错误场景下的行为
bricks/basic/package.json - 新增依赖@next-core/easyops-runtime,版本为^0.13.3
bricks/basic/src/link/index.tsx - 修改ExtendedLocationDescriptorTarget的导出声明为类型导出
bricks/basic/src/popover/index.tsx - 修改Placement的导出声明为类型导出

详细变更

功能变更

  1. SvgCache.ts中引入了新的正则表达式常量REGEX_MICRO_APPS_WITH_VERSION,用于匹配包含版本号的微应用URL。
  2. resolveIcon函数增加了isFix参数,用于处理URL版本切换的特殊情况。
  3. 新增错误处理逻辑:当遇到404错误且URL匹配版本正则时,自动尝试切换URL版本(v2/v3)。
  4. package.json中新增了对@next-core/easyops-runtime的依赖。

测试变更

  1. index.spec.ts中模拟了更复杂的fetch行为。
  2. 新增测试用例验证图标组件在不同URL和错误场景下的表现。

类型导出变更

  1. link/index.tsx中,将ExtendedLocationDescriptorTarget的导出声明修改为类型导出。
  2. popover/index.tsx中,将Placement的导出声明修改为类型导出。

这些变更旨在提高图标加载和错误处理的健壮性,特别是在处理不同版本微应用的图标时,同时增强了代码的类型安全性。

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.47%. Comparing base (579c3c3) to head (cc5357e).
Report is 3 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1481      +/-   ##
==========================================
+ Coverage   90.38%   90.47%   +0.08%     
==========================================
  Files         124      124              
  Lines        2757     2762       +5     
  Branches      377      379       +2     
==========================================
+ Hits         2492     2499       +7     
+ Misses        171      169       -2     
  Partials       94       94              
Files with missing lines Coverage Δ
bricks/basic/src/link/index.tsx 80.48% <ø> (ø)
bricks/basic/src/popover/index.tsx 94.54% <ø> (ø)
bricks/icons/src/shared/SvgCache.ts 85.96% <100.00%> (+5.19%) ⬆️

Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (5)
bricks/icons/src/shared/SvgCache.ts (2)

21-23: 建议改进参数命名

布尔参数isFix的命名可以更具描述性,建议修改为更明确的名称,如isVersionRetryisUrlVersionFixed,以便更好地表达其用途。

 async function resolveIcon(
   url: string,
   options?: ResolveIconOptions,
-  isFix?: boolean
+  isVersionRetry?: boolean
 ): Promise<SVGResult> {

28-42: 建议增强错误处理机制

当前实现存在以下可以改进的地方:

  1. 建议添加重试次数限制,防止潜在的无限递归
  2. 考虑添加日志记录,便于问题追踪
  3. 可以优化错误信息的返回,提供更多上下文信息
     if (!fileData.ok) {
       // Fix accessing images of v2 micro-apps in v3 container, and vice versa.
       if (
         !isFix &&
         fileData.status === 404 &&
         REGEX_MICRO_APPS_WITH_VERSION.test(url)
       ) {
+        console.debug(`Attempting to fix version mismatch for URL: ${url}`);
         const fixedUrl = url.replace(
           REGEX_MICRO_APPS_WITH_VERSION,
           (_, v) => `/micro-apps/v${v === "2" ? "3" : "2"}/`
         );
         return resolveIcon(fixedUrl, options, true);
       }
-      return fileData.status === 410 ? CACHEABLE_ERROR : RETRYABLE_ERROR;
+      const error = fileData.status === 410 ? CACHEABLE_ERROR : RETRYABLE_ERROR;
+      console.debug(`Failed to fetch icon: ${url}, status: ${fileData.status}`);
+      return error;
     }
bricks/icons/src/svg-icon/index.spec.ts (3)

Line range hint 5-32: 建议扩展测试用例覆盖范围

当前的模拟实现很好,但建议添加以下测试场景:

  1. 网络超时情况
  2. 畸形SVG响应
  3. 多次重试场景
  4. 不同版本号的边界情况
 (global as any).fetch = jest.fn((url) =>
   url?.includes("/micro-apps/v3/")
     ? Promise.resolve({
         ok: false,
         status: 404,
       })
+    : url?.includes("/timeout/")
+      ? Promise.reject(new Error("Network timeout"))
+    : url?.includes("/malformed/")
+      ? Promise.resolve({
+          ok: true,
+          text: () => Promise.resolve("<invalid>svg</invalid>")
+        })
     : url?.includes("/fail/")

119-129: 建议增强URL修复测试用例

当前测试用例可以通过以下方式加强:

  1. 验证切换后的URL是否正确
  2. 检查SVG内容是否符合预期
  3. 添加错误事件处理的测试
  4. 验证版本切换的性能表现
   test("fix url", async () => {
     const element = document.createElement("eo-svg-icon") as SvgIcon;
     element.imgSrc = "/sa-static/micro-apps/v3/app/test.svg";
 
+    const onIconFound = jest.fn();
+    element.addEventListener("icon.found", (e) => {
+      onIconFound((e as CustomEvent).detail);
+    });
+
     document.body.appendChild(element);
     await (global as any).flushPromises();
 
     expect(element.shadowRoot?.querySelector("svg")).toBeTruthy();
+    expect(onIconFound).toHaveBeenCalledWith(true);
+    expect(fetch).toHaveBeenCalledWith(expect.stringContaining("/micro-apps/v2/"));
 
     document.body.removeChild(element);
   });

131-146: 建议添加更多失败场景测试

建议增加以下失败场景的测试:

  1. 连续失败的情况
  2. 不同HTTP状态码的处理
  3. 网络错误的处理
  4. 资源加载超时的处理
+  test("consecutive failures", async () => {
+    const element = document.createElement("eo-svg-icon") as SvgIcon;
+    element.imgSrc = "/fail/test.svg";
+    
+    document.body.appendChild(element);
+    await (global as any).flushPromises();
+    
+    // Try changing the URL and verify it still fails
+    element.imgSrc = "/fail/another-test.svg";
+    await (global as any).flushPromises();
+    
+    expect(element.shadowRoot?.childNodes.length).toBe(1);
+    document.body.removeChild(element);
+  });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5762d1b and 69f1ee9.

📒 Files selected for processing (2)
  • bricks/icons/src/shared/SvgCache.ts (1 hunks)
  • bricks/icons/src/svg-icon/index.spec.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Size check (20.x)
  • GitHub Check: Build docs (20.x)
🔇 Additional comments (1)
bricks/icons/src/shared/SvgCache.ts (1)

17-17: 正则表达式实现合理!

正则表达式能够准确匹配并捕获微应用版本号(v2或v3)。

Copy link

github-actions bot commented Jan 17, 2025

@github-actions github-actions bot temporarily deployed to pull request January 17, 2025 10:50 Inactive
Copy link

github-actions bot commented Jan 17, 2025

📐🤏 Size check result (579c3c3...f1ae2bf):

See full diff

Load all bricks together

Name Prev Now Diff
All bricks 4,526.33 KB 4,526.31 KB

Critical changes: None.

See full changes
Name Prev Now Diff
<core> 311.43 KB 311.41 KB
<react> 53.61 KB 53.61 KB 🟰
advanced 517.84 KB 517.8 KB
ai 287.76 KB 287.75 KB
api-market 10.56 KB 10.56 KB 🟰
basic 183.28 KB 183.23 KB
containers 95.05 KB 95.05 KB 🟰
data-view 639.69 KB 639.74 KB
diagram 177.35 KB 177.32 KB
form 329.51 KB 329.49 KB
form-platform 12.57 KB 12.57 KB 🟰
icons 15.04 KB 15.12 KB
illustrations 17.3 KB 17.3 KB 🟰
inject 56.22 KB 56.22 KB 🟰
markdown 248.95 KB 248.92 KB
mini-chart 10.61 KB 10.61 KB 🟰
nav 121.16 KB 121.16 KB 🟰
presentational 134.36 KB 134.36 KB 🟰
recent-history 32.53 KB 32.53 KB 🟰
shoelace 325.85 KB 325.85 KB 🟰
visual-builder 418.33 KB 418.35 KB
vs 838.76 KB 838.77 KB

Load bricks by each package

Critical changes: None.

See full changes
Name Prev Now Diff
advanced 750.25 KB 750.25 KB 🟰
ai 500.08 KB 500.12 KB
api-market 206.73 KB 206.76 KB
basic 338.78 KB 338.81 KB
containers 233.43 KB 233.47 KB
data-view 735.75 KB 735.86 KB 🔼 +0.11 KB
diagram 247.96 KB 247.95 KB
form 499.79 KB 499.81 KB
form-platform 176.85 KB 176.89 KB
icons 72.75 KB 72.83 KB
illustrations 91.39 KB 91.47 KB
inject 56.22 KB 56.22 KB 🟰
markdown 337.78 KB 337.91 KB 🔼 +0.13 KB
mini-chart 76.29 KB 76.29 KB 🟰
nav 396.91 KB 396.94 KB
presentational 345.56 KB 345.59 KB
recent-history 169.46 KB 169.5 KB
shoelace 325.85 KB 325.85 KB 🟰
visual-builder 1,510.1 KB 1,510.14 KB
vs 1,013.8 KB 1,013.84 KB
widget-editors 0 KB 0 KB 🟰

Load by each brick

Critical changes: None.

See full changes
Name Prev Now Diff
advanced.capture-snapshot 52.37 KB 52.37 KB 🟰
advanced.general-cascader 216.09 KB 216.17 KB
advanced.general-table 331.72 KB 331.76 KB
advanced.pdf-viewer 199.15 KB 199.16 KB
ai.chat-agent 67.81 KB 67.81 KB 🟰
ai.chat-view 495.34 KB 495.3 KB
api-market.apis-directory-tree 206.73 KB 206.76 KB
basic.active-element-blur 8.7 KB 8.69 KB
basic.change-language 8.69 KB 8.68 KB
basic.copy-to-clipboard 8.85 KB 8.84 KB
basic.dropdown-button 154.75 KB 154.78 KB
basic.general-button 128.42 KB 128.46 KB
basic.general-image 88.58 KB 88.66 KB
basic.general-link 123.1 KB 123.14 KB
basic.general-menu 68.98 KB 68.97 KB
basic.general-menu-item 83.46 KB 83.53 KB
basic.general-popover 102.81 KB 102.79 KB
basic.general-tag 85.53 KB 85.6 KB
basic.general-tag-list 89.91 KB 89.98 KB
basic.general-text 161.39 KB 161.43 KB
basic.get-language 8.68 KB 8.67 KB
basic.home-redirect 14.19 KB 14.18 KB
basic.http-proxy-request 8.76 KB 8.75 KB
basic.http-request 8.68 KB 8.67 KB
basic.lock-body-scroll 10.43 KB 10.42 KB
basic.set-theme-by-apps 8.69 KB 8.69 KB 🟰
basic.set-timeout 8.69 KB 8.68 KB
basic.show-dialog 180.71 KB 180.75 KB
basic.show-notification 149.05 KB 149.09 KB
basic.show-watermark 10.43 KB 10.43 KB 🟰
basic.v3-widget-mate 8.67 KB 8.66 KB
containers.easy-view 67.12 KB 67.12 KB 🟰
containers.flex-layout 66.86 KB 66.86 KB 🟰
containers.general-card 140.04 KB 140.08 KB
containers.general-category 67.48 KB 67.48 KB 🟰
containers.general-drawer 93.31 KB 93.39 KB
containers.general-modal 142.06 KB 142.1 KB
containers.grid-layout 67.95 KB 67.95 KB 🟰
containers.micro-view 78.56 KB 78.55 KB
containers.search-bar 66.98 KB 66.98 KB 🟰
containers.tab-group 72.14 KB 72.14 KB 🟰
containers.tab-item 98.5 KB 98.57 KB
containers.tab-list 98.5 KB 98.57 KB
data-view.app-wall-card-item 70.06 KB 70.06 KB 🟰
data-view.app-wall-relation-line 69.76 KB 69.76 KB 🟰
data-view.app-wall-system-card 84.06 KB 84.14 KB
data-view.basic-index-group 69.35 KB 69.35 KB 🟰
data-view.battery-chart 70.08 KB 70.08 KB 🟰
data-view.brick-notification 83.28 KB 83.33 KB
data-view.bubbles-indicator 108.01 KB 108.08 KB
data-view.cabinet-app-layer 69.75 KB 69.75 KB 🟰
data-view.cabinet-button 69.36 KB 69.36 KB 🟰
data-view.cabinet-container 79.63 KB 79.63 KB 🟰
data-view.cabinet-graph 93.8 KB 93.8 KB 🟰
data-view.cabinet-node 70.16 KB 70.16 KB 🟰
data-view.cabinet-thumbnail 83.45 KB 83.45 KB 🟰
data-view.china-map 95.52 KB 95.57 KB
data-view.china-map-chart 376.31 KB 376.33 KB
data-view.complex-search 95.81 KB 95.86 KB
data-view.crystal-ball-indicator 102.4 KB 102.47 KB
data-view.data-display-flipper 69.3 KB 69.3 KB 🟰
data-view.data-display-flipper-fifth 69.17 KB 69.17 KB 🟰
data-view.data-display-flipper-sixth 69.02 KB 69.02 KB 🟰
data-view.dropdown-menu 85.35 KB 85.46 KB 🔼 +0.11 KB
data-view.gauge-chart 70.22 KB 70.22 KB 🟰
data-view.gear-background 115.33 KB 115.33 KB 🟰
data-view.globe-with-gear-indicator 153.26 KB 153.33 KB
data-view.globe-with-halo-indicator 103.4 KB 103.47 KB
data-view.globe-with-orbit-indicator 103.22 KB 103.3 KB
data-view.graph-layout-grid 86.54 KB 86.54 KB 🟰
data-view.graph-node 69.22 KB 69.22 KB 🟰
data-view.graph-text 77.69 KB 77.69 KB 🟰
data-view.grid-background 104.56 KB 104.56 KB 🟰
data-view.hi-tech-button 69.99 KB 69.99 KB 🟰
data-view.indicator-card 69.46 KB 69.46 KB 🟰
data-view.lights-component-title 68.89 KB 68.89 KB 🟰
data-view.loading-panel 73.27 KB 73.27 KB 🟰
data-view.modern-style-component-title 69.96 KB 69.96 KB 🟰
data-view.modern-style-page-title 70 KB 70 KB 🟰
data-view.modern-style-treemap 80.55 KB 80.55 KB 🟰
data-view.particle-animation 69.89 KB 69.89 KB 🟰
data-view.progress-bar-list 72.06 KB 72.06 KB 🟰
data-view.radar-chart 70.93 KB 70.93 KB 🟰
data-view.simple-card-item 69.57 KB 69.57 KB 🟰
data-view.tabs-drawer 85.21 KB 85.29 KB
data-view.tabs-page-title 72.11 KB 72.11 KB 🟰
data-view.tech-mesh-base-view 68.46 KB 68.46 KB 🟰
data-view.title-text 69.65 KB 69.65 KB 🟰
data-view.top-title-bar 80.83 KB 80.83 KB 🟰
diagram.editable-label 67.76 KB 67.76 KB 🟰
diagram.experimental-node 67.22 KB 67.22 KB 🟰
eo-actions 142.05 KB 142.08 KB
eo-alert 87.48 KB 87.56 KB
eo-antd-icon 71.58 KB 71.66 KB
eo-app-bar-wrapper 68.07 KB 68.07 KB 🟰
eo-auto-complete 102.01 KB 102.09 KB
eo-avatar 106.08 KB 106.15 KB
eo-avatar-group 104.65 KB 104.72 KB
eo-banner 86.56 KB 86.56 KB 🟰
eo-breadcrumb 127.36 KB 127.4 KB
eo-breadcrumb-item 126.93 KB 126.97 KB
eo-broadcast-channel 69.38 KB 69.37 KB
eo-button 128.42 KB 128.46 KB
eo-card 140.04 KB 140.08 KB
eo-card-item 167.32 KB 167.35 KB
eo-carousel-text 75.36 KB 75.36 KB 🟰
eo-cascader 216.09 KB 216.21 KB 🔼 +0.12 KB
eo-category 67.48 KB 67.48 KB 🟰
eo-checkbox 106.25 KB 106.34 KB
eo-code-display 232.73 KB 232.76 KB
eo-color-picker 240.84 KB 240.84 KB 🟰
eo-content-layout 66.42 KB 66.42 KB 🟰
eo-context-menu 148.57 KB 148.6 KB
eo-counter-badge 84.07 KB 84.14 KB
eo-current-time 86.16 KB 86.24 KB
eo-date-picker 233.93 KB 234.02 KB
eo-descriptions 163.7 KB 163.74 KB
eo-diagram 121.44 KB 121.44 KB 🟰
eo-directory 131.88 KB 131.96 KB
eo-directory-tree 120.93 KB 121 KB
eo-directory-tree-internal-node 82.72 KB 82.8 KB
eo-directory-tree-leaf 82.04 KB 82.11 KB
eo-display-canvas 215.85 KB 215.85 KB 🟰
eo-divider 73.17 KB 73.17 KB 🟰
eo-draw-canvas 223.11 KB 223.11 KB 🟰
eo-drawer 93.31 KB 93.39 KB
eo-dropdown-actions 145.76 KB 145.79 KB
eo-dropdown-button 154.75 KB 154.78 KB
eo-dropdown-select 139.9 KB 139.96 KB
eo-dynamic-form-item 165.6 KB 165.64 KB
eo-easy-view 67.12 KB 67.12 KB 🟰
eo-easyops-avatar 110.21 KB 110.28 KB
eo-easyops-icon 71.58 KB 71.66 KB
eo-event-agent 13.73 KB 13.72 KB
eo-fa-icon 71.58 KB 71.66 KB
eo-flex-layout 66.86 KB 66.86 KB 🟰
eo-form 69.22 KB 69.22 KB 🟰
eo-form-item 74.99 KB 74.99 KB 🟰
eo-formatter-number 69.43 KB 69.43 KB 🟰
eo-frame-breadcrumb 143.79 KB 143.83 KB
eo-grid-layout 67.95 KB 67.95 KB 🟰
eo-humanize-time 139.31 KB 139.35 KB
eo-icon 71.58 KB 71.66 KB
eo-icon-select 195.83 KB 195.87 KB
eo-iframe 69.42 KB 69.42 KB 🟰
eo-illustration-message 87.18 KB 87.27 KB
eo-image 88.58 KB 88.66 KB
eo-img-icon 71.58 KB 71.66 KB
eo-info-card-item 137.04 KB 137.11 KB
eo-input 96 KB 96.08 KB
eo-launchpad-button 161.07 KB 161.11 KB
eo-launchpad-button-v2 215.69 KB 215.73 KB
eo-launchpad-quick-access 202.31 KB 202.35 KB
eo-launchpad-recent-visits 201.14 KB 201.17 KB
eo-link 123.1 KB 123.14 KB
eo-loading-container 83.28 KB 83.35 KB
eo-loading-step 100.57 KB 100.6 KB
eo-main-view 86.56 KB 86.56 KB 🟰
eo-markdown-display 140.95 KB 140.95 KB 🟰
eo-markdown-editor 299.57 KB 299.71 KB 🔼 +0.14 KB
eo-menu 68.98 KB 68.97 KB
eo-menu-group 68.76 KB 68.75 KB
eo-menu-item 83.46 KB 83.53 KB
eo-menu-item-sub-menu 83.92 KB 83.99 KB
eo-message-listener 69.16 KB 69.15 KB
eo-micro-view 78.56 KB 78.55 KB
eo-mini-actions 146.65 KB 146.68 KB
eo-mini-line-chart 76.29 KB 76.29 KB 🟰
eo-modal 142.06 KB 142.1 KB
eo-narrow-view 75.17 KB 75.17 KB 🟰
eo-nav-menu 192.26 KB 192.29 KB
eo-next-table 382.43 KB 382.47 KB
eo-page-title 69.1 KB 69.09 KB
eo-page-view 75.17 KB 75.17 KB 🟰
eo-pagination 172.24 KB 172.27 KB
eo-popover 102.81 KB 102.79 KB
eo-popup 95.39 KB 95.47 KB
eo-radio 98.01 KB 98.09 KB
eo-resizable-box 68.84 KB 68.84 KB 🟰
eo-search 100.05 KB 100.12 KB
eo-search-bar 66.98 KB 66.98 KB 🟰
eo-search-launchpad 204.97 KB 205.01 KB
eo-select 145.63 KB 145.7 KB
eo-sidebar 167.75 KB 167.79 KB
eo-sidebar-menu 148.78 KB 148.82 KB
eo-sidebar-menu-group 148.78 KB 148.82 KB
eo-sidebar-menu-item 133.63 KB 133.67 KB
eo-sidebar-menu-submenu 148.78 KB 148.82 KB
eo-sidebar-sub-menu 148.8 KB 148.84 KB
eo-spin 67.31 KB 67.31 KB 🟰
eo-statistics-card 87.36 KB 87.44 KB
eo-submit-buttons 150.12 KB 150.16 KB
eo-svg-icon 71.58 KB 71.66 KB
eo-switch 94.21 KB 94.29 KB
eo-tab-group 72.14 KB 72.14 KB 🟰
eo-tab-item 98.5 KB 98.57 KB
eo-tab-list 98.5 KB 98.57 KB
eo-table 331.72 KB 331.8 KB
eo-tag 85.53 KB 85.6 KB
eo-tag-list 89.91 KB 89.98 KB
eo-text 161.39 KB 161.43 KB
eo-text-tooltip 141.64 KB 141.64 KB 🟰
eo-textarea 84.07 KB 84.07 KB 🟰
eo-time-picker 216.24 KB 216.24 KB 🟰
eo-time-range-picker 233.18 KB 233.26 KB
eo-tooltip 118.12 KB 118.19 KB
eo-tree 141.18 KB 141.18 KB 🟰
eo-tree-select 228.77 KB 228.85 KB
eo-upload-file 162.13 KB 162.17 KB
eo-upload-image 170.75 KB 170.78 KB
eo-user-or-user-group-select 176.85 KB 176.89 KB
eo-workbench-layout 259.83 KB 259.86 KB
eo-workbench-layout-v2 261.32 KB 261.35 KB
form.dynamic-form-item 165.6 KB 165.64 KB
form.general-checkbox 106.26 KB 106.33 KB
form.general-form 69.22 KB 69.22 KB 🟰
form.general-form-item 74.99 KB 74.99 KB 🟰
form.general-input 96 KB 96.08 KB
form.general-radio 98 KB 98.08 KB
form.general-search 100.05 KB 100.12 KB
form.general-select 145.63 KB 145.7 KB
form.general-switch 94.21 KB 94.29 KB
form.general-textarea 84.07 KB 84.07 KB 🟰
form.icon-select 195.83 KB 195.87 KB
form.submit-buttons 150.12 KB 150.16 KB
form.upload-image 170.75 KB 170.78 KB
icons.antd-icon 71.58 KB 71.66 KB
icons.easyops-icon 71.58 KB 71.66 KB
icons.fa-icon 71.58 KB 71.66 KB
icons.general-icon 71.58 KB 71.66 KB
icons.get-antd-icons 6.61 KB 6.62 KB
icons.get-easyops-icons 6.61 KB 6.62 KB
icons.get-fa-icons 6.61 KB 6.62 KB
icons.get-libs 6.61 KB 6.62 KB
icons.search-icons 6.61 KB 6.62 KB
illustrations.error-message 87.19 KB 87.27 KB
illustrations.get-illustration 9.11 KB 9.11 KB 🟰
illustrations.get-illustrations-by-category 6.01 KB 6.01 KB 🟰
illustrations.loading-transition 66.63 KB 66.63 KB 🟰
illustrations.translate-illustration-config 9.11 KB 9.11 KB 🟰
inject.visual-builder-preview-agent 56.22 KB 56.22 KB 🟰
markdown.markdown-editor 299.59 KB 299.66 KB
nav.app-bar-wrapper 68.07 KB 68.07 KB 🟰
nav.easyops-navbar-alerts 136.08 KB 136.12 KB
nav.get-menu-config-options 7.82 KB 7.82 KB 🟰
nav.get-menu-config-tree 8.32 KB 8.32 KB 🟰
nav.launchpad-config 216.14 KB 216.17 KB
nav.nav-logo 132.66 KB 132.7 KB
nav.poll-announce 169.14 KB 169.18 KB
presentational.code-display 232.73 KB 232.76 KB
presentational.general-alert 87.48 KB 87.56 KB
presentational.general-descriptions 163.7 KB 163.74 KB
presentational.humanize-time 139.31 KB 139.35 KB
recent-history.clear-history 28.36 KB 28.36 KB 🟰
recent-history.get-all-history 28.36 KB 28.36 KB 🟰
recent-history.push-history 28.36 KB 28.36 KB 🟰
recent-history.recent-visit 168.37 KB 168.41 KB
sl-alert 31.11 KB 31.11 KB 🟰
sl-animated-image 25.37 KB 25.37 KB 🟰
sl-animation 25.54 KB 25.54 KB 🟰
sl-avatar 25.85 KB 25.85 KB 🟰
sl-badge 22.41 KB 22.41 KB 🟰
sl-breadcrumb 27.9 KB 27.9 KB 🟰
sl-breadcrumb-item 27.9 KB 27.9 KB 🟰
sl-button 33.09 KB 33.09 KB 🟰
sl-button-group 21.66 KB 21.66 KB 🟰
sl-card 22.67 KB 22.67 KB 🟰
sl-carousel 31.92 KB 31.92 KB 🟰
sl-carousel-item 31.92 KB 31.92 KB 🟰
sl-checkbox 30.29 KB 30.29 KB 🟰
sl-color-picker 64.47 KB 64.47 KB 🟰
sl-details 28.09 KB 28.09 KB 🟰
sl-dialog 33.02 KB 33.02 KB 🟰
sl-divider 21.5 KB 21.5 KB 🟰
sl-drawer 34.1 KB 34.1 KB 🟰
sl-dropdown 36.15 KB 36.15 KB 🟰
sl-format-bytes 22.32 KB 22.32 KB 🟰
sl-format-date 22.37 KB 22.37 KB 🟰
sl-format-number 22.38 KB 22.38 KB 🟰
sl-icon 24.5 KB 24.5 KB 🟰
sl-icon-button 27.13 KB 27.13 KB 🟰
sl-image-comparer 27.79 KB 27.79 KB 🟰
sl-input 33.79 KB 33.79 KB 🟰
sl-menu 41.75 KB 41.75 KB 🟰
sl-menu-item 41.75 KB 41.75 KB 🟰
sl-menu-label 21.23 KB 21.23 KB 🟰
sl-mutation-observer 21.72 KB 21.72 KB 🟰
sl-option 27.37 KB 27.37 KB 🟰
sl-popup 31.88 KB 31.88 KB 🟰
sl-progress-bar 23.98 KB 23.98 KB 🟰
sl-progress-ring 23.06 KB 23.06 KB 🟰
sl-qr-code 26.97 KB 26.97 KB 🟰
sl-radio 26.26 KB 26.26 KB 🟰
sl-radio-button 26.01 KB 26.01 KB 🟰
sl-radio-group 26.35 KB 26.35 KB 🟰
sl-range 29.08 KB 29.08 KB 🟰
sl-rating 28.43 KB 28.43 KB 🟰
sl-relative-time 22.58 KB 22.58 KB 🟰
sl-resize-observer 21.61 KB 21.61 KB 🟰
sl-select 48.53 KB 48.53 KB 🟰
sl-skeleton 22.21 KB 22.21 KB 🟰
sl-spinner 22.67 KB 22.67 KB 🟰
sl-split-panel 24.31 KB 24.31 KB 🟰
sl-switch 27.19 KB 27.19 KB 🟰
sl-tab 34.18 KB 34.18 KB 🟰
sl-tab-group 34.18 KB 34.18 KB 🟰
sl-tab-panel 34.18 KB 34.18 KB 🟰
sl-tag 29.28 KB 29.28 KB 🟰
sl-textarea 27.88 KB 27.88 KB 🟰
sl-tooltip 34.25 KB 34.25 KB 🟰
sl-tree 37.25 KB 37.25 KB 🟰
sl-tree-item 37.25 KB 37.25 KB 🟰
sl-visually-hidden 21.2 KB 21.2 KB 🟰
visual-builder.batch-update-raw-data-generated-view 7.48 KB 7.48 KB 🟰
visual-builder.chat-conversation 183.91 KB 183.94 KB
visual-builder.chat-preview 69.54 KB 69.54 KB 🟰
visual-builder.check-editor-by-name 7.1 KB 7.1 KB 🟰
visual-builder.contract-select 122.43 KB 122.51 KB
visual-builder.generate-snippets-context-menu 146.5 KB 146.57 KB
visual-builder.get-data-deps 7.11 KB 7.11 KB 🟰
visual-builder.get-dependency-tree 7.49 KB 7.49 KB 🟰
visual-builder.get-raw-data-system-prompts 11.46 KB 11.46 KB 🟰
visual-builder.inject-chat-preview-agent 8.06 KB 8.06 KB 🟰
visual-builder.page-arch-node 130.85 KB 130.92 KB
visual-builder.parse-path 8.73 KB 8.73 KB 🟰
visual-builder.pre-generated-container 69.9 KB 69.9 KB 🟰
visual-builder.pre-generated-preview 69.52 KB 69.52 KB 🟰
visual-builder.pre-generated-table-view 67.13 KB 67.13 KB 🟰
visual-builder.property-editor 1,316.94 KB 1,316.93 KB
visual-builder.raw-data-preview 72.43 KB 72.43 KB 🟰
visual-builder.workbench-action 134.61 KB 134.64 KB
visual-builder.workbench-action-list 140.03 KB 140.07 KB
visual-builder.workbench-history-action 168.21 KB 168.24 KB
visual-builder.workbench-pane 83.03 KB 83.13 KB 🔼 +0.1 KB
visual-builder.workbench-sidebar 68.01 KB 68.01 KB 🟰
visual-builder.workbench-tree 140.08 KB 140.12 KB
vs.code-editor 1,013.87 KB 1,013.84 KB

Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (2)
bricks/icons/src/shared/SvgCache.ts (1)

28-42: 建议添加错误日志记录!

当前实现在版本切换时能够正确处理404错误,但建议添加日志记录以便于问题排查。

建议添加如下修改:

 if (!fileData.ok) {
+  console.warn(`Failed to fetch icon from ${url}: ${fileData.status}`);
   // Fix accessing images of v2 micro-apps in v3 container, and vice versa.
   if (
     !isFix &&
bricks/icons/src/svg-icon/index.spec.ts (1)

119-129: 建议增强测试用例的断言!

当前测试用例验证了版本切换功能,但建议添加更多断言以确保行为正确性。

建议添加如下断言:

   expect(element.shadowRoot?.querySelector("svg")).toBeTruthy();
+  // 验证请求次数
+  expect(fetch).toHaveBeenCalledTimes(2);
+  // 验证请求的URL
+  expect(fetch).toHaveBeenCalledWith("/sa-static/micro-apps/v2/app/test.svg");
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 69f1ee9 and d5a0343.

📒 Files selected for processing (2)
  • bricks/icons/src/shared/SvgCache.ts (1 hunks)
  • bricks/icons/src/svg-icon/index.spec.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: CodeQL
  • GitHub Check: Build bricks (20.x)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
bricks/icons/src/shared/SvgCache.ts (2)

17-17: 正则表达式实现合理!

正则表达式能够准确匹配微应用的版本号(v2或v3),并通过捕获组方便后续的URL转换。


21-23: 函数签名更新合理!

新增的可选参数isFix用于防止无限递归,同时保持了向后兼容性。

bricks/icons/src/svg-icon/index.spec.ts (2)

Line range hint 5-32: 测试用例模拟实现完善!

fetch模拟实现合理地处理了不同的URL模式和状态码,包括:

  • v3微应用的404错误
  • 失败URL的410错误
  • 成功请求的SVG响应

131-146: 错误处理测试用例设计合理!

测试用例完整验证了:

  • 失败URL的错误处理
  • 事件派发机制
  • DOM状态变化

@github-actions github-actions bot temporarily deployed to pull request January 20, 2025 02:45 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
bricks/icons/src/shared/SvgCache.ts (1)

28-42: 版本切换逻辑实现完善

修复了 v2/v3 容器间图片访问的问题,实现要点:

  1. 仅对 404 错误进行处理
  2. 使用 isFix 标志防止递归
  3. 版本切换逻辑清晰(v2 ↔ v3)

建议添加日志记录以便追踪版本切换情况。

 if (
   !isFix &&
   fileData.status === 404 &&
   REGEX_MICRO_APPS_WITH_VERSION.test(url)
 ) {
   const fixedUrl = url.replace(
     REGEX_MICRO_APPS_WITH_VERSION,
     (_, v) => `/micro-apps/v${v === "2" ? "3" : "2"}/`
   );
+  console.debug(`[SvgCache] Switching version for URL: ${url} -> ${fixedUrl}`);
   return resolveIcon(fixedUrl, options, true);
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d5a0343 and cc5357e.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • bricks/basic/package.json (1 hunks)
  • bricks/basic/src/link/index.tsx (1 hunks)
  • bricks/basic/src/popover/index.tsx (1 hunks)
  • bricks/icons/src/shared/SvgCache.ts (1 hunks)
  • bricks/icons/src/svg-icon/index.spec.ts (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • bricks/basic/src/popover/index.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • bricks/icons/src/svg-icon/index.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build bricks (20.x)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
bricks/basic/src/link/index.tsx (1)

23-23: 类型导入导出的改进!

ExtendedLocationDescriptorTarget 的导入导出更改为类型导入导出,提高了类型安全性和代码清晰度。

Also applies to: 27-28

bricks/basic/package.json (1)

43-43: 请验证新依赖的必要性和版本兼容性

新增了 @next-core/easyops-runtime 依赖,版本为 ^0.13.3

请运行以下脚本验证依赖版本的安全性和必要性:

bricks/icons/src/shared/SvgCache.ts (2)

17-18: 正则表达式定义清晰明确

REGEX_MICRO_APPS_WITH_VERSION 正则表达式用于匹配和识别 v2/v3 微应用的 URL,实现方式简洁有效。


21-23: 函数参数扩展合理

resolveIcon 函数添加 isFix 参数,用于防止无限递归,这是一个很好的安全措施。

@github-actions github-actions bot temporarily deployed to pull request January 20, 2025 02:51 Inactive
@qiaofengxi qiaofengxi merged commit c12d16f into master Jan 20, 2025
9 checks passed
@qiaofengxi qiaofengxi deleted the steve/fix-icon-url branch January 20, 2025 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants