

240822 정다정 대화지문 API 추가
@5fbbd6bdaef940a4c7906a8fbb059449f83f2dd2
--- client/views/pages/main/Chapter/Chapter1_2.vue
+++ client/views/pages/main/Chapter/Chapter1_2.vue
... | ... | @@ -1,131 +1,154 @@ |
1 | 1 |
<template> |
2 |
- <div id="Chapter1_2" class="content-wrap"> |
|
3 |
- <div style="margin: 30px 0px 50px; width: 20%"> |
|
4 |
- <router-link to="/MyPlan.page"> |
|
5 |
- <div class="logo mb25"><img src="../../../../resources/img/logo2.png" alt=""></div> |
|
6 |
- </router-link> |
|
7 |
- </div> |
|
8 |
- <div class="title-box mb25 flex align-center mt40" style=" |
|
9 |
- justify-content: space-between; |
|
10 |
-"> |
|
11 |
- <div> |
|
12 |
- <span class="title mr40">1. Hello WORLD</span> |
|
13 |
- <span class="subtitle">my name is dd</span> |
|
14 |
- </div> |
|
15 |
- <button class="completeBtn" @click="complete"> 학습 종료 </button> |
|
16 |
- </div> |
|
17 |
- <div class="flex justify-between align-center"> |
|
18 |
- <div class="pre-btn" @click="goToPage('Chapter1_1')"><img src="../../../../resources/img/left.png" alt=""></div> |
|
19 |
- <div class="content title-box"> |
|
20 |
- <p class="title mt25 title-bg">step1. Hello WORLD</p> |
|
21 |
- <div class="flex justify-center"> |
|
22 |
- <div class="readGroup"> |
|
23 |
- <h4>각 인물들의 대화를 집중해서 읽어보세요</h4> |
|
24 |
- <div> |
|
25 |
- <div class="textbox"> |
|
26 |
- <article class="flex align-start mb10"> |
|
27 |
- <div class="icon mr40"> |
|
28 |
- <img src="../../../../resources/img/img37_s.png" alt=""> |
|
29 |
- <p class="name">발화자</p> |
|
30 |
- </div> |
|
31 |
- <p class="read">What’s up man, nice to meet you Minsu. how are you today?</p> |
|
32 |
- </article> |
|
33 |
- <article class="flex align-start mb10 justify-end"> |
|
34 |
- <p class="read mr40">What’s up man, nice to meet you Minsu. how are you today?</p> |
|
35 |
- <div class="icon "> |
|
36 |
- <img src="../../../../resources/img/img37_s.png" alt=""> |
|
37 |
- <p class="name">발화자</p> |
|
38 |
- </div> |
|
39 |
- </article> |
|
40 |
- <article class="flex align-start mb10"> |
|
41 |
- <div class="icon mr40"> |
|
42 |
- <img src="../../../../resources/img/img37_s.png" alt=""> |
|
43 |
- <p class="name">발화자</p> |
|
44 |
- </div> |
|
45 |
- <p class="read">What’s up man, nice to meet you Minsu. how are you today?</p> |
|
46 |
- </article> |
|
47 |
- <article class="flex align-start mb10 justify-end"> |
|
48 |
- <p class="read mr40">What’s up man, nice to meet you Minsu. how are you today?</p> |
|
49 |
- <div class="icon "> |
|
50 |
- <img src="../../../../resources/img/img37_s.png" alt=""> |
|
51 |
- <p class="name">발화자</p> |
|
52 |
- </div> |
|
53 |
- </article> |
|
54 |
- </div> |
|
55 |
- </div> |
|
56 |
- |
|
57 |
- </div> |
|
2 |
+ <div id="Chapter1_2" class="content-wrap"> |
|
3 |
+ <div style="margin: 30px 0px 50px; width: 20%"> |
|
4 |
+ <router-link to="/MyPlan.page"> |
|
5 |
+ <div class="logo mb25"><img src="../../../../resources/img/logo2.png" alt="" /></div> |
|
6 |
+ </router-link> |
|
58 | 7 |
</div> |
59 |
- </div> |
|
60 |
- <div class="next-btn" @click="goToPage('Chapter1_3')"><img src="../../../../resources/img/right.png" alt=""></div> |
|
8 |
+ <div class="title-box mb25 flex align-center mt40" style="justify-content: space-between"> |
|
9 |
+ <div> |
|
10 |
+ <span class="title mr40">1. Hello WORLD</span> |
|
11 |
+ <span class="subtitle">my name is dd</span> |
|
12 |
+ </div> |
|
13 |
+ <button class="completeBtn" @click="complete">학습 종료</button> |
|
14 |
+ </div> |
|
15 |
+ <div class="flex justify-between align-center"> |
|
16 |
+ <div class="pre-btn" @click="goToPage('Chapter1_1')"><img src="../../../../resources/img/left.png" alt="" /></div> |
|
17 |
+ <div class="content title-box"> |
|
18 |
+ <p class="title mt25 title-bg">step1. Hello WORLD</p> |
|
19 |
+ <div class="flex justify-center"> |
|
20 |
+ <div class="readGroup"> |
|
21 |
+ <h4>각 인물들의 대화를 집중해서 읽어보세요</h4> |
|
22 |
+ <div> |
|
23 |
+ <div class="textbox"> |
|
24 |
+ <article v-for="(line, index) in combinedLines" :key="index" :class="['flex', 'align-start', 'mb10', { 'justify-end': index % 2 !== 0 }]"> |
|
25 |
+ <div v-if="index % 2 === 0" class="icon mr40"> |
|
26 |
+ <img src="../../../../resources/img/img37_s.png" alt="" /> |
|
27 |
+ <p class="name">{{ speakerA_name }}</p> |
|
28 |
+ </div> |
|
29 |
+ <p v-if="index % 2 === 0" class="read">{{ line }}</p> |
|
30 |
+ |
|
31 |
+ <p v-if="index % 2 !== 0" class="read mr40">{{ line }}</p> |
|
32 |
+ <div v-if="index % 2 !== 0" class="icon"> |
|
33 |
+ <img src="../../../../resources/img/img37_s.png" alt="" /> |
|
34 |
+ <p class="name">{{ speakerB_name }}</p> |
|
35 |
+ </div> |
|
36 |
+ </article> |
|
37 |
+ </div> |
|
38 |
+ </div> |
|
39 |
+ </div> |
|
40 |
+ </div> |
|
41 |
+ </div> |
|
42 |
+ <div class="next-btn" @click="goToPage('Chapter1_3')"><img src="../../../../resources/img/right.png" alt="" /></div> |
|
43 |
+ </div> |
|
44 |
+ <TextToImage /> |
|
61 | 45 |
</div> |
62 |
- <TextToImage /> |
|
63 |
- </div> |
|
64 | 46 |
</template> |
65 | 47 |
|
66 | 48 |
<script> |
67 |
-import TextToImage from '../../../component/TextToImage.vue'; |
|
49 |
+import TextToImage from "../../../component/TextToImage.vue"; |
|
50 |
+import axios from "axios"; |
|
68 | 51 |
export default { |
69 |
- data() { |
|
70 |
- return { |
|
71 |
- } |
|
72 |
- }, |
|
73 |
- methods: { |
|
74 |
- complete() { |
|
75 |
- const { unit_id, book_id } = this.$route.query; |
|
76 |
- this.$router.push({ name: 'Dashboard', query: { value: 1, unit_id, book_id } }); |
|
52 |
+ data() { |
|
53 |
+ return { |
|
54 |
+ text_id: "TEXT_000000000000050", |
|
55 |
+ text_data: null, // 받아온 지문 정보 |
|
56 |
+ speakerA_name: null, |
|
57 |
+ speakerB_name: null, |
|
58 |
+ speakerA: [], |
|
59 |
+ speakerB: [], |
|
60 |
+ }; |
|
77 | 61 |
}, |
78 |
- goToPage(page) { |
|
79 |
- this.$router.push({ name: page }); |
|
80 |
- } |
|
81 |
- }, |
|
82 |
- watch: { |
|
62 |
+ methods: { |
|
63 |
+ complete() { |
|
64 |
+ const { unit_id, book_id } = this.$route.query; |
|
65 |
+ this.$router.push({ name: "Dashboard", query: { value: 1, unit_id, book_id } }); |
|
66 |
+ }, |
|
67 |
+ goToPage(page) { |
|
68 |
+ this.$router.push({ name: page }); |
|
69 |
+ }, |
|
70 |
+ // 대화 지문 API |
|
71 |
+ async fetchText() { |
|
72 |
+ axios({ |
|
73 |
+ url: "/text/selectOneText.json", |
|
74 |
+ method: "post", |
|
75 |
+ headers: { |
|
76 |
+ "Content-Type": "application/json; charset=UTF-8", |
|
77 |
+ }, |
|
78 |
+ data: { |
|
79 |
+ textId: this.text_id, |
|
80 |
+ }, |
|
81 |
+ }) |
|
82 |
+ .then((response) => { |
|
83 |
+ this.text_data = response.data[0].text_cnt; |
|
84 |
+ this.splitConversation(); |
|
85 |
+ }) |
|
86 |
+ .catch((err) => { |
|
87 |
+ console.log("지문 에러 : ", err); |
|
88 |
+ }); |
|
89 |
+ }, |
|
90 |
+ // 대화 지문 split |
|
91 |
+ splitConversation() { |
|
92 |
+ const lines = this.text_data.split("/"); |
|
93 |
+ const speakers = {}; |
|
83 | 94 |
|
84 |
- }, |
|
85 |
- computed: { |
|
95 |
+ lines.forEach((line) => { |
|
96 |
+ const [speaker, message] = line.trim().split(":"); |
|
86 | 97 |
|
87 |
- }, |
|
88 |
- components: { |
|
89 |
- TextToImage: TextToImage |
|
90 |
- }, |
|
91 |
- mounted() { |
|
92 |
- const textArea = this.$refs.textArea; |
|
93 |
- const popup = this.$refs.popup; |
|
98 |
+ if (!speakers.speakerA_name && !speakers.speakerB_name) { |
|
99 |
+ // 첫 번째 발화자를 speakerA_name으로 설정 |
|
100 |
+ speakers.speakerA_name = speaker.trim(); |
|
101 |
+ this.speakerA.push(message.trim()); |
|
102 |
+ } else if (speakers.speakerA_name && !speakers.speakerB_name && speakers.speakerA_name !== speaker.trim()) { |
|
103 |
+ // 두 번째 발화자를 speakerB_name으로 설정 |
|
104 |
+ speakers.speakerB_name = speaker.trim(); |
|
105 |
+ this.speakerB.push(message.trim()); |
|
106 |
+ } else if (speaker.trim() === speakers.speakerA_name) { |
|
107 |
+ // speakerA_name에 내용 추가 |
|
108 |
+ this.speakerA.push(message.trim()); |
|
109 |
+ } else if (speaker.trim() === speakers.speakerB_name) { |
|
110 |
+ // speakerB_name에 내용 추가 |
|
111 |
+ this.speakerB.push(message.trim()); |
|
112 |
+ } |
|
113 |
+ }); |
|
94 | 114 |
|
95 |
- textArea.addEventListener('mousemove', (event) => { |
|
96 |
- const text = textArea.value; |
|
97 |
- const words = text.split(' '); |
|
98 |
- const selectionStart = textArea.selectionStart; |
|
99 |
- const selectionEnd = textArea.selectionEnd; |
|
115 |
+ this.speakerA_name = speakers.speakerA_name; |
|
116 |
+ this.speakerB_name = speakers.speakerB_name; |
|
117 |
+ }, |
|
118 |
+ }, |
|
119 |
+ watch: {}, |
|
120 |
+ computed: { |
|
121 |
+ combinedLines() { |
|
122 |
+ const maxLength = Math.max(this.speakerA.length, this.speakerB.length); |
|
123 |
+ const lines = []; |
|
100 | 124 |
|
101 |
- if (selectionStart !== selectionEnd) { |
|
102 |
- const selectedText = text.substring(selectionStart, selectionEnd); |
|
103 |
- const rect = textArea.getBoundingClientRect(); |
|
104 |
- popup.style.left = `${event.clientX}px`; |
|
105 |
- popup.style.top = `${event.clientY + window.scrollY}px`; |
|
106 |
- popup.innerHTML = `You selected: ${selectedText}`; |
|
107 |
- popup.style.display = 'block'; |
|
108 |
- } else { |
|
109 |
- popup.style.display = 'none'; |
|
110 |
- } |
|
111 |
- }); |
|
112 |
- |
|
113 |
- document.addEventListener('click', (event) => { |
|
114 |
- if (!textArea.contains(event.target) && !popup.contains(event.target)) { |
|
115 |
- popup.style.display = 'none'; |
|
116 |
- } |
|
117 |
- }); |
|
118 |
- } |
|
119 |
-} |
|
125 |
+ for (let i = 0; i < maxLength; i++) { |
|
126 |
+ if (i < this.speakerA.length) { |
|
127 |
+ lines.push(this.speakerA[i]); |
|
128 |
+ } |
|
129 |
+ if (i < this.speakerB.length) { |
|
130 |
+ lines.push(this.speakerB[i]); |
|
131 |
+ } |
|
132 |
+ } |
|
133 |
+ return lines; |
|
134 |
+ }, |
|
135 |
+ }, |
|
136 |
+ components: { |
|
137 |
+ TextToImage: TextToImage, |
|
138 |
+ }, |
|
139 |
+ mounted() { |
|
140 |
+ this.fetchText(); |
|
141 |
+ }, |
|
142 |
+}; |
|
120 | 143 |
</script> |
121 | 144 |
|
122 | 145 |
<style> |
123 | 146 |
.completeBtn { |
124 |
- margin-right: 100px; |
|
125 |
- background-color: #ffba08; |
|
126 |
- padding: 10px 30px; |
|
127 |
- border-radius: 10px; |
|
128 |
- font-size: 28px; |
|
129 |
- font-family: 'ONEMobilePOPOTF'; |
|
147 |
+ margin-right: 100px; |
|
148 |
+ background-color: #ffba08; |
|
149 |
+ padding: 10px 30px; |
|
150 |
+ border-radius: 10px; |
|
151 |
+ font-size: 28px; |
|
152 |
+ font-family: "ONEMobilePOPOTF"; |
|
130 | 153 |
} |
131 |
-</style>(No newline at end of file) |
|
154 |
+</style> |
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?