jichoi / lms_front star
정다정 2024-09-11
240911 정다정 그림생성 검색바로 변경
@c60ea9b63fca2e1da68e98fbfb5201a9efd9e27d
 
client/resources/img/new_img/icon/search-icon.png (Binary) (added)
+++ client/resources/img/new_img/icon/search-icon.png
Binary file is not shown
client/views/component/TextToImage.vue
--- client/views/component/TextToImage.vue
+++ client/views/component/TextToImage.vue
@@ -1,32 +1,35 @@
 <template>
-    <div class="flex justify-center align-center" style="margin-top : 30px">
-        <div class="content title-box aibox">
-            <p class="title mt25 title-bg">모르는 단어를 물어봐~!</p>
-            <div class="propmt-container">
-                <div class="input-conatiner">
-                    <input v-model="word" @keyup.enter="startProgress(word)"/>
-                    <button @click="startProgress(word)"> <p> 생성하기 </p> </button>
+    <div class="flex justify-center align-center">
+        <div class="propmt-container">
+            <div class="input-conatiner">
+                <input v-model="word" @keyup.enter="startProgress(word)" />
+                <button @click="startProgress(word)">
+                    <img src="../../resources/img/new_img/icon/search-icon.png" style="width: 52px" />
+                </button>
+            </div>
+        </div>
+        <div class="modal-container flex" v-if="!modalClose">
+            <div class="progress-container" v-if="progressWidth < 100 && progressWidth > 1">
+                <div class="progress-bar" :style="{ width: progressWidth + '%' }">{{ Math.floor(progressWidth) }}%</div>
+                <!-- 로딩 이미지 -->
+                <div class="loading-container">
+                    <img src="../../resources/img/jumpingRabbit.gif" alt="Loading" class="loading-gif" />
+                    <p>잠깐만 기다려봐~</p>
                 </div>
-                <div class="progress-container">
-                    <div class="progress-bar" :style="{ width: progressWidth + '%' }">{{ Math.floor(progressWidth) }}%</div>
-                    
-                    <!-- 로딩 이미지 -->
-                    <div v-if="progressWidth < 100 && progressWidth > 1" class="loading-container">
-                        <img src="../../resources/img/jumpingRabbit.gif" alt="Loading" class="loading-gif"/>
-                        <p> 잠깐만 기다려봐~ </p>
-                    </div>
-
-                </div>
-                <div v-if="visibleWord" class="result-container">
-                    <img :src="imageSrc"/>
+            </div>
+            <div v-if="visibleWord" class="result-container">
+                <div class="flex align-center modal-box">
+                    <img :src="imageSrc" />
                     <div class="word-container">
-                        <h2> {{ inputWord }}  </h2>
+                        <h2>{{ inputWord }}</h2>
                     </div>
                 </div>
+                <button @click="handleModalClose">
+                    <img src="../../resources/img/btn25_93t_normal.png" alt="" style="width: auto" />
+                </button>
             </div>
         </div>
     </div>
-    
 </template>
 
 <script>
@@ -36,22 +39,22 @@
     data() {
         return {
             progressWidth: 0,
-            inputWord : "",
+            inputWord: '',
 
-            // 하드 코딩 -> 수정 필요 : API
-            word : "",
-            imageSrc : "",
+            word: '',
+            imageSrc: '',
             imageData: null, // 서버에서 받아온 이미지 데이터 저장
 
-            visibleWord : false,
+            visibleWord: false,
+            modalClose: true, // 초기 상태 === 닫힘
         };
     },
