Explorar el Código

feat(国际化): 添加生成中状态提示并优化关键词显示

- 在hk/cn/en.json中添加ssGeneratingContent翻译字段
- 在choiceQuestionDetailDialog.vue中添加生成中状态提示
- 限制关键词显示数量为前5个
SanHQin hace 5 días
padre
commit
7fc906656a

+ 14 - 3
src/views/Student/components/choiceQuestionDetailDialog.vue

@@ -75,6 +75,7 @@
           <div class="ai_echartsData" v-if="currentAnalysis && currentAnalysis.json.keyword">
           <div class="ai_echartsData" v-if="currentAnalysis && currentAnalysis.json.keyword">
             {{ currentAnalysis.json.keyword }}
             {{ currentAnalysis.json.keyword }}
           </div>
           </div>
+          <div class="generatingContent" v-if="currentAnalysis && currentAnalysis.loading">{{lang.ssGeneratingContent}}...</div>
           <div class="ai_updateTime" v-if="currentAnalysis">{{ lang.ssUpdateTime }}:{{ currentAnalysis.update_at }}
           <div class="ai_updateTime" v-if="currentAnalysis">{{ lang.ssUpdateTime }}:{{ currentAnalysis.update_at }}
           </div>
           </div>
         </div>
         </div>
@@ -146,6 +147,7 @@
             <span v-for="(item,index) in currentAnalysis.json.keyword" :key="index">{{ item }}</span>
             <span v-for="(item,index) in currentAnalysis.json.keyword" :key="index">{{ item }}</span>
             <div class="btn" @click="openEchatsDialog()">{{ lang.ssViewKeywordCloud }}</div>
             <div class="btn" @click="openEchatsDialog()">{{ lang.ssViewKeywordCloud }}</div>
           </div>
           </div>
+          <div class="generatingContent" v-if="currentAnalysis && currentAnalysis.generatingContent">{{ lang.ssGeneratingContent }}...</div>
           <div class="ai_updateTime" v-if="currentAnalysis">{{ lang.ssUpdateTime }}:{{ currentAnalysis.update_at }}
           <div class="ai_updateTime" v-if="currentAnalysis">{{ lang.ssUpdateTime }}:{{ currentAnalysis.update_at }}
           </div>
           </div>
         </div>
         </div>
