From 6cadc276bdaed78a5c60b5f6e2930bc77233af5b Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Sat, 4 Jul 2026 09:55:13 +0800 Subject: [PATCH] =?UTF-8?q?docs(design):=20=E5=85=A8=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=BE=BD=E7=AB=A0=E5=9C=86=E7=82=B9=E7=BB=9F=E4=B8=80=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E5=8C=96=EF=BC=88icons.js=20BADGE=5FICON=20=E5=8D=95?= =?UTF-8?q?=E6=BA=90=E8=87=AA=E5=8A=A8=E6=B3=A8=E5=85=A5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - icons.js 新增 BADGE_ICON 全量状态映射(库存/单据/往来/角色/设备/盘点/兑换券/ 收付 28 词)+ MutationObserver 运行时增强:任何屏渲染的 .badge.b-* 自动注入 代表图标并隐藏圆点,动态重渲染同样生效,屏内无需手写 svg - 新增状态只需在 BADGE_ICON 登记一行即全局生效;已手写 .bi/.ico 的徽章跳过 - index.html 徽章登记区注明机制;实测 index 47/47、库存/往来/移动出入库全部命中 Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01JJ1g8XV1YhhmHRzhwWEW7o --- .superpowers/prototype/index.html | 2 +- .superpowers/prototype/screens/icons.js | 29 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.superpowers/prototype/index.html b/.superpowers/prototype/index.html index 9bc91c4..7ea4ec6 100644 --- a/.superpowers/prototype/index.html +++ b/.superpowers/prototype/index.html @@ -366,7 +366,7 @@
分类 浓香
时间范围
-

状态徽章 · 全部

.badge .b-* · 对齐 schema 真实枚举
+

状态徽章 · 全部

.badge .b-* · 对齐 schema 真实枚举 · 圆点已全局图标化(icons.js BADGE_ICON 单源映射自动注入,屏内无需手写 svg)
库存 · 按 min_stock 派生在售预警缺货
单据 · 入库/出库草稿待审核已通过已驳回
diff --git a/.superpowers/prototype/screens/icons.js b/.superpowers/prototype/screens/icons.js index aab40b7..dd49d03 100644 --- a/.superpowers/prototype/screens/icons.js +++ b/.superpowers/prototype/screens/icons.js @@ -5,4 +5,33 @@ var SPRITE=''; function inject(){ if(document.getElementById('ym-icon-sprite'))return; var d=document.createElement('div'); d.id='ym-icon-sprite'; d.style.cssText='position:absolute;width:0;height:0'; d.innerHTML=SPRITE; document.body.insertBefore(d,document.body.firstChild); } if(document.readyState!=='loading')inject(); else document.addEventListener('DOMContentLoaded',inject); + // ---- 徽章图标化(2026-07-04 拍板:全系统圆点→代表图标)---- + // 单一真相源映射:任何屏渲染出的 .badge.b-*(无 .bi/.ico 者)自动注入图标并隐藏圆点。 + // 屏内无需手写 svg;新增状态在此登记即可全局生效。 + var BADGE_ICON = { + '在售':'i-check','预警':'i-alert','缺货':'i-close', + '草稿':'i-ic06','待审核':'i-ic04','已审核':'i-check','已拒绝':'i-close','已通过':'i-check','已驳回':'i-close', + '部分退单':'i-undo','已退单':'i-undo','待定价':'i-yen', + '启用':'i-check','停用':'i-close','供应商':'i-box','客户':'i-ic37','两者':'i-refresh', + '管理员':'i-shield-2','普通':'i-ic37','只读':'i-eye', + '在线':'i-check','离线':'i-close', + '进行中':'i-ic04','已完成':'i-check', + '未使用':'i-tag','已兑换':'i-check','作废':'i-close', + '未结清':'i-ic04','已结清':'i-check','收款':'i-download','付款':'i-upload' + }; + window.BADGE_ICON = BADGE_ICON; + function enhanceBadges(){ + document.querySelectorAll('.badge:not(.bi):not(.ico)').forEach(function(b){ + var st=''; b.classList.forEach(function(c){ if(c.indexOf('b-')===0) st=c.slice(2); }); + var ic=BADGE_ICON[st]; if(!ic) return; + b.classList.add('bi'); + b.insertAdjacentHTML('afterbegin',''); + }); + } + function watchBadges(){ + enhanceBadges(); + new MutationObserver(function(){ enhanceBadges(); }).observe(document.body,{childList:true,subtree:true}); + } + if(document.readyState!=='loading')watchBadges(); else document.addEventListener('DOMContentLoaded',watchBadges); + })();