refactor(ui): 全站 svg 图标收进 index.html 的 symbol sprite
前端 99 处 svg、56 个唯一图形(× 号 11 次、+ 号 6 次、复制与文档各 5 次), 43 处是纯冗余路径:改一个图标得在两三个文件里同步,加个新图标又要复制一份 path。 现在几何图形统一定义在 index.html 里的一份 sprite,引用写成 <svg 原属性><use href="#i-xxx"/></svg>——外层 class、尺寸、fill/stroke 原样保留, 所以大小和描边仍归各处 CSS 管(.ic / .tree-act svg / .files-fab svg),形状逐像素照搬。 脚本按几何指纹建映射,99 处全部命中,零未匹配;校验结果 symbol 56 个、 引用 99 处、无缺失、无未被引用、sprite 外无残留几何标签,JS 全部 node --check 通过。 同形但历史写法不同的(folder/folder-b/folder-c、x-line/x-line-b/x-path、eye/eye-sm 等) 各留一份 symbol,保证替换前后完全一致,后续要收敛只改引用指向即可。 sprite 容器用 position:absolute + 零尺寸,不用 display:none:后者在部分旧浏览器上 会让被引用的 symbol 也一并不渲染。 体积:index.html +6KB(sprite 定义),js 合计 -5.3KB,总量基本持平。
This commit is contained in:
@@ -148,11 +148,11 @@
|
||||
const MODES = {
|
||||
secretary: {
|
||||
label: '文秘助理', hint: '支持文字输入,可起草、润色、整理文书',
|
||||
icon: '<svg class="header-mode-icon" viewBox="0 0 24 24"><path d="M6 3h12l4 6-10 13L2 9z"></path><polyline points="2 9 22 9"></polyline><polyline points="10 3 8 9 12 22"></polyline><polyline points="14 3 16 9 12 22"></polyline></svg>',
|
||||
icon: '<svg class="header-mode-icon" viewBox="0 0 24 24"><use href="#i-gem"/></svg>',
|
||||
},
|
||||
vision: {
|
||||
label: '识图专家', hint: '支持图片识别输入',
|
||||
icon: '<svg class="header-mode-icon" viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>',
|
||||
icon: '<svg class="header-mode-icon" viewBox="0 0 24 24"><use href="#i-image"/></svg>',
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user