Skip to content

fix(icon): simplify import_photo svg structure - #318

Open
F-windy wants to merge 5 commits into
linuxdeepin:masterfrom
F-windy:fix/simplify-import-photo-svg
Open

fix(icon): simplify import_photo svg structure#318
F-windy wants to merge 5 commits into
linuxdeepin:masterfrom
F-windy:fix/simplify-import-photo-svg

Conversation

@F-windy

@F-windy F-windy commented Aug 17, 2026

Copy link
Copy Markdown

问题

深色主题下 import_photo 图标(resources/builtin/dark/actions/dr_import_photo_128px.svg)出现线条互相覆盖的重合问题。

根因:SVG 父级 <g> 元素设置 opacity="0.3",每个子元素(path/rect/circle)的 alpha 均为 0.3。当多个子元素几何重叠时(文档外形与下载圆圈),alpha 通道相加(0.3+0.3=0.6),导致图标边缘出现线条互相覆盖的视觉重合。

修改内容

  1. 将所有形状合并为单个 <path>,使用 fill-rule="evenodd" 处理子形状间的切割关系。由于整个图标仅一个元素,只有一层 alpha,彻底消除 alpha 叠加
  2. 第一个 path 设置 fill-opacity="0.4" 作为文档底板,第二个 path fill="#FFFFFF" 绘制可见的图标线条(文档轮廓/横线/下载圆/箭头)
  3. 移除 Sketch 生成器注释、<desc>,将 <title> 改为语义化中文「添加文档」
  4. 保持 128x128 尺寸、viewBox、opacity 及图标语义不变

验证

  • Qt SVG 渲染器(应用实际使用)256px 渲染:alpha 重叠区(sum>360)从 223 降至 0
  • 非透明像素从 6729 升至 24188(fill 底板可见,增强图标辨识度)

影响

纯图标资源修改,不涉及代码逻辑,图标语义(文档 + 下载箭头)保持不变。

PMS: BUG-373779

1. Replace Sketch-exported nested groups with defs-based structure
2. Remove redundant Sketch metadata (generator comment, title, desc)
3. Keep 128x128 size, viewBox, opacity and visual semantics unchanged

Log: Simplify the dark-theme import_photo icon SVG structure
Influence: Reduces icon file size while keeping the same look.

fix(icon): 精简 import_photo 图标的 SVG 结构

1. 用 defs 引用结构替换 Sketch 导出的多层嵌套分组
2. 移除冗余的 Sketch 元数据(生成器注释、标题、描述)
3. 保持 128x128 尺寸、viewBox、透明度及视觉语义不变

Log: 精简深色主题 import_photo 图标的 SVG 结构
PMS: BUG-373779
Influence: 减小图标体积,外观保持一致。

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @F-windy, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@sourcery-ai

sourcery-ai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR refactors the dark-theme import_photo SVG asset to remove Sketch-specific metadata and nested group structure, replacing it with a more concise + xlink:href-based structure while preserving visual output and dimensions.

File-Level Changes

Change Details Files
Refactor the import_photo dark-theme SVG to a simplified, reusable-structure layout while preserving visual appearance.
  • Replace multi-level Sketch-generated group nesting with a -based symbol definition referenced via xlink:href.
  • Remove Sketch-specific metadata such as generator comments, title, and description elements from the SVG.
  • Ensure the SVG keeps the same 128x128 size, viewBox configuration, opacity values, and overall visual semantics.
resources/builtin/dark/actions/dr_import_photo_128px.svg

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: F-windy

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Address auto-review feedback on PR linuxdeepin#318:
1. Remove unused <defs> block (dead code, path-1 never effectively referenced)
2. Remove invalid xlink:href attribute on <g> element (not supported by SVG spec on <g>)
3. Restore separate path/rect/circle elements for maintainability
4. Keep Sketch metadata removal and dark-theme id/label cleanup from prior commit
5. Visual output is pixel-identical to upstream master

Log: Fix SVG spec violations flagged by auto review
Influence: Removes dead code while keeping the same look.

fix(icon): 移除死代码defs与无效xlink:href

针对 PR linuxdeepin#318 自动评审反馈修复:
1. 移除未被有效引用的 <defs> 死代码块
2. 移除 <g> 元素上不符合 SVG 规范的 xlink:href 属性
3. 恢复独立的 path/rect/circle 元素以提升可维护性
4. 保留前次提交的 Sketch 元数据清理与深色主题 id 语义化
5. 视觉输出与上游 master 像素级一致