-    mounted() {
-        
-    },
+    mounted() {},
     methods: {
         // 상태 진행 바(progress bar)
         startProgress(word) {
+            this.modalClose = false;
+
             if (this.progressWidth == 100) {
                 this.resetProgress();
             }
@@ -72,7 +75,7 @@
                     clearInterval(progressInterval);
                     this.visibleWord = true;
 
-                     // 진행이 완료된 후에 이미지 데이터 렌더링
+                    // 진행이 완료된 후에 이미지 데이터 렌더링
                     if (this.imageData) {
                         this.imageSrc = this.imageUrl;
                     }
@@ -86,31 +89,38 @@
             this.inputWord = word;
             this.visibleWord = false;
         },
-        
+
         resetProgress() {
             this.progressWidth = 0;
             this.visibleWord = false;
-            this.imageSrc = ""; // 이미지 URL 초기화
+            this.imageSrc = ''; // 이미지 URL 초기화
             this.imageData = null; // 이미지 데이터 초기화
+            this.word = '';
+        },
+
+        handleModalClose() {
+            this.resetProgress();
+            this.modalClose = true;
+            console.log('모달 상태 : ', this.modalClose);
         },
 
         // 이미지 API
-        async getAiImage(){
-            const url = "http://takensoftai.iptime.org:20200/generate_json";
+        async getAiImage() {
+            const url = 'http://takensoftai.iptime.org:20200/generate_json';
             // console.log(`word : ${this.word}`);
             try {
                 const response = await axios({
                     url: url,
-                    method: "post",
+                    method: 'post',
                     headers: {
-                        "Content-Type": "application/json; charset=UTF-8",
+                        'Content-Type': 'application/json; charset=UTF-8',
                     },
                     responseType: 'arraybuffer',
                     data: {
-                        text: this.word
+                        text: this.word,
                     },
                 });
-                
+
                 // console.log(`응답 : ${response}`);
 
                 // 바이너리 데이터 -> Blob으로 변환
@@ -124,23 +134,22 @@
             } catch (err) {
                 console.log(err);
             }
-        }
-    }
-}
+        },
+    },
+};
 </script>
 
 <style>
