류윤주 류윤주 04-16
250416 류윤주 스와이퍼 수정
@011f48428b8d89b1cfd77058a327c771bb3e46f9
client/views/pages/adm/boardManagement/template/galleryTemplate/GallerySelectListOne.vue
--- client/views/pages/adm/boardManagement/template/galleryTemplate/GallerySelectListOne.vue
+++ client/views/pages/adm/boardManagement/template/galleryTemplate/GallerySelectListOne.vue
@@ -17,7 +17,7 @@
               <div class="form-content grid-none overflow-y">
                 <div ref="first">
                     <div class="gallery-wrap">
-                      <div class="swiper mySwiper2">
+                      <div v-if="imgFileList.length > 0" class="swiper mySwiper2">
                         <div class="swiper-wrapper">
                           <div class="swiper-slide"
                             v-for="(item, index) in imgFileList"
@@ -28,7 +28,7 @@
                         </div>
                       </div>
 
-                      <div thumbsSlider="" class="swiper mySwiper">
+                      <div v-if="imgFileList.length > 0" thumbsSlider="" class="swiper mySwiper">
                         <div class="swiper-wrapper">
                           <div class="swiper-slide"
                           v-for="(item, index) in imgFileList"
@@ -168,6 +168,8 @@
 import DOMPurify from "dompurify";
 import "../../../../../component/ckeditor5/ckeditor.css";
 import { mdiDownload } from "@mdi/js";
+import Swiper from 'swiper/bundle';
+
 export default {
   mixins: [queryParams],
   data() {
@@ -196,6 +198,8 @@
       upCmntId: null,
       cmnt: {},
       cmntList: [],
+      gallerySwiperInstance1: null,
+      gallerySwiperInstance2: null,
     };
   },
   created() {
@@ -390,6 +394,42 @@
         }
       });
     },
+    // Swiper 인스턴스 초기화 메서드
+    initSwipers() {
+      // 두 번째 Swiper 인스턴스 생성 (gallerySwiper2)
+      this.gallerySwiperInstance2 = new Swiper('.mySwiper', {
+          loop: true,
+          spaceBetween: 10,
+          slidesPerView: 4,
+          freeMode: true,
+          watchSlidesProgress: true
+          // 추가적인 설정 가능
+      });        
+      // 첫 번째 Swiper 인스턴스 생성 (gallerySwiper)
+      this.gallerySwiperInstance1 = new Swiper('.mySwiper2', {
+          spaceBetween: 10,
+          navigation: {
+              nextEl: '.gall-next',
+              prevEl: '.gall-prev'
+          },
+          thumbs: {
+              swiper: this.gallerySwiperInstance2,
+          },
+      });
+    },
+
+    // Swiper 인스턴스 파괴
+    destroySwipers() {
+    if (this.gallerySwiperInstance1) {
+        this.gallerySwiperInstance1.destroy();
+        this.gallerySwiperInstance1 = null;
+    }
+    else if (this.gallerySwiperInstance2) {
+        this.gallerySwiperInstance2.destroy();
+        this.gallerySwiperInstance2 = null;
+    }
+
+    },
   },
   watch: {
     $route(to, from) {
@@ -413,6 +453,23 @@
       },
       deep: true,
     },
