File tree Expand file tree Collapse file tree 3 files changed +20
-20
lines changed Expand file tree Collapse file tree 3 files changed +20
-20
lines changed Original file line number Diff line number Diff line change @@ -168,15 +168,6 @@ onMounted(async () => {
168168 template = ' Generate image for field {{field}} in {{resource}}. No text should be on image.' ;
169169 }
170170 prompt .value = template ;
171-
172- const recordId = props .record [props .meta .recorPkFieldName ];
173- if (! recordId ) {
174- emit (' error' , {
175- isError: true ,
176- errorMessage: ' Record ID not found, cannot generate images'
177- });
178- return ;
179- }
180171});
181172
182173
@@ -334,7 +325,7 @@ async function generateImages() {
334325
335326 await nextTick ();
336327
337- sliderRef .value ?.slideTo (images .value .length );
328+ sliderRef .value ?.slideTo (images .value .length - 1 );
338329
339330 await nextTick ();
340331
Original file line number Diff line number Diff line change @@ -15,11 +15,25 @@ const props = defineProps<{images: string[]}>()
1515let swiperEl: any ;
1616
1717function getActiveIndex() {
18- return swiperEl .swiper .activeIndex
18+ if (swiperEl && swiperEl .swiper ) {
19+ return swiperEl .swiper .activeIndex ;
20+ }
21+ return 0 ;
1922}
2023
2124function slideTo(index ) {
22- swiperEl .swiper .slideTo (index )
25+
26+ if (! swiperEl || ! swiperEl .swiper ) {
27+ setTimeout (() => slideTo (index ), 50 );
28+ return ;
29+ }
30+
31+ if (index >= 0 && index < props .images .length ) {
32+ swiperEl .swiper .update ();
33+ setTimeout (() => {
34+ swiperEl .swiper .slideTo (index , 300 );
35+ }, 10 );
36+ }
2337}
2438
2539defineExpose ({
@@ -29,24 +43,19 @@ defineExpose({
2943
3044register ()
3145onMounted (() => {
32- swiperEl = document .querySelector (' swiper-container' )
46+ swiperEl = document .querySelector (' swiper-container' )
3347
3448 const swiperParams: SwiperOptions = {
3549 slidesPerView: 1 ,
3650 navigation: true ,
3751 pagination: {
3852 type: ' fraction' ,
3953 },
40- on: {
41- init() {
42- console .log (' swiper initialized' )
43- },
44- },
54+ allowTouchMove: true ,
4555 }
4656
4757 Object .assign (swiperEl , swiperParams )
4858 swiperEl .initialize ()
49- swiperEl .swiper ;
5059})
5160 </script >
5261
Original file line number Diff line number Diff line change 9191
9292 <div v-if =" isAiResponseReceivedImage[tableColumnsIndexes.findIndex(el => el[primaryKey] === item[primaryKey])]" >
9393 <div v-if =" isInColumnImage(n)" >
94- <div class =" mt-2 flex items-center justify-center gap-2" >
94+ <div class =" mt-2 flex items-center justify-start gap-2" >
9595 <img v-if =" isValidUrl(selected[tableColumnsIndexes.findIndex(el => el[primaryKey] === item[primaryKey])][n])"
9696 :src =" selected[tableColumnsIndexes.findIndex(el => el[primaryKey] === item[primaryKey])][n]"
9797 class =" w-20 h-20 object-cover rounded cursor-pointer border hover:border-blue-500 transition"
You can’t perform that action at this time.
0 commit comments