jichoi / lms_front star
woals 2024-08-22
240822 권민수 단어장 ID 리스트 상태 저장 로직 추가
@2c9a87b48ccc008b3f8626cbe037839522343625
client/views/pages/AppStore.js
--- client/views/pages/AppStore.js
+++ client/views/pages/AppStore.js
@@ -16,6 +16,7 @@
         currentLabel: null,
         currentProblemIndex: 0,
         textId: null,
+        wdBookIdList: [],
     },
     getters: {
         isLoggedIn(state) {
@@ -52,6 +53,9 @@
         currentLabel: (state) => state.currentLabel,
         currentProblemIndex: (state) => state.currentProblemIndex,
         prblmTypeId: (state) => state.prblmTypeId,
+        getWdBookIdList(state) {
+            return state.wdBookIdList;
+        },
     },
     mutations: {
         setToken(state, token) {
@@ -111,6 +115,9 @@
                 state.currentProblemIndex--;
             }
         },
+        setWdBookIdList(state, wdBookIdList) {
+            state.wdBookIdList = wdBookIdList;
+        }
     },
     actions: {
         login({ commit }, token) {
@@ -160,5 +167,8 @@
         goToPreviousProblem({ commit }) {
             commit("decrementProblemIndex");
         },
+        updateWdBookIdList({ commit }, wdBookIdList) {
+            commit('setWdBookIdList', wdBookIdList);
+        },
     },
 });
client/views/pages/main/Chapter/Chapter2.vue
--- client/views/pages/main/Chapter/Chapter2.vue
+++ client/views/pages/main/Chapter/Chapter2.vue
@@ -95,24 +95,6 @@
     };
   },
   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 {
         const response = await axios.post("/word/getWordsByBookId.json", {
@@ -160,7 +142,6 @@
   },
   mounted() {
     console.log("챕터2 단어장 마운트 완료");
-    // this.storeWdBookId(); // 1. 마운트 시 호출
     this.fetchWordList();
   },
 };
client/views/pages/main/Dashboard.vue
--- client/views/pages/main/Dashboard.vue
+++ client/views/pages/main/Dashboard.vue
@@ -563,8 +563,11 @@
                 .then((response) => {
                     this.wordContentList = response.data;
 
-                    // 단어장 ID 리스트에서 첫 번째 단어장 ID를 사용
-                    const wdBookId = this.wordContentList[0].wd_book_id;
+                this.$store.dispatch('updateWdBookIdList', this.wordContentList.map(content => content.wd_book_id));
+                console.log("저장한 단어장 id 리스트: ", this.$store.getters.getWdBookIdList);
+
+                // 단어장 ID 리스트에서 첫 번째 단어장 ID를 사용
+                const wdBookId = this.wordContentList[0].wd_book_id;
 
                     // 단어장 정보 가져오기
                     return axios.post("/wordbook/find.json", {
Add a comment
List