-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
120 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,35 @@ | ||
<template> | ||
<v-row v-if="images" class="my-2"> | ||
<v-col class="pa-2" cols="1" v-for="image in images" :key="image.id"> | ||
<a :href="image.url" target="_blank"><v-img | ||
:src="`https://web-shot.ir/api/gallery/${image.id}?width=200&height=150`"></v-img></a> | ||
<v-row v-if="images && !error" class="my-2" justify="center"> | ||
<v-col class="pa-2" cols="1" v-for="(image, i) in images" :key="i"> | ||
<a :href="image.url" target="_blank"> | ||
<v-img v-if="image.id" | ||
:src="getPublickEndPoint(`api/gallery/${image.id}?width=200&height=150`)"></v-img> | ||
<v-img v-if="!image.id" | ||
:src="getPublickEndPoint(`capture?url=${image.url}&width=200&height=150`)"></v-img> | ||
</a> | ||
</v-col> | ||
</v-row> | ||
<v-progress-circular v-if="pending" indeterminate class="my-5" color="primary" /> | ||
<v-alert class="my-5 text-start" v-if="error" :text="$t('fetch-data.error.server')" type="error" variant="tonal" | ||
closable></v-alert> | ||
</template> | ||
<script lang="ts"> | ||
import { defineComponent } from 'vue'; | ||
import type { PropType } from 'vue' | ||
import { getPublickEndPoint } from '~/utilities'; | ||
interface IImage { | ||
id: number; | ||
id?: number; | ||
url: string; | ||
} | ||
export default defineComponent({ | ||
async setup(app) { | ||
let images: IImage[] | undefined; | ||
let pending: boolean = true; | ||
let error: boolean = false; | ||
try { | ||
const params = new URLSearchParams({ 'count': app.count }); | ||
images = await $fetch(`https://web-shot.ir/api/gallery?${params.toString()}`); | ||
} | ||
catch { | ||
error = true; | ||
} | ||
finally{ | ||
pending = false; | ||
} | ||
return { images, error, pending }; | ||
setup() { | ||
return { getPublickEndPoint }; | ||
}, | ||
props:{ | ||
count: { | ||
type: String, | ||
required: true | ||
} | ||
props: { | ||
images: { | ||
type: Array as PropType<IImage[]> | ||
}, | ||
pending: Boolean, | ||
error: Boolean | ||
}, | ||
created(){ | ||
this.sendImageNum(); | ||
}, | ||
methods:{ | ||
sendImageNum(){ | ||
this.$emit("imagesNum", this.images ? this.images.length : 0) | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function getPublickEndPoint(endPoint: string): string { | ||
return import.meta.env.VITE_SERVER_URL + endPoint; | ||
} |