Procházet zdrojové kódy

语音矩阵评分详情拼音内容加上拼音字体

dsy před 1 týdnem
rodič
revize
25c50b9737

+ 35 - 12
src/views/book/courseware/preview/common/RecordScoreWholeDetail.vue

@@ -71,23 +71,31 @@
       </div>
     </div>
 
-    <h5>{{ scoreTitle }}</h5>
+    <h5>
+      <template v-if="scoreTitleParts.length">
+        <template v-for="(part, index) in scoreTitleParts"
+          ><span v-if="part.isPinyin" :key="index" style="font-family: 'League'">{{ part.text }}</span
+          ><template v-else>{{ part.text }}</template></template
+        >
+      </template>
+      <template v-else>{{ scoreTitle }}</template>
+    </h5>
     <div v-for="(items, indexs) in recordScoreDetail" :key="indexs" class="whole-detail">
       <div class="top" :style="wordScoreItem(items.score_total)">
         <span v-if="showIndex">第{{ indexs + 1 }}{{ itemUnit }}</span>
         <p>
-          <span v-html="items.text_new_word || items.text"></span
-          ><i v-if="items.position" class="position" v-html="items.position"></i>
+          <span v-html="items.text_new_word || items.text"></span>
+          <i v-if="items.position" class="position" v-html="items.position"></i>
         </p>
         <template v-if="items.detail_list">
           <b :style="textColor(items.score_total)">{{ items.score_total }}</b>
-          <a @click="items.isShow = !items.isShow">{{ items.isShow ? '收起' : '详情' }}</a>
+          <a @click="toggleItem(indexs)">{{ isItemExpanded(indexs) ? '收起' : '详情' }}</a>
         </template>
         <template v-else>
           <i>未读</i>
         </template>
       </div>
-      <template v-if="items.isShow">
+      <template v-if="isItemExpanded(indexs)">
         <div class="voice-box">
           <a
             class="voice-item"
@@ -180,6 +188,11 @@ export default {
       type: String,
       default: '按句得分',
     },
+    // 得分明细的小标题的组成部分,用于显示拼音字体
+    scoreTitleParts: {
+      type: Array,
+      default: () => [],
+    },
     // 明细条目的计量单位(课文为句,语音矩阵为词)
     itemUnit: {
       type: String,
@@ -216,9 +229,15 @@ export default {
       fluency: 0,
       integrity: 0,
       playIndex: null,
+      expandedItems: {},
     };
   },
   computed: {},
