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

This commit is contained in:
GJ committed 2026-09-07 14:17:53 +08:00
1 parent a37b0b613f
commit 0f8b2074e4
14 files changed
+209 -118

No files matched your search

+10 -16
View File
@@ -1,20 +1,14 @@
import { coverImage } from './model'
import type { SubjectFormAsset } from './types'
/** 图库展示方式;仅改变卡片排版,不影响素材顺序、筛选及后端查询。 */
export type GalleryLayout = 'grid' | 'masonry'
/** 按正式封面尺寸预留瀑布流图片高度,避免懒加载时卡片跳动;旧记录缺少尺寸时使用 4:3。 */
export function formCoverAspectRatio(form: SubjectFormAsset): string {
const image = coverImage(form)
const width = image?.width
const height = image?.height
return typeof width === 'number' &&
typeof height === 'number' &&
Number.isFinite(width) &&
Number.isFinite(height) &&
width > 0 &&
height > 0
? `${width} / ${height}`
: '4 / 3'
/**
* 计算瀑布流卡片需要跨越的网格行数。
* @param height 卡片实际高度
* @param rowHeight 隐式网格行高
* @param rowGap 网格行间距
* @returns 卡片需要跨越的网格行数
*/
export function masonryRowSpan(height: number, rowHeight: number, rowGap: number): number {
if (![height, rowHeight, rowGap].every(Number.isFinite) || height <= 0 || rowHeight <= 0 || rowGap < 0) return 1
return Math.max(1, Math.ceil((height + rowGap) / (rowHeight + rowGap)))
}