Преглед на файлове

填空题弹窗的正确答案,显示拼音模式下,底部对齐文本与正确答案文本

dsy преди 6 дни
родител
ревизия
4fd8ce096b
променени са 2 файла, в които са добавени 44 реда и са изтрити 10 реда
  1. 1 1
      .env
  2. 43 9
      src/views/book/courseware/preview/components/fill/FillPreview.vue

+ 1 - 1
.env

@@ -11,4 +11,4 @@ VUE_APP_BookWebSI = '/GCLSBookWebSI/ServiceInterface'
 VUE_APP_EepServer = '/EEPServer/SI'
 
 #version
-VUE_APP_VERSION = '2026.11.25'
+VUE_APP_VERSION = '2026.11.26'

+ 43 - 9
src/views/book/courseware/preview/components/fill/FillPreview.vue

@@ -9,7 +9,7 @@
         :color="data.unified_attrib?.topic_color"
         :file-id="data.audio_file_id"
       />
-      <div class="fill-wrapper">
+      <div class="fill-wrapper" :class="{ 'without-pinyin': !isEnable(data.property.view_pinyin) }">
         <div class="fill-content">
           <template v-for="(group, gi) in groupedModelEssay">
             <span :key="`group-${gi}`" :style="groupStyle(group)">
@@ -148,6 +148,7 @@
         v-if="isShowJudgeCorrect"
         slot="right-answer"
         class="fill-wrapper"
+        :class="{ 'without-pinyin': !isEnable(data.property.view_pinyin) }"
         :style="{ '--fill-font-family': data.property.fill_font }"
       >
         <div class="fill-content">
@@ -373,9 +374,8 @@ export default {
     /**
      * 计算填空控件需要补偿的 margin-bottom。
      * 显示拼音时,拼音词块在底部补了 (line-height - 1)em 的行间留白,汉字底部相应上移;
-     * 不显示拼音时汉字按段落行高居中,只需补偿半行留白。
-     * 输入框需要使用相同补偿,才能与词级文本处于同一视觉基线。
-     * 预览页再按实际渲染微调:开启拼音 +6px,未开启拼音 +1px。
+     * 不显示拼音时使用 CSS 基线对齐,不需要行高补偿。
+     * 显示拼音时预览页在原有补偿基础上再微调 +6px。
      * 返回值默认用 em(随控件字号缩放);答案解析里的答案文字字号与输入框的 em 基准不同,
      * 同一个 calc 会算出不同的 px,此时传 toPixel 按输入框基准换算成 px,保证两处横线偏移一致。
      * @param {Object} li 填空块对象
@@ -383,6 +383,8 @@ export default {
      * @returns {String} 与拼音词块行间距一致的补偿值
      */
     resolveFillControlMargin(li, toPixel = false) {
+      if (!this.isEnable(this.data?.property?.view_pinyin)) return '0px';
+
       let lineHeight = '';
       (li?.rich_text_list || []).forEach((item) => {
         const match = String(item?.text || '').match(/line-height\s*:\s*([^;"']+)/i);
@@ -392,8 +394,8 @@ export default {
       if (!/^\d*\.?\d+$/.test(lineHeight)) lineHeight = '1.5';
 
       const ratio = Number(lineHeight);
-      const isShowPinyin = this.isEnable(this.data?.property?.view_pinyin);
-      const spacing = isShowPinyin ? ratio - 1 : (ratio - 1) / 2;
+      const spacing = ratio - 1;
+      // 根据行高计算基础偏移量,后续会在此基础上进行微调
       const lineHeightOffsets = [
         { ratio: 1, offset: -6 },
         { ratio: 1.2, offset: -3 },
@@ -413,7 +415,7 @@ export default {
         offset = lower.offset + ((ratio - lower.ratio) / (upper.ratio - lower.ratio)) * (upper.offset - lower.offset);
       }
       // 预览页在原有补偿基础上追加微调量
-      const totalOffset = offset + (isShowPinyin ? 6 : 1);
+      const totalOffset = offset + 6;
       // 按输入框的 em 基准(见样式里 .el-input 的 font-size)换算成 px,
       // 避免不同字号的元素用同一 em 算式却得到不同偏移
       if (toPixel) return `${Number((spacing * FILL_CONTROL_EM_BASIS_PX + totalOffset).toFixed(2))}px`;
@@ -718,8 +720,7 @@ export default {
       margin: 0 10px;
       margin-bottom: -2px;
 
-      // 显式固定 em 补偿的基准(element-ui 默认值):
-      // 模板传入的 marginBottom 是 em 单位,基准需与 resolveFillControlMargin 中的换算保持一致
+      // 显示拼音时,em 补偿的基准需与 resolveFillControlMargin 中的换算保持一致
       font-size: 14px;
       vertical-align: bottom;
 
@@ -776,6 +777,39 @@ export default {
       vertical-align: bottom;
       border-bottom: 1px solid $font-color;
     }
+
+    &.without-pinyin {
+      :deep .pinyin-area .pinyin-text,
+      .el-input,
+      .right-answer {
+        vertical-align: baseline;
+      }
+
+      .el-input {
+        align-items: flex-end;
+        font-family: var(--fill-font-family, 'arial'), sans-serif;
+        font-size: 16pt;
+        line-height: 1em;
+
+        // 输入框本身的基线位于边框,使用零宽字符提供文字基线。
+        &::before {
+          content: '\200b';
+        }
+      }
+
+      // 选词框与输入框共用一套盒模型:1em 高的盒子 + 文字贴底,
+      // 下边框即填空横线,文字底部与正文齐平;
+      // 零宽字符保证未选词时也有文字基线,选词前后行盒高度一致。
+      .select-content {
+        height: 1em;
+        line-height: 1em;
+        vertical-align: baseline;
+
+        &::before {
+          content: '\200b';
+        }
+      }
+    }
   }
 
   .record-box {