+  watch: {
+    recordScoreDetail() {
+      this.expandedItems = {};
+    },
+  },
 
   created() {
     let accuracy = 0;
@@ -229,7 +248,7 @@ export default {
 
     this.recordScoreDetail.forEach((item) => {
       if (item.detail_list) {
-        n++;
+        n += 1;
         score_total += item.score_total;
         accuracy += item.accuracy;
         fluency += item.fluency;
@@ -244,6 +263,12 @@ export default {
     this.integrity = average(integrity);
   },
   methods: {
+    isItemExpanded(index) {
+      return Boolean(this.expandedItems[index]);
+    },
+    toggleItem(index) {
+      this.$set(this.expandedItems, index, !this.isItemExpanded(index));
+    },
     handleClose() {
       this.$emit('update:visible', false);
     },
@@ -298,13 +323,11 @@ export default {
         this.oldSrc = mp3;
         this.mp3Url = mp3;
         this.playIndex = index;
-        if (time === undefined) {
-          time = 0;
-          edTime = 100000;
-        }
+        const startTime = time === undefined ? 0 : time;
+        const endTime = time === undefined ? 100000 : edTime;
         this.$nextTick(() => {
-          this.$refs.audioLine.onTimeupdateTime(time / 1000, true);
-          this.ed = edTime;
+          this.$refs.audioLine.onTimeupdateTime(startTime / 1000, true);
+          this.ed = endTime;
           this.type = type;
           this.stopAudioS = true;
         });

+ 51 - 16
src/views/book/courseware/preview/components/voice_matrix/components/MatrixRecord.vue

@@ -54,7 +54,12 @@
           <b class="record-score-tips" @click="openScoreDetail">详情</b>
         </template>
         <span v-if="showScoring" class="selection-tip" :title="selectionLabel">
-          {{ selectionLabel }}
+          {{ selectionDisplay.prefix
+          }}<template v-for="(word, index) in selectionDisplay.words"
+            ><template v-if="index">、</template
+            ><span v-if="isPinyinWord(word.text)" :key="index" class="word-pinyin">{{ word.text }}</span
+            ><template v-else>{{ word.text }}</template></template
+          >{{ selectionDisplay.suffix }}
         </span>
       </div>
     </div>
@@ -79,6 +84,7 @@
       :attrib="attrib"
       :record-score-detail="scoreDetails"
       :score-title="scoreTitle"
+      :score-title-parts="scoreTitleParts"
       item-unit="词"
       :show-index="false"
     />
@@ -137,15 +143,23 @@ export default {
     selectedRecord() {
       return this.selectedIndex === null ? null : this.records[this.selectedIndex] || null;
     },
-    selectionLabel() {
+    selectionDisplay() {
       if (this.recording) {
-        if (this.recordMode === 'free') return '随意录制中';
-        return this.sessionAll
-          ? '整体朗读中'
-          : `已选:${this.describeSelection(this.sessionSelection, this.sessionWords)}`;
+        if (this.recordMode === 'free') return { prefix: '随意录制中', words: [], suffix: '' };
+        if (this.sessionAll) return { prefix: '整体朗读中', words: [], suffix: '' };
+      }
+      const words = this.recording ? this.sessionWords : this.selectedWords;
+      if (!this.recording && !words.length) return { prefix: '未选择词汇', words: [], suffix: '' };
+      const selection = this.recording ? this.sessionSelection : this.selectData;
+      if (selection.type === 'row' || selection.type === 'column') {
+        const unit = selection.type === 'row' ? '行' : '列';
+        return { prefix: `已选:第 ${selection.index + 1} ${unit}(`, words, suffix: ')' };
       }
-      if (!this.selectedWords.length) return '未选择词汇';
-      return `已选:${this.describeSelection(this.selectData, this.selectedWords)}`;
+      return { prefix: '已选:词汇「', words, suffix: '」' };
+    },
+    selectionLabel() {
+      const { prefix, words, suffix } = this.selectionDisplay;
+      return `${prefix}${words.map((word) => word.text).join('、')}${suffix}`;
     },
     averageScore() {
       const words = this.selectedRecord && this.selectedRecord.words;
@@ -158,7 +172,12 @@ export default {
       const words = this.selectedRecord && this.selectedRecord.words;
       if (!words) return [];
       // 兼容历史答案中缺少逐词评分的情况,避免详情弹窗读到 undefined
-      return words.map((word) => word.score || { text: word.text, isShow: false });
+      return words.map((word) => {
+        const score = word.score || { text: word.text, isShow: false };
+        const text = score.text_new_word || score.text;
+        if (!this.isPinyinWord(text)) return score;
+        return { ...score, text_new_word: `<span style="font-family:League">${text}</span>` };
+      });
     },
     // 得分明细小标题:单个单元格为逐字得分,整行/整列为第 x 行(词1、词2)
     scoreTitle() {
@@ -171,6 +190,20 @@ export default {
       if (selection.type === 'all') return '整体朗读(逐词连录)';
       return '逐字得分';
     },
+    scoreTitleParts() {
+      const record = this.selectedRecord;
+      if (!record || !record.words || !record.words.length) return [];
+      const selection = record.selectData || {};
+      if (selection.type !== 'row' && selection.type !== 'column') return [];
+      const unit = selection.type === 'row' ? '行' : '列';
+      const parts = [{ text: `第 ${selection.index + 1} ${unit}(` }];
+      record.words.forEach((word, index) => {
+        if (index) parts.push({ text: '、' });
+        parts.push({ text: word.text, isPinyin: this.isPinyinWord(word.text) });
+      });
+      parts.push({ text: ')' });
+      return parts;
+    },
     currentWordText() {
       const word = this.sessionWords[this.currentIndex];
       return word ? word.text : '';
@@ -219,12 +252,11 @@ export default {
       const time = Math.max(0, Math.floor(seconds || 0));
       return `${String(Math.floor(time / 60)).padStart(2, '0')}:${String(time % 60).padStart(2, '0')}`;
     },
-    // 已选对象描述:单词用引号,整行/整列带序号和词汇列表
-    describeSelection(selection, words) {
-      const texts = words.map((word) => word.text).join('、');
-      if (selection.type === 'row') return `第 ${selection.index + 1} 行(${texts})`;
-      if (selection.type === 'column') return `第 ${selection.index + 1} 列(${texts})`;
-      return `词汇「${texts}」`;
+    isPinyinWord(text) {
+      return (
+        typeof text === 'string' &&
+        /^[a-zāáǎàōóǒòēéěèīíǐìūúǔùǖǘǚǜü]+(?:\s+[a-zāáǎàōóǒòēéěèīíǐìūúǔùǖǘǚǜü]+)*$/i.test(text.trim().normalize('NFC'))
+      );
     },
     onPlay() {
       this.playing = true;
@@ -758,11 +790,14 @@ export default {
   flex: 0 1 auto;
   min-width: 0;
   overflow: hidden;
-  font-family: 'Inter', 'League', system-ui, 'Avenir', 'Helvetica', 'Arial', sans-serif;
   font-size: 12px;
   color: #8b97a8;
   text-overflow: ellipsis;
   white-space: nowrap;
+
+  .word-pinyin {
+    font-family: 'League';
+  }
 }
 
 .record-score-content {