diff --git a/mpuniapp/static/tab-card-active.png b/mpuniapp/static/tab-card-active.png index 31f83a0..0ef3f66 100644 Binary files a/mpuniapp/static/tab-card-active.png and b/mpuniapp/static/tab-card-active.png differ diff --git a/mpuniapp/static/tab-card.png b/mpuniapp/static/tab-card.png index fbb116d..1652b64 100644 Binary files a/mpuniapp/static/tab-card.png and b/mpuniapp/static/tab-card.png differ diff --git a/mpuniapp/static/tab-leads-active.png b/mpuniapp/static/tab-leads-active.png index 4018448..f4178cc 100644 Binary files a/mpuniapp/static/tab-leads-active.png and b/mpuniapp/static/tab-leads-active.png differ diff --git a/mpuniapp/static/tab-leads.png b/mpuniapp/static/tab-leads.png index 409ec9b..1b21be2 100644 Binary files a/mpuniapp/static/tab-leads.png and b/mpuniapp/static/tab-leads.png differ diff --git a/mpuniapp/static/tab-profile-active.png b/mpuniapp/static/tab-profile-active.png index 3d42434..6045a4a 100644 Binary files a/mpuniapp/static/tab-profile-active.png and b/mpuniapp/static/tab-profile-active.png differ diff --git a/mpuniapp/static/tab-profile.png b/mpuniapp/static/tab-profile.png index cb2a18d..5ec4baa 100644 Binary files a/mpuniapp/static/tab-profile.png and b/mpuniapp/static/tab-profile.png differ diff --git a/mpuniapp/static/tab-radar-active.png b/mpuniapp/static/tab-radar-active.png index 1d2d805..b7c96f8 100644 Binary files a/mpuniapp/static/tab-radar-active.png and b/mpuniapp/static/tab-radar-active.png differ diff --git a/mpuniapp/static/tab-radar.png b/mpuniapp/static/tab-radar.png index 9f9b728..bdee691 100644 Binary files a/mpuniapp/static/tab-radar.png and b/mpuniapp/static/tab-radar.png differ diff --git a/mpuniapp/static/tab-workplace-active.png b/mpuniapp/static/tab-workplace-active.png index 8c04644..16da656 100644 Binary files a/mpuniapp/static/tab-workplace-active.png and b/mpuniapp/static/tab-workplace-active.png differ diff --git a/mpuniapp/static/tab-workplace.png b/mpuniapp/static/tab-workplace.png index eca53e3..71fc1e3 100644 Binary files a/mpuniapp/static/tab-workplace.png and b/mpuniapp/static/tab-workplace.png differ diff --git a/mpuniapp/tests/tabbar-icons.test.ts b/mpuniapp/tests/tabbar-icons.test.ts new file mode 100644 index 0000000..b3a8111 --- /dev/null +++ b/mpuniapp/tests/tabbar-icons.test.ts @@ -0,0 +1,63 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import path from 'node:path'; +import crypto from 'node:crypto'; + +const MP_ROOT = path.resolve('m:/2026项目/CRMmp/mpuniapp'); +const pagesJsonPath = path.join(MP_ROOT, 'pages.json'); + +// 旧占位符(来自官方 hello uni-app demo 的 component/api/css/template)的 SHA-256 哈希 +const OBSOLETE_HASHES: Record = { + 'tab-card.png': '694f03d3c20a', + 'tab-card-active.png': '3291476de8d0', + 'tab-radar.png': 'ce31e8591429', + 'tab-radar-active.png': '4c76333c9103', + 'tab-leads.png': 'eec5efb627c1', + 'tab-leads-active.png': '5efc171d40d1', + 'tab-profile.png': '5e550e2f2368', + 'tab-profile-active.png': 'ac196ab3ab73', +}; + +test('1. TabBar 图标静态资源完整性与 Retina 规范校验', () => { + assert.ok(fs.existsSync(pagesJsonPath), 'pages.json 必须存在'); + const config = JSON.parse(fs.readFileSync(pagesJsonPath, 'utf-8')); + const list = config.tabBar?.list || []; + + assert.equal(list.length, 5, 'TabBar 应当精确配置 5 个项'); + + for (const item of list) { + const iconFile = path.join(MP_ROOT, item.iconPath); + const activeIconFile = path.join(MP_ROOT, item.selectedIconPath); + + assert.ok(fs.existsSync(iconFile), `图标文件不存在: ${item.iconPath}`); + assert.ok(fs.existsSync(activeIconFile), `选中态图标文件不存在: ${item.selectedIconPath}`); + + for (const file of [iconFile, activeIconFile]) { + const buf = fs.readFileSync(file); + // 验证 PNG 魔数: 89 50 4E 47 0D 0A 1A 0A + const isPng = buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4e && buf[3] === 0x47; + assert.ok(isPng, `${path.basename(file)} 必须为有效 PNG 文件`); + + // 验证尺寸为 81x81 + const width = buf.readUInt32BE(16); + const height = buf.readUInt32BE(20); + assert.equal(width, 81, `${path.basename(file)} 宽度必须为 81px`); + assert.equal(height, 81, `${path.basename(file)} 高度必须为 81px`); + } + } +}); + +test('2. 杜绝旧版开发占位符(去除 , API, {}, 4方块 等 demo 遗留图标)', () => { + for (const [filename, oldHashPrefix] of Object.entries(OBSOLETE_HASHES)) { + const file = path.join(MP_ROOT, 'static', filename); + assert.ok(fs.existsSync(file), `目标文件 ${filename} 存在`); + const buf = fs.readFileSync(file); + const hash = crypto.createHash('sha256').update(buf).digest('hex'); + assert.notEqual( + hash.slice(0, 12), + oldHashPrefix, + `${filename} 仍为旧版占位符图标,必须替换为正式商务设计图标` + ); + } +});