jiajunchen il y a 3 semaines
Parent
révision
c98f1433e3

+ 9
- 3
src/view/dati/classOne/class2.vue Voir le fichier

@@ -101,10 +101,16 @@ const isBefore = (fromDateStr) => {
101 101
 };
102 102
 
103 103
 // 当前时间是否在 toDate 之后(已结束)
104
-const isAfter = (toDateStr) => {
104
+const isAfter = (dateStr) => {
105
+  if (!dateStr) return false;
106
+
105 107
   const now = new Date();
106
-  const toDate = parseDate(toDateStr);
107
-  return toDate && now > toDate;
108
+  const today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); // 今天 00:00:00
109
+
110
+  const [y, m, d] = dateStr.split('-').map(Number);
111
+  const deadline = new Date(y, m - 1, d); // 截止日 00:00:00
112
+
113
+  return today > deadline;
108 114
 };
109 115
 
110 116
 const getProjectTypeName = (code) => {

+ 61
- 0
src/view/dati/classOne/line.vue Voir le fichier

@@ -32,6 +32,27 @@
32 32
         />
33 33
         {{ currentQuestion.stem }}
34 34
       </p>
35
+      <!-- 附件区域:图片或视频 -->
36
+      <div v-if="currentQuestion.fileUrl" class="question-attachment-wrapper">
37
+        <img
38
+          v-if="isImageType(currentQuestion.fileType)"
39
+          :src="currentQuestion.fileUrl"
40
+          alt="题目图片"
41
+          class="media-preview"
42
+        />
43
+        <video
44
+          v-else-if="isVideoType(currentQuestion.fileType)"
45
+          controls
46
+          preload="metadata"
47
+          class="media-preview"
48
+        >
49
+          <source
50
+            :src="currentQuestion.fileUrl"
51
+            :type="getMimeType(currentQuestion.fileType)"
52
+          />
53
+          您的浏览器不支持视频播放。
54
+        </video>
55
+      </div>
35 56
 
36 57
 
37 58
       <!-- 单选题 -->
@@ -277,6 +298,30 @@ const getQuestionTypeImage = (category) => {
277 298
   }
278 299
 };
279 300
 
301
+// 判断是否为图片类型
302
+const isImageType = (type) => {
303
+  return ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp'].includes((type || '').toLowerCase());
304
+};
305
+
306
+// 判断是否为视频类型
307
+const isVideoType = (type) => {
308
+  return ['mp4', 'mov', 'avi', 'wmv', 'flv', 'webm'].includes((type || '').toLowerCase());
309
+};
310
+
311
+// 获取 MIME 类型(用于 video 的 source)
312
+const getMimeType = (type) => {
313
+  const map = {
314
+    mp4: 'video/mp4',
315
+    mov: 'video/quicktime',
316
+    avi: 'video/x-msvideo',
317
+    wmv: 'video/x-ms-wmv',
318
+    flv: 'video/x-flv',
319
+    webm: 'video/webm'
320
+  };
321
+  return map[type?.toLowerCase()] || 'video/mp4';
322
+};
323
+
324
+
280 325
 //返回答题首页
