From 51a2f3718009e4a6eb385c5b06c1020c0616f610 Mon Sep 17 00:00:00 2001 From: wikiboss Date: Mon, 21 Sep 2026 15:23:15 +0800 Subject: [PATCH] =?UTF-8?q?refactor(mpuniapp):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=BA=95=E9=83=A8=E5=AF=BC=E8=88=AA=E6=A0=8F=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=9E=B6=E6=9E=84=EF=BC=8C=E7=A7=BB=E5=87=BA=E5=BE=AE=E5=AE=98?= =?UTF-8?q?=E7=BD=91=E4=B8=BA=E7=8B=AC=E7=AB=8B=E8=90=BD=E5=9C=B0=E9=A1=B5?= =?UTF-8?q?=EF=BC=8C=E7=BA=AF=E5=8C=96=E5=90=8D=E7=89=87=E4=B8=BB=E7=AE=A1?= =?UTF-8?q?=E5=AE=B6=E5=B7=A5=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mpuniapp/pages.json | 20 +++------ mpuniapp/pages/owner/profile/index.uvue | 1 - mpuniapp/tests/tabbar-ia.test.ts | 60 +++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 14 deletions(-) create mode 100644 mpuniapp/tests/tabbar-ia.test.ts diff --git a/mpuniapp/pages.json b/mpuniapp/pages.json index d91c175..68b3639 100644 --- a/mpuniapp/pages.json +++ b/mpuniapp/pages.json @@ -1,5 +1,12 @@ { "pages": [ + { + "path": "pages/owner/card/index", + "style": { + "navigationBarTitleText": "我的名片", + "backgroundColorContent": "#F7F8FA" + } + }, { "path": "pages/portal/index", "style": { @@ -51,13 +58,6 @@ "backgroundColorContent": "#F7F8FA" } }, - { - "path": "pages/owner/card/index", - "style": { - "navigationBarTitleText": "我的名片", - "backgroundColorContent": "#F7F8FA" - } - }, { "path": "pages/owner/radar", "style": { @@ -164,12 +164,6 @@ "backgroundColor": "#FFFFFF", "borderStyle": "white", "list": [ - { - "pagePath": "pages/portal/index", - "iconPath": "static/tab-portal.png", - "selectedIconPath": "static/tab-portal-active.png", - "text": "官网" - }, { "pagePath": "pages/owner/card/index", "iconPath": "static/tab-card.png", diff --git a/mpuniapp/pages/owner/profile/index.uvue b/mpuniapp/pages/owner/profile/index.uvue index e0f6eed..ab6d221 100644 --- a/mpuniapp/pages/owner/profile/index.uvue +++ b/mpuniapp/pages/owner/profile/index.uvue @@ -445,7 +445,6 @@ function onQuotaClick(): void { function openPage(url: string): void { const tabPages = [ - '/pages/portal/index', '/pages/owner/card/index', '/pages/owner/radar', '/pages/owner/leads', diff --git a/mpuniapp/tests/tabbar-ia.test.ts b/mpuniapp/tests/tabbar-ia.test.ts new file mode 100644 index 0000000..83e45f9 --- /dev/null +++ b/mpuniapp/tests/tabbar-ia.test.ts @@ -0,0 +1,60 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import path from 'node:path'; + +const MP_ROOT = path.resolve('m:/2026项目/CRMmp/mpuniapp'); +const pagesJsonPath = path.join(MP_ROOT, 'pages.json'); +const profileUvuePath = path.join(MP_ROOT, 'pages/owner/profile/index.uvue'); +const cardHomeUtsPath = path.join(MP_ROOT, 'pages/owner/card/useCardHome.uts'); + +test('1. pages.json TabBar 信息架构纯正性审查 (只保留名片主 4 大工作台,移除微官网)', () => { + assert.ok(fs.existsSync(pagesJsonPath), 'pages.json 必须存在'); + const content = fs.readFileSync(pagesJsonPath, 'utf-8'); + const config = JSON.parse(content); + + const tabBarList = config.tabBar?.list || []; + assert.equal(tabBarList.length, 4, 'TabBar 应当仅包含 4 个核心工作台 Tab'); + + // 验证不包含微官网 pages/portal/index + const hasPortalInTabBar = tabBarList.some((item: any) => item.pagePath === 'pages/portal/index'); + assert.equal(hasPortalInTabBar, false, '微官网 pages/portal/index 严禁作为 TabBar 常驻项,应作为独立落地页'); + + // 验证 4 个 Tab 顺序与路由 + assert.equal(tabBarList[0].pagePath, 'pages/owner/card/index', 'TabBar 第 1 项必须是名片'); + assert.equal(tabBarList[0].text, '名片'); + + assert.equal(tabBarList[1].pagePath, 'pages/owner/radar', 'TabBar 第 2 项必须是雷达'); + assert.equal(tabBarList[1].text, '雷达'); + + assert.equal(tabBarList[2].pagePath, 'pages/owner/leads', 'TabBar 第 3 项必须是潜客'); + assert.equal(tabBarList[2].text, '潜客'); + + assert.equal(tabBarList[3].pagePath, 'pages/owner/profile/index', 'TabBar 第 4 项必须是我的'); + assert.equal(tabBarList[3].text, '我的'); + + // 验证 pages[0] 首屏页面为名片页 + assert.equal(config.pages[0].path, 'pages/owner/card/index', '应用首屏 pages[0] 应设为名片首页'); + + // 验证微官网依然保留在 pages 路由列表中供扫码和独立预览访问 + const hasPortalInPages = config.pages.some((item: any) => item.path === 'pages/portal/index'); + assert.equal(hasPortalInPages, true, '微官网 pages/portal/index 必须保留在 pages 列表中供独立沉浸访问'); +}); + +test('2. profile/index.uvue 的 openPage 导航守卫与新 TabBar 保持 100% 一致', () => { + const content = fs.readFileSync(profileUvuePath, 'utf-8'); + + // 验证 tabPages 数组不包含 portal/index,且包含 4 个管理页 + assert.ok(content.includes("'/pages/owner/card/index'"), 'tabPages 必须包含 /pages/owner/card/index'); + assert.ok(content.includes("'/pages/owner/radar'"), 'tabPages 必须包含 /pages/owner/radar'); + assert.ok(content.includes("'/pages/owner/leads'"), 'tabPages 必须包含 /pages/owner/leads'); + assert.ok(content.includes("'/pages/owner/profile/index'"), 'tabPages 必须包含 /pages/owner/profile/index'); + assert.equal(content.includes("'/pages/portal/index'"), false, 'tabPages 严禁包含 /pages/portal/index,微官网应通过 uni.navigateTo 打开'); +}); + +test('3. useCardHome.uts 中的 buildPortalPreviewUrl 保持对微官网的独立全屏预览能力', () => { + const content = fs.readFileSync(cardHomeUtsPath, 'utf-8'); + assert.ok(content.includes('buildPortalPreviewUrl'), '必须包含 buildPortalPreviewUrl'); + assert.ok(content.includes('openCardPreview'), '必须包含 openCardPreview'); + assert.ok(content.includes('/pages/portal/index'), '预览链接必须指向微官网 /pages/portal/index'); +});