@@ -910,6 +912,7 @@ const aiAnalysisRefresh45 = () => {
       pid: props.workId,
       pid: props.workId,
       index: props.showData.workIndex,
       index: props.showData.workIndex,
       loading: true,
       loading: true,
+      generatingContent: true,
       json: { text: '', echartsData: '' },
       json: { text: '', echartsData: '' },
       noEnd: true,
       noEnd: true,
       update_at: '',
       update_at: '',
@@ -929,7 +932,7 @@ const aiAnalysisRefresh45 = () => {
     if (event.type === 'message') {
     if (event.type === 'message') {
       aiAnalysisData.value.find((item: any) => {
       aiAnalysisData.value.find((item: any) => {
         return item.pid === props.workId && item.index === props.showData.workIndex
         return item.pid === props.workId && item.index === props.showData.workIndex
-      }).json = event.data
+      }).json.text = event.data
 
 
       aiAnalysisData.value.find((item: any) => {
       aiAnalysisData.value.find((item: any) => {
         return item.pid === props.workId && item.index === props.showData.workIndex
         return item.pid === props.workId && item.index === props.showData.workIndex
@@ -938,7 +941,7 @@ const aiAnalysisRefresh45 = () => {
     else if (event.type === 'messageEnd') {
     else if (event.type === 'messageEnd') {
       aiAnalysisData.value.find((item: any) => {
       aiAnalysisData.value.find((item: any) => {
         return item.pid === props.workId && item.index === props.showData.workIndex
         return item.pid === props.workId && item.index === props.showData.workIndex
-      }).json = event.data
+      }).json.text = event.data
       aiAnalysisData.value.find((item: any) => {
       aiAnalysisData.value.find((item: any) => {
         return item.pid === props.workId && item.index === props.showData.workIndex
         return item.pid === props.workId && item.index === props.showData.workIndex
       }).noEnd = false
       }).noEnd = false
@@ -988,6 +991,7 @@ const aiAnalysisRefresh15 = () => {
       pid: props.workId,
       pid: props.workId,
       index: props.showData.workIndex,
       index: props.showData.workIndex,
       loading: true,
       loading: true,
+      generatingContent: true,
       json: { text: '', echartsData: '' },
       json: { text: '', echartsData: '' },
       noEnd: true,
       noEnd: true,
       update_at: '',
       update_at: '',
@@ -1001,14 +1005,21 @@ const aiAnalysisRefresh15 = () => {
     aiAnalysisData.value.find((item: any) => {
     aiAnalysisData.value.find((item: any) => {
       return item.pid === props.workId && item.index === props.showData.workIndex
       return item.pid === props.workId && item.index === props.showData.workIndex
     }).json = { text: '', echartsData: '' }
     }).json = { text: '', echartsData: '' }
+    aiAnalysisData.value.find((item: any) => {
+      return item.pid === props.workId && item.index === props.showData.workIndex
+    }).generatingContent = true
   }
   }
   getWordCloud15().then((res) => {
   getWordCloud15().then((res) => {
     flag += 1
     flag += 1
+    aiAnalysisData.value.find((item: any) => {
+      return item.pid === props.workId && item.index === props.showData.workIndex
+    }).generatingContent = false
     if (flag == 2) {
     if (flag == 2) {
       saveAnalysis()
       saveAnalysis()
     }
     }
   })
   })
   chat_stream(msg, 'a7741704-ba56-40b7-a6b8-62a423ef9376', props.userId, lang.lang, (event) => {
   chat_stream(msg, 'a7741704-ba56-40b7-a6b8-62a423ef9376', props.userId, lang.lang, (event) => {
+    console.log(event)
     if (event.type === 'message') {
     if (event.type === 'message') {
       aiAnalysisData.value.find((item: any) => {
       aiAnalysisData.value.find((item: any) => {
         return item.pid === props.workId && item.index === props.showData.workIndex
         return item.pid === props.workId && item.index === props.showData.workIndex
@@ -1187,7 +1198,7 @@ const currentAnalysis = computed(() => {
   })
   })
 
 
   if (_result?.json?.echartsData) {
   if (_result?.json?.echartsData) {
-    _result.json.keyword = _result.json.echartsData?.series?.[0]?.data?.map((item: any) => item.name)
+    _result.json.keyword = _result.json.echartsData?.series?.[0]?.data?.slice(0, 5).map((item: any) => item.name)
   }
   }
 
 
 
 

+ 2 - 1
src/views/lang/cn.json

@@ -751,5 +751,6 @@
   "ssPageSizeMismatch": "待添加页面与当前页面大小不一致,是否继续?",
   "ssPageSizeMismatch": "待添加页面与当前页面大小不一致,是否继续?",
   "ssViewKeywordCloud":"点击查看词云",
   "ssViewKeywordCloud":"点击查看词云",
   "ssKeyword":"关键词",
   "ssKeyword":"关键词",
-  "ssKeywordCloud":"词云"
+  "ssKeywordCloud":"词云",
+  "ssGeneratingContent":"生成中"
 }
 }

+ 2 - 1
src/views/lang/en.json

@@ -751,5 +751,6 @@
   "ssPageSizeMismatch": "Page size mismatch, continue?",
   "ssPageSizeMismatch": "Page size mismatch, continue?",
   "ssViewKeywordCloud": "Click to view keyword cloud",
   "ssViewKeywordCloud": "Click to view keyword cloud",
   "ssKeyword": "Keyword",
   "ssKeyword": "Keyword",
-  "ssKeywordCloud": "Word Cloud"
+  "ssKeywordCloud": "Word Cloud",
+  "ssGeneratingContent": "Generating Content"
 }
 }

+ 2 - 1
src/views/lang/hk.json

@@ -751,5 +751,6 @@
   "ssPageSizeMismatch": "頁面大小不一致,是否繼續?",
   "ssPageSizeMismatch": "頁面大小不一致,是否繼續?",
   "ssViewKeywordCloud":"點擊查看詞雲",
   "ssViewKeywordCloud":"點擊查看詞雲",
   "ssKeyword":"關鍵詞",
   "ssKeyword":"關鍵詞",
-  "ssKeywordCloud":"詞雲"
+  "ssKeywordCloud":"詞雲",
+  "ssGeneratingContent":"生成中"
 }
 }