jichoi / lms_front star
woals 2024-08-22
240822 권민수 단어장 콘텐츠 인덱스 설정 추가
@554cc5f67a17705030885a864d754dc979f5eb28
client/views/pages/AppStore.js
--- client/views/pages/AppStore.js
+++ client/views/pages/AppStore.js
@@ -17,6 +17,7 @@
         currentProblemIndex: 0,
         textId: null,
         wdBookIdList: [],
+        currentWdBkIndex: 0,
     },
     getters: {
         isLoggedIn(state) {
@@ -56,6 +57,7 @@
         getWdBookIdList(state) {
             return state.wdBookIdList;
         },
+        getCurrentWdBkIndex: (state) => state.currentWdBkIndex,
     },
     mutations: {
         setToken(state, token) {
@@ -117,6 +119,9 @@
         },
         setWdBookIdList(state, wdBookIdList) {
             state.wdBookIdList = wdBookIdList;
+        },
+        setCurrentWdBkIndex(state, currentWdBkIndex) {
+            state.currentWdBkIndex = currentWdBkIndex;
         }
     },
     actions: {
@@ -170,5 +175,8 @@
         updateWdBookIdList({ commit }, wdBookIdList) {
             commit('setWdBookIdList', wdBookIdList);
         },
+        updateCurrentWdBkIndex({ commit }, currentWdBkIndex) {
+            commit('setCurrentWdBkIndex', currentWdBkIndex);
+        }
     },
 });
client/views/pages/main/Chapter/Chapter2_2.vue
--- client/views/pages/main/Chapter/Chapter2_2.vue
+++ client/views/pages/main/Chapter/Chapter2_2.vue
@@ -104,9 +104,17 @@
       timer: 0,
       intervalId: null,
       currentIndex: 0,
+      wdBookId: "",
+      currentWdBkIndex: 0,
     };
   },
   methods: {
+    async fetchWordList() {
+      console.log("현재 단어장 콘텐츠 인덱스: ", this.$store.getters.getCurrentWdBkIndex);
+      this.currentWdBkIndex = this.$store.getters.getCurrentWdBkIndex;
+      console.log("현재 단어장 콘텐츠 인덱스에 대한 단어장 id: ", this.$store.getters.getWdBookIdList[this.currentWdBkIndex]);
+    },
+
     complete() {
       const { unit_id, book_id } = this.$route.query;
       this.$router.push({ name: 'Dashboard', query: { value: 2, unit_id, book_id } });
@@ -157,6 +165,7 @@
     },
   },
   mounted() {
+    this.fetchWordList();
     this.startTimer();
   },
 };
client/views/pages/main/Dashboard.vue
--- client/views/pages/main/Dashboard.vue
+++ client/views/pages/main/Dashboard.vue
@@ -564,6 +564,7 @@
                     this.wordContentList = response.data;
 
                 this.$store.dispatch('updateWdBookIdList', this.wordContentList.map(content => content.wd_book_id));
+                this.$store.dispatch('updateCurrentWdBkIndex', 0);
                 console.log("저장한 단어장 id 리스트: ", this.$store.getters.getWdBookIdList);
 
                 // 단어장 ID 리스트에서 첫 번째 단어장 ID를 사용
@@ -576,7 +577,6 @@
                 })
                 .then((response) => {
                     const wordbookData = response.data;
-                    console.log("wordbookData: ", wordbookData); // 응답 데이터 확인
 
                     // 단어장 타입에 따라 페이지 설정
                     if (wordbookData && wordbookData.wdBookTypeId) {
Add a comment
List