feat(distribution): 分站首页改为联名标题并同步手机轮播
首页主标题显示为站名×大锤商行,手机端使用与电脑端相同的分站自定义海报。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { formatDistributionCoBrandName, mapDistributionHomeBanners } from './distributionSite'
|
||||
|
||||
describe('formatDistributionCoBrandName', () => {
|
||||
it('joins a distribution site with the main brand', () => {
|
||||
expect(formatDistributionCoBrandName('天域商行', true)).toBe('天域商行×大锤商行')
|
||||
})
|
||||
|
||||
it('keeps the main site name', () => {
|
||||
expect(formatDistributionCoBrandName('大锤商行', false)).toBe('大锤商行')
|
||||
})
|
||||
})
|
||||
|
||||
describe('mapDistributionHomeBanners', () => {
|
||||
it('uses the custom image without overlay copy', () => {
|
||||
const [slide] = mapDistributionHomeBanners(
|
||||
[{ image_url: 'https://cdn.example/poster.webp', title: '海报标题' }],
|
||||
'天域商行'
|
||||
)
|
||||
expect(slide?.image_url).toBe('https://cdn.example/poster.webp')
|
||||
expect(slide?.title).toBe('')
|
||||
expect(slide?.eyebrow).toBe('')
|
||||
expect(slide?.pill).toBe('')
|
||||
})
|
||||
})
|
||||
@@ -14,6 +14,50 @@ export interface DistributionBanner {
|
||||
title?: string
|
||||
}
|
||||
|
||||
export interface DistributionHomeBanner {
|
||||
eyebrow: string
|
||||
title: string
|
||||
badge: string
|
||||
pill: string
|
||||
tone: string
|
||||
image_url?: string
|
||||
}
|
||||
|
||||
/** 分站首页主标题:站名与主站联名。主站或站名已含主站名时保持原样。 */
|
||||
export function formatDistributionCoBrandName(siteName: string, isDistribution: boolean): string {
|
||||
const name = siteName.trim()
|
||||
if (!isDistribution) return name || '大锤商行'
|
||||
if (!name || name.includes('大锤商行')) return name || '大锤商行'
|
||||
return `${name}×大锤商行`
|
||||
}
|
||||
|
||||
/** 分站首页轮播:有图时不再叠标题,避免整幅压暗。 */
|
||||
export function mapDistributionHomeBanners(
|
||||
banners: DistributionBanner[],
|
||||
siteName: string
|
||||
): DistributionHomeBanner[] {
|
||||
return banners.map(banner => {
|
||||
const imageUrl = banner.image_url?.trim() || ''
|
||||
if (imageUrl) {
|
||||
return {
|
||||
eyebrow: '',
|
||||
title: '',
|
||||
badge: '本店精选',
|
||||
pill: '',
|
||||
tone: 'gold',
|
||||
image_url: imageUrl,
|
||||
}
|
||||
}
|
||||
return {
|
||||
eyebrow: siteName,
|
||||
title: banner.title?.trim() || '精选游戏账号 · 随租随玩',
|
||||
badge: '本店精选',
|
||||
pill: '官方保障',
|
||||
tone: 'gold',
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export interface DistributionFooterInfo {
|
||||
icp?: string
|
||||
copyright?: string
|
||||
@@ -92,6 +136,10 @@ export const useDistributionSiteStore = defineStore('distributionSite', {
|
||||
brandMark(state): string {
|
||||
return state.isDistribution && state.siteName ? state.siteName.slice(0, 1) : '锤'
|
||||
},
|
||||
/** 分站首页主标题:站名与主站联名。 */
|
||||
coBrandName(state): string {
|
||||
return formatDistributionCoBrandName(state.siteName, state.isDistribution)
|
||||
},
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
||||
Reference in New Issue
Block a user