feat(consignment): 打手端寄卖页标题跟随分类 tab 名称
This commit is contained in:
@@ -64,6 +64,7 @@ import type { UploadedFile } from '@/types/worker-platform'
|
||||
import { DEFAULT_CONSIGNMENT_INTAKE_FIELDS, buildSpecItemName } from '@/utils/consignment-spec'
|
||||
import { formatConsignmentContactSupporter } from '@/utils/consignment-contact'
|
||||
import { formatGiftCooldownRemaining } from '@/utils/consignment-cooldown'
|
||||
import { resolveConsignmentPageTitle } from '@/utils/consignment-page-title'
|
||||
import { canWorkerPublishConsignment } from '@/utils/consignment-whitelist'
|
||||
import { formatDateTime } from '@/utils/date-time'
|
||||
import { useIsMobile } from '@/utils/use-is-mobile'
|
||||
@@ -205,6 +206,7 @@ export default function WorkerConsignmentPage() {
|
||||
consignmentProfiles[0] ||
|
||||
null
|
||||
const selectedSpecs: ConsignmentSpecField[] = selectedProfile?.config.specs ?? []
|
||||
const pageTitle = resolveConsignmentPageTitle(selectedProfile)
|
||||
const intakeFields: ConsignmentIntakeField[] =
|
||||
selectedProfile?.config.intake?.fields ?? DEFAULT_CONSIGNMENT_INTAKE_FIELDS
|
||||
useEffect(() => {
|
||||
@@ -684,7 +686,7 @@ export default function WorkerConsignmentPage() {
|
||||
寄卖功能暂未开通
|
||||
</Typography.Title>
|
||||
<Typography.Paragraph type="secondary" style={{ fontSize: 13, marginBottom: 20 }}>
|
||||
平台当前开启寄卖白名单。请联系客服申请开通,由后台运营开通后即可发布苏尔南寄卖。
|
||||
平台当前开启寄卖白名单。请联系客服申请开通,由后台运营开通后即可发布寄卖。
|
||||
</Typography.Paragraph>
|
||||
<Button
|
||||
type="primary"
|
||||
@@ -1069,7 +1071,7 @@ export default function WorkerConsignmentPage() {
|
||||
<div className="worker-orders-desktop-header">
|
||||
<div className="worker-orders-header-left">
|
||||
<Typography.Title level={3} className="worker-orders-heading">
|
||||
苏尔南寄卖
|
||||
{pageTitle}
|
||||
</Typography.Title>
|
||||
<span className="worker-orders-live-badge">
|
||||
<span className="worker-orders-pulse-dot" />
|
||||
|
||||
@@ -4460,6 +4460,19 @@ body {
|
||||
.worker-consignment-page .worker-orders-desktop-header {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
/* 标题跟随分类配置,最长 30 字;移动端允许换行,避免挤压右侧刷新按钮 */
|
||||
.worker-consignment-page .worker-orders-header-left {
|
||||
min-width: 0;
|
||||
flex-shrink: 1;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.worker-consignment-page .worker-orders-heading.ant-typography {
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
line-height: 1.25;
|
||||
}
|
||||
}
|
||||
|
||||
.worker-consignment-page .worker-orders-card {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { WorkerConsignmentProfile } from '../types/consignment'
|
||||
|
||||
type ConsignmentPageTitleProfile =
|
||||
| Pick<WorkerConsignmentProfile, 'tabTitle' | 'categoryName'>
|
||||
| null
|
||||
| undefined
|
||||
|
||||
/**
|
||||
* 打手端寄卖页大标题:跟随当前选中的寄卖分类。
|
||||
* 后台「打手端 tab 名称」留空时按分类名称兜底,与配置页提示保持一致。
|
||||
*/
|
||||
export function resolveConsignmentPageTitle(profile: ConsignmentPageTitleProfile): string {
|
||||
const tabTitle = profile?.tabTitle?.trim()
|
||||
if (tabTitle) return tabTitle
|
||||
const categoryName = profile?.categoryName?.trim()
|
||||
if (categoryName) return categoryName
|
||||
return '寄卖'
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import test from 'node:test'
|
||||
|
||||
import { resolveConsignmentPageTitle } from '../src/utils/consignment-page-title.ts'
|
||||
|
||||
test('寄卖页标题优先使用打手端 tab 名称', () => {
|
||||
assert.equal(
|
||||
resolveConsignmentPageTitle({ tabTitle: ' 苏尔南寄卖 ', categoryName: '苏尔南手枪' }),
|
||||
'苏尔南寄卖',
|
||||
)
|
||||
})
|
||||
|
||||
test('打手端 tab 名称为空时回退分类名称', () => {
|
||||
assert.equal(
|
||||
resolveConsignmentPageTitle({ tabTitle: ' ', categoryName: ' 暗潮手枪 ' }),
|
||||
'暗潮手枪',
|
||||
)
|
||||
})
|
||||
|
||||
test('tab 名称与分类名称都为空时回退「寄卖」', () => {
|
||||
assert.equal(resolveConsignmentPageTitle({ tabTitle: '', categoryName: '' }), '寄卖')
|
||||
assert.equal(resolveConsignmentPageTitle(null), '寄卖')
|
||||
assert.equal(resolveConsignmentPageTitle(undefined), '寄卖')
|
||||
})
|
||||
|
||||
test('打手端寄卖页标题必须跟随选中分类,不得硬编码', () => {
|
||||
const page = readFileSync(
|
||||
fileURLToPath(new URL('../src/pages/worker/WorkerConsignmentPage.tsx', import.meta.url)),
|
||||
'utf8',
|
||||
)
|
||||
assert.ok(
|
||||
page.includes('const pageTitle = resolveConsignmentPageTitle(selectedProfile)'),
|
||||
'标题必须由当前选中的寄卖配置计算',
|
||||
)
|
||||
const headingStart = page.indexOf('className="worker-orders-heading"')
|
||||
assert.ok(headingStart > 0, '找不到寄卖页大标题')
|
||||
const headingBlock = page.slice(headingStart, headingStart + 160)
|
||||
assert.ok(headingBlock.includes('{pageTitle}'), '大标题必须渲染动态 pageTitle')
|
||||
assert.ok(!headingBlock.includes('苏尔南寄卖'), '大标题不得再硬编码苏尔南寄卖')
|
||||
assert.ok(page.includes('即可发布寄卖'), '白名单提示应使用通用「寄卖」文案')
|
||||
assert.ok(!page.includes('即可发布苏尔南寄卖'), '白名单提示不得再硬编码苏尔南寄卖')
|
||||
})
|
||||
Reference in New Issue
Block a user