feat(uniapp): 小程序端(用户端 uni-app)源码入库到 uniapp/ 目录
需求:小程序端代码要同时同步到服务器与 git 远程仓库,此前前端仅存在于本地目录(无 remote,从未推送), 服务器与 gitcode 上只有后端。现并入本仓库,复用现有「push 即部署」链路,一次推送双端落地。 - 新增 uniapp/:小程序端源码全量快照(150 文件 / 1.2M) pages(13 页面) · components(fc-navbar/fc-tabbar/fc-post-card/fc-empty) · common(api·utils·mock·assets·store·config) · static(74 图标 + 3 轮播插画 + LOGO) · docs(01-04 交付文档) · tests(零依赖全链路用例) · tools(图标/主题/轮播配图生成脚本) - 明确排除:AGENTS.md(含后台密码、服务器 root 密码、小程序 AppSecret,切勿入库)、 unpackage/(构建产物,由 uniapp/.gitignore 忽略)、node_modules、.DS_Store、*.log - .gitignore 新增 /uniapp/AGENTS.md 兜底(与根 /AGENTS.md、/fluniapp/ 同一约定) - README.md 增补「本项目结构 + 部署链路」章节,说明 uniapp/ 为源码快照、 小程序真正上线仍需微信开发者工具 cli upload 说明:本次为源码快照,未携带前端本地仓库历史——其历史提交中含 AGENTS.md 凭据, 若做 subtree 合并会把密码永久写入本仓库历史,故采用快照方式。
这个提交包含在:
29
uniapp/tools/banner-art.mjs
普通文件
29
uniapp/tools/banner-art.mjs
普通文件
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 轮播配图(白色插画)源 · v1
|
||||
* ------------------------------------------------------------
|
||||
* 设计立意:轮播卡的大圆徽章里放「白色大插画」,与品牌 LOGO 的白色定位针同一手法:
|
||||
* · 插画只取白 + 极浅薄荷两档,压在生态绿渐变上对比度约 5:1,白得干净、绿得更深;
|
||||
* · 图形直接复用 `icon-svg.mjs` 的 ART 母版,轮播与全站图标同一套造型语言;
|
||||
* · 卡片底色 / 圆环 / 远山 / 光晕全部由页面 CSS 绘制(颜色随后台 `color` 字段走),
|
||||
* 因此本轮只产出 3 张「透明底、纯白插画」的 PNG(约 5KB/张),不给小程序包体添负担。
|
||||
* 占位符 {c1} {c2} {c3} 由生成器替换。
|
||||
*/
|
||||
import { ART } from './icon-svg.mjs'
|
||||
|
||||
/** id/art 与首页 3 张内置轮播一一对应(二手 / 招聘 / 本地服务上门) */
|
||||
export const BANNER_ART = [
|
||||
{ id: 1, file: 'banner-art-1.png', art: 'box', c1: '#FFFFFF', c2: '#CDF8E4' },
|
||||
{ id: 2, file: 'banner-art-2.png', art: 'briefcase', c1: '#FFFFFF', c2: '#A9F2CE' },
|
||||
{ id: 3, file: 'banner-art-3.png', art: 'house', c1: '#CDF8E4', c2: '#FFFFFF' },
|
||||
]
|
||||
|
||||
/** 生成一版 SVG(backdrop 用于两次渲染,白底/黑底反解 alpha) */
|
||||
export function buildBannerArtSvg(def, backdrop) {
|
||||
const art = ART[def.art].replace(/\{(c1|c2|c3)\}/g, (_, k) => ({ c1: def.c1, c2: def.c2, c3: '#FFFFFF' })[k])
|
||||
return (
|
||||
`<svg xmlns="http://www.w3.org/2000/svg" width="384" height="384" viewBox="0 0 96 96">` +
|
||||
`<rect x="0" y="0" width="96" height="96" fill="${backdrop}"/>` +
|
||||
art +
|
||||
'</svg>'
|
||||
)
|
||||
}
|
||||
50
uniapp/tools/check-scss.cjs
普通文件
50
uniapp/tools/check-scss.cjs
普通文件
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* SCSS 语法校验
|
||||
* 用 HBuilderX 内置 dart-sass 编译每个 .vue 的 <style lang="scss">,
|
||||
* 并注入 uni.scss 变量(模拟 uni-app 的全局注入行为)。
|
||||
* 运行: node tools/check-scss.cjs
|
||||
*/
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const { execFileSync } = require('child_process')
|
||||
|
||||
const HX = '/Applications/HBuilderX.app/Contents/HBuilderX'
|
||||
const NODE = path.join(HX, 'plugins/node/node')
|
||||
const SASS = path.join(HX, 'plugins/compile-dart-sass/node_modules/sass/sass.js')
|
||||
const ROOT = path.resolve(__dirname, '..')
|
||||
const vars = fs.readFileSync(path.join(ROOT, 'uni.scss'), 'utf8')
|
||||
|
||||
const SKIP = ['node_modules', 'unpackage', '.git', 'static', 'tools', 'tests', 'docs']
|
||||
function walk(dir, out = []) {
|
||||
for (const n of fs.readdirSync(dir)) {
|
||||
if (SKIP.includes(n)) continue
|
||||
const p = path.join(dir, n)
|
||||
const st = fs.statSync(p)
|
||||
if (st.isDirectory()) walk(p, out)
|
||||
else if (n.endsWith('.vue')) out.push(p)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
let ok = 0
|
||||
const failed = []
|
||||
for (const f of walk(ROOT)) {
|
||||
const src = fs.readFileSync(f, 'utf8')
|
||||
const m = src.match(/<style[^>]*lang="scss"[^>]*>([\s\S]*?)<\/style>/)
|
||||
if (!m) continue
|
||||
const rel = path.relative(ROOT, f)
|
||||
try {
|
||||
execFileSync(NODE, [SASS, '--stdin', '--no-source-map', '--quiet'], {
|
||||
input: vars + '\n' + m[1],
|
||||
stdio: ['pipe', 'ignore', 'pipe'],
|
||||
})
|
||||
ok++
|
||||
console.log(' OK ' + rel)
|
||||
} catch (e) {
|
||||
failed.push(rel)
|
||||
const msg = String(e.stderr || e.message).split('\n').slice(0, 3).join(' | ')
|
||||
console.log(' FAIL ' + rel + '\n ' + msg)
|
||||
}
|
||||
}
|
||||
console.log('\nSCSS 编译通过 ' + ok + ' 个,失败 ' + failed.length + ' 个')
|
||||
process.exitCode = failed.length ? 1 : 0
|
||||
79
uniapp/tools/gen-banner-art.mjs
普通文件
79
uniapp/tools/gen-banner-art.mjs
普通文件
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* 轮播配图(白色插画)生成器
|
||||
* ------------------------------------------------------------
|
||||
* 与 gen-icons.mjs 完全同一套链路:同一份 SVG 渲染「白底」「黑底」两遍 →
|
||||
* 两式联立解出真实 alpha → contentBox 定位内容区 → 2× 降采样 → 192×192 真实透明 PNG。
|
||||
* 运行: node tools/gen-banner-art.mjs
|
||||
*/
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import os from 'node:os'
|
||||
import url from 'node:url'
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { BANNER_ART, buildBannerArtSvg } from './banner-art.mjs'
|
||||
import { decodePng, encodePng, extractAlpha, transparentRatio, contentBox, crop, downscale } from './png-util.mjs'
|
||||
|
||||
const ROOT = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), '..')
|
||||
const OUT_DIR = path.join(ROOT, 'static', 'banners')
|
||||
const SIZE = 384 // 渲染分辨率(96 坐标系 → 4×)
|
||||
const TARGET = 192 // 最终输出边长
|
||||
const TMP = fs.mkdtempSync(path.join(os.tmpdir(), 'fc-bannerart-'))
|
||||
const SRC = path.join(TMP, 'src')
|
||||
const RST = path.join(TMP, 'out')
|
||||
fs.mkdirSync(SRC, { recursive: true })
|
||||
fs.mkdirSync(RST, { recursive: true })
|
||||
fs.mkdirSync(OUT_DIR, { recursive: true })
|
||||
|
||||
/* 1. 两版 SVG */
|
||||
const names = []
|
||||
for (const def of BANNER_ART) {
|
||||
const base = def.file.replace(/\.png$/, '')
|
||||
fs.writeFileSync(path.join(SRC, `${base}__w.svg`), buildBannerArtSvg(def, '#FFFFFF'), 'utf8')
|
||||
fs.writeFileSync(path.join(SRC, `${base}__b.svg`), buildBannerArtSvg(def, '#000000'), 'utf8')
|
||||
names.push(base)
|
||||
}
|
||||
|
||||
/* 2. 渲染(qlmanage 会把内容贴到正方形画布上,其余补白,用 contentBox 裁掉) */
|
||||
try {
|
||||
execFileSync(
|
||||
'qlmanage',
|
||||
['-t', '-s', String(SIZE), '-o', RST, ...names.flatMap((n) => [path.join(SRC, `${n}__w.svg`), path.join(SRC, `${n}__b.svg`)])],
|
||||
{ stdio: 'ignore' },
|
||||
)
|
||||
} catch (e) {
|
||||
/* 忽略,后续按产物校验 */
|
||||
}
|
||||
|
||||
/* 3. 反解 alpha -> 透明 PNG */
|
||||
let ok = 0
|
||||
const missing = []
|
||||
const lowAlpha = []
|
||||
const sizeSet = new Set()
|
||||
for (const n of names) {
|
||||
const fw = path.join(RST, `${n}__w.svg.png`)
|
||||
const fb = path.join(RST, `${n}__b.svg.png`)
|
||||
if (!fs.existsSync(fw) || !fs.existsSync(fb)) {
|
||||
missing.push(n)
|
||||
continue
|
||||
}
|
||||
const black = decodePng(fs.readFileSync(fb))
|
||||
const box = contentBox(black)
|
||||
let img = extractAlpha(crop(decodePng(fs.readFileSync(fw)), box), crop(black, box))
|
||||
img = downscale(img, Math.max(1, Math.floor(img.width / TARGET)))
|
||||
const ratio = transparentRatio(img)
|
||||
if (ratio < 0.1) lowAlpha.push(`${n}(${ratio.toFixed(2)})`)
|
||||
fs.writeFileSync(path.join(OUT_DIR, `${n}.png`), encodePng(img))
|
||||
sizeSet.add(`${img.width}×${img.height}`)
|
||||
ok++
|
||||
}
|
||||
|
||||
fs.rmSync(TMP, { recursive: true, force: true })
|
||||
|
||||
const bytes = fs
|
||||
.readdirSync(OUT_DIR)
|
||||
.filter((f) => f.endsWith('.png'))
|
||||
.reduce((s, f) => s + fs.statSync(path.join(OUT_DIR, f)).size, 0)
|
||||
console.log(`✅ 轮播配图生成完成:${ok}/${names.length} 张 → static/banners/(${[...sizeSet].join(', ')},真实透明,合计 ${(bytes / 1024).toFixed(1)}KB)`)
|
||||
if (missing.length) console.log(`⚠️ 未生成:${missing.join(', ')}`)
|
||||
if (lowAlpha.length) console.log(`⚠️ 透明区域异常:${lowAlpha.join(', ')}`)
|
||||
if (missing.length) process.exitCode = 1
|
||||
136
uniapp/tools/gen-icons.mjs
普通文件
136
uniapp/tools/gen-icons.mjs
普通文件
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* 配图资源生成器 v3
|
||||
* ------------------------------------------------------------
|
||||
* 1. 每个图标用同一份 SVG 渲染「白底」「黑底」两次
|
||||
* 2. 通过两式联立解出真实 alpha(见 tools/png-util.mjs)→ 得到精确抗锯齿的透明 PNG
|
||||
* 3. 徽章类图形使用「垂直渐变圆角底」,提升质感与统一性
|
||||
* 运行: node tools/gen-icons.mjs
|
||||
*/
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import os from 'node:os'
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import url from 'node:url'
|
||||
import { ART, OUTPUTS } from './icon-svg.mjs'
|
||||
import { decodePng, encodePng, extractAlpha, transparentRatio, contentBox, crop, downscale } from './png-util.mjs'
|
||||
|
||||
const ROOT = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), '..')
|
||||
const OUT_DIR = path.join(ROOT, 'static', 'icons')
|
||||
const SIZE = 384 // 渲染分辨率
|
||||
const TARGET = 192 // 最终输出边长(2 倍降采样,锐度与体积兼顾)
|
||||
const BADGE_SCALE = 0.66
|
||||
const BADGE_OFFSET = (96 - 96 * BADGE_SCALE) / 2
|
||||
const TMP = fs.mkdtempSync(path.join(os.tmpdir(), 'fc-illus-'))
|
||||
const SRC = path.join(TMP, 'src')
|
||||
const RST = path.join(TMP, 'out')
|
||||
fs.mkdirSync(SRC, { recursive: true })
|
||||
fs.mkdirSync(RST, { recursive: true })
|
||||
fs.mkdirSync(OUT_DIR, { recursive: true })
|
||||
|
||||
/** 调色板替换 */
|
||||
function paint(art, item) {
|
||||
const p = { c1: item.c1, c2: item.c2 || item.c1, c3: item.c3 || '#FFFFFF' }
|
||||
return art.replace(/\{(c1|c2|c3)\}/g, (_, k) => p[k])
|
||||
}
|
||||
|
||||
/** 生成一版 SVG:backdrop 用于两次渲染(白 / 黑) */
|
||||
function buildSvg(item, backdrop) {
|
||||
const body = paint(ART[item.art], item)
|
||||
const head = `<svg xmlns="http://www.w3.org/2000/svg" width="${SIZE}" height="${SIZE}" viewBox="0 0 96 96">`
|
||||
// 底色层:徽章用渐变圆角块,其余用纯色 backdrop 便于抠出 alpha
|
||||
let layer
|
||||
if (item.bg) {
|
||||
layer =
|
||||
`<defs><linearGradient id="g" x1="0" y1="0" x2="0.35" y2="1">` +
|
||||
`<stop offset="0" stop-color="${item.bg[0]}"/><stop offset="1" stop-color="${item.bg[1]}"/>` +
|
||||
`</linearGradient></defs>` +
|
||||
`<rect x="0" y="0" width="96" height="96" rx="30" fill="url(#g)"/>`
|
||||
} else {
|
||||
layer = ''
|
||||
}
|
||||
const base = `<rect x="0" y="0" width="96" height="96" fill="${backdrop}"/>`
|
||||
// 徽章类:插画缩到 66% 居中,四周留出圆角底
|
||||
// 透明类:插画铺满画布,保证在 CSS 给定尺寸下的视觉重量
|
||||
const inner = item.bg
|
||||
? `<g transform="translate(${BADGE_OFFSET.toFixed(2)},${BADGE_OFFSET.toFixed(2)}) scale(${BADGE_SCALE})">${body}</g>`
|
||||
: body
|
||||
return head + base + layer + inner + '</svg>'
|
||||
}
|
||||
|
||||
/** 品牌 LOGO */
|
||||
const LOGO_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512">
|
||||
<defs><linearGradient id="g" x1="0" y1="0" x2="0.4" y2="1">
|
||||
<stop offset="0" stop-color="#00E070"/><stop offset="0.5" stop-color="#00A855"/><stop offset="1" stop-color="#046B3B"/>
|
||||
</linearGradient></defs>
|
||||
<rect width="512" height="512" rx="112" fill="url(#g)"/>
|
||||
<path d="M256 404C340 330 370 272 370 222A114 114 0 1 0 142 222C142 272 172 330 256 404Z" fill="#ffffff"/>
|
||||
<g fill="#F5A623">
|
||||
<rect x="188" y="178" width="136" height="22" rx="11"/>
|
||||
<rect x="188" y="226" width="96" height="22" rx="11"/>
|
||||
<rect x="188" y="274" width="120" height="22" rx="11"/>
|
||||
</g></svg>`
|
||||
|
||||
// 1. 生成两版 SVG
|
||||
const names = []
|
||||
for (const item of OUTPUTS) {
|
||||
const base = item.file.replace(/\.png$/, '')
|
||||
fs.writeFileSync(path.join(SRC, `${base}__w.svg`), buildSvg(item, '#FFFFFF'), 'utf8')
|
||||
fs.writeFileSync(path.join(SRC, `${base}__b.svg`), buildSvg(item, '#000000'), 'utf8')
|
||||
names.push(base)
|
||||
}
|
||||
fs.writeFileSync(path.join(SRC, 'logo__w.svg'), LOGO_SVG.replace('<path d="M256', '<path d="M256'), 'utf8')
|
||||
|
||||
// 2. 批量渲染
|
||||
function render(list, size) {
|
||||
for (let i = 0; i < list.length; i += 12) {
|
||||
const chunk = list.slice(i, i + 12).map((n) => path.join(SRC, n))
|
||||
try {
|
||||
execFileSync('qlmanage', ['-t', '-s', String(size), '-o', RST, ...chunk], { stdio: 'ignore' })
|
||||
} catch (e) {
|
||||
/* 忽略,后续按产物校验 */
|
||||
}
|
||||
}
|
||||
}
|
||||
render(names.map((n) => `${n}__w.svg`).concat(names.map((n) => `${n}__b.svg`)), SIZE)
|
||||
render(['logo__w.svg'], 512)
|
||||
|
||||
// 3. 两式联立 -> 透明 PNG
|
||||
let ok = 0
|
||||
const missing = []
|
||||
const lowAlpha = []
|
||||
const sizes = new Set()
|
||||
for (const n of names) {
|
||||
const fw = path.join(RST, `${n}__w.svg.png`)
|
||||
const fb = path.join(RST, `${n}__b.svg.png`)
|
||||
if (!fs.existsSync(fw) || !fs.existsSync(fb)) { missing.push(n); continue }
|
||||
const black = decodePng(fs.readFileSync(fb))
|
||||
// qlmanage 会把内容渲染到子矩形并补白衬,先用黑底图定位真实内容区
|
||||
const box = contentBox(black)
|
||||
let img = extractAlpha(crop(decodePng(fs.readFileSync(fw)), box), crop(black, box))
|
||||
// 整数倍降采样到目标尺寸
|
||||
const factor = Math.max(1, Math.floor(img.width / TARGET))
|
||||
img = downscale(img, factor)
|
||||
const ratio = transparentRatio(img)
|
||||
sizes.add(`${img.width}x${img.height}`)
|
||||
// 非徽章类图标应当有明显透明区域(徽章类自带圆角底,透明仅出现在四角)
|
||||
const item = OUTPUTS.find((o) => o.file === `${n}.png`)
|
||||
if (!item.bg && ratio < 0.1) lowAlpha.push(`${n}(${ratio.toFixed(2)})`)
|
||||
fs.writeFileSync(path.join(OUT_DIR, `${n}.png`), encodePng(img))
|
||||
ok++
|
||||
}
|
||||
|
||||
// 4. LOGO(白底渲染 -> 裁剪 -> 直接使用,自身不透明)
|
||||
const logoW = path.join(RST, 'logo__w.svg.png')
|
||||
if (fs.existsSync(logoW)) {
|
||||
const limg = decodePng(fs.readFileSync(logoW))
|
||||
fs.writeFileSync(path.join(ROOT, 'static', 'logo.png'), encodePng(crop(limg, contentBox(limg))))
|
||||
}
|
||||
const legacy = path.join(ROOT, 'static', 'logo-512.png')
|
||||
if (fs.existsSync(legacy)) fs.rmSync(legacy, { force: true })
|
||||
|
||||
fs.rmSync(TMP, { recursive: true, force: true })
|
||||
|
||||
console.log(`✅ 配图生成完成:${ok}/${names.length} 个 → static/icons/(${[...sizes].join(', ')},真实透明)`)
|
||||
if (missing.length) console.log(`⚠️ 未生成:${missing.join(', ')}`)
|
||||
if (lowAlpha.length) console.log(`⚠️ 透明区域异常:${lowAlpha.join(', ')}`)
|
||||
console.log('✅ LOGO 生成:static/logo.png')
|
||||
333
uniapp/tools/icon-svg.mjs
普通文件
333
uniapp/tools/icon-svg.mjs
普通文件
@@ -0,0 +1,333 @@
|
||||
/**
|
||||
* 配图源(96×96 viewBox)· 专业扁平插画 v2
|
||||
* ------------------------------------------------------------
|
||||
* 设计语言:
|
||||
* 1) 纯填充色块,无细描边;形体饱满、笔画厚重,小尺寸下依然清晰
|
||||
* 2) 每张图仅用「主色 c1 + 深色 c2 + 纯白高光」三档,配色统一、画面干净
|
||||
* 3) 图形占画布 6%~90%,保证在 36rpx 与 96rpx 两种场景下视觉重量一致
|
||||
* 4) 徽章类使用「浅色垂直渐变圆角底」,提升质感与统一性
|
||||
* 占位符 {c1} {c2} {c3} 由生成器按调色板替换。
|
||||
*/
|
||||
export const ART = {
|
||||
// ==================== 底部导航 ====================
|
||||
home:
|
||||
'<path d="M48 8 90 44a7 7 0 0 1-5 12H11a7 7 0 0 1-5-12z" fill="{c2}"/>' +
|
||||
'<rect x="18" y="52" width="60" height="36" rx="10" fill="{c1}"/>' +
|
||||
'<rect x="38" y="64" width="20" height="24" rx="7" fill="#FFFFFF"/>',
|
||||
|
||||
plusCircle:
|
||||
'<circle cx="48" cy="48" r="38" fill="{c1}"/>' +
|
||||
'<path d="M48 30v36M30 48h36" stroke="{c3}" stroke-width="12" stroke-linecap="round" fill="none"/>',
|
||||
|
||||
plusLine:
|
||||
'<path d="M48 16v64M16 48h64" stroke="{c1}" stroke-width="15" stroke-linecap="round" fill="none"/>',
|
||||
|
||||
comment:
|
||||
'<path d="M16 16h64a12 12 0 0 1 12 12v30a12 12 0 0 1-12 12H48l-20 16V70H16A12 12 0 0 1 4 58V28A12 12 0 0 1 16 16z" fill="{c1}"/>' +
|
||||
'<circle cx="32" cy="43" r="5.5" fill="#FFFFFF"/>' +
|
||||
'<circle cx="48" cy="43" r="5.5" fill="#FFFFFF"/>' +
|
||||
'<circle cx="64" cy="43" r="5.5" fill="#FFFFFF"/>',
|
||||
|
||||
person:
|
||||
'<circle cx="48" cy="32" r="18" fill="{c2}"/>' +
|
||||
'<path d="M8 86a40 40 0 0 1 80 0z" fill="{c1}"/>',
|
||||
|
||||
// ==================== 同城分类 ====================
|
||||
briefcase:
|
||||
'<path d="M34 32V24a14 14 0 0 1 28 0v8h-10v-8a4 4 0 0 0-8 0v8z" fill="{c2}"/>' +
|
||||
'<rect x="6" y="30" width="84" height="54" rx="14" fill="{c1}"/>' +
|
||||
'<path d="M6 50h84v9H6z" fill="{c2}" opacity="0.38"/>' +
|
||||
'<rect x="40" y="49" width="16" height="12" rx="4" fill="#FFFFFF"/>',
|
||||
|
||||
house:
|
||||
'<path d="M48 8 90 44a7 7 0 0 1-5 12H11a7 7 0 0 1-5-12z" fill="{c2}"/>' +
|
||||
'<rect x="18" y="52" width="60" height="36" rx="10" fill="{c1}"/>' +
|
||||
'<rect x="38" y="64" width="20" height="24" rx="7" fill="#FFFFFF"/>' +
|
||||
'<rect x="24" y="62" width="10" height="10" rx="3" fill="#FFFFFF" opacity="0.85"/>',
|
||||
|
||||
box:
|
||||
'<path d="M48 50 88 29v37L48 88z" fill="{c2}"/>' +
|
||||
'<path d="M48 50 8 29v37l40 21z" fill="{c1}"/>' +
|
||||
'<path d="M48 8 88 29 48 50 8 29z" fill="#FFFFFF"/>',
|
||||
|
||||
car:
|
||||
'<path d="M22 52 29 34a11 11 0 0 1 10-7h18a11 11 0 0 1 10 7l7 18z" fill="{c2}"/>' +
|
||||
'<rect x="6" y="50" width="84" height="26" rx="13" fill="{c1}"/>' +
|
||||
'<rect x="20" y="55" width="22" height="13" rx="6" fill="#FFFFFF"/>' +
|
||||
'<rect x="54" y="55" width="22" height="13" rx="6" fill="#FFFFFF"/>' +
|
||||
'<circle cx="27" cy="80" r="11" fill="{c2}"/><circle cx="27" cy="80" r="4.5" fill="#FFFFFF"/>' +
|
||||
'<circle cx="69" cy="80" r="11" fill="{c2}"/><circle cx="69" cy="80" r="4.5" fill="#FFFFFF"/>',
|
||||
|
||||
gear:
|
||||
'<g fill="{c1}">' +
|
||||
'<rect x="41" y="2" width="14" height="22" rx="6"/>' +
|
||||
'<rect x="41" y="72" width="14" height="22" rx="6"/>' +
|
||||
'<rect x="2" y="41" width="22" height="14" rx="6"/>' +
|
||||
'<rect x="72" y="41" width="22" height="14" rx="6"/>' +
|
||||
'<rect x="41" y="2" width="14" height="22" rx="6" transform="rotate(45 48 48)"/>' +
|
||||
'<rect x="41" y="72" width="14" height="22" rx="6" transform="rotate(45 48 48)"/>' +
|
||||
'<rect x="2" y="41" width="22" height="14" rx="6" transform="rotate(45 48 48)"/>' +
|
||||
'<rect x="72" y="41" width="22" height="14" rx="6" transform="rotate(45 48 48)"/>' +
|
||||
'<circle cx="48" cy="48" r="27"/></g>' +
|
||||
'<circle cx="48" cy="48" r="11" fill="#FFFFFF"/>',
|
||||
|
||||
graduation:
|
||||
'<path d="M48 10 94 34 48 58 2 34z" fill="{c1}"/>' +
|
||||
'<path d="M22 44v20c0 9 12 15 26 15s26-6 26-15V44L48 58z" fill="{c2}"/>' +
|
||||
'<path d="M84 36v22" stroke="{c2}" stroke-width="7" stroke-linecap="round" fill="none"/>' +
|
||||
'<circle cx="84" cy="64" r="7" fill="{c1}"/>',
|
||||
|
||||
sparkle:
|
||||
'<path d="M30 4 36.5 21 53.5 27.5 36.5 34 30 51 23.5 34 6.5 27.5 23.5 21z" fill="{c1}"/>' +
|
||||
'<path d="M71 22 76 36.5 90.5 41.5 76 46.5 71 61 66 46.5 51.5 41.5 66 36.5z" fill="{c2}"/>' +
|
||||
'<path d="M46 50 51.5 64 65.5 69.5 51.5 75 46 89 40.5 75 26.5 69.5 40.5 64z" fill="{c1}" opacity="0.72"/>',
|
||||
|
||||
heart:
|
||||
'<path d="M48 86S6 60 6 36A22 22 0 0 1 48 26 22 22 0 0 1 90 36c0 24-42 50-42 50z" fill="{c1}"/>' +
|
||||
'<ellipse cx="30" cy="33" rx="9" ry="6.5" fill="#FFFFFF" opacity="0.6" transform="rotate(-28 30 33)"/>',
|
||||
|
||||
// ==================== 定位 / 搜索 / 消息 ====================
|
||||
pin:
|
||||
'<path d="M48 4C25 4 6 23 6 46c0 30 42 50 42 50s42-20 42-50C90 23 71 4 48 4z" fill="{c1}"/>' +
|
||||
'<circle cx="48" cy="44" r="16" fill="{c3}"/>',
|
||||
|
||||
search:
|
||||
'<circle cx="42" cy="42" r="30" fill="{c3}"/>' +
|
||||
'<circle cx="42" cy="42" r="30" fill="none" stroke="{c1}" stroke-width="10"/>' +
|
||||
'<path d="M64 64 88 88" stroke="{c1}" stroke-width="13" stroke-linecap="round" fill="none"/>',
|
||||
|
||||
bell:
|
||||
'<path d="M48 8a27 27 0 0 1 27 27c0 17 7 24 7 24H14s7-7 7-24A27 27 0 0 1 48 8z" fill="{c1}"/>' +
|
||||
'<path d="M36 76a12 12 0 0 0 24 0z" fill="{c2}"/>' +
|
||||
'<circle cx="48" cy="5" r="6" fill="{c2}"/>',
|
||||
|
||||
crown:
|
||||
'<path d="M8 30 28 46 48 12l20 34 20-16v42a10 10 0 0 1-10 10H18a10 10 0 0 1-10-10z" fill="{c1}"/>' +
|
||||
'<circle cx="48" cy="12" r="7.5" fill="{c2}"/>' +
|
||||
'<circle cx="8" cy="28" r="7.5" fill="{c2}"/>' +
|
||||
'<circle cx="88" cy="28" r="7.5" fill="{c2}"/>',
|
||||
|
||||
// ==================== 通用功能 ====================
|
||||
check:
|
||||
'<circle cx="48" cy="48" r="40" fill="{c1}"/>' +
|
||||
'<path d="M28 49 42 63 69 34" stroke="#FFFFFF" stroke-width="10" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',
|
||||
|
||||
shield:
|
||||
'<path d="M48 4 92 20v30c0 24-18 40-44 46C22 90 4 74 4 50V20z" fill="{c1}"/>' +
|
||||
'<path d="M30 47 43 60 67 34" stroke="#FFFFFF" stroke-width="9" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',
|
||||
|
||||
picture:
|
||||
'<rect x="4" y="14" width="88" height="68" rx="16" fill="{c1}"/>' +
|
||||
'<circle cx="30" cy="36" r="9" fill="#FFFFFF"/>' +
|
||||
'<path d="M12 76 40 46l15 15 13-13 14 28z" fill="{c2}"/>',
|
||||
|
||||
wallet:
|
||||
'<rect x="2" y="18" width="92" height="62" rx="16" fill="{c1}"/>' +
|
||||
'<path d="M18 18h60a16 16 0 0 1 16 16v4H2v-4a16 16 0 0 1 16-16z" fill="{c2}"/>' +
|
||||
'<rect x="58" y="46" width="36" height="20" rx="10" fill="#FFFFFF"/>',
|
||||
|
||||
paywechat:
|
||||
'<rect x="4" y="4" width="88" height="88" rx="28" fill="{c1}"/>' +
|
||||
'<path d="M26 30 48 53 70 30M48 53v22M33 61h30" stroke="#FFFFFF" stroke-width="8" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',
|
||||
|
||||
phone:
|
||||
'<g transform="scale(4)"><path d="M20.5 16.9v2.6a1.8 1.8 0 0 1-2 1.8 18 18 0 0 1-7.8-2.8 17.6 17.6 0 0 1-5.4-5.4A18 18 0 0 1 2.5 5.3a1.8 1.8 0 0 1 1.8-2h2.6a1.8 1.8 0 0 1 1.8 1.6c.1.9.3 1.7.6 2.5a1.8 1.8 0 0 1-.4 1.9L8 10.2a14.4 14.4 0 0 0 5.4 5.4l.9-.9a1.8 1.8 0 0 1 1.9-.4c.8.3 1.6.5 2.5.6a1.8 1.8 0 0 1 1.8 1.9z" fill="{c1}"/></g>',
|
||||
|
||||
phonebind:
|
||||
'<rect x="22" y="2" width="52" height="92" rx="15" fill="{c1}"/>' +
|
||||
'<rect x="40" y="12" width="16" height="6" rx="3" fill="{c2}"/>' +
|
||||
'<rect x="30" y="26" width="36" height="48" rx="8" fill="#FFFFFF"/>',
|
||||
|
||||
lock:
|
||||
'<path d="M28 46V32a20 20 0 0 1 40 0v14h-11V32a9 9 0 0 0-18 0v14z" fill="{c2}"/>' +
|
||||
'<rect x="8" y="42" width="80" height="52" rx="15" fill="{c1}"/>' +
|
||||
'<circle cx="48" cy="63" r="8" fill="#FFFFFF"/>' +
|
||||
'<rect x="43.5" y="66" width="9" height="15" rx="4.5" fill="#FFFFFF"/>',
|
||||
|
||||
star:
|
||||
'<path d="M48 4 61.5 36 96 40 70.5 63 77.5 96 48 79 18.5 96 25.5 63 0 40 34.5 36z" fill="{c1}"/>',
|
||||
|
||||
starO:
|
||||
'<path d="M48 4 61.5 36 96 40 70.5 63 77.5 96 48 79 18.5 96 25.5 63 0 40 34.5 36z" fill="{c3}"/>' +
|
||||
'<path d="M48 4 61.5 36 96 40 70.5 63 77.5 96 48 79 18.5 96 25.5 63 0 40 34.5 36z" fill="none" stroke="{c1}" stroke-width="7" stroke-linejoin="round"/>',
|
||||
|
||||
close:
|
||||
'<circle cx="48" cy="48" r="38" fill="{c3}"/>' +
|
||||
'<path d="M33 33 63 63M63 33 33 63" stroke="{c1}" stroke-width="10" stroke-linecap="round" fill="none"/>',
|
||||
|
||||
fire:
|
||||
'<path d="M50 4c9 14 24 25 24 43a26 26 0 0 1-52 0c0-7 3-13 7-19 2 5 6 8 10 9-3-12 3-24 11-33z" fill="{c1}"/>' +
|
||||
'<path d="M48 56c4.5 3.8 7 7.4 7 11.6a7 7 0 0 1-14 0c0-4.2 2.5-7.8 7-11.6z" fill="{c2}"/>',
|
||||
|
||||
share:
|
||||
'<circle cx="72" cy="18" r="15" fill="{c1}"/>' +
|
||||
'<circle cx="24" cy="48" r="15" fill="{c1}"/>' +
|
||||
'<circle cx="72" cy="78" r="15" fill="{c1}"/>' +
|
||||
'<path d="M36 41 60 25M36 55 60 71" stroke="{c2}" stroke-width="9" stroke-linecap="round" fill="none"/>',
|
||||
|
||||
qrcode:
|
||||
'<rect x="6" y="6" width="34" height="34" rx="10" fill="{c1}"/>' +
|
||||
'<rect x="56" y="6" width="34" height="34" rx="10" fill="{c1}"/>' +
|
||||
'<rect x="6" y="56" width="34" height="34" rx="10" fill="{c1}"/>' +
|
||||
'<rect x="18" y="18" width="10" height="10" rx="3" fill="#FFFFFF"/>' +
|
||||
'<rect x="68" y="18" width="10" height="10" rx="3" fill="#FFFFFF"/>' +
|
||||
'<rect x="18" y="68" width="10" height="10" rx="3" fill="#FFFFFF"/>' +
|
||||
'<rect x="56" y="56" width="16" height="16" rx="5" fill="{c2}"/>' +
|
||||
'<rect x="78" y="56" width="12" height="12" rx="4" fill="{c2}"/>' +
|
||||
'<rect x="56" y="78" width="34" height="12" rx="4" fill="{c2}"/>',
|
||||
|
||||
eye:
|
||||
'<path d="M4 48s19-27 44-27 44 27 44 27-19 27-44 27S4 48 4 48z" fill="{c3}"/>' +
|
||||
'<path d="M4 48s19-27 44-27 44 27 44 27-19 27-44 27S4 48 4 48z" fill="none" stroke="{c1}" stroke-width="7"/>' +
|
||||
'<circle cx="48" cy="48" r="13" fill="{c1}"/>' +
|
||||
'<circle cx="53" cy="43" r="5" fill="#FFFFFF"/>',
|
||||
|
||||
edit:
|
||||
'<path d="M72 6a14 14 0 0 1 20 20L34 84 6 92l8-28z" fill="{c1}"/>' +
|
||||
'<path d="M62 16 82 36" stroke="#FFFFFF" stroke-width="8" fill="none"/>',
|
||||
|
||||
folder:
|
||||
'<path d="M4 26a14 14 0 0 1 14-14h18l11 12h35a14 14 0 0 1 14 14v36a14 14 0 0 1-14 14H18A14 14 0 0 1 4 74z" fill="{c1}"/>' +
|
||||
'<path d="M4 34h88v8H4z" fill="{c2}" opacity="0.5"/>',
|
||||
|
||||
inbox:
|
||||
'<path d="M12 14h72l12 38v26a14 14 0 0 1-14 14H14A14 14 0 0 1 0 78V52z" fill="{c1}"/>' +
|
||||
'<path d="M0 52h26l8 14h28l8-14h26z" fill="#FFFFFF"/>',
|
||||
|
||||
users:
|
||||
'<circle cx="36" cy="30" r="19" fill="{c1}"/>' +
|
||||
'<path d="M0 86a36 36 0 0 1 72 0z" fill="{c1}"/>' +
|
||||
'<circle cx="74" cy="26" r="13" fill="{c2}"/>' +
|
||||
'<path d="M62 86a26 26 0 0 1 34 0z" fill="{c2}"/>',
|
||||
|
||||
info:
|
||||
'<circle cx="48" cy="48" r="40" fill="{c1}"/>' +
|
||||
'<circle cx="48" cy="28" r="6.5" fill="#FFFFFF"/>' +
|
||||
'<rect x="41.5" y="40" width="13" height="32" rx="6.5" fill="#FFFFFF"/>',
|
||||
|
||||
receipt:
|
||||
'<path d="M16 4h64v78l-11-9-11 9-11-9-11 9-10-9-10 9z" fill="{c1}"/>' +
|
||||
'<rect x="28" y="24" width="40" height="8" rx="4" fill="#FFFFFF"/>' +
|
||||
'<rect x="28" y="42" width="40" height="8" rx="4" fill="#FFFFFF"/>' +
|
||||
'<rect x="28" y="60" width="24" height="8" rx="4" fill="#FFFFFF"/>',
|
||||
|
||||
network:
|
||||
'<circle cx="16" cy="16" r="14" fill="{c1}"/>' +
|
||||
'<circle cx="16" cy="80" r="14" fill="{c1}"/>' +
|
||||
'<circle cx="80" cy="48" r="17" fill="{c2}"/>' +
|
||||
'<path d="M32 20h24a14 14 0 0 1 14 14v6" stroke="{c1}" stroke-width="9" fill="none" stroke-linecap="round"/>' +
|
||||
'<path d="M32 76h24a14 14 0 0 0 14-14v-6" stroke="{c1}" stroke-width="9" fill="none" stroke-linecap="round"/>',
|
||||
|
||||
store:
|
||||
'<path d="M4 38 15 8h66l11 30z" fill="{c2}"/>' +
|
||||
'<rect x="10" y="36" width="76" height="50" rx="10" fill="{c1}"/>' +
|
||||
'<rect x="34" y="58" width="28" height="28" rx="6" fill="#FFFFFF"/>',
|
||||
|
||||
card:
|
||||
'<rect x="2" y="18" width="92" height="60" rx="14" fill="{c1}"/>' +
|
||||
'<path d="M2 32h92v14H2z" fill="{c2}"/>' +
|
||||
'<rect x="16" y="58" width="28" height="11" rx="5.5" fill="#FFFFFF"/>',
|
||||
}
|
||||
/**
|
||||
* 输出清单(文件与注册表 key 一一对应)· 春绿配色 v4
|
||||
* file: 输出文件名 | art: ART 图形 | c1: 主色 | c2: 第二色 | c3: 高光
|
||||
* bg: [浅, 深] 垂直渐变圆角底(存在即为「配图徽章」,透明底则省略)
|
||||
*
|
||||
* 配色规范(Spring Green):
|
||||
* · 常态/次要 = 灰绿 #7C9A8B / #A5BFB0(低饱和,不抢视线)
|
||||
* · 品牌件 = 春绿 #04874A(深 #046B3B / 亮 #049E52;亮绿 #00E070 只做 CSS 面,不做图形)
|
||||
* · 分类图标 = 统一绿系(8 色相微差,保证品牌一致),仅「同城交友」点缀暖金
|
||||
* · 会员/热度/收藏/余额 = 阳光金 #F5A623(金只给“值得关注”的信息)
|
||||
* · 徽章底色 = 浅绿渐变(#E9FEF3 → #CFF7E3 一族),金类徽章用浅金渐变
|
||||
*/
|
||||
export const OUTPUTS = [
|
||||
// ---------- 底部导航(灰绿常态 / 品牌绿选中态) ----------
|
||||
{ file: 'tab-home.png', art: 'home', c1: '#7C9A8B', c2: '#B4CDC0', c3: '#FFFFFF' },
|
||||
{ file: 'tab-home-on.png', art: 'home', c1: '#04874A', c2: '#A9F2CE', c3: '#FFFFFF' },
|
||||
{ file: 'tab-post.png', art: 'plusCircle', c1: '#7C9A8B', c3: '#FFFFFF' },
|
||||
{ file: 'tab-post-on.png', art: 'plusCircle', c1: '#04874A', c3: '#FFFFFF' },
|
||||
{ file: 'plus-white.png', art: 'plusLine', c1: '#FFFFFF' },
|
||||
{ file: 'plus-ink.png', art: 'plusLine', c1: '#04301E' },
|
||||
{ file: 'tab-message.png', art: 'comment', c1: '#7C9A8B', c3: '#FFFFFF' },
|
||||
{ file: 'tab-message-on.png', art: 'comment', c1: '#04874A', c3: '#FFFFFF' },
|
||||
{ file: 'tab-mine.png', art: 'person', c1: '#7C9A8B', c2: '#B4CDC0' },
|
||||
{ file: 'tab-mine-on.png', art: 'person', c1: '#04874A', c2: '#A9F2CE' },
|
||||
|
||||
// ---------- 同城分类(统一绿系 + 浅绿徽章底;交友点缀暖金) ----------
|
||||
{ file: 'cat-job.png', art: 'briefcase', bg: ['#E9FEF3', '#CFF7E3'], c1: '#04874A', c2: '#046B3B' },
|
||||
{ file: 'cat-house.png', art: 'house', bg: ['#EAFEF1', '#D2F8E0'], c1: '#1F8C4C', c2: '#146B38' },
|
||||
{ file: 'cat-goods.png', art: 'box', bg: ['#F2FBE4', '#E2F3C9'], c1: '#5F9A2F', c2: '#44661A' },
|
||||
{ file: 'cat-car.png', art: 'car', bg: ['#E8FBF4', '#CFF5E6'], c1: '#0E8C6A', c2: '#0A6B52' },
|
||||
{ file: 'cat-service.png', art: 'gear', bg: ['#E8FEF5', '#CFFAE6'], c1: '#17BF7A', c2: '#0E9E60' },
|
||||
{ file: 'cat-education.png', art: 'graduation', bg: ['#EFFBF3', '#DCF5E5'], c1: '#3E8C5E', c2: '#2A6B45' },
|
||||
{ file: 'cat-clean.png', art: 'sparkle', bg: ['#EAFDF3', '#D2F8E4'], c1: '#17B368', c2: '#127F4A' },
|
||||
{ file: 'cat-friend.png', art: 'heart', bg: ['#FFF6E4', '#FBE7C0'], c1: '#E9A23B', c2: '#C9811B' },
|
||||
|
||||
// ---------- 首页与展示(叠在深绿头部上,故取白 + 浅绿/浅金) ----------
|
||||
{ file: 'home-location.png', art: 'pin', c1: '#FFFFFF', c2: '#CDF8E4', c3: '#04874A' },
|
||||
{ file: 'location.png', art: 'pin', c1: '#04874A', c2: '#046B3B', c3: '#FFFFFF' },
|
||||
{ file: 'home-search.png', art: 'search', c1: '#6B8A7B', c3: '#E9FDF4' },
|
||||
{ file: 'home-bell.png', art: 'bell', c1: '#FFFFFF', c2: '#CDF8E4' },
|
||||
{ file: 'home-crown.png', art: 'crown', c1: '#FFFFFF', c2: '#FFD79A' },
|
||||
|
||||
// ---------- 通用功能(主色件绿,会员/热度/收藏/余额金) ----------
|
||||
{ file: 'search.png', art: 'search', c1: '#6B8A7B', c3: '#E9FDF4' },
|
||||
{ file: 'close.png', art: 'close', c1: '#6B8A7B', c3: '#EAFDF4' },
|
||||
{ file: 'fire.png', art: 'fire', c1: '#F5A623', c2: '#FFE0A8' },
|
||||
{ file: 'crown.png', art: 'crown', c1: '#F0A020', c2: '#FFD080' },
|
||||
{ file: 'check.png', art: 'check', c1: '#04874A' },
|
||||
{ file: 'shield.png', art: 'shield', c1: '#04874A' },
|
||||
{ file: 'image.png', art: 'picture', c1: '#049E52', c2: '#046B3B' },
|
||||
{ file: 'image-white.png', art: 'picture', c1: '#FFFFFF', c2: '#CDF8E4' },
|
||||
{ file: 'wallet.png', art: 'wallet', c1: '#F5A623', c2: '#D98A0B' },
|
||||
{ file: 'paywechat.png', art: 'paywechat', c1: '#3FBE5E' }, // 微信品牌绿,保持不变
|
||||
{ file: 'phone.png', art: 'phone', c1: '#FFFFFF' },
|
||||
{ file: 'phone-orange.png', art: 'phone', c1: '#04874A' },
|
||||
{ file: 'phonebind.png', art: 'phonebind', c1: '#04874A', c2: '#046B3B' },
|
||||
{ file: 'lock.png', art: 'lock', c1: '#04874A', c2: '#C3F6DE' },
|
||||
{ file: 'star.png', art: 'star', c1: '#F5A623' },
|
||||
{ file: 'star-o.png', art: 'starO', c1: '#A5BFB0', c3: '#EDFDF5' },
|
||||
{ file: 'share.png', art: 'share', c1: '#04874A', c2: '#C3F6DE' },
|
||||
{ file: 'qrcode.png', art: 'qrcode', c1: '#04874A', c2: '#046B3B', c3: '#FFFFFF' },
|
||||
{ file: 'eye.png', art: 'eye', c1: '#6B8A7B', c3: '#EDFDF5' },
|
||||
{ file: 'comment-gray.png', art: 'comment', c1: '#A5BFB0', c3: '#FFFFFF' },
|
||||
{ file: 'edit.png', art: 'edit', c1: '#04874A' },
|
||||
{ file: 'folder.png', art: 'folder', c1: '#049E52', c2: '#046B3B' },
|
||||
{ file: 'inbox.png', art: 'inbox', c1: '#049E52' },
|
||||
{ file: 'users.png', art: 'users', c1: '#049E52', c2: '#C3F6DE' },
|
||||
{ file: 'settings.png', art: 'gear', c1: '#6B8A7B', c3: '#FFFFFF' },
|
||||
{ file: 'info.png', art: 'info', c1: '#049E52' },
|
||||
{ file: 'receipt.png', art: 'receipt', c1: '#A5BFB0' },
|
||||
{ file: 'network.png', art: 'network', c1: '#049E52', c2: '#C3F6DE' },
|
||||
|
||||
// ---------- 登录身份 / 消息类型(个人=绿,商家=金) ----------
|
||||
{ file: 'login-person.png', art: 'person', bg: ['#E9FEF3', '#CFF7E3'], c1: '#04874A', c2: '#C3F6DE' },
|
||||
{ file: 'login-shop.png', art: 'store', bg: ['#FFF6E4', '#FBE4BC'], c1: '#E9A23B', c2: '#C9811B' },
|
||||
{ file: 'msg-system.png', art: 'bell', bg: ['#E9FEF3', '#CFF7E3'], c1: '#04874A', c2: '#C3F6DE' },
|
||||
{ file: 'msg-interact.png', art: 'comment', bg: ['#FFF6E4', '#FBE7C0'], c1: '#F5A623', c3: '#FFFFFF' },
|
||||
|
||||
// ---------- 我的(绿=内容/工具,金=会员/资产) ----------
|
||||
{ file: 'mine-post.png', art: 'edit', bg: ['#E9FEF3', '#CFF7E3'], c1: '#04874A' },
|
||||
{ file: 'mine-order.png', art: 'box', bg: ['#F2FBE4', '#E2F3C9'], c1: '#5F9A2F', c2: '#44661A' },
|
||||
{ file: 'mine-dist.png', art: 'network', bg: ['#E8FBF4', '#CFF5E6'], c1: '#0E8C6A', c2: '#C3F6DE' },
|
||||
{ file: 'mine-vip.png', art: 'crown', bg: ['#FFF3E0', '#FBE2B8'], c1: '#E9A23B', c2: '#FFD080' },
|
||||
{ file: 'mine-draft.png', art: 'folder', bg: ['#EAFEF1', '#D2F8E0'], c1: '#1F8C4C', c2: '#146B38' },
|
||||
{ file: 'mine-history.png', art: 'search', bg: ['#E8FEF5', '#CFFAE6'], c1: '#17BF7A', c3: '#F7FFFB' },
|
||||
{ file: 'mine-setting.png', art: 'gear', bg: ['#EFF8F4', '#DEF1E8'], c1: '#6B8A7B', c3: '#FFFFFF' },
|
||||
{ file: 'mine-about.png', art: 'info', bg: ['#EFFBF3', '#DCF5E5'], c1: '#3E8C5E' },
|
||||
|
||||
// ---------- 会员与订单 ----------
|
||||
{ file: 'link-order.png', art: 'box', bg: ['#F2FBE4', '#E2F3C9'], c1: '#5F9A2F', c2: '#44661A' },
|
||||
{ file: 'link-recharge.png', art: 'card', bg: ['#E9FEF3', '#CFF7E3'], c1: '#04874A', c2: '#046B3B' },
|
||||
{ file: 'link-dist.png', art: 'network', bg: ['#E8FBF4', '#CFF5E6'], c1: '#0E8C6A', c2: '#C3F6DE' },
|
||||
{ file: 'order-post.png', art: 'edit', c1: '#04874A' },
|
||||
{ file: 'order-member.png', art: 'crown', c1: '#F5A623', c2: '#FFD080' },
|
||||
{ file: 'order-recharge.png', art: 'card', c1: '#049E52', c2: '#046B3B' },
|
||||
{ file: 'order-other.png', art: 'receipt', c1: '#A5BFB0' },
|
||||
|
||||
// ---------- 详情操作栏 ----------
|
||||
{ file: 'bar-fav.png', art: 'starO', c1: '#6B8A7B', c3: '#EDFDF5' },
|
||||
{ file: 'bar-fav-on.png', art: 'star', c1: '#F5A623' },
|
||||
{ file: 'bar-share.png', art: 'share', c1: '#6B8A7B', c2: '#B4CDC0' },
|
||||
{ file: 'bar-poster.png', art: 'picture', c1: '#6B8A7B', c2: '#B4CDC0' },
|
||||
]
|
||||
266
uniapp/tools/png-util.mjs
普通文件
266
uniapp/tools/png-util.mjs
普通文件
@@ -0,0 +1,266 @@
|
||||
/**
|
||||
* 零依赖 PNG 解码 / 编码 / 透明通道提取
|
||||
* 背景:macOS qlmanage 渲染 SVG 时会合成到不透明白底上,无法直接得到透明 PNG。
|
||||
* 方案:同一张 SVG 分别渲染到「白底」「黑底」两次,用两式联立解出真实的 alpha 与颜色:
|
||||
* Pw = a·C + (1-a)·255
|
||||
* Pb = a·C + (1-a)·0
|
||||
* => a = 1 - (Pw - Pb)/255, C = Pb / a
|
||||
* 结果就是精确抗锯齿的真实透明 PNG。
|
||||
*/
|
||||
import zlib from 'node:zlib'
|
||||
|
||||
const SIG = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])
|
||||
|
||||
let CRC_TABLE = null
|
||||
function crcTable() {
|
||||
if (CRC_TABLE) return CRC_TABLE
|
||||
CRC_TABLE = new Int32Array(256)
|
||||
for (let n = 0; n < 256; n++) {
|
||||
let c = n
|
||||
for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1
|
||||
CRC_TABLE[n] = c
|
||||
}
|
||||
return CRC_TABLE
|
||||
}
|
||||
function crc32(buf) {
|
||||
const t = crcTable()
|
||||
let c = 0xffffffff
|
||||
for (let i = 0; i < buf.length; i++) c = t[(c ^ buf[i]) & 0xff] ^ (c >>> 8)
|
||||
return (c ^ 0xffffffff) >>> 0
|
||||
}
|
||||
function chunk(type, data) {
|
||||
const len = Buffer.alloc(4)
|
||||
len.writeUInt32BE(data.length, 0)
|
||||
const typeBuf = Buffer.from(type, 'ascii')
|
||||
const crc = Buffer.alloc(4)
|
||||
crc.writeUInt32BE(crc32(Buffer.concat([typeBuf, data])), 0)
|
||||
return Buffer.concat([len, typeBuf, data, crc])
|
||||
}
|
||||
|
||||
/** 解码 PNG -> { width, height, rgba: Buffer(RGBA) } */
|
||||
export function decodePng(buf) {
|
||||
if (!buf.slice(0, 8).equals(SIG)) throw new Error('不是有效的 PNG')
|
||||
let off = 8
|
||||
let width = 0
|
||||
let height = 0
|
||||
let colorType = 0
|
||||
let bitDepth = 0
|
||||
const idat = []
|
||||
while (off < buf.length) {
|
||||
const len = buf.readUInt32BE(off)
|
||||
const type = buf.toString('ascii', off + 4, off + 8)
|
||||
const data = buf.slice(off + 8, off + 8 + len)
|
||||
if (type === 'IHDR') {
|
||||
width = data.readUInt32BE(0)
|
||||
height = data.readUInt32BE(4)
|
||||
bitDepth = data[8]
|
||||
colorType = data[9]
|
||||
} else if (type === 'IDAT') idat.push(data)
|
||||
else if (type === 'IEND') break
|
||||
off += 12 + len
|
||||
}
|
||||
if (bitDepth !== 8) throw new Error('仅支持 8bit PNG')
|
||||
const ch = colorType === 6 ? 4 : colorType === 2 ? 3 : colorType === 4 ? 2 : 1
|
||||
const raw = zlib.inflateSync(Buffer.concat(idat))
|
||||
const stride = width * ch
|
||||
const rgba = Buffer.alloc(width * height * 4)
|
||||
let prev = Buffer.alloc(stride)
|
||||
for (let y = 0; y < height; y++) {
|
||||
const ft = raw[y * (stride + 1)]
|
||||
const line = Buffer.from(raw.slice(y * (stride + 1) + 1, y * (stride + 1) + 1 + stride))
|
||||
for (let i = 0; i < stride; i++) {
|
||||
const a = i >= ch ? line[i - ch] : 0
|
||||
const b = prev[i]
|
||||
const c = i >= ch ? prev[i - ch] : 0
|
||||
if (ft === 1) line[i] = (line[i] + a) & 255
|
||||
else if (ft === 2) line[i] = (line[i] + b) & 255
|
||||
else if (ft === 3) line[i] = (line[i] + ((a + b) >> 1)) & 255
|
||||
else if (ft === 4) {
|
||||
const p = a + b - c
|
||||
const pa = Math.abs(p - a)
|
||||
const pb = Math.abs(p - b)
|
||||
const pc = Math.abs(p - c)
|
||||
line[i] = (line[i] + (pa <= pb && pa <= pc ? a : pb <= pc ? b : c)) & 255
|
||||
}
|
||||
}
|
||||
for (let x = 0; x < width; x++) {
|
||||
const si = x * ch
|
||||
const di = (y * width + x) * 4
|
||||
if (ch === 4) {
|
||||
rgba[di] = line[si]; rgba[di + 1] = line[si + 1]; rgba[di + 2] = line[si + 2]; rgba[di + 3] = line[si + 3]
|
||||
} else if (ch === 3) {
|
||||
rgba[di] = line[si]; rgba[di + 1] = line[si + 1]; rgba[di + 2] = line[si + 2]; rgba[di + 3] = 255
|
||||
} else {
|
||||
rgba[di] = rgba[di + 1] = rgba[di + 2] = line[si]; rgba[di + 3] = ch === 2 ? line[si + 1] : 255
|
||||
}
|
||||
}
|
||||
prev = line
|
||||
}
|
||||
return { width, height, rgba }
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码 RGBA -> PNG(无损)
|
||||
* filter:PNG 行滤波器,0=不过滤(默认,保持图标产物字节不变)、1=Sub、2=Up、3=Avg、4=Paeth。
|
||||
* 大面积渐变图(如轮播配图)用 1~4 可把体积降到 1/3 以下;图形类图标用 0 已足够小。
|
||||
*/
|
||||
export function encodePng({ width, height, rgba }, { filter = 0 } = {}) {
|
||||
const stride = width * 4
|
||||
const raw = Buffer.alloc((stride + 1) * height)
|
||||
const bpp = 4
|
||||
if (!filter) {
|
||||
for (let y = 0; y < height; y++) {
|
||||
raw[y * (stride + 1)] = 0
|
||||
rgba.copy(raw, y * (stride + 1) + 1, y * stride, y * stride + stride)
|
||||
}
|
||||
} else {
|
||||
let prev = Buffer.alloc(stride)
|
||||
const line = Buffer.alloc(stride)
|
||||
for (let y = 0; y < height; y++) {
|
||||
const base = y * stride
|
||||
for (let i = 0; i < stride; i++) {
|
||||
const cur = rgba[base + i]
|
||||
const a = i >= bpp ? rgba[base + i - bpp] : 0
|
||||
const b = prev[i]
|
||||
const c = i >= bpp ? prev[i - bpp] : 0
|
||||
let pred
|
||||
if (filter === 1) pred = a
|
||||
else if (filter === 2) pred = b
|
||||
else if (filter === 3) pred = (a + b) >> 1
|
||||
else {
|
||||
const p = a + b - c
|
||||
const pa = Math.abs(p - a)
|
||||
const pb = Math.abs(p - b)
|
||||
const pc = Math.abs(p - c)
|
||||
pred = pa <= pb && pa <= pc ? a : pb <= pc ? b : c
|
||||
}
|
||||
line[i] = (cur - pred) & 255
|
||||
}
|
||||
raw[y * (stride + 1)] = filter
|
||||
line.copy(raw, y * (stride + 1) + 1)
|
||||
prev = Buffer.from(line)
|
||||
}
|
||||
}
|
||||
const ihdr = Buffer.alloc(13)
|
||||
ihdr.writeUInt32BE(width, 0)
|
||||
ihdr.writeUInt32BE(height, 4)
|
||||
ihdr[8] = 8
|
||||
ihdr[9] = 6
|
||||
return Buffer.concat([SIG, chunk('IHDR', ihdr), chunk('IDAT', zlib.deflateSync(raw, { level: 9 })), chunk('IEND', Buffer.alloc(0))])
|
||||
}
|
||||
|
||||
/** 由「白底」「黑底」两张同尺寸渲染图解出真实透明 RGBA */
|
||||
export function extractAlpha(white, black) {
|
||||
const { width, height } = white
|
||||
const out = Buffer.alloc(width * height * 4)
|
||||
for (let i = 0; i < width * height; i++) {
|
||||
const di = i * 4
|
||||
const dw = ((white.rgba[di] - black.rgba[di]) + (white.rgba[di + 1] - black.rgba[di + 1]) + (white.rgba[di + 2] - black.rgba[di + 2])) / 3
|
||||
let a = 1 - dw / 255
|
||||
if (a < 0) a = 0
|
||||
if (a > 1) a = 1
|
||||
if (a <= 0.008) {
|
||||
out[di] = 0; out[di + 1] = 0; out[di + 2] = 0; out[di + 3] = 0
|
||||
continue
|
||||
}
|
||||
out[di] = Math.min(255, Math.round(black.rgba[di] / a))
|
||||
out[di + 1] = Math.min(255, Math.round(black.rgba[di + 1] / a))
|
||||
out[di + 2] = Math.min(255, Math.round(black.rgba[di + 2] / a))
|
||||
out[di + 3] = Math.round(a * 255)
|
||||
}
|
||||
return { width, height, rgba: out }
|
||||
}
|
||||
|
||||
/** 统计透明像素占比(用于自检) */
|
||||
export function transparentRatio(img) {
|
||||
let n = 0
|
||||
for (let i = 0; i < img.width * img.height; i++) if (img.rgba[i * 4 + 3] < 10) n++
|
||||
return n / (img.width * img.height)
|
||||
}
|
||||
|
||||
/**
|
||||
* 求「非纯白像素」的包围盒。
|
||||
* 用途:qlmanage 会把 SVG 渲染到一个更小的子矩形里,其余填充纯白衬底,
|
||||
* 因此对「黑底渲染图」求非白包围盒即可精确定位真实内容区域。
|
||||
*/
|
||||
export function contentBox(img) {
|
||||
const { width: W, height: H, rgba } = img
|
||||
let minX = W
|
||||
let maxX = -1
|
||||
let minY = H
|
||||
let maxY = -1
|
||||
for (let y = 0; y < H; y++) {
|
||||
for (let x = 0; x < W; x++) {
|
||||
const d = (y * W + x) * 4
|
||||
const isWhite = rgba[d] >= 250 && rgba[d + 1] >= 250 && rgba[d + 2] >= 250
|
||||
if (!isWhite) {
|
||||
if (x < minX) minX = x
|
||||
if (x > maxX) maxX = x
|
||||
if (y < minY) minY = y
|
||||
if (y > maxY) maxY = y
|
||||
}
|
||||
}
|
||||
}
|
||||
if (maxX < 0) return { x: 0, y: 0, w: W, h: H }
|
||||
return { x: minX, y: minY, w: maxX - minX + 1, h: maxY - minY + 1 }
|
||||
}
|
||||
|
||||
/** 按包围盒裁剪 */
|
||||
export function crop(img, box) {
|
||||
const out = Buffer.alloc(box.w * box.h * 4)
|
||||
for (let y = 0; y < box.h; y++) {
|
||||
const src = ((box.y + y) * img.width + box.x) * 4
|
||||
img.rgba.copy(out, y * box.w * 4, src, src + box.w * 4)
|
||||
}
|
||||
return { width: box.w, height: box.h, rgba: out }
|
||||
}
|
||||
|
||||
/**
|
||||
* 整数倍降采样(盒式滤波,按预乘 alpha 平均,避免半透明边缘发暗)
|
||||
* 用于把高分辨率渲染结果压到目标尺寸,兼顾锐度与体积。
|
||||
*/
|
||||
export function downscale(img, factor) {
|
||||
if (factor <= 1) return img
|
||||
const w = Math.floor(img.width / factor)
|
||||
const h = Math.floor(img.height / factor)
|
||||
const out = Buffer.alloc(w * h * 4)
|
||||
const n = factor * factor
|
||||
for (let y = 0; y < h; y++) {
|
||||
for (let x = 0; x < w; x++) {
|
||||
let r = 0
|
||||
let g = 0
|
||||
let b = 0
|
||||
let a = 0
|
||||
for (let dy = 0; dy < factor; dy++) {
|
||||
for (let dx = 0; dx < factor; dx++) {
|
||||
const d = ((y * factor + dy) * img.width + (x * factor + dx)) * 4
|
||||
const al = img.rgba[d + 3]
|
||||
r += img.rgba[d] * al
|
||||
g += img.rgba[d + 1] * al
|
||||
b += img.rgba[d + 2] * al
|
||||
a += al
|
||||
}
|
||||
}
|
||||
const o = (y * w + x) * 4
|
||||
if (a === 0) {
|
||||
out[o] = out[o + 1] = out[o + 2] = out[o + 3] = 0
|
||||
} else {
|
||||
out[o] = Math.round(r / a)
|
||||
out[o + 1] = Math.round(g / a)
|
||||
out[o + 2] = Math.round(b / a)
|
||||
out[o + 3] = Math.round(a / n)
|
||||
}
|
||||
}
|
||||
}
|
||||
return { width: w, height: h, rgba: out }
|
||||
}
|
||||
|
||||
/** 统计「纯白且不透明」像素占比(用于自检底噪) */
|
||||
export function opaqueWhiteRatio(img) {
|
||||
let n = 0
|
||||
for (let i = 0; i < img.width * img.height; i++) {
|
||||
const d = i * 4
|
||||
if (img.rgba[d + 3] > 250 && img.rgba[d] > 250 && img.rgba[d + 1] > 250 && img.rgba[d + 2] > 250) n++
|
||||
}
|
||||
return n / (img.width * img.height)
|
||||
}
|
||||
523
uniapp/tools/preview-theme.mjs
普通文件
523
uniapp/tools/preview-theme.mjs
普通文件
@@ -0,0 +1,523 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* 生态绿主题 · 预览出图(改配色后的目检工具)
|
||||
* ------------------------------------------------------------
|
||||
* 为什么需要它:小程序只能跑在 HBuilderX / 微信开发者工具里,改主题时无法快速目检。
|
||||
* 本脚本用「仓库里真实的 SCSS/CSS + 真实的 mock 数据」拼出一张预览图:
|
||||
* 配色是否协调、有没有漏改的旧色,一眼就能看出来。
|
||||
*
|
||||
* 做法:
|
||||
* 1) 用 HBuilderX 内置 dart-sass 编译 uni.scss(令牌)+ 页面/组件的 <style> 段;
|
||||
* 2) rpx → px(按 375px 手机宽换算:750rpx = 100vw);
|
||||
* 3) 用 common/mock/data.js 的真实数据填充首页结构
|
||||
* (深绿头部 / 轮播 / 分类九宫格 / 会员条 / 筛选 / 信息流卡片 / tabbar);
|
||||
* 4) 另附「设计令牌色板 + 组件样例」,最后可选调用 qlmanage 渲染成 PNG。
|
||||
*
|
||||
* 用法:
|
||||
* node tools/preview-theme.mjs # 只产出 HTML(任意浏览器可开)
|
||||
* node tools/preview-theme.mjs --render # 同时用 qlmanage 出 PNG(仅 macOS)
|
||||
* node tools/preview-theme.mjs --out /tmp/preview --render
|
||||
*/
|
||||
import fs from 'node:fs'
|
||||
import os from 'node:os'
|
||||
import path from 'node:path'
|
||||
import url from 'node:url'
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { createRequire } from 'node:module'
|
||||
import { datasets } from '../common/mock/data.js'
|
||||
import { CATEGORY_ICON_KEY } from '../common/assets/icons.js'
|
||||
import { bannerArtUrl, bannerHasValue, bannerBg } from '../common/assets/banners.js'
|
||||
|
||||
const ROOT = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), '..')
|
||||
const argv = process.argv.slice(2)
|
||||
const argOf = (n, d) => {
|
||||
const i = argv.indexOf(n)
|
||||
return i >= 0 && argv[i + 1] && !argv[i + 1].startsWith('--') ? argv[i + 1] : d
|
||||
}
|
||||
const OUT_DIR = path.resolve(argOf('--out', path.join(os.tmpdir(), 'fc-theme-preview')))
|
||||
const DO_RENDER = argv.includes('--render')
|
||||
const FRAME_W = 375 // 手机预览宽度(px)
|
||||
|
||||
/* ---------------- 1. dart-sass(优先用 HBuilderX 内置) ---------------- */
|
||||
const SASS_CANDIDATES = [
|
||||
process.env.FC_SASS,
|
||||
'/Applications/HBuilderX.app/Contents/HBuilderX/plugins/compile-dart-sass/node_modules/sass',
|
||||
path.join(ROOT, 'node_modules/sass'),
|
||||
].filter(Boolean)
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
let sass = null
|
||||
let sassFrom = ''
|
||||
for (const c of SASS_CANDIDATES) {
|
||||
try {
|
||||
sass = require(c)
|
||||
sassFrom = c
|
||||
break
|
||||
} catch (e) {
|
||||
/* 继续尝试下一个 */
|
||||
}
|
||||
}
|
||||
if (!sass) {
|
||||
console.error('❌ 未找到 dart-sass。可设置环境变量 FC_SASS 指向 sass 模块目录后重试。')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const read = (rel) => fs.readFileSync(path.join(ROOT, rel), 'utf8')
|
||||
const styleOf = (rel) => {
|
||||
const m = read(rel).match(/<style[^>]*>([\s\S]*?)<\/style>/)
|
||||
return m ? m[1] : ''
|
||||
}
|
||||
const TOKENS = read('uni.scss')
|
||||
|
||||
/** 编译 SCSS(令牌自动注入,与 uni-app 行为一致) */
|
||||
function compile(scss, label) {
|
||||
try {
|
||||
return String(sass.renderSync({ data: TOKENS + '\n' + scss, style: 'expanded' }).css)
|
||||
} catch (e) {
|
||||
console.error(`❌ ${label} 编译失败:${e.message.split('\n')[0]}`)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
/** rpx → px(750rpx = 屏宽) */
|
||||
const rpxToPx = (css, screenPx) =>
|
||||
css.replace(/(-?[\d.]+)rpx/g, (_, n) => `${(parseFloat(n) * (screenPx / 750)).toFixed(3)}px`)
|
||||
|
||||
/* ---------------- 2. 编译真实样式 ---------------- */
|
||||
const cssHome = rpxToPx(compile(styleOf('pages/index/index.vue'), 'pages/index/index.vue'), FRAME_W)
|
||||
const cssCard = rpxToPx(compile(styleOf('components/fc-post-card/fc-post-card.vue'), 'fc-post-card'), FRAME_W)
|
||||
const cssTabbar = rpxToPx(compile(styleOf('components/fc-tabbar/fc-tabbar.vue'), 'fc-tabbar'), FRAME_W)
|
||||
const cssNavbar = rpxToPx(compile(styleOf('components/fc-navbar/fc-navbar.vue'), 'fc-navbar'), FRAME_W)
|
||||
const cssLogin = rpxToPx(compile(styleOf('pages/auth/login.vue'), 'pages/auth/login.vue'), FRAME_W)
|
||||
const cssGlobal = rpxToPx(
|
||||
styleOf('App.vue').replace(/(^|\n)\s*page\s*\{/, '$1.fc-frame {'),
|
||||
FRAME_W,
|
||||
)
|
||||
|
||||
/* ---------------- 3. 令牌解析(色板用) ---------------- */
|
||||
const tokenLines = TOKENS.split(/\r?\n/)
|
||||
.map((l) => l.match(/^\s*(\$fc-[a-z-]+)\s*:\s*(.+?);\s*(\/\/.*)?$/))
|
||||
.filter(Boolean)
|
||||
.map((m) => ({ name: m[1], value: m[2].trim(), note: (m[3] || '').replace(/^\/\/\s*/, '') }))
|
||||
const colorTokens = tokenLines.filter((t) => /^#[0-9a-f]{3,8}$/i.test(t.value))
|
||||
const gradientTokens = tokenLines.filter((t) => t.value.startsWith('linear-gradient'))
|
||||
/* ---------------- 4. 首页仿真(真实结构 + 真实 mock 数据) ---------------- */
|
||||
const { banners, categories, posts } = datasets
|
||||
const icon = (file, cls, extra = '') =>
|
||||
`<img class="${cls}" src="static/icons/${file}.png" ${extra}>`
|
||||
|
||||
/** 轮播卡:与 pages/index/index.vue 的模板结构 + 编译后的真实 CSS 完全一致 */
|
||||
function bannerCard(b, i) {
|
||||
const deco = b.image
|
||||
? `<img class="home__banner-photo" src="${b.image}">`
|
||||
: `<div class="home__banner-deco">
|
||||
<div class="home__banner-glow"></div>
|
||||
<div class="home__banner-vein"></div>
|
||||
<div class="home__banner-hill home__banner-hill--far"></div>
|
||||
<div class="home__banner-hill home__banner-hill--near"></div>
|
||||
<div class="home__banner-badge">
|
||||
<div class="home__banner-ring home__banner-ring--outer"></div>
|
||||
<div class="home__banner-ring home__banner-ring--inner"></div>
|
||||
<img class="home__banner-art" src="static/banners/${bannerArtUrl(i).split('/').pop()}">
|
||||
${
|
||||
bannerHasValue(i)
|
||||
? `<div class="home__banner-value">
|
||||
<div class="home__banner-value-dot"></div>
|
||||
<div class="home__banner-value-dot home__banner-value-dot--sm"></div>
|
||||
</div>`
|
||||
: ''
|
||||
}
|
||||
</div>
|
||||
</div>`
|
||||
return `
|
||||
<div class="home__banner-item" style="background:${bannerBg(b, i)}">
|
||||
${deco}
|
||||
<div class="home__banner-shade"></div>
|
||||
<div class="home__banner-text">
|
||||
<span class="home__banner-tag">同城精选</span>
|
||||
<span class="home__banner-title">${b.title}</span>
|
||||
<div class="home__banner-cta"><span class="home__banner-cta-text">立即查看 ›</span></div>
|
||||
</div>
|
||||
</div>`
|
||||
}
|
||||
|
||||
/** 轮播三态 + 旧暖色数据回落演示(后台数据未同步时的护栏) */
|
||||
const bannerDemos = [
|
||||
...banners.map((b, i) => ({ b, i, cap: `banner ${i + 1} · 内置渐变 + 白色插画 ${i + 1}` })),
|
||||
{ b: { ...banners[0], id: 9, color: '#FF8A5B' }, i: 0, cap: 'banner 1 · 旧暖色 #FF8A5B → 自动回落春绿渐变' },
|
||||
]
|
||||
|
||||
function postCard(p) {
|
||||
const key = CATEGORY_ICON_KEY[p.categoryId] || 'cat-job'
|
||||
const tags = (p.tags || [])
|
||||
.slice(0, 2)
|
||||
.map((t) => `<span class="fc-tag fc-post-card__tag">${t}</span>`)
|
||||
.join('')
|
||||
const paid = p.isPaid ? '<span class="fc-post-card__tag fc-post-card__tag--paid">置顶</span>' : ''
|
||||
const price =
|
||||
p.price > 0
|
||||
? `<span class="fc-price__symbol">¥</span><span class="fc-post-card__amount">${p.price}</span>`
|
||||
: '<span class="fc-post-card__neg">面议</span>'
|
||||
return `
|
||||
<div class="fc-post-card">
|
||||
<div class="fc-post-card__thumb"><img class="fc-post-card__thumb-img" src="static/icons/${key}.png"></div>
|
||||
<div class="fc-post-card__body">
|
||||
<div class="fc-post-card__title fc-ellipsis-2">${p.title}</div>
|
||||
<div class="fc-post-card__tags">${tags}${paid}</div>
|
||||
<div class="fc-post-card__meta">
|
||||
<span>${p.area}</span><span class="fc-post-card__dot">·</span><span>2 小时前</span>
|
||||
</div>
|
||||
<div class="fc-post-card__bottom">
|
||||
<div class="fc-price">${price}<span class="fc-post-card__unit">${p.priceUnit}</span></div>
|
||||
<div class="fc-post-card__stats">
|
||||
<div class="fc-post-card__stat">${icon('eye', 'fc-icon fc-icon--xs')}<span class="fc-post-card__stat-num">${p.views}</span></div>
|
||||
<div class="fc-post-card__stat">${icon('comment-gray', 'fc-icon fc-icon--xs')}<span class="fc-post-card__stat-num">${p.commentCount || 0}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
}
|
||||
|
||||
const tabbar = `
|
||||
<div class="fc-tabbar">
|
||||
<div class="fc-tabbar__item fc-tabbar__item--active">
|
||||
<div class="fc-tabbar__icon">${icon('tab-home-on', 'fc-tabbar__img')}</div><span class="fc-tabbar__text">首页</span>
|
||||
</div>
|
||||
<div class="fc-tabbar__item fc-tabbar__item--primary">
|
||||
<div class="fc-tabbar__icon fc-tabbar__icon--circle">${icon('plus-ink', 'fc-tabbar__plus')}</div><span class="fc-tabbar__text">发布</span>
|
||||
</div>
|
||||
<div class="fc-tabbar__item">
|
||||
<div class="fc-tabbar__icon">${icon('tab-message', 'fc-tabbar__img')}</div><span class="fc-tabbar__text">消息</span>
|
||||
</div>
|
||||
<div class="fc-tabbar__item">
|
||||
<div class="fc-tabbar__icon">${icon('tab-mine', 'fc-tabbar__img')}</div><span class="fc-tabbar__text">我的</span>
|
||||
</div>
|
||||
<div class="fc-safe-bottom"></div>
|
||||
</div>`
|
||||
|
||||
/* 登录页(品牌区 + 身份双选 + 一键登录)——生态绿品牌第一屏 */
|
||||
const loginScreen = `
|
||||
<div class="phone fc-frame">
|
||||
<div class="login">
|
||||
<div class="login__bg"></div>
|
||||
<div class="login__status" style="height:20px"></div>
|
||||
<div class="login__brand">
|
||||
<img class="fc-logo fc-logo--lg" src="static/logo.png">
|
||||
<span class="login__title">山间小仓</span>
|
||||
<span class="login__slogan">招聘 · 房产 · 二手 · 本地服务,一站直达</span>
|
||||
</div>
|
||||
<div class="login__panel">
|
||||
<span class="login__panel-title">选择身份</span>
|
||||
<div class="login__types">
|
||||
<div class="login__type login__type--active">
|
||||
${icon('login-person', 'fc-icon--badge-sm')}
|
||||
<span class="login__type-name">个人用户</span>
|
||||
<span class="login__type-desc">发布闲置 / 查看信息</span>
|
||||
</div>
|
||||
<div class="login__type">
|
||||
${icon('login-shop', 'fc-icon--badge-sm')}
|
||||
<span class="login__type-name">商家用户</span>
|
||||
<span class="login__type-desc">需营业执照资质认证</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="login__btn">微信一键登录</div>
|
||||
<div class="login__phone">${icon('phonebind', 'fc-icon fc-icon--sm')}<span class="login__phone-text">手机号授权绑定</span></div>
|
||||
<span class="login__agree">登录即代表同意《用户协议》与《隐私政策》</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
|
||||
const homeScreen = `
|
||||
<div class="phone fc-frame">
|
||||
<div class="fc-page home">
|
||||
<div class="home__header">
|
||||
<div class="home__header-status" style="height:20px"></div>
|
||||
<div class="home__header-bar">
|
||||
<img class="fc-logo fc-logo--sm" src="static/logo.png">
|
||||
<div class="home__location">
|
||||
${icon('home-location', 'fc-icon fc-icon--sm')}
|
||||
<span class="home__location-text fc-ellipsis">观山湖区</span>
|
||||
<span class="home__location-arrow">▾</span>
|
||||
</div>
|
||||
<div class="home__msg">
|
||||
${icon('home-bell', 'fc-icon fc-icon--sm')}
|
||||
<div class="home__msg-dot">3</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="home__search">
|
||||
${icon('home-search', 'fc-icon fc-icon--sm')}
|
||||
<span class="home__search-ph">搜索招聘、租房、二手…</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="home__banner">
|
||||
${bannerCard(banners[0], 0)}
|
||||
</div>
|
||||
|
||||
<div class="fc-card home__cats">
|
||||
<div class="home__cats-head"><span class="home__cats-title">同城分类</span><span class="home__cats-more">全部分类 ›</span></div>
|
||||
<div class="home__cats-grid">
|
||||
${categories
|
||||
.map(
|
||||
(c) => `<div class="home__cat">
|
||||
<div class="home__cat-icon">${icon(c.iconKey, 'fc-icon--badge')}</div>
|
||||
<span class="home__cat-name">${c.name}</span>
|
||||
</div>`,
|
||||
)
|
||||
.join('')}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="home__vip">
|
||||
<div class="home__vip-left">
|
||||
${icon('home-crown', 'fc-icon fc-icon--md')}
|
||||
<div class="home__vip-texts">
|
||||
<span class="home__vip-title">开通会员,发布 8 折</span>
|
||||
<span class="home__vip-sub">超值月卡 ¥19.9 起</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="home__vip-btn">立即开通</div>
|
||||
</div>
|
||||
|
||||
<div class="home__filter">
|
||||
<div class="home__filter-item home__filter-item--active"><span>最新</span></div>
|
||||
<div class="home__filter-item"><span>附近</span></div>
|
||||
<div class="home__filter-item"><span>热门</span></div>
|
||||
<div class="home__filter-item home__filter-item--area"><span>观山湖区 ▾</span></div>
|
||||
</div>
|
||||
|
||||
${posts.slice(0, 3).map(postCard).join('')}
|
||||
<div class="home__loadmore">上拉加载更多</div>
|
||||
<div class="home__tabbar-space"></div>
|
||||
</div>
|
||||
${tabbar}
|
||||
</div>`
|
||||
|
||||
/* ---------------- 5. 令牌色板 + 组件样例 ---------------- */
|
||||
const swatchRow = (list) =>
|
||||
list
|
||||
.map(
|
||||
(t) => `<div class="sw"><i style="background:${t.value}"></i>
|
||||
<div><b>${t.name.replace('$fc-', '')}</b><s>${t.value}</s></div></div>`,
|
||||
)
|
||||
.join('')
|
||||
|
||||
const gradRow = (list) =>
|
||||
list
|
||||
.map(
|
||||
(t) =>
|
||||
`<div class="gr"><i style="background:${t.value}"></i><b>${t.name.replace('$fc-', '')}</b></div>`,
|
||||
)
|
||||
.join('')
|
||||
|
||||
const bg = (tokenLines.find((t) => t.name === '$fc-bg') || {}).value || '#f2fef7'
|
||||
|
||||
const panel = `
|
||||
<div class="panel">
|
||||
<h2>设计令牌 · 春绿 Spring Green(实时解析 uni.scss)</h2>
|
||||
<h3>设计稿参考色(本轮定色依据:图片均值 #04E06E / 众数 #00DF6C)</h3>
|
||||
<div class="grid">
|
||||
<div class="sw"><i style="background:#00E070"></i><div><b>采用主色 #00E070</b><s>亮绿 = 面(配墨绿字 8.2:1)</s></div></div>
|
||||
<div class="sw"><i style="background:#04E06E"></i><div><b>图片均值 #04E06E</b><s>参考图取样</s></div></div>
|
||||
<div class="sw"><i style="background:#04874A"></i><div><b>白字安全绿 #04874A</b><s>白字 4.6:1(AA)</s></div></div>
|
||||
</div>
|
||||
<h3>主色系 · 春绿</h3>
|
||||
<div class="grid">${swatchRow(colorTokens.filter((t) => t.name.startsWith('$fc-primary')))}</div>
|
||||
<h3>辅助色 · 阳光金(只给会员 / 热度 / 价格)</h3>
|
||||
<div class="grid">${swatchRow(colorTokens.filter((t) => t.name.startsWith('$fc-accent')))}</div>
|
||||
<h3>文字 / 背景 / 边框</h3>
|
||||
<div class="grid">${swatchRow(
|
||||
colorTokens.filter((t) => /^\$fc-(text|bg|border)/.test(t.name)),
|
||||
)}</div>
|
||||
<h3>功能色</h3>
|
||||
<div class="grid">${swatchRow(
|
||||
colorTokens.filter((t) => /^\$fc-(success|warning|danger|info|price)/.test(t.name)),
|
||||
)}</div>
|
||||
<h3>渐变</h3>
|
||||
<div class="grid">${gradRow(gradientTokens)}</div>
|
||||
|
||||
<h2>组件样例 · 真实 CSS</h2>
|
||||
<div class="demo">
|
||||
<div class="demo-col">
|
||||
<div class="fc-btn">立即发布</div>
|
||||
<div class="fc-btn fc-btn--ghost">查看详情</div>
|
||||
<div class="fc-btn fc-btn--disabled">已售罄</div>
|
||||
</div>
|
||||
<div class="demo-col">
|
||||
<div class="row">
|
||||
<span class="fc-tag">精装</span><span class="fc-tag">近地铁</span>
|
||||
<span class="fc-tag fc-tag--paid">置顶</span>
|
||||
</div>
|
||||
<div class="fc-price" style="font-size:22px">
|
||||
<span class="fc-price__symbol">¥</span>1800<span class="unit">元/月</span>
|
||||
</div>
|
||||
<div class="fc-thumb" style="width:130px;height:92px;font-size:26px">图</div>
|
||||
</div>
|
||||
<div class="demo-col">
|
||||
<div class="fc-navbar fc-navbar--gradient">
|
||||
<div class="fc-navbar__bar" style="height:44px">
|
||||
<div class="fc-navbar__back"><span class="fc-navbar__back-icon">‹</span></div>
|
||||
<div class="fc-navbar__title fc-navbar__title--center"><span class="fc-navbar__title-text">会员中心</span></div>
|
||||
<div class="fc-navbar__right"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fc-navbar fc-navbar--white">
|
||||
<div class="fc-navbar__bar" style="height:44px">
|
||||
<div class="fc-navbar__back"><span class="fc-navbar__back-icon">‹</span></div>
|
||||
<div class="fc-navbar__title fc-navbar__title--center"><span class="fc-navbar__title-text">发布信息</span></div>
|
||||
<div class="fc-navbar__right"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fc-skeleton" style="height:22px;width:70%"></div>
|
||||
<div class="fc-empty" style="padding:20px 0">暂无相关数据</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>轮播配图 · 三态(后台改 color / image 即时生效)</h2>
|
||||
<div class="banners">
|
||||
${bannerDemos
|
||||
.map(
|
||||
(d) =>
|
||||
`<div class="banners__item"><b class="banners__cap">${d.cap}</b><div class="home__banner">${bannerCard(d.b, d.i)}</div></div>`,
|
||||
)
|
||||
.join('')}
|
||||
</div>
|
||||
</div>`
|
||||
|
||||
/* ---------------- 6. 预览专用样式(不进入小程序产物) ---------------- */
|
||||
const previewCss = `
|
||||
* { box-sizing: border-box; }
|
||||
body { margin: 0; padding: 22px 26px; background: #eafaf2; color: #04291c;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", Arial, sans-serif; }
|
||||
.title { font-size: 20px; font-weight: 800; letter-spacing: 1px; color: #023a21; margin: 0 0 4px; }
|
||||
.sub { font-size: 12px; color: #6d8a80; margin: 0 0 18px; }
|
||||
.wrap { display: flex; gap: 26px; align-items: flex-start; }
|
||||
.phone { position: relative; width: 375px; height: 812px; flex: 0 0 375px; border-radius: 34px;
|
||||
overflow: hidden; border: 1px solid #cdf0dd; box-shadow: 0 26px 60px -22px rgba(4, 48, 42, .55); }
|
||||
.phone .fc-page { min-height: 0; padding-bottom: 0; }
|
||||
.phone .login { min-height: 0; height: 100%; padding-bottom: 0; }
|
||||
.phone .fc-tabbar { position: absolute; }
|
||||
.phone .fc-post-card { margin: 0 12px 10px; }
|
||||
.panel { width: 1140px; margin-top: 22px; }
|
||||
.panel h2 { font-size: 15px; color: #04874a; margin: 2px 0 10px; padding-left: 9px; border-left: 4px solid #00e070; }
|
||||
.panel h3 { font-size: 12px; font-weight: 600; color: #6d8a80; margin: 14px 0 7px; }
|
||||
.grid { display: flex; flex-wrap: wrap; gap: 8px; }
|
||||
.sw { display: flex; align-items: center; gap: 9px; min-width: 188px; padding: 6px 10px;
|
||||
background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(14, 124, 102, .08); }
|
||||
.sw i { flex: 0 0 28px; width: 28px; height: 28px; border-radius: 8px; border: 1px solid rgba(0, 0, 0, .06); }
|
||||
.sw b { display: block; font-size: 11px; color: #04291c; }
|
||||
.sw s { display: block; font-size: 10px; color: #6d8a80; text-decoration: none; }
|
||||
.gr { padding: 8px; background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(14, 124, 102, .08); }
|
||||
.gr i { display: block; width: 206px; height: 26px; border-radius: 8px; }
|
||||
.gr b { display: block; margin-top: 5px; font-size: 10px; color: #6d8a80; }
|
||||
.demo { display: flex; gap: 16px; }
|
||||
.demo-col { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 14px;
|
||||
background: #fff; border-radius: 14px; box-shadow: 0 6px 20px rgba(14, 124, 102, .1); }
|
||||
.demo-col .row { display: flex; gap: 6px; flex-wrap: wrap; }
|
||||
.demo-col .unit { margin-left: 4px; font-size: 12px; font-weight: 400; color: #6d8a80; }
|
||||
.fc-tag--paid { background: linear-gradient(135deg, #ffc25c 0%, #f5a623 55%, #d98a0b 100%) !important; color: #04301e; }
|
||||
/* 轮播三态演示:抵消 .home__banner 的负外边距,逐条单独占位 */
|
||||
.banners { display: flex; flex-direction: column; gap: 14px; }
|
||||
.banners__item { width: 375px; padding-top: 26px; }
|
||||
.banners__cap { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 600; color: #6d8a80; }
|
||||
.banners__item .home__banner { box-shadow: 0 12px 40px rgba(14, 124, 102, .18); }
|
||||
`
|
||||
|
||||
const html = `<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>春绿主题预览 · 山间小仓</title>
|
||||
<style>${previewCss}</style>
|
||||
<style>${cssGlobal}</style>
|
||||
<style>${cssHome}</style>
|
||||
<style>${cssCard}</style>
|
||||
<style>${cssTabbar}</style>
|
||||
<style>${cssNavbar}</style>
|
||||
<style>${cssLogin}</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="title">山间小仓 · 同城分类信息小程序 — 春绿主题预览(参考设计稿 #00E070)</div>
|
||||
<div class="sub">样式来源:uni.scss + App.vue + pages/index/index.vue + pages/auth/login.vue + components/*(rpx 已按 ${FRAME_W}px 宽换算,手机框即真实 750rpx 设计稿)|数据来源:common/mock/data.js</div>
|
||||
<div class="wrap">
|
||||
<div>${homeScreen}</div>
|
||||
<div>${loginScreen}</div>
|
||||
</div>
|
||||
${panel}
|
||||
</body>
|
||||
</html>`
|
||||
|
||||
/* ---------------- 7. 落盘(HTML + 静态资源副本) ---------------- */
|
||||
fs.mkdirSync(OUT_DIR, { recursive: true })
|
||||
fs.cpSync(path.join(ROOT, 'static'), path.join(OUT_DIR, 'static'), { recursive: true })
|
||||
const htmlPath = path.join(OUT_DIR, 'preview.html')
|
||||
fs.writeFileSync(htmlPath, html)
|
||||
|
||||
/* ---------------- 8. 旧暖色残留自检(防止改主题漏改) ---------------- */
|
||||
const WARM = [
|
||||
'#ff6f3c', '#ff8f5e', '#fff0e8', '#f4542a', '#fff8f2', '#ffb03a', '#fff2e8',
|
||||
'#f5e6d9', '#2b2118', '#5c4b3d', '#8a7a6d', '#b9a99b', '#ffd9c2', '#ffb088',
|
||||
'#ecd9cc', '#f7ece3', '#ff9a8b', 'rgba(255, 111, 60', 'rgba(43, 33, 24',
|
||||
// 旧版轮播种子色(后台 fc_banner 历史数据,前端由 bannerBg() 回落拦截)
|
||||
'#ff8a5b', '#ffb86b', '#ff6f61',
|
||||
// 上一版主题「生态绿 v1.2」(v4 春绿起整套退役,防止改主题时漏改)
|
||||
'#0e7c66', '#14a085', '#0a5d4d', '#04302a', '#18a587', '#0e6b62', '#07443e',
|
||||
'#7fd0bb', '#8ed9c4', '#bfe8da', '#e9f7f2', '#d2efe5', '#2fa36b',
|
||||
'#f4f9f6', '#10261f', '#6d8a80',
|
||||
]
|
||||
function walk(dir, out = []) {
|
||||
for (const name of fs.readdirSync(dir)) {
|
||||
if (name === 'node_modules' || name === '.git' || name === 'unpackage') continue
|
||||
const full = path.join(dir, name)
|
||||
if (fs.statSync(full).isDirectory()) walk(full, out)
|
||||
else if (/\.(vue|js|mjs|json|scss)$/.test(name)) out.push(full)
|
||||
}
|
||||
return out
|
||||
}
|
||||
const scanFiles = [
|
||||
path.join(ROOT, 'App.vue'),
|
||||
path.join(ROOT, 'pages.json'),
|
||||
path.join(ROOT, 'uni.scss'),
|
||||
...walk(path.join(ROOT, 'pages')),
|
||||
...walk(path.join(ROOT, 'components')),
|
||||
...walk(path.join(ROOT, 'common')),
|
||||
path.join(ROOT, 'tools/icon-svg.mjs'),
|
||||
path.join(ROOT, 'tools/gen-icons.mjs'),
|
||||
path.join(ROOT, 'tools/banner-art.mjs'),
|
||||
path.join(ROOT, 'tools/gen-banner-art.mjs'),
|
||||
]
|
||||
const hits = []
|
||||
for (const f of scanFiles) {
|
||||
// 去掉注释再扫描:文档里点名旧色值不算残留,只有代码/样式里真正用到才报错
|
||||
const src = fs
|
||||
.readFileSync(f, 'utf8')
|
||||
.replace(/\/\*[\s\S]*?\*\//g, '')
|
||||
.replace(/^[ \t]*\/\/.*$/gm, '')
|
||||
.toLowerCase()
|
||||
const found = WARM.filter((w) => src.includes(w))
|
||||
if (found.length) hits.push(`${path.relative(ROOT, f)} → ${found.join(', ')}`)
|
||||
}
|
||||
|
||||
/* ---------------- 9. 可选:qlmanage 出 PNG(仅 macOS) ---------------- */
|
||||
let pngPath = ''
|
||||
if (DO_RENDER) {
|
||||
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'fc-preview-'))
|
||||
try {
|
||||
execFileSync('qlmanage', ['-t', '-s', '1700', '-o', tmp, htmlPath], { stdio: 'ignore' })
|
||||
const produced = fs.readdirSync(tmp).find((f) => f.endsWith('.png'))
|
||||
if (produced) {
|
||||
pngPath = path.join(OUT_DIR, 'preview.png')
|
||||
fs.copyFileSync(path.join(tmp, produced), pngPath)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('⚠️ qlmanage 出图失败(需 macOS),HTML 仍可直接用浏览器打开')
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`
|
||||
✅ 春绿主题预览已生成(dart-sass: ${sassFrom})
|
||||
HTML :${htmlPath}${pngPath ? `\n PNG :${pngPath}` : ''}
|
||||
令牌 :实色 ${colorTokens.length} 项 / 渐变 ${gradientTokens.length} 项
|
||||
旧色自检:${hits.length ? `❌ 仍有 ${hits.length} 处旧暖色` : '✅ 无旧暖色残留'}
|
||||
${hits.map((h) => ` · ${h}`).join('\n')}
|
||||
`)
|
||||
if (hits.length) process.exitCode = 1
|
||||
在新工单中引用
屏蔽一个用户