feat(short-drama-agent-front): 调整工作台布局与图库瀑布流

This commit is contained in:
GJ
2026-09-07 14:17:53 +08:00
parent a37b0b613f
commit 0f8b2074e4
14 changed files with 209 additions and 118 deletions
+7 -27
View File
@@ -1,31 +1,11 @@
import { describe, expect, it } from 'vitest'
import { formCoverAspectRatio } from '@/features/subject-images/layout'
import { formFixture, imageFixture } from '@/features/subject-images/testing/fixtures'
import { masonryRowSpan } from '@/features/subject-images/layout'
describe('图库瀑布流图片比例', () => {
it.each([
[800, 1200],
[1600, 900],
[1024, 1024]
])('保留正式图片尺寸 %s × %s', (width, height) => {
const form = formFixture()
form.images = [imageFixture({ width, height })]
expect(formCoverAspectRatio(form)).toBe(`${width} / ${height}`)
})
it.each([null, 0, -1, NaN, Infinity])('尺寸 %s 无效时使用稳定占位比例', width => {
const form = formFixture()
form.images = [imageFixture({ width })]
expect(formCoverAspectRatio(form)).toBe('4 / 3')
form.images = [imageFixture({ height: width })]
expect(formCoverAspectRatio(form)).toBe('4 / 3')
})
it('无图片时保留占位,候选封面也使用自己的尺寸', () => {
const form = formFixture()
form.images = []
expect(formCoverAspectRatio(form)).toBe('4 / 3')
form.images = [imageFixture({ isPrimary: false, width: 800, height: 1200 })]
expect(formCoverAspectRatio(form)).toBe('800 / 1200')
describe('图库瀑布流卡片布局', () => {
it('按卡片实际高度计算网格跨度', () => {
expect(masonryRowSpan(420, 1, 20)).toBe(21)
expect(masonryRowSpan(421, 1, 20)).toBe(21)
expect(masonryRowSpan(422, 1, 20)).toBe(22)
expect(masonryRowSpan(0, 1, 20)).toBe(1)
})
})