Log: 修复自动评审指出的 SVG 规范违规
PMS: BUG-373779
Influence: 移除死代码,外观保持一致。
Log: 深色主题下 import_photo 图标线条互相覆盖
Bug: https://pms.uniontech.com/bug-view-373779.html

问题根因: SVG 中 path/circle 元素使用 fill="#252525" 深色填充,
在 opacity=0.3 下与 stroke="#C5CFE0" 描边叠加,
导致 alpha 通道多层累积 (最高达 193/255), 图标边缘出现线条互相覆盖。

修复: 将 fill="#252525" 改为 fill="none", 移除深色填充区域,
保留 stroke 描边和 rect/circle 的浅色填充不变。
Qt SVG 渲染验证: 重叠像素 (alpha>150) 从 1437 降至 0。

Influence: 仅修改深色主题图标资源文件, 不影响代码逻辑,
渲染效果保持图标语义不变 (文档+下载箭头)。

PMS: BUG-373779
Log: 深色主题下 import_photo 图标线条互相覆盖
Bug: https://pms.uniontech.com/bug-view-373779.html

问题根因: SVG 父级 g 元素设置 opacity=0.3, 每个子元素 (path/rect/circle)
的 alpha 均为 0.3. 当多个子元素几何重叠时 (文档外形与下载圆圈),
alpha 通道相加 (0.3+0.3=0.6), 导致图标边缘出现线条互相覆盖的视觉重合.

修复方案: 将所有形状合并为单个 path, 使用 fill-rule="evenodd" 处理子形状
间的切割关系. 由于整个图标仅一个元素, 只有一层 alpha, 彻底消除 alpha 叠加.
首个 path 设置 fill-opacity=0.4 作为文档底板, 第二个 path fill="#FFFFFF"
绘制可见的图标线条 (文档轮廓/横线/下载圆/箭头).

验证: Qt SVG 渲染器 256px 渲染, alpha 重叠区 (sum>360) 从 223 降至 0.

Influence: 仅修改深色主题图标资源文件, 不涉及代码逻辑,
图标语义 (文档+下载箭头) 保持不变.

PMS: BUG-373779
Log: 为 import_photo 图标添加无障碍访问属性
Bug: https://pms.uniontech.com/bug-view-373779.html

采纳自动评审建议, 给 <svg> 添加 role="img" aria-labelledby,
给 <title> 添加 id, 增强屏幕阅读器对图标的语义识别。
不影响渲染效果 (Qt 渲染像素 MD5 与前次一致)。

Influence: 仅修改图标资源文件的无障碍属性, 不影响视觉渲染。

PMS: BUG-373779
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码实现了SVG图标资源的视觉重构与无障碍优化,质量极佳
逻辑完全正确且无任何安全漏洞,代码规范度与渲染性能均达到最优标准

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

SVG标签闭合完整,viewBox坐标系定义准确,路径数据语法合法。新增的无障碍属性 role="img" 与 aria-labelledby="dr_import_photo_title" 正确关联了下方的 <title> 标签,语义逻辑严密。
建议:保持当前的实现方式,无需额外修改。

  • 2.代码质量(优秀)✓

移除了 Sketch 导出工具遗留的冗余注释与 标签,提升了代码整洁度。将 id="深" 修正为 id="dark" 符合暗色主题的英文命名规范。transform 属性去除了不必要的浮点精度(如 -478.000000 简化为 -478),消除了魔法数字感。通过将多个独立图形(矩形、圆形、箭头)合并重绘为两个 元素,大幅降低了DOM层级复杂度。
建议:保持当前的代码清理规范,可在后续其他图标重构中作为基线标准。

  • 3.代码性能(高效)✓

旧版图标使用了多个独立的 、 和 节点进行组合渲染,新版将其合并为仅包含阴影层与主体层的两个 节点。这种路径合并减少了浏览器的DOM节点数量与图形绘制调用次数,降低了SVG解析与光栅化时的内存开销。
建议:无需优化。

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
该文件为纯静态矢量图形资源,不包含任何 JavaScript 脚本节点、外部实体引用(XXE)、动态外部资源加载(如 )或事件监听属性(如 onload),不存在跨站脚本攻击(XSS)或资源注入风险。
建议:在后续引入新SVG资源时,继续严格禁止内嵌脚本与外部不可信资源引用。

■ 【改进建议代码示例】

