feat(tabbar): 底部菜单增加框架自带原生tabBar,首屏对齐微官网门户并适配安全区间距

这个提交包含在:
wikiboss
2026-09-21 10:26:38 +08:00
父节点 d7c0050258
当前提交 4843c6d713
共有 5 个文件被更改,包括 211 次插入 和 4663 次删除

查看文件

@@ -0,0 +1,45 @@
import * as fs from 'fs';
import * as path from 'path';
describe('uni-app 框架自带原生 tabBar 规范测试 (TDD Red -> Green)', () => {
const rootDir = path.resolve(__dirname, '../../../mpuniapp');
const pagesJsonPath = path.join(rootDir, 'pages.json');
it('1. pages.json 中必须配置合法且符合 uni-app 原生规范的 tabBar', () => {
expect(fs.existsSync(pagesJsonPath)).toBe(true);
const content = fs.readFileSync(pagesJsonPath, 'utf-8');
// 去除 json 中的注释
const cleanJson = content.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm, '$1');
const config = JSON.parse(cleanJson);
expect(config.tabBar).toBeDefined();
expect(Array.isArray(config.tabBar.list)).toBe(true);
expect(config.tabBar.list.length).toBeGreaterThanOrEqual(2);
expect(config.tabBar.list.length).toBeLessThanOrEqual(5);
// 关键规范:tabBar.list[0].pagePath 必须与 pages[0].path 一致,原生 tabBar 才能在首屏正常加载
expect(config.tabBar.list[0].pagePath).toBe(config.pages[0].path);
expect(config.tabBar.list[0].text).toBe('官网');
// 校验颜色 Token
expect(config.tabBar.color.toLowerCase()).toBe('#667085');
expect(config.tabBar.selectedColor.toLowerCase()).toBe('#0b5cff');
});
it('2. tabBar 中声明的所有图标资源文件必须真实存在', () => {
const content = fs.readFileSync(pagesJsonPath, 'utf-8');
const cleanJson = content.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm, '$1');
const config = JSON.parse(cleanJson);
for (const item of config.tabBar.list) {
if (item.iconPath) {
const iconFile = path.join(rootDir, item.iconPath);
expect(fs.existsSync(iconFile)).toBe(true);
}
if (item.selectedIconPath) {
const selIconFile = path.join(rootDir, item.selectedIconPath);
expect(fs.existsSync(selIconFile)).toBe(true);
}
}
});
});