-.propmt-container{
-    padding: 0px 50px 30px 50px;
+.propmt-container {
+    /*padding: 0px 50px 30px 50px;*/
 }
 /* 입력 컨테이너  */
-.input-conatiner{
+.input-conatiner {
     display: flex;
     align-items: center;
-    gap: 30px;
-    height: 50px;
+    width: 80rem;
 }
-.input-conatiner input{
+.input-conatiner input {
     width: 90%;
     height: 100%;
     padding: 10px 30px;
@@ -148,34 +157,35 @@
     border-radius: 10px;
     box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
     outline: none;
-    font-size : 28px;
+    font-size: 28px;
 }
-.input-conatiner button{
+.input-conatiner button {
     width: 15%;
     height: 100%;
     border: none;
     border-radius: 10px;
     cursor: pointer;
-    background-color: #ffba08;
+    /*background-color: #ffba08;*/
     display: flex;
     justify-content: center;
     align-items: center;
 }
 
-.input-conatiner button p{
-    font-size : 28px;
+.input-conatiner button p {
+    font-size: 28px;
 }
 
 /* 진행 상태바 */
 .progress-container {
-    width: 100%;
+    width: 50rem;
+    height: fit-content;
     background-color: #ffffff;
-    border-radius: 5px;
+    border-radius: 10px;
     overflow: hidden;
-    margin-top: 20px;
-    display : flex;
+    display: flex;
     flex-direction: column;
-    gap :30px;
+    gap: 30px;
+    padding: 30px;
 }
 
 .progress-bar {
@@ -185,42 +195,43 @@
     text-align: center;
     line-height: 30px;
     color: white;
-    border : none;
+    border: none;
     border-radius: 5px;
     transition: width 0.3s;
-    font-size : 20px;
+    font-size: 20px;
 }
 
 /* 로딩 gif */
-.loading-container{
-    display : flex;
-    flex-direction: column;
-    align-items: center;
-    gap: 30px;
-    text-align: center;
-    margin-top : 30px;
-    padding-bottom : 40px;
-}
-.loading-gif{
-    width: 25%;
-    border-radius: 500px;
-}
-.loading-container p {
-    font-size : 25px;
-}
-
-/* 결과 container */
-.result-container{
-    margin-top: 30px;
+.loading-container {
     display: flex;
     flex-direction: column;
     align-items: center;
     gap: 30px;
+    text-align: center;
 }
-.result-container img{
-    width : 30%;
+.loading-gif {
+    width: 52%;
+    border-radius: 500px;
 }
-.word-container{
+.loading-container p {
+    font-size: 25px;
+}
+
+/* 결과 container */
+.result-container {
+    display: flex;
+    flex-direction: row;
+    align-items: flex-start;
+    background-color: #fff;
+    padding: 30px;
+    border-radius: 10px;
+    width: 50rem;
+    height: 100%;
+}
+.result-container img {
+    width: 60%;
+}
+.word-container {
     width: 30%;
     text-align: center;
     padding: 20px 0px;
@@ -231,14 +242,31 @@
     gap: 15px;
 }
 .word-container h2 {
-    font-size : 28px;
+    font-size: 28px;
 }
 
-.aibox{
+.aibox {
     display: flex;
     flex-direction: column;
     justify-content: center;
     height: auto;
     padding: 30px 0px;
 }
+
+.modal-container {
+    width: 50rem;
+    height: 40rem;
+    border-radius: 10px;
+    z-index: 100;
+    position: absolute;
+    top: 25rem;
+    right: 10%;
+    box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px;
+}
+
+.modal-box {
+    gap: 30px;
+    margin-top: 10%;
+    margin-left: 5%;
+}
 </style>
client/views/pages/main/Chapter/Chapter1_2.vue
--- client/views/pages/main/Chapter/Chapter1_2.vue
+++ client/views/pages/main/Chapter/Chapter1_2.vue
@@ -1,192 +1,182 @@
 <template>
-  <div id="Chapter1_2" class="content-wrap">
-    <div style="margin: 30px 0px 50px; width: 20%">
-      <router-link to="/MyPlan.page">
-        <div class="logo mb25">
-          <img src="../../../../resources/img/logo2.png" alt="" />
+    <div id="Chapter1_2" class="content-wrap">
+        <div style="margin: 30px 0px 50px; width: 20%">
+            <router-link to="/MyPlan.page">
+                <div class="logo mb25">
+                    <img src="../../../../resources/img/logo2.png" alt="" />
+                </div>
+            </router-link>
         </div>
-      </router-link>
-    </div>
-    <div
-      class="title-box mb25 flex align-center mt40"
-      style="justify-content: space-between"
-    >
-      <div>
-        <span class="title mr40">1. Hello WORLD</span>
-        <span class="subtitle">my name is dd</span>
-      </div>
-      <button class="completeBtn" @click="complete">학습 종료</button>
-    </div>
-    <div class="flex justify-between align-center">
-      <div
-        class="pre-btn"
-        style="visibility: hidden"
-        @click="goToPage('Chapter1_1')"
-      >
-        <img src="../../../../resources/img/left.png" alt="" />
-      </div>
-      <div class="content title-box">
-        <p class="title mt25 title-bg">step1. Hello WORLD</p>
-        <div class="flex justify-center">
-          <div class="readGroup">
-            <h4>각 인물들의 대화를 집중해서 읽어보세요</h4>
+        <div class="title-box mb25 flex align-center mt40" style="justify-content: space-between">
             <div>
-              <div class="textbox">
-                <article
-                  v-for="(line, index) in combinedLines"
-                  :key="index"
-                  :class="[
-                    'flex',
-                    'align-start',
-                    'mb10',
-                    { 'justify-end': index % 2 !== 0 },
-                  ]"
-                >
-                  <div v-if="index % 2 === 0" class="icon mr40">
-                    <img src="../../../../resources/img/img37_s.png" alt="" />
-                    <p class="name">{{ speakerA_name }}</p>
-                  </div>
-                  <p v-if="index % 2 === 0" class="read">{{ line }}</p>
-
-                  <p v-if="index % 2 !== 0" class="read mr40">{{ line }}</p>
-                  <div v-if="index % 2 !== 0" class="icon">
-                    <img src="../../../../resources/img/img37_s.png" alt="" />
-                    <p class="name">{{ speakerB_name }}</p>
-                  </div>
-                </article>
-              </div>
+                <span class="title mr40">1. Hello WORLD</span>
+                <span class="subtitle">my name is dd</span>
             </div>
-          </div>
+            <div class="flex">
+                <TextToImage />
+                <button class="completeBtn" @click="complete">학습 종료</button>
+            </div>
         </div>
-      </div>
-      <div class="next-btn" @click="goToNextPage">
-        <img src="../../../../resources/img/right.png" alt="" />
-      </div>
+        <div class="flex justify-between align-center">
+            <div class="pre-btn" style="visibility: hidden" @click="goToPage('Chapter1_1')">
+                <img src="../../../../resources/img/left.png" alt="" />
+            </div>
+            <div class="content title-box">
+                <p class="title mt25 title-bg">step1. Hello WORLD</p>
+                <div class="flex justify-center">
+                    <div class="readGroup">
+                        <h4>각 인물들의 대화를 집중해서 읽어보세요</h4>
+                        <div>
+                            <div class="textbox">
+                                <article
+                                    v-for="(line, index) in combinedLines"
+                                    :key="index"
+                                    :class="['flex', 'align-start', 'mb10', { 'justify-end': index % 2 !== 0 }]"
+                                >
+                                    <div v-if="index % 2 === 0" class="icon mr40">
+                                        <img src="../../../../resources/img/img37_s.png" alt="" />
+                                        <p class="name">{{ speakerA_name }}</p>
+                                    </div>
+                                    <p v-if="index % 2 === 0" class="read">{{ line }}</p>
+
+                                    <p v-if="index % 2 !== 0" class="read mr40">{{ line }}</p>
+                                    <div v-if="index % 2 !== 0" class="icon">
+                                        <img src="../../../../resources/img/img37_s.png" alt="" />
+                                        <p class="name">{{ speakerB_name }}</p>
+                                    </div>
+                                </article>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="next-btn" @click="goToNextPage">
+                <img src="../../../../resources/img/right.png" alt="" />
+            </div>
+        </div>
     </div>
-    <TextToImage />
-  </div>
 </template>
 
 <script>
-import TextToImage from "../../../component/TextToImage.vue";
-import axios from "axios";
+import TextToImage from '../../../component/TextToImage.vue';
+import axios from 'axios';
 export default {
-  data() {
-    return {
-      text_data: null, // 받아온 지문 정보
-      speakerA_name: null,
-      speakerB_name: null,
-      speakerA: [],
-      speakerB: [],
+    data() {
+        return {
+            text_data: null, // 받아온 지문 정보
+            speakerA_name: null,
+            speakerB_name: null,
+            speakerA: [],
+            speakerB: [],
 
-      seq: this.$store.getters.seqNum,
-    };
-  },
-  methods: {
-    complete() {
-      const { unit_id, book_id } = this.$route.query;
-      this.$router.push({
-        name: "Dashboard",
-        query: { value: this.seq, unit_id, book_id },
-      });
+            seq: this.$store.getters.seqNum,
+        };
     },
-    goToPage(page) {
-      this.$router.push({ name: page });
-    },
-    goToNextPage() {
-      alert("지문 학습 완료!");
-      this.complete();
-    },
-    // 대화 지문 API
-    async fetchText() {
-      axios({
-        url: "/text/selectOneText.json",
-        method: "post",
-        headers: {
-          "Content-Type": "application/json; charset=UTF-8",
+    methods: {
+        complete() {
+            const { unit_id, book_id } = this.$route.query;
+            this.$router.push({
+                name: 'Dashboard',
+                query: { value: this.seq, unit_id, book_id },
+            });
         },
-        data: {
-          textId: this.textId,
+        goToPage(page) {
+            this.$router.push({ name: page });
         },
-      })
-        .then((response) => {
-          this.text_data = response.data[0].text_cnt;
-          this.splitConversation();
-        })
-        .catch((err) => {
-          console.log("지문 에러 : ", err);
-        });
-    },
-    // 대화 지문 split
-    splitConversation() {
-      const lines = this.text_data.split("/");
-      const speakers = {};
+        goToNextPage() {
+            alert('지문 학습 완료!');
+            this.complete();
+        },
+        // 대화 지문 API
+        async fetchText() {
+            axios({
+                url: '/text/selectOneText.json',
+                method: 'post',
+                headers: {
+                    'Content-Type': 'application/json; charset=UTF-8',
+                },
+                data: {
+                    textId: this.textId,
+                },
+            })
+                .then((response) => {
+                    this.text_data = response.data[0].text_cnt;
+                    this.splitConversation();
+                })
+                .catch((err) => {
+                    console.log('지문 에러 : ', err);
+                });
+        },
+        // 대화 지문 split
+        splitConversation() {
+            const lines = this.text_data.split('/');
+            const speakers = {};
 
-      lines.forEach((line) => {
-        const [speaker, message] = line.trim().split(":");
+            lines.forEach((line) => {
+                const [speaker, message] = line.trim().split(':');
 
-        if (!speakers.speakerA_name && !speakers.speakerB_name) {
-          // 첫 번째 발화자를 speakerA_name으로 설정
-          speakers.speakerA_name = speaker.trim();
-          this.speakerA.push(message.trim());
-        } else if (
-          speakers.speakerA_name &&
-          !speakers.speakerB_name &&
-          speakers.speakerA_name !== speaker.trim()
-        ) {
-          // 두 번째 발화자를 speakerB_name으로 설정
-          speakers.speakerB_name = speaker.trim();
-          this.speakerB.push(message.trim());
-        } else if (speaker.trim() === speakers.speakerA_name) {
-          // speakerA_name에 내용 추가
-          this.speakerA.push(message.trim());
-        } else if (speaker.trim() === speakers.speakerB_name) {
-          // speakerB_name에 내용 추가
-          this.speakerB.push(message.trim());
-        }
-      });
+                if (!speakers.speakerA_name && !speakers.speakerB_name) {
+                    // 첫 번째 발화자를 speakerA_name으로 설정
+                    speakers.speakerA_name = speaker.trim();
+                    this.speakerA.push(message.trim());
+                } else if (
+                    speakers.speakerA_name &&
+                    !speakers.speakerB_name &&
+                    speakers.speakerA_name !== speaker.trim()
+                ) {
+                    // 두 번째 발화자를 speakerB_name으로 설정
+                    speakers.speakerB_name = speaker.trim();
+                    this.speakerB.push(message.trim());
+                } else if (speaker.trim() === speakers.speakerA_name) {
+                    // speakerA_name에 내용 추가
+                    this.speakerA.push(message.trim());
+                } else if (speaker.trim() === speakers.speakerB_name) {
+                    // speakerB_name에 내용 추가
+                    this.speakerB.push(message.trim());
+                }
+            });
 
-      this.speakerA_name = speakers.speakerA_name;
-      this.speakerB_name = speakers.speakerB_name;
+            this.speakerA_name = speakers.speakerA_name;
+            this.speakerB_name = speakers.speakerB_name;
+        },
     },
-  },
-  watch: {},
-  computed: {
-    textId() {
-      //console.log("지문 화면 아이디 : ", this.$store.getters.getTextId);
-      return this.$store.getters.getTextId;
-    },
-    combinedLines() {
-      const maxLength = Math.max(this.speakerA.length, this.speakerB.length);
-      const lines = [];
+    watch: {},
+    computed: {
+        textId() {
+            //console.log("지문 화면 아이디 : ", this.$store.getters.getTextId);
+            return this.$store.getters.getTextId;
+        },
+        combinedLines() {
+            const maxLength = Math.max(this.speakerA.length, this.speakerB.length);
+            const lines = [];
 
-      for (let i = 0; i < maxLength; i++) {
-        if (i < this.speakerA.length) {
-          lines.push(this.speakerA[i]);
-        }
-        if (i < this.speakerB.length) {
-          lines.push(this.speakerB[i]);
-        }
-      }
-      return lines;
+            for (let i = 0; i < maxLength; i++) {
+                if (i < this.speakerA.length) {
+                    lines.push(this.speakerA[i]);
+                }
+                if (i < this.speakerB.length) {
+                    lines.push(this.speakerB[i]);
+                }
+            }
+            return lines;
+        },
     },
-  },
-  components: {
-    TextToImage: TextToImage,
-  },
-  mounted() {
-    this.fetchText();
-  },
+    components: {
+        TextToImage: TextToImage,
+    },
+    mounted() {
+        this.fetchText();
+    },
 };
 </script>
 
 <style>
 .completeBtn {
-  margin-right: 100px;
-  background-color: #ffba08;
-  padding: 10px 30px;
-  border-radius: 10px;
-  font-size: 28px;
-  font-family: "ONEMobilePOPOTF";
+    margin-right: 100px;
+    background-color: #ffba08;
+    padding: 10px 30px;
+    border-radius: 10px;
+    font-size: 28px;
+    font-family: 'ONEMobilePOPOTF';
 }
 </style>
Add a comment
List