mirror of
https://github.com/qwertyforce/scenery.git
synced 2025-05-02 13:39:40 +00:00
Update show.tsx
This commit is contained in:
parent
e48b324888
commit
e9d489f5b5
@ -4,10 +4,18 @@ import AppBar from '../components/AppBar'
|
|||||||
import db_ops from '../server/helpers/db_ops'
|
import db_ops from '../server/helpers/db_ops'
|
||||||
import Photo from '../components/Photo'
|
import Photo from '../components/Photo'
|
||||||
import ErrorPage from 'next/error'
|
import ErrorPage from 'next/error'
|
||||||
|
interface Photo{
|
||||||
|
src:string,
|
||||||
|
key: string,
|
||||||
|
width: number,
|
||||||
|
height: number
|
||||||
|
}
|
||||||
|
interface ShowProps{
|
||||||
|
photos:Photo[],
|
||||||
|
err:boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Show(props: ShowProps) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
export default function Show(props: any) {
|
|
||||||
if (props.err) {
|
if (props.err) {
|
||||||
return <ErrorPage statusCode={404} />
|
return <ErrorPage statusCode={404} />
|
||||||
}
|
}
|
||||||
@ -30,13 +38,13 @@ export async function getServerSideProps(context: any) {
|
|||||||
const img_data = await db_ops.image_ops.find_image_by_id(parseInt(id))
|
const img_data = await db_ops.image_ops.find_image_by_id(parseInt(id))
|
||||||
if(img_data[0]){images.push(img_data[0])}
|
if(img_data[0]){images.push(img_data[0])}
|
||||||
}
|
}
|
||||||
const photos = []
|
const photos:Photo[] = []
|
||||||
for (const image of images) {
|
for (const image of images) {
|
||||||
photos.push({
|
photos.push({
|
||||||
src: `/thumbnails/${image.id}.jpg`,
|
src: `/thumbnails/${image.id}.jpg`,
|
||||||
key: `/image/${image.id}`,
|
key: `/image/${image.id}`,
|
||||||
width: image.width,
|
width: image.width as number,
|
||||||
height: image.height
|
height: image.height as number
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if(photos.length!==0){
|
if(photos.length!==0){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user