Ver código fonte

优化考试工坊前端

FanHong 1 semana atrás
pai
commit
a7a56d6716

+ 8 - 1
shudao-vue-frontend/src/views/Chat.vue

@@ -66,7 +66,7 @@
 
       <!-- 考试工坊内容区域 -->
       <div v-if="currentMode === 'exam-workshop'" class="exam-workshop-wrapper" style="height: 100%; flex: 1;">
-        <ExamWorkshop :hideSidebar="true" />
+        <ExamWorkshop :hideSidebar="true" @return-to-ai="setMode('ai-qa')" />
       </div>
 
       <!-- 聊天内容区域 -->
@@ -720,6 +720,13 @@ const setMode = (mode) => {
   } else {
     currentMode.value = mode
   }
+  
+  // 切换回AI问答时,确保输入框和聊天区域正常显示
+  if (currentMode.value === 'ai-qa' && !chatMessages.value.length) {
+    showChat.value = false
+  } else if (currentMode.value === 'ai-qa' && chatMessages.value.length > 0) {
+    showChat.value = true
+  }
 }
 
 // ReportGenerator相关状态

+ 45 - 5
shudao-vue-frontend/src/views/ExamWorkshop.vue

@@ -53,7 +53,8 @@
     </div>
 
     <!-- 右侧工作区域 -->
-    <div class="main-work" :style="{ background: showExamDetail ? 'transparent' : '#ebf3ff' }">
+    <div class="main-work" :style="{ background: showExamDetail ? 'transparent' : '#ebf3ff', position: 'relative' }">
+
       <!-- 头部 -->
       <div class="work-header" v-if="showExamDetail">
         <h2>考试工坊</h2>
@@ -69,9 +70,12 @@
         <!-- 考试工坊主界面 -->
         <div v-if="!showExamDetail" class="exam-workshop-card app-container">
             <!-- 中间主操作区 -->
-            <main class="main-content">
-
-                <div class="form-group">
+            <main class="main-content" style="padding-top: 36px;">
+                <div class="form-group" style="position: relative;">
+                    <!-- 返回AI问答按钮 -->
+                    <button v-if="hideSidebar && !showExamDetail" class="return-ai-btn" @click="handleReturnToAI">
+                      返回AI问答
+                    </button>
                     <label class="form-label">试卷名称</label>
                     <input type="text" class="form-control" v-model="examName" maxlength="32" placeholder="请输入试卷名称..." :disabled="isGenerating">
                     <div class="char-count">{{ examName?.length || 0 }}/32</div>
@@ -560,7 +564,7 @@
 </template>
 
 <script setup>
-import { ref, computed, onMounted, onUnmounted, reactive, watch, defineProps } from "vue";
+import { ref, computed, onMounted, onUnmounted, reactive, watch, defineProps, defineEmits } from "vue";
 import Sidebar from "@/components/Sidebar.vue";
 import DeleteConfirmModal from "@/components/DeleteConfirmModal.vue";
 
@@ -570,6 +574,12 @@ const props = defineProps({
     default: false
   }
 });
+
+const emit = defineEmits(['return-to-ai']);
+
+const handleReturnToAI = () => {
+  emit('return-to-ai');
+};
 import { apis } from '@/request/apis.js'
 import { ElMessage } from 'element-plus'
 // ===== 已删除:getUserId - 不再需要,改用token =====
@@ -2168,6 +2178,7 @@ const createHTMLContent = (exportData, includeAnswers = true) => {
       font-weight: bold;
       color: #2c5aa0;
     }
+
   </style>
 </head>
 <body>
@@ -5562,6 +5573,35 @@ onUnmounted(() => {
   font-weight: 500;
 }
 
+.return-ai-btn {
+  position: absolute;
+  top: -15px;
+  right: 0;
+  z-index: 100;
+  background: white;
+  border: 1px solid rgba(0, 0, 0, 0.06);
+  border-radius: 12px;
+  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
+  padding: 6px 16px;
+  font-size: 13px;
+  font-weight: 500;
+  color: #2563eb; /* 改为蓝色文字 */
+  cursor: pointer;
+  display: flex;
+  align-items: center;
+  gap: 5px;
+  transition: all 0.3s ease;
+}
 
+.return-ai-btn:hover {
+  box-shadow: 0 8px 24px rgba(13, 110, 253, 0.12);
+  color: #0d6efd;
+  border-color: rgba(13, 110, 253, 0.2);
+}
 
+.return-ai-btn::before {
+  content: '←';
+  font-size: 16px;
+  font-weight: bold;
+}
 </style>