jichoi / lms_front star
woals 2024-08-22
240822 권민수 단어장 Chapter2_3 이미지 파일 경로 설정
@f61c7548dbb944e77ddb292ff9ff3ee83d387a35
client/views/pages/main/Chapter/Chapter2.vue
--- client/views/pages/main/Chapter/Chapter2.vue
+++ client/views/pages/main/Chapter/Chapter2.vue
@@ -38,7 +38,7 @@
               <article class="flex align-center">
                 <div class="imgGroup mr30">
                   <img
-                    :src="'http://localhost:9080/' + word.fileApath"
+                    :src= word.fileApath
                     data-num="1"
                     style="width: 200px"
                   />
@@ -90,11 +90,28 @@
     return {
       wdBookId: "WORD_BOOK_000000000000042",
       wordList: [],
-      // wordContentList: [],
-      // wdContentId: "",
+      wordContentList: [],
+      wdContentId: "",
     };
   },
   methods: {
+    checkAndNavigate() {
+        this.wdContentId = this.$store.getters.getLearningId; // 2. wdContentId를 가져옴
+        console.log("learning_id: ", this.wdContentId);
+
+        axios.post("/wordContent/selectWordContent.json", {
+          wordContentId: this.wdContentId,
+        })
+        .then((response) => {
+          // console.log(response.data);
+          this.wordContentList = response.data;
+          console.log(this.wordContentList[0].wd_book_id); // 3. 단어장 콘텐츠의 첫번째 단어장 id를 표시
+
+        })
+        .catch((error) => {
+          console.error("단어 컨텐츠 목록을 불러오는 중 오류 발생:", error);
+        })
+    },
 
     async fetchWordList() {
       try {
@@ -113,7 +130,7 @@
           const fileApath = fileResponse.data.list.length > 0 ? fileResponse.data.list[0].fileApath : null;
           console.log("각 단어의 fileApath: ", fileApath);
 
-          word.fileApath = fileApath; // fileApath 값을 해당 객체에 추가
+          word.fileApath = "http://localhost:9080/" + fileApath; // fileApath 값을 해당 객체에 추가
         });
 
         // 모든 요청이 완료될 때까지 대기
@@ -143,6 +160,7 @@
   },
   mounted() {
     console.log("챕터2 단어장 마운트 완료");
+    // this.storeWdBookId(); // 1. 마운트 시 호출
     this.fetchWordList();
   },
 };
client/views/pages/main/Chapter/Chapter2_3.vue
--- client/views/pages/main/Chapter/Chapter2_3.vue
+++ client/views/pages/main/Chapter/Chapter2_3.vue
@@ -119,6 +119,7 @@
         updateContent(index) {
             this.selectedIndex = index;
             this.currentCon = this.items[index].con;
+            console.log(this.currentCon.imgSrc);
             this.startTimer();
         },
         startTimer() {
@@ -214,14 +215,21 @@
 
                 this.wordList = response.data;
 
-                this.items = this.wordList.map((word, index) => {
-                    const imgSrc1 = `client/resources/img/img53_${6 + index}_35s.png`;
-                    const imgSrc2 = `client/resources/img/img53_${1 + index}_35s.png`;
+                const requests = this.wordList.map(async (word, index) => {
+                    // fileApath를 받아오기 위한 요청
+                    const fileResponse = await axios.post('/file/find.json', {
+                        file_mng_id: word.fileMngId,
+                    });
+
+                    // fileResponse.data.list에서 fileApath 값을 추출하여 imgSrc에 설정
+                    const fileApath = fileResponse.data.list.length > 0 ? fileResponse.data.list[0].fileApath : null;
+                    const imgSrc = fileApath ? `http://localhost:9080/${fileApath}` : '';
+
                     return {
-                        imgSrc1,
-                        imgSrc2,
+                        imgSrc1: `client/resources/img/img53_${6 + index}_35s.png`,
+                        imgSrc2: `client/resources/img/img53_${1 + index}_35s.png`,
                         con: {
-                            imgSrc: 'client/resources/img/img54_s.png', // 일단은 구름 사진으로 고정
+                            imgSrc, // fileApath를 imgSrc에 설정
                             titleEm: word.wdNm.charAt(0), // 단어의 첫 글자
                             title: word.wdNm.slice(1), // 단어의 나머지 부분
                             boxText: '명',
@@ -230,6 +238,9 @@
                     };
                 });
 
+                // 모든 요청이 완료될 때까지 대기
+                this.items = await Promise.all(requests);
+
                 // items 리스트의 첫 번째 항목을 currentCon에 설정
                 if (this.items.length > 0) {
                     this.currentCon = this.items[0].con;
client/views/pages/main/Dashboard.vue
--- client/views/pages/main/Dashboard.vue
+++ client/views/pages/main/Dashboard.vue
@@ -27,7 +27,7 @@
                         </button>
                         <p>{{ labeledItems[0].label }}</p>
                     </div>
-                    <div class="race-btn" @click="[goToPage('Chapter2'), storeLearningId(labeledItems[1].learning_id)]">
+                    <div class="race-btn" @click="[goToPage('Chapter2'), storeLearningId(labeledItems[1])]">
                         <div class="rabbit-running"><img src="../../../resources/img/img09_s.png" alt=""
                                 :style="{ display: rabbitPos[2] ? 'block' : 'none' }"></div>
                         <button class="popTxt" v-for="(item, index) in items" :key="index" @click="toggleImage(index)"
@@ -589,6 +589,7 @@
         },
         storeLearningId(labeledItems) {
             this.$store.dispatch('updateLearningData', labeledItems)
+            console.log("레이블된 아이템이라매: ", labeledItems);
             if (labeledItems.label.startsWith('문제')) {
                 this.handleProblemDetail(this.$store.getters.currentLearningId)
                 this.goToPage(this.problemType)
Add a comment
List