2026-09-10 16:06:11 +08:00
|
|
|
|
import assert from 'node:assert/strict'
|
|
|
|
|
|
import { existsSync, readFileSync } from 'node:fs'
|
|
|
|
|
|
import { resolve } from 'node:path'
|
|
|
|
|
|
|
|
|
|
|
|
const root = resolve(import.meta.dirname, '..')
|
|
|
|
|
|
const read = (path) => readFileSync(resolve(root, path), 'utf8')
|
|
|
|
|
|
|
|
|
|
|
|
function assertInOrder(source, labels, scope) {
|
|
|
|
|
|
let previous = -1
|
|
|
|
|
|
for (const label of labels) {
|
|
|
|
|
|
const position = source.indexOf(label)
|
|
|
|
|
|
assert.notEqual(position, -1, `${scope}缺少“${label}”`)
|
|
|
|
|
|
assert.ok(position > previous, `${scope}中“${label}”顺序错误`)
|
|
|
|
|
|
previous = position
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const appConfig = JSON.parse(read('miniapp/app.json'))
|
2026-10-11 13:08:02 +08:00
|
|
|
|
// ZC-MM-003(B1 立项):contact-consent 联系授权确认页(用户单独明示同意)→ 63 → 64
|
|
|
|
|
|
assert.equal(appConfig.pages.length, 64, '小程序页面清单必须完整覆盖 64 页')
|
2026-09-11 16:08:17 +08:00
|
|
|
|
const redesignMatrix = read('docs/UI_REDESIGN_PAGE_MATRIX_V1.1.md')
|
2026-09-13 21:12:50 +08:00
|
|
|
|
for (const page of [
|
|
|
|
|
|
'pages/index/index', 'pages/discover/discover', 'pages/messages/messages',
|
|
|
|
|
|
'pages/activity/activity', 'pages/mine/mine', 'pages/matchmaker/matchmaker',
|
|
|
|
|
|
'pages/counseling-intro/counseling-intro', 'pages/premarital-intro/premarital-intro',
|
|
|
|
|
|
'pages/content/content', 'pages/anti-fraud/anti-fraud', 'pages/service-station/service-station',
|
|
|
|
|
|
]) {
|
|
|
|
|
|
assert.ok(redesignMatrix.includes(`\`/${page}\``), `首批页面矩阵遗漏 /${page}`)
|
2026-09-11 16:08:17 +08:00
|
|
|
|
}
|
2026-09-10 16:06:11 +08:00
|
|
|
|
assert.deepEqual(
|
|
|
|
|
|
appConfig.tabBar.list.map((item) => item.text),
|
|
|
|
|
|
['首页', '找对象', '消息', '活动', '我的'],
|
|
|
|
|
|
'底部导航顺序必须固定',
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const requiredPages = [
|
|
|
|
|
|
'pages/service-center/service-center',
|
|
|
|
|
|
'pages/service-station/service-station',
|
|
|
|
|
|
'pages/service-appointment/service-appointment',
|
|
|
|
|
|
'pages/my-appointments/my-appointments',
|
|
|
|
|
|
'pages/content/content',
|
|
|
|
|
|
'pages/content-detail/content-detail',
|
|
|
|
|
|
'pages/anti-fraud/anti-fraud',
|
|
|
|
|
|
'pages/service-program/service-program',
|
|
|
|
|
|
'pages/service-history/service-history',
|
|
|
|
|
|
]
|
|
|
|
|
|
for (const page of requiredPages) {
|
|
|
|
|
|
assert.ok(appConfig.pages.includes(page), `小程序未注册页面 ${page}`)
|
2026-09-13 21:12:50 +08:00
|
|
|
|
for (const extension of ['json', 'wxml', 'wxss']) {
|
2026-09-10 16:06:11 +08:00
|
|
|
|
assert.ok(existsSync(resolve(root, `miniapp/${page}.${extension}`)), `小程序页面文件缺失:${page}.${extension}`)
|
|
|
|
|
|
}
|
2026-09-13 21:12:50 +08:00
|
|
|
|
assert.ok(
|
|
|
|
|
|
existsSync(resolve(root, `miniapp/${page}.ts`)) || existsSync(resolve(root, `miniapp/${page}.js`)),
|
|
|
|
|
|
`小程序页面缺少 TypeScript 或 JavaScript 逻辑源:${page}`,
|
|
|
|
|
|
)
|
2026-09-10 16:06:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 18:37:53 +08:00
|
|
|
|
const sharedServiceStyle = read('miniapp/styles/service-page.wxss')
|
|
|
|
|
|
assert.doesNotMatch(sharedServiceStyle, /@import\s+["']\.\.\/\.\.\/app\.wxss["']/, '共享页面样式不能错误导入 ../../app.wxss')
|
2026-09-10 16:06:11 +08:00
|
|
|
|
const homeMarkup = read('miniapp/pages/index/index.wxml')
|
2026-09-10 18:37:53 +08:00
|
|
|
|
assert.doesNotMatch(homeMarkup, /<[^>]+wx:elif="\{\{recommendations\.length\}\}"[^>]+wx:for=/, '推荐条件分支与循环必须分离,避免 wx:else 失联')
|
2026-09-13 21:12:50 +08:00
|
|
|
|
assert.match(homeMarkup, /wx:elif="\{\{recommendations\.length\}\}"/, '推荐列表必须有独立条件分支')
|
2026-09-10 16:06:11 +08:00
|
|
|
|
|
2026-09-13 21:12:50 +08:00
|
|
|
|
const homeLogic = read('miniapp/pages/index/index.ts')
|
2026-09-10 16:06:11 +08:00
|
|
|
|
assertInOrder(homeLogic, [
|
|
|
|
|
|
"label: '找对象'", "label: '公益红娘'", "label: '公益活动'", "label: '婚恋咨询'",
|
|
|
|
|
|
"label: '婚恋课堂'", "label: '婚前辅导'", "label: '婚恋反诈'", "label: '善缘服务站'",
|
|
|
|
|
|
], '首页核心入口')
|
|
|
|
|
|
assert.doesNotMatch(homeLogic, /功能开发中/, '首页核心入口不得使用“功能开发中”占位')
|
|
|
|
|
|
|
|
|
|
|
|
const activityDetailMarkup = read('miniapp/pages/activity-detail/activity-detail.wxml')
|
|
|
|
|
|
assert.doesNotMatch(activityDetailMarkup, /页面:\s*activity-detail/, '活动详情页不得是占位页面')
|
|
|
|
|
|
assert.match(activityDetailMarkup, /活动信息/, '活动详情页必须展示活动信息')
|
|
|
|
|
|
assert.match(activityDetailMarkup, /报名须知/, '活动详情页必须展示报名须知')
|
|
|
|
|
|
|
|
|
|
|
|
const adminLayout = read('admin-web/src/layouts/MainLayout.vue')
|
|
|
|
|
|
assert.match(adminLayout, /善缘丹阳/, '后台品牌名称必须为善缘丹阳')
|
|
|
|
|
|
|
2026-09-10 21:31:38 +08:00
|
|
|
|
const adminApiContracts = [
|
|
|
|
|
|
['admin-web/src/modules/banner/BannerManagementView.vue', '/operator/banners'],
|
|
|
|
|
|
['admin-web/src/modules/service-station/ServiceStationView.vue', '/operator/service-locations'],
|
|
|
|
|
|
['admin-web/src/modules/service-appointment/ServiceAppointmentView.vue', '/service-appointments/operator/list'],
|
|
|
|
|
|
['admin-web/src/modules/activity/ActivityInterestView.vue', '/activities/operator/activity-interest-summary'],
|
|
|
|
|
|
]
|
|
|
|
|
|
for (const [file, endpoint] of adminApiContracts) {
|
|
|
|
|
|
assert.ok(read(file).includes(endpoint), `${file} 未使用实际后台接口 ${endpoint}`)
|
|
|
|
|
|
}
|
|
|
|
|
|
assert.doesNotMatch(read('admin-web/src/modules/risk/ReportCenterView.vue'), /tableData\.value = res \|\|/, '举报列表不能把响应信封当数组')
|
|
|
|
|
|
assert.doesNotMatch(read('admin-web/src/modules/appeal/AppealCenterView.vue'), /tableData\.value = res \|\|/, '申诉列表不能把响应信封当数组')
|
|
|
|
|
|
|
2026-09-10 16:06:11 +08:00
|
|
|
|
console.log('UI contracts passed')
|