Files
bridget/assets/ts/resources.ts
Sped0n 3cbbc5b6da refactor(resources.ts): update ImageJSON interface to include separate properties for low resolution and high resolution image URLs, heights, and widths for better organization and clarity
refactor(imageJSON.html): modify image resizing logic to generate separate low resolution and high resolution image URLs, heights, and widths to improve performance and optimize image loading
2023-10-30 17:44:59 +08:00

26 lines
511 B
TypeScript

// data structure for images info
export interface ImageJSON {
index: number
loUrl: string
loImgH: number
loImgW: number
hiUrl: string
hiImgH: number
hiImgW: number
}
export function initResources(): ImageJSON[] {
const imagesJson = document.getElementById('imagesSource')
if (!imagesJson) {
return []
}
return JSON.parse(imagesJson.textContent as string).sort(
(a: ImageJSON, b: ImageJSON) => {
if (a.index < b.index) {
return -1
}
return 1
}
)
}