Przeglądaj źródła

课文添加文本分析按钮

natasha 1 rok temu
rodzic
commit
1217c3b8cf

+ 4 - 13
src/api/ajax.js

@@ -1,5 +1,5 @@
 import request from '@/utils/request'
-import { getToken } from '@/utils/auth'
+import { getToken,getAccessToken } from '@/utils/auth'
 export function getContent(MethodName, data) {
     let userInfor = getToken();
     let UserCode = '',
@@ -337,19 +337,10 @@ export function compareSenTenceTime(data) {
 
 // 文本分析 
 export function analysSubmit(data) {
-    let userInfor = getToken();
-    let UserCode = '',
-        UserType = '',
-        SessionID = ''
-    if (userInfor) {
-        let user = JSON.parse(getToken());
-        UserCode = user.user_code;
-        UserType = user.user_type;
-        SessionID = user.session_id;
-    }
     return request({
-        url: `/GCLSTCServer/tools/TS/analys?UserCode=${UserCode}&UserType=${UserType}&SessionID=${SessionID}`,
         method: 'post',
-        data
+        url: `/TeachingServer/TextAnalyser/Analyse`,
+        params: getAccessToken(),
+        data,
     })
 }

+ 61 - 2
src/components/Adult/preview/ArticleViewChs/index.vue

@@ -2,7 +2,22 @@
 <template>
   <div class="NPC-ArticleView NPC-ArticleView-container">
     <div class="ArticleView-header">
-      <a class="ArticleView-full" @click="fullScreen">全屏模式</a>
+      <a class="ArticleView-full" @click="fullScreen">黑板模式</a>
+      <div>
+        <div
+          class="left"
+          @click="submit"
+          :style="{ marginLeft: showPractice ? '97px' : '' }"
+          v-if="
+            tokenData &&
+              tokenData.popedom_code_list &&
+              tokenData.popedom_code_list.indexOf(2000001) != -1
+          "
+        >
+          <img src="../../../../assets/NPC/wbfx-icon.png" alt="" />
+          文本分析
+        </div>
+      </div>
       <template v-if="curQue.checkList.indexOf(1) > -1">
         <el-switch
           style="display: block"
@@ -149,6 +164,8 @@ import NormalModelChs from "./NormalModelChs.vue";
 import Practice from "./Practicechs.vue"; // 语音练习模式
 import WordModel from "./WordModelChs.vue"; // 语音练习模式
 import Voicefullscreen from "../Voicefullscreen.vue";
+import { getToken } from "@/utils/auth";
+import { analysSubmit } from "@/api/ajax";
 
 export default {
   name: "ArticleViewChs",
@@ -194,6 +211,7 @@ export default {
         writeModel: {}, //生词/取词模式
         practiceModel: {} //练习模式
       },
+      tokenData: null,
       mathNum: Math.random()
         .toString(36)
         .substr(2),
@@ -280,6 +298,28 @@ export default {
       });
       return pinyin;
     },
+    submit() {
+      let loading = this.$loading({
+        lock: true,
+        text: "Loading",
+        spinner: "el-icon-loading",
+        background: "rgba(0, 0, 0, 0.7)"
+      });
+      analysSubmit({
+        app_user_id: "",
+        text: this.curQue.article
+      })
+        .then(res => {
+          window.open(
+            window.location.origin +
+              `/GCLS-TC/#/textanalysis/Result?id=${res.record.id}&type=文本分析`
+          );
+          loading.close();
+        })
+        .catch(res => {
+          loading.close();
+        });
+    },
     //语音全屏
     fullScreen() {
       this.pauseAudio();
@@ -510,6 +550,8 @@ export default {
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {
+    let data = getToken() ? JSON.parse(getToken()) : null;
+    this.tokenData = data;
     if (this.NNPENewWordList && this.NNPENewWordList.length > 0) {
       this.handleNewword();
     }
@@ -563,7 +605,7 @@ export default {
   }
   .ArticleView-full {
     position: absolute;
-    top: 0;
+    top: 5px;
     background: url("../../../../assets/NPC/full-screen-red.png") left center
       no-repeat;
     background-size: 16px 16px;
@@ -581,6 +623,23 @@ export default {
     align-items: center;
     margin-bottom: 16px;
     position: relative;
+    .left {
+      display: flex;
+      align-items: center;
+      justify-content: center;
+      width: 104px;
+      height: 32px;
+      background: #ffffff;
+      border: 1px solid rgba(0, 0, 0, 0.25);
+      box-shadow: 0px 2px 0px rgba(0, 0, 0, 0.02);
+      border-radius: 4px;
+      cursor: pointer;
+      img {
+        width: 24px;
+        height: 24px;
+        margin-right: 4px;
+      }
+    }
     .setting-fontsize {
       display: flex;
       margin-left: 24px;

+ 14 - 10
src/components/Adult/preview/DialogueArticleViewChs/index.vue

@@ -6,17 +6,21 @@
     v-if="curQue && curQue.Bookanswer"
   >
     <div class="ArticleView-header">
-      <a class="ArticleView-full" @click="fullScreen">全屏模式</a>
+      <a class="ArticleView-full" @click="fullScreen">黑板模式</a>
       <div>
-        <!-- <div
+        <div
           class="left"
           @click="submit"
-          :style="{ marginLeft: showPractice ? '97px' : '' }"
-          v-if="tokenData.popedom_code_list.indexOf(2000001) != -1"
+          :style="{ marginLeft: '97px' }"
+          v-if="
+            tokenData &&
+              tokenData.popedom_code_list &&
+              tokenData.popedom_code_list.indexOf(2000001) != -1
+          "
         >
           <img src="../../../../assets/NPC/wbfx-icon.png" alt="" />
           文本分析
-        </div> -->
+        </div>
       </div>
 
       <div class="right">
@@ -260,13 +264,13 @@ export default {
         background: "rgba(0, 0, 0, 0.7)"
       });
       analysSubmit({
-        tenantId: "",
+        app_user_id: "",
         text: this.curQue.article
       })
         .then(res => {
           window.open(
-            process.env.VUE_APP_BASE_API +
-              `/GCLS-TC/#/textanalysis/Result?partitionKey=${res.data.result.partitionKey}&subjectWords=${res.data.result.subjectWords}&wordTextCount=${res.data.result.wordTextCount}&wordCount=${res.data.result.wordCount}&vocabularyTextCount=${res.data.result.vocabularyTextCount}&vocabularyCount=${res.data.result.vocabularyCount}&pinyinCount=${res.data.result.pinyinCount}&pinyinTextCount=${res.data.result.pinyinTextCount}&pinyinDifficulty=${res.data.result.pinyinDifficulty}&wordDifficulty=${res.data.result.wordDifficulty}&vocabularyDifficulty=${res.data.result.vocabularyDifficulty}&type=文本分析`
+            window.location.origin +
+              `/GCLS-TC/#/textanalysis/Result?id=${res.record.id}&type=文本分析`
           );
           loading.close();
         })
@@ -585,7 +589,7 @@ export default {
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {
-    let data = JSON.parse(getToken());
+    let data = getToken() ? JSON.parse(getToken()) : null;
     this.tokenData = data;
     if (this.NNPENewWordList && this.NNPENewWordList.length > 0) {
       this.handleNewword();
@@ -647,7 +651,7 @@ export default {
   }
   .ArticleView-full {
     position: absolute;
-    top: 0;
+    top: 5px;
     background: url("../../../../assets/NPC/full-screen-red.png") left center
       no-repeat;
     background-size: 16px 16px;

+ 4 - 0
src/utils/auth.js

@@ -50,4 +50,8 @@ export function CopyToClipboard(element, root) {
         type: "success",
     });
     window.getSelection().removeAllRanges();
+}
+export function getAccessToken() {
+  const token = JSON.parse(Cookies.get(TokenKey));
+  return { AccessToken: token?.access_token || '' };
 }