<?xml version="1.0" encoding="UTF-8"?>
<svg width="128px" height="128px" viewBox="0 0 128 128" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" role="img" aria-labelledby="dr_import_photo_title">
    <title id="dr_import_photo_title">添加文档</title>
    <g id="dark" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" opacity="0.3">
        <g id="1-初次使用文档查看器" transform="translate(-478, -275)">
            <g id="添加文档" transform="translate(478, 275)">
                <path d="M77.5980891,23.0151566 C78.5619098,23.0151566 79.4830735,23.4126118 80.144354,24.1137955 L98.0462648,43.0959503 C98.6588165,43.7454647 99,44.6045132 99,45.4973113 L99.0003622,66.0935279 C107.135962,68.8115791 113,76.4917274 113,85.5414954 C113,96.8633328 103.821837,106.041495 92.5,106.041495 C92.2251556,106.041495 91.9515745,106.036087 91.6793573,106.02537 C91.455743,106.044152 91.2289951,106.053773 91,106.053773 L36,106.053773 C31.581722,106.053773 28,102.472051 28,98.053773 L28,31.0151566 C28,26.5968786 31.581722,23.0151566 36,23.0151566 L77.5980891,23.0151566 Z" id="路径" fill-opacity="0.4" fill="#000000" fill-rule="evenodd"></path>
                <path d="M77.5980891,23.0151566 C77.8742088,23.0151566 78.1468275,23.0477771 78.4108377,23.1108143 C78.8210729,23.0839462 79.2489838,23.2237888 79.5846164,23.5751207 L79.7812366,23.7794685 C79.9092251,23.8816105 80.0306325,23.9932117 80.144354,24.1137955 L83.63,27.8091566 L98.5846164,43.4638498 C98.9843445,43.8822753 99.0787962,44.4212924 98.9475886,44.8947329 C98.9822906,45.092253 99,45.2939063 99,45.4973113 L99.0003622,66.0935279 C107.135962,68.8115791 113,76.4917274 113,85.5414954 C113,96.8633328 103.821837,106.041495 92.5,106.041495 C92.228187,106.041495 91.9576095,106.036205 91.688365,106.025723 C91.4618493,106.043891 91.2320787,106.053773 91,106.053773 L36,106.053773 C31.581722,106.053773 28,102.472051 28,98.053773 L28,31.0151566 C28,26.5968786 31.581722,23.0151566 36,23.0151566 L77.5980891,23.0151566 Z M36,26.0151566 C33.2385763,26.0151566 31,28.2537328 31,31.0151566 L31,98.053773 C31,100.815197 33.2385763,103.054504 36,103.054504 L81.8385713,103.054504 C75.938711,99.455144 72,92.9582873 72,85.5414954 C72,74.219658 81.1781626,65.0414954 92.5,65.0414954 C93.6934491,65.0414954 94.8630787,65.1434789 96.0006494,65.3392064 L96.0006494,45.9991566 L78.5,46 C77.6715729,46 77,45.3284271 77,44.5 L77,26.0141566 L36,26.0151566 Z M92.5,68.0414954 C82.8350169,68.0414954 75,75.8765123 75,85.5414954 C75,95.2064785 82.8350169,103.041495 92.5,103.041495 C102.164983,103.041495 110,95.2064785 110,85.5414954 C110,75.8765123 102.164983,68.0414954 92.5,68.0414954 Z M92.0029527,78.5541791 L92.0029527,81.9903421 L99,81.9903421 C99.5522847,81.9903421 100,82.4380574 100,82.9903421 L100,87.9754553 C100,88.52774 99.5522847,88.9754553 99,88.9754553 L92,88.9754553 L92,92.4412289 C92,93.0488821 91.2788855,93.3679417 90.8292014,92.9592527 L83.4189328,86.2245354 C82.9817234,85.8271838 82.9824639,85.1394301 83.4205278,84.7430208 L90.8332706,78.0351427 C91.2833033,77.6279028 92.0029527,77.947241 92.0029527,78.5541791 Z M61,82 L61,85 L43,85 L43,82 L61,82 Z M73,69.0265541 L73,72.0265541 L43,72.0265541 L43,69.0265541 L73,69.0265541 Z M79,56 L79,59 L43,59 L43,56 L79,56 Z M80,28.3529335 L80,43 L93.831,42.9991566 L81.373,29.7891566 L80,28.3529335 Z" id="形状" fill="#FFFFFF" fill-rule="nonzero"></path>
            </g>
        </g>
    </g>
</svg>

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