feat: 支持图库瀑布流切换并调整列表间距
This commit is contained in:
1 parent
de421f985e
commit
989f2c1834
7 files changed
+177
-10
No files matched your search
@@ -0,0 +1,20 @@
|
||||
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'
|
||||
}
|
||||
Reference in new issue
Block a user