// 临时生成脚本:从图标库提取底部导航 5 个菜单图标,生成双态对比预览页(勿提交) const fs = require('fs'); const path = 'js/data/sources/'; global.window = {}; const RED = '#C8102E'; const GRAY = '#999999'; function load(sid) { eval(fs.readFileSync(path + sid + '.js', 'utf8')); return window['HGB_Source_' + sid]; } function findIcon(data, ref) { const namePart = ref.includes(':') ? ref.split(':')[1] : ref; return (data.icons || []).find(i => i.id === ref || i.name === namePart) || null; } // style: native(自带currentColor) / fill(根fill) / stroke(根stroke) const SOURCES = { fluent: { style: 'native', vb: 24 }, 'material-symbols': { style: 'native', vb: 24 }, remix: { style: 'fill', vb: 24 }, lucide: { style: 'stroke', vb: 24 }, ionicons: { style: 'fill', vb: 512 }, mingcute: { style: 'native', vb: 24 } }; function renderSVG(ic, src, color) { const { style, vb } = src; let attrs = 'xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ' + vb + ' ' + vb + '"'; if (style === 'stroke') attrs += ' fill="none" stroke="' + color + '" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"'; else if (style === 'fill') attrs += ' fill="' + color + '"'; return '' + ic.svg + ''; } const SOLUTIONS = [ { key: 'A', title: 'Fluent 微软圆润', desc: '微软现代风格,描边/实心双态,与现款同源;「发房」= 房子+加号', source: 'fluent', pub: 'fluent:home-add-24-filled', items: [ { label: '首页', n: 'fluent:home-24-regular', a: 'fluent:home-24-filled' }, { label: '租房', n: 'fluent:search-24-regular', a: 'fluent:search-24-filled' }, { label: '消息', n: 'fluent:chat-24-regular', a: 'fluent:chat-24-filled' }, { label: '我的', n: 'fluent:person-24-regular', a: 'fluent:person-24-filled' } ] }, { key: 'B', title: 'Material Symbols 谷歌圆角', desc: 'Material Design 风格,圆角厚重,实心为主;「发房」= 房子+加号', source: 'material-symbols', pub: 'material-symbols:add-home-rounded', items: [ { label: '首页', n: 'material-symbols:home-outline-rounded', a: 'material-symbols:home-rounded' }, { label: '租房', n: 'material-symbols:search-outline-rounded', a: 'material-symbols:search-rounded' }, { label: '消息', n: 'material-symbols:chat-outline-rounded', a: 'material-symbols:chat-rounded' }, { label: '我的', n: 'material-symbols:person-outline-rounded', a: 'material-symbols:person-rounded' } ] }, { key: 'C', title: 'Remix 锐克思', desc: '国内产品最常见图标库,线条/实心双态;「发房」= 铅笔编辑', source: 'remix', pub: 'remix:edit-2-fill', items: [ { label: '首页', n: 'remix:home-5-line', a: 'remix:home-5-fill' }, { label: '租房', n: 'remix:search-line', a: 'remix:search-fill' }, { label: '消息', n: 'remix:message-3-line', a: 'remix:message-3-fill' }, { label: '我的', n: 'remix:user-3-line', a: 'remix:user-3-fill' } ] }, { key: 'D', title: 'Lucide 轻细线条', desc: '精致细线条风格,克制优雅;「发房」= 房子+加号(线条)', source: 'lucide', pub: 'lucide:house-plus', items: [ { label: '首页', n: 'lucide:house', a: 'lucide:house' }, { label: '租房', n: 'lucide:search', a: 'lucide:search' }, { label: '消息', n: 'lucide:message-square', a: 'lucide:message-square' }, { label: '我的', n: 'lucide:user', a: 'lucide:user' } ] }, { key: 'E', title: 'Ionicons iOS 经典', desc: 'iOS 系统同源图标,实心/描边双态;「发房」= 铅笔', source: 'ionicons', pub: 'ionicons:create', items: [ { label: '首页', n: 'ionicons:home-outline', a: 'ionicons:home' }, { label: '租房', n: 'ionicons:search-outline', a: 'ionicons:search' }, { label: '消息', n: 'ionicons:chatbox-ellipses-outline', a: 'ionicons:chatbox-ellipses' }, { label: '我的', n: 'ionicons:person-outline', a: 'ionicons:person' } ] }, { key: 'F', title: 'Mingcute 圆润可爱', desc: '圆头线条/实心双态,造型年轻活泼;「发房」= 铅笔编辑', source: 'mingcute', pub: 'mingcute:edit-2-fill', items: [ { label: '首页', n: 'mingcute:home-1-line', a: 'mingcute:home-1-fill' }, { label: '租房', n: 'mingcute:search-2-line', a: 'mingcute:search-2-fill' }, { label: '消息', n: 'mingcute:chat-1-line', a: 'mingcute:chat-1-fill' }, { label: '我的', n: 'mingcute:user-3-line', a: 'mingcute:user-3-fill' } ] } ]; // 预加载所有源 const dataCache = {}; for (const sid of Object.keys(SOURCES)) { try { dataCache[sid] = load(sid); } catch (e) { console.error('加载失败 ' + sid); process.exit(1); } } // 发房按钮:红色渐变圆钮 + 匹配图标(白色) function pubBtn(sol) { const src = SOURCES[sol.source]; const ic = findIcon(dataCache[sol.source], sol.pub); if (!ic) { missList.push(sol.pub); return '
+
'; } return '
' + renderSVG(ic, src, '#ffffff') + '
'; } let cards = ''; const missList = []; for (const sol of SOLUTIONS) { const src = SOURCES[sol.source]; const res = []; for (const it of sol.items) { const nIc = findIcon(dataCache[sol.source], it.n); const aIc = findIcon(dataCache[sol.source], it.a); if (!nIc) missList.push(it.n); if (!aIc) missList.push(it.a); res.push({ label: it.label, normal: nIc ? renderSVG(nIc, src, GRAY) : '', active: aIc ? renderSVG(aIc, src, RED) : '' }); } const plus = pubBtn(sol); // 常规态 TabBar mock const arrNormal = [res[0], res[1], null, res[2], res[3]]; const barActive = `
` + arrNormal.map((r, i) => r ? `
${i === 0 ? r.active : r.normal}
${r.label}
` : `
${plus}
发房
`) .join('') + `
`; const barNormalFull = `
` + arrNormal.map(r => r ? `
${r.normal}
${r.label}
` : `
${plus}
发房
`) .join('') + `
`; const ids = [...sol.items.map(it => it.n), ...sol.items.map(it => it.a)].join('、'); cards += `
方案 ${sol.key}${sol.title}
${sol.desc}
常规态
${barNormalFull}
选中态(首页高亮)
${barActive}
${res.map(r => `
${r.normal}
${r.label}·未选
${r.active}
${r.label}·选中
`).join('')}
图标:${ids}
`; } const html = ` 小虎租房 · 底部导航图标方案

小虎租房 · 底部导航图标方案

数据来自「画个标」内置图标库 · 共 6 套方案 · 未选中 #999999 / 选中 ${RED}(品牌红)·「发房」红色圆钮内置匹配图标(房子+加号/铅笔编辑)
${cards} `; fs.writeFileSync('D:/SGP_KF3/ruyizu_web/docs/tabbar-icons-preview.html', html, 'utf8'); if (missList.length) console.log('缺失图标: ' + missList.join(', ')); else console.log('OK,已生成 docs/tabbar-icons-preview.html(' + SOLUTIONS.length + ' 套方案,全部图标命中)');