

240822 권민수 단어장 ID 리스트 상태 저장 로직 추가
@2c9a87b48ccc008b3f8626cbe037839522343625
--- client/views/pages/AppStore.js
+++ client/views/pages/AppStore.js
... | ... | @@ -16,6 +16,7 @@ |
16 | 16 |
currentLabel: null, |
17 | 17 |
currentProblemIndex: 0, |
18 | 18 |
textId: null, |
19 |
+ wdBookIdList: [], |
|
19 | 20 |
}, |
20 | 21 |
getters: { |
21 | 22 |
isLoggedIn(state) { |
... | ... | @@ -52,6 +53,9 @@ |
52 | 53 |
currentLabel: (state) => state.currentLabel, |
53 | 54 |
currentProblemIndex: (state) => state.currentProblemIndex, |
54 | 55 |
prblmTypeId: (state) => state.prblmTypeId, |
56 |
+ getWdBookIdList(state) { |
|
57 |
+ return state.wdBookIdList; |
|
58 |
+ }, |
|
55 | 59 |
}, |
56 | 60 |
mutations: { |
57 | 61 |
setToken(state, token) { |
... | ... | @@ -111,6 +115,9 @@ |
111 | 115 |
state.currentProblemIndex--; |
112 | 116 |
} |
113 | 117 |
}, |
118 |
+ setWdBookIdList(state, wdBookIdList) { |
|
119 |
+ state.wdBookIdList = wdBookIdList; |
|
120 |
+ } |
|
114 | 121 |
}, |
115 | 122 |
actions: { |
116 | 123 |
login({ commit }, token) { |
... | ... | @@ -160,5 +167,8 @@ |
160 | 167 |
goToPreviousProblem({ commit }) { |
161 | 168 |
commit("decrementProblemIndex"); |
162 | 169 |
}, |
170 |
+ updateWdBookIdList({ commit }, wdBookIdList) { |
|
171 |
+ commit('setWdBookIdList', wdBookIdList); |
|
172 |
+ }, |
|
163 | 173 |
}, |
164 | 174 |
}); |
--- client/views/pages/main/Chapter/Chapter2.vue
+++ client/views/pages/main/Chapter/Chapter2.vue
... | ... | @@ -95,24 +95,6 @@ |
95 | 95 |
}; |
96 | 96 |
}, |
97 | 97 |
methods: { |
98 |
- checkAndNavigate() { |
|
99 |
- this.wdContentId = this.$store.getters.getLearningId; // 2. wdContentId를 가져옴 |
|
100 |
- console.log("learning_id: ", this.wdContentId); |
|
101 |
- |
|
102 |
- axios.post("/wordContent/selectWordContent.json", { |
|
103 |
- wordContentId: this.wdContentId, |
|
104 |
- }) |
|
105 |
- .then((response) => { |
|
106 |
- // console.log(response.data); |
|
107 |
- this.wordContentList = response.data; |
|
108 |
- console.log(this.wordContentList[0].wd_book_id); // 3. 단어장 콘텐츠의 첫번째 단어장 id를 표시 |
|
109 |
- |
|
110 |
- }) |
|
111 |
- .catch((error) => { |
|
112 |
- console.error("단어 컨텐츠 목록을 불러오는 중 오류 발생:", error); |
|
113 |
- }); |
|
114 |
- }, |
|
115 |
- |
|
116 | 98 |
async fetchWordList() { |
117 | 99 |
try { |
118 | 100 |
const response = await axios.post("/word/getWordsByBookId.json", { |
... | ... | @@ -160,7 +142,6 @@ |
160 | 142 |
}, |
161 | 143 |
mounted() { |
162 | 144 |
console.log("챕터2 단어장 마운트 완료"); |
163 |
- // this.storeWdBookId(); // 1. 마운트 시 호출 |
|
164 | 145 |
this.fetchWordList(); |
165 | 146 |
}, |
166 | 147 |
}; |
--- client/views/pages/main/Dashboard.vue
+++ client/views/pages/main/Dashboard.vue
... | ... | @@ -563,8 +563,11 @@ |
563 | 563 |
.then((response) => { |
564 | 564 |
this.wordContentList = response.data; |
565 | 565 |
|
566 |
- // 단어장 ID 리스트에서 첫 번째 단어장 ID를 사용 |
|
567 |
- const wdBookId = this.wordContentList[0].wd_book_id; |
|
566 |
+ this.$store.dispatch('updateWdBookIdList', this.wordContentList.map(content => content.wd_book_id)); |
|
567 |
+ console.log("저장한 단어장 id 리스트: ", this.$store.getters.getWdBookIdList); |
|
568 |
+ |
|
569 |
+ // 단어장 ID 리스트에서 첫 번째 단어장 ID를 사용 |
|
570 |
+ const wdBookId = this.wordContentList[0].wd_book_id; |
|
568 | 571 |
|
569 | 572 |
// 단어장 정보 가져오기 |
570 | 573 |
return axios.post("/wordbook/find.json", { |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?