281 326
 const goBack = () => {
282 327
   router.push({
@@ -637,5 +682,21 @@ const renderAnalysis = (content) => {
637 682
   border-radius: 4px;
638 683
   overflow-x: auto;
639 684
 }
685
+/* 附件容器:在题干下方,左侧缩进对齐题干文字 */
686
+.question-attachment-wrapper {
687
+  margin: 12px 0 20px 54px; /* 54px = .question-type-img 宽度,确保对齐文字起始位置 */
688
+}
640 689
 
690
+/* 图片 & 视频统一预览 */
691
+.media-preview {
692
+  display: block;
693
+  max-width: 100%;
694
+  max-height: 320px;
695
+  width: auto;
696
+  height: auto;
697
+  object-fit: contain;
698
+  border-radius: 6px;
699
+  background-color: #f8f9fa;
700
+  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
701
+}
641 702
 </style>

+ 61
- 1
src/view/dati/daily/datistart.vue Voir le fichier

@@ -32,7 +32,27 @@
32 32
         />
33 33
         {{ currentQuestion.stem }}
34 34
       </p>
35
-
35
+      <!-- 附件区域:图片或视频 -->
36
+      <div v-if="currentQuestion.fileUrl" class="question-attachment-wrapper">
37
+        <img
38
+          v-if="isImageType(currentQuestion.fileType)"
39
+          :src="currentQuestion.fileUrl"
40
+          alt="题目图片"
41
+          class="media-preview"
42
+        />
43
+        <video
44
+          v-else-if="isVideoType(currentQuestion.fileType)"
45
+          controls
46
+          preload="metadata"
47
+          class="media-preview"
48
+        >
49
+          <source
50
+            :src="currentQuestion.fileUrl"
51
+            :type="getMimeType(currentQuestion.fileType)"
52
+          />
53
+          您的浏览器不支持视频播放。
54
+        </video>
55
+      </div>
36 56
 
37 57
       <!-- 单选题 -->
38 58
       <div v-if="currentQuestion.category === '单选'">
@@ -215,6 +235,30 @@ const userId = route.query.userId;
215 235
 if (userId == '' || userId == 'undefined') userId = localStorage.getItem('userId')
216 236
 const todayStr = route.query.todayStr;
217 237
 
238
+
239
+// 判断是否为图片类型
240
+const isImageType = (type) => {
241
+  return ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp'].includes((type || '').toLowerCase());
242
+};
243
+
244
+// 判断是否为视频类型
245
+const isVideoType = (type) => {
246
+  return ['mp4', 'mov', 'avi', 'wmv', 'flv', 'webm'].includes((type || '').toLowerCase());
247
+};
248
+
249
+// 获取 MIME 类型(用于 video 的 source)
250
+const getMimeType = (type) => {
251
+  const map = {
252
+    mp4: 'video/mp4',
253
+    mov: 'video/quicktime',
254
+    avi: 'video/x-msvideo',
255
+    wmv: 'video/x-ms-wmv',
256
+    flv: 'video/x-flv',
257
+    webm: 'video/webm'
258
+  };
259
+  return map[type?.toLowerCase()] || 'video/mp4';
260
+};
261
+
218 262
 const questions = ref([]);
219 263
 
220 264
 const userAnswers = ref({});
@@ -681,5 +725,21 @@ const renderAnalysis = (content) => {
681 725
   border-radius: 4px;
682 726
   overflow-x: auto;
683 727
 }
728
+/* 附件容器:在题干下方,左侧缩进对齐题干文字 */
729
+.question-attachment-wrapper {
730
+  margin: 12px 0 20px 54px; /* 54px = .question-type-img 宽度,确保对齐文字起始位置 */
731
+}
684 732
 
733
+/* 图片 & 视频统一预览 */
734
+.media-preview {
735
+  display: block;
736
+  max-width: 100%;
737
+  max-height: 320px;
738
+  width: auto;
739
+  height: auto;
740
+  object-fit: contain;
741
+  border-radius: 6px;
742
+  background-color: #f8f9fa;
743
+  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
744
+}
685 745
 </style>

+ 63
- 1
src/view/dati/examCheck/fcbkdatistart.vue Voir le fichier

@@ -32,7 +32,27 @@
32 32
         />
33 33
         {{ currentQuestion.stem }}
34 34
       </p>
35
-
35
+      <!-- 附件区域:图片或视频 -->
36
+      <div v-if="currentQuestion.fileUrl" class="question-attachment-wrapper">
37
+        <img
38
+          v-if="isImageType(currentQuestion.fileType)"
39
+          :src="currentQuestion.fileUrl"
40
+          alt="题目图片"
41
+          class="media-preview"
42
+        />
43
+        <video
44
+          v-else-if="isVideoType(currentQuestion.fileType)"
45
+          controls
46
+          preload="metadata"
47
+          class="media-preview"
48
+        >
49
+          <source
50
+            :src="currentQuestion.fileUrl"
51
+            :type="getMimeType(currentQuestion.fileType)"
52
+          />
53
+          您的浏览器不支持视频播放。
54
+        </video>
55
+      </div>
36 56
 
37 57
       <!-- 单选题 -->
38 58
       <div v-if="currentQuestion.category === '单选'">
@@ -244,6 +264,32 @@ const hasUnanswered = ref(false);
244 264
 const unansweredText = "有题目未完成,是否确认交卷?";
245 265
 const completedText = "已完成所有题目,是否确认交卷?";
246 266
 const overlayloading = ref(false);
267
+
268
+
269
+// 判断是否为图片类型
270
+const isImageType = (type) => {
271
+  return ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp'].includes((type || '').toLowerCase());
272
+};
273
+
274
+// 判断是否为视频类型
275
+const isVideoType = (type) => {
276
+  return ['mp4', 'mov', 'avi', 'wmv', 'flv', 'webm'].includes((type || '').toLowerCase());
277
+};
278
+
279
+// 获取 MIME 类型(用于 video 的 source)
280
+const getMimeType = (type) => {
281
+  const map = {
282
+    mp4: 'video/mp4',
283
+    mov: 'video/quicktime',
284
+    avi: 'video/x-msvideo',
285
+    wmv: 'video/x-ms-wmv',
286
+    flv: 'video/x-flv',
287
+    webm: 'video/webm'
288
+  };
289
+  return map[type?.toLowerCase()] || 'video/mp4';
290
+};
291
+
292
+
247 293
 // 在组件挂载时获取试卷
248 294
 onMounted(async () => {
249 295
   overlayloading.value = true;
@@ -723,5 +769,21 @@ const renderAnalysis = (content) => {
723 769
   border-radius: 4px;
724 770
   overflow-x: auto;
725 771
 }
772
+/* 附件容器:在题干下方,左侧缩进对齐题干文字 */
773
+.question-attachment-wrapper {
774
+  margin: 12px 0 20px 54px; /* 54px = .question-type-img 宽度,确保对齐文字起始位置 */
775
+}
726 776
 
777
+/* 图片 & 视频统一预览 */
778
+.media-preview {
779
+  display: block;
780
+  max-width: 100%;
781
+  max-height: 320px;
782
+  width: auto;
783
+  height: auto;
784
+  object-fit: contain;
785
+  border-radius: 6px;
786
+  background-color: #f8f9fa;
787
+  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
788
+}
727 789
 </style>

Loading…
Annuler
Enregistrer