update: pobieranie zdjęć z API (gh)

This commit is contained in:
2023-01-03 19:21:54 +01:00
parent c5b3e8f3e0
commit 8e0cf04562
2 changed files with 10 additions and 6 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ export default defineComponent({
async created() {
const stockData = await (
await fetch(`https://spythere.github.io/api/stockDataNew.json?t=${Math.floor(Date.now() / 60000)}`)
await fetch(`https://spythere.github.io/api/td2/data/stockData.json?t=${Math.floor(Date.now() / 60000)}`)
).json();
this.store.stockData = stockData;
+9 -5
View File
@@ -3,20 +3,22 @@
<div class="train-image__wrapper">
<div class="train-image__content">
<transition name="img-message-anim">
<div class="empty-message" v-if="store.imageLoading && store.chosenVehicle?.imageSrc">ŁADOWANIE OBRAZU...</div>
<div class="empty-message" v-if="store.imageLoading && store.chosenVehicle?.imageSrc">
ŁADOWANIE OBRAZU...
</div>
</transition>
<div class="no-img" v-if="!store.chosenVehicle">PODGLĄD WYBRANEGO POJAZDU</div>
<img
v-if="store.chosenVehicle && store.chosenVehicle.imageSrc"
:src="store.chosenVehicle.imageSrc"
v-if="store.chosenVehicle"
:src="`https://spythere.github.io/api/td2/images/${store.chosenVehicle.type}--300px.jpg`"
:alt="store.chosenVehicle.type"
@load="onImageLoad"
@click="onImageClick"
/>
<div class="empty-message" v-if="store.chosenVehicle && !store.chosenVehicle.imageSrc">Ten pojazd nie ma jeszcze podglądu!</div>
<!-- <div class="empty-message" v-if="store.chosenVehicle && !store.chosenVehicle.imageSrc">Ten pojazd nie ma jeszcze podglądu!</div> -->
</div>
<div class="train-image__info" v-if="store.chosenVehicle">
@@ -81,6 +83,8 @@ export default defineComponent({
watch: {
chosenVehicle(vehicle: Vehicle, prevVehicle: Vehicle) {
console.log(vehicle);
if (vehicle && vehicle.type != prevVehicle?.type) {
this.store.imageLoading = true;
}
@@ -101,7 +105,7 @@ export default defineComponent({
if (!chosenVehicle) return;
this.store.vehiclePreviewSrc = chosenVehicle.imageSrc.replace('300', '800');
this.store.vehiclePreviewSrc = `https://spythere.github.io/api/td2/images/${chosenVehicle.type}--800px.jpg`;
},
},
});