+    imgFileList: {
+      handler(newVal) {
+          if (newVal.length > 0) {
+            console.log("갤러리",newVal)
+              // 기존의 swiper 인스턴스가 있으면 파괴하고 다시 초기화
+              if (this.gallerySwiperInstance1 && this.gallerySwiperInstance2) {
+                  this.gallerySwiperInstance1.destroy();
+                  this.gallerySwiperInstance2.destroy();
+              }
+              this.$nextTick(() => {                       
+                  this.initSwipers();
+              });
+          }
+
+      },
+      deep: true // 객체 또는 배열 내부의 변경도 감지
+    }
   },
   computed: {
     sanitizedContent() {
package-lock.json
--- package-lock.json
+++ package-lock.json
@@ -25,7 +25,7 @@
         "moment": "^2.30.1",
         "new-line": "^1.1.1",
         "pg": "8.8.0",
-        "swiper": "^5.3.7",
+        "swiper": "^11.1.5",
         "url-loader": "4.1.1",
         "vue": "3.2.40",
         "vue-cookies": "^1.8.4",
@@ -3020,21 +3020,6 @@
       "funding": {
         "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1"
       }
-    },
-    "node_modules/dom7": {
-      "version": "2.1.5",
-      "resolved": "https://registry.npmjs.org/dom7/-/dom7-2.1.5.tgz",
-      "integrity": "sha512-xnhwVgyOh3eD++/XGtH+5qBwYTgCm0aW91GFgPJ3XG+jlsRLyJivnbP0QmUBFhI+Oaz9FV0s7cxgXHezwOEBYA==",
-      "license": "MIT",
-      "dependencies": {
-        "ssr-window": "^2.0.0"
-      }
-    },
-    "node_modules/dom7/node_modules/ssr-window": {
-      "version": "2.0.0",
-      "resolved": "https://registry.npmjs.org/ssr-window/-/ssr-window-2.0.0.tgz",
-      "integrity": "sha512-NXzN+/HPObKAx191H3zKlYomE5WrVIkoCB5IaSdvKokxTpjBdWfr0RaP+1Z5KOfDT0ZVz+2tdtiBkhsEQ9p+0A==",
-      "license": "MIT"
     },
     "node_modules/domelementtype": {
       "version": "2.3.0",
@@ -7123,12 +7108,6 @@
       "dev": true,
       "license": "BSD-3-Clause"
     },
-    "node_modules/ssr-window": {
-      "version": "1.0.1",
-      "resolved": "https://registry.npmjs.org/ssr-window/-/ssr-window-1.0.1.tgz",
-      "integrity": "sha512-dgFqB+f00LJTEgb6UXhx0h+SrG50LJvti2yMKMqAgzfUmUXZrLSv2fjULF7AWGwK25EXu8+smLR3jYsJQChPsg==",
-      "license": "MIT"
-    },
     "node_modules/ssri": {
       "version": "9.0.1",
       "resolved": "https://registry.npmjs.org/ssri/-/ssri-9.0.1.tgz",
@@ -7354,21 +7333,22 @@
       "integrity": "sha512-djbJ/vZKZO+gPoSDThGNpKDO+o+bAeA4XQKovvkNCqnIS2t+S4qnLAGQhyyrulhCFRl1WWzAp0wUDV8PpTVU3g=="
     },
     "node_modules/swiper": {
-      "version": "5.3.7",
-      "resolved": "https://registry.npmjs.org/swiper/-/swiper-5.3.7.tgz",
-      "integrity": "sha512-BFpXllmUNj1k/Uz6FRW7ykZfUfeCpfqUZxOxeTFZKYy3gv/kOWULHjwy0xlQIJdsiVGF5nZgRG2VbVl6XWy3gw==",
-      "hasInstallScript": true,
+      "version": "11.2.6",
+      "resolved": "https://registry.npmjs.org/swiper/-/swiper-11.2.6.tgz",
+      "integrity": "sha512-8aXpYKtjy3DjcbzZfz+/OX/GhcU5h+looA6PbAzHMZT6ESSycSp9nAjPCenczgJyslV+rUGse64LMGpWE3PX9Q==",
+      "funding": [
+        {
+          "type": "patreon",
+          "url": "https://www.patreon.com/swiperjs"
+        },
+        {
+          "type": "open_collective",
+          "url": "http://opencollective.com/swiper"
+        }
+      ],
       "license": "MIT",
-      "dependencies": {
-        "dom7": "^2.1.3",
-        "ssr-window": "^1.0.1"
-      },
       "engines": {
         "node": ">= 4.7.0"
-      },
-      "funding": {
-        "type": "patreon",
-        "url": "https://www.patreon.com/vladimirkharlampidi"
       }
     },
     "node_modules/tapable": {
package.json
--- package.json
+++ package.json
@@ -20,7 +20,7 @@
     "moment": "^2.30.1",
     "new-line": "^1.1.1",
     "pg": "8.8.0",
-    "swiper": "^5.3.7",
+    "swiper": "^11.1.5",
     "url-loader": "4.1.1",
     "vue": "3.2.40",
     "vue-cookies": "^1.8.4",
Add a comment
List