15270821319 6 місяців тому
батько
коміт
50d63debb2

+ 15 - 3
AiStudy-app/src/app/tab1/tab1.page.html

@@ -1,16 +1,23 @@
 <ion-header [translucent]="true">
   <ion-toolbar>
+    <ion-buttons slot="start">
+      <ion-button style="opacity: 0; pointer-events: none;">
+        <ion-icon slot="icon-only" name="save-outline"></ion-icon>
+      </ion-button>
+    </ion-buttons>
+
     <ion-title>
       <div id="select-teacher" (click)="showTeacherOptions()">
-        <div class="teacher-info" style="display:flex;flex-direction: column;min-height: 50px;">
-          <div style="display:flex;">
+        <div class="teacher-info">
+          <div class="header-row">
             <ion-icon name="person-circle-outline" class="teacher-icon"></ion-icon>
-            <div class="teacher-name">{{ selectedTeacher.name }}</div>
+            <span class="teacher-name">{{ selectedTeacher.name }}</span>
           </div>
           <div class="teacher-description">{{ selectedTeacher.description }}</div>
         </div>
       </div>
     </ion-title>
+
     <ion-buttons slot="end">
       <ion-button 
         (click)="saveCurrentSession()" 
@@ -32,6 +39,11 @@
 <ion-content [fullscreen]="true">
   <div class="chat-container">
     <div class="chat-content">
+      <!-- 添加欢迎提示文字 -->
+      <div class="welcome-message" *ngIf="messages.length === 0">
+        <div class="welcome-text">今天想学些什么呢?</div>
+      </div>
+
       <!-- 历史消息显示 -->
       <div *ngFor="let message of messages" 
            [ngClass]="{'user-message': message.isUser, 'ai-message': !message.isUser}" 

+ 337 - 15
AiStudy-app/src/app/tab1/tab1.page.scss

@@ -1,40 +1,65 @@
 .chat-container {
   display: flex;
   flex-direction: column;
-  padding: 16px;
-  padding-bottom: 60px;
   height: 100%;
-  overflow-y: auto;
-  scroll-behavior: smooth;
-  margin-top: 10px;
-  position: relative;
+  background-color: #f8f9fa;
+  
+  background-image: linear-gradient(
+    to bottom,
+    rgba(255, 255, 255, 0.95),
+    rgba(248, 249, 250, 0.95)
+  );
 }
 
 .chat-content {
   padding: 16px;
-  padding-bottom: 60px;
-  padding-top: 80px;
+  padding-bottom: 80px;
+  padding-top: 85px;
+  overflow-y: auto;
+  scroll-behavior: smooth;
 }
 
 .message-wrapper {
   display: flex;
   margin: 8px 0;
+  animation: fadeIn 0.3s ease-in-out;
   
   &.user-message {
     justify-content: flex-end;
+    
+    .message-bubble {
+      background: linear-gradient(135deg, #007AFF, #0056b3);
+      color: white;
+      border-radius: 18px 18px 4px 18px;
+      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
+      margin-left: 20%;
+    }
   }
   
   &.ai-message {
     justify-content: flex-start;
+    
+    .message-bubble {
+      background: white;
+      color: #2c3e50;
+      border-radius: 18px 18px 18px 4px;
+      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
+      margin-right: 20%;
+      border: 1px solid rgba(0, 0, 0, 0.05);
+    }
   }
 }
 
 .message-bubble {
   max-width: 75%;
   padding: 12px 16px;
-  border-radius: 18px;
   word-wrap: break-word;
   position: relative;
+  transition: transform 0.2s ease;
+  
+  &:hover {
+    transform: translateY(-1px);
+  }
 }
 
 .user-message .message-bubble {
@@ -50,12 +75,13 @@
 }
 
 .message-content {
-  font-size: 16px;
-  line-height: 1.4;
+  font-size: 15px;
+  line-height: 1.5;
+  margin-bottom: 4px;
 }
 
 .message-time {
-  font-size: 12px;
+  font-size: 11px;
   opacity: 0.7;
   margin-top: 4px;
   text-align: right;
@@ -64,7 +90,12 @@
 .loading-indicator {
   display: flex;
   justify-content: center;
+  align-items: center;
   padding: 20px;
+  
+  ion-spinner {
+    --color: var(--ion-color-primary);
+  }
 }
 
 ion-footer ion-toolbar {
@@ -178,19 +209,310 @@ ion-icon[name="add-circle-outline"] {
 
 // 在现有样式的末尾添加
 ion-toolbar {
+  --background: rgba(255, 255, 255, 0.98);
+  --border-color: transparent;
+  box-shadow: none;
+  min-height: 70px;
+  padding-top: 4px;
+  
+  // 标题区域(中间的教师信息)
+  ion-title {
+    position: absolute;
+    left: 0;
+    right: 0;
+    width: 100%;
+    height: 100%;
+    text-align: center;
+    pointer-events: none;
+    padding: 0;
+    margin-top: -4px;
+    
+    #select-teacher {
+      display: inline-block;
+      pointer-events: auto;
+      cursor: pointer;
+      padding: 10px 16px;
+      max-width: 320px;
+      margin: 0 auto;
+      
+      .teacher-info {
+        display: flex;
+        flex-direction: column;
+        align-items: center;
+        
+        .header-row {
+          display: flex;
+          align-items: center;
+          justify-content: center;
+          margin-bottom: 6px;
+          
+          .teacher-icon {
+            font-size: 28px;
+            color: var(--ion-color-primary);
+            margin-right: 10px;
+          }
+          
+          .teacher-name {
+            font-size: 20px;
+            font-weight: 600;
+            color: #2c3e50;
+            letter-spacing: 0.3px;
+          }
+        }
+        
+        .teacher-description {
+          font-size: 14px;
+          color: #64748b;
+          font-weight: normal;
+          margin-top: 3px;
+          letter-spacing: 0.2px;
+          line-height: 1.4;
+          opacity: 0.85;
+          max-width: 280px;
+          text-align: center;
+          white-space: nowrap;
+          overflow: hidden;
+          text-overflow: ellipsis;
+        }
+      }
+      
+      &:hover {
+        .teacher-info {
+          transform: translateY(-1px);
+          transition: transform 0.2s ease;
+          
+          .teacher-name {
+            color: var(--ion-color-primary);
+          }
+          
+          .teacher-description {
+            opacity: 1;
+          }
+        }
+      }
+    }
+  }
+  
+  // 右侧按钮样式
   ion-buttons {
+    position: relative;
+    z-index: 2;
+    margin-top: 4px;
+    
+    &[slot="start"] {
+      visibility: hidden;
+    }
+    
+    &[slot="end"] {
+      padding-right: 12px;
+    }
+    
     ion-button {
-      --padding-start: 8px;
-      --padding-end: 8px;
+      --padding-start: 10px;
+      --padding-end: 10px;
+      height: 44px;
       
       ion-icon {
-        font-size: 24px;
+        font-size: 22px;
+        color: #64748b;
+        transition: color 0.2s ease;
+      }
+      
+      &:hover:not([disabled]) {
+        ion-icon {
+          color: var(--ion-color-primary);
+        }
+      }
+      
+      &[disabled] {
+        opacity: 0.5;
       }
     }
   }
 }
 
+// 替换分隔线效果为更柔和的渐变阴影
+ion-header::after {
+  content: '';
+  position: absolute;
+  bottom: -1px;
+  left: 0;
+  right: 0;
+  height: 6px;
+  background: linear-gradient(
+    to bottom,
+    rgba(0, 0, 0, 0.015),
+    transparent
+  );
+  border: none;
+}
+
+// 移除之前的一些重复或冲突的样式
+.teacher-selector,
+.teacher-info:not(#select-teacher .teacher-info),
+.teacher-icon:not(#select-teacher .teacher-icon),
+.teacher-name:not(#select-teacher .teacher-name),
+.teacher-description:not(#select-teacher .teacher-description) {
+  display: none;
+}
+
 // 保存按钮禁用状态样式
 ion-button[disabled] {
   opacity: 0.5;
 }
+
+// 底部输入区域样式优化
+ion-footer {
+  background: rgba(255, 255, 255, 0.95);
+  box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.05);
+  
+  ion-toolbar {
+    --padding-top: 0;
+    --padding-bottom: 0;
+    --min-height: 56px;
+  }
+  
+  ion-item {
+    --background: transparent;
+    --border-color: transparent;
+    --padding-start: 12px;
+    --padding-end: 8px;
+    --inner-padding-end: 8px;
+    
+    ion-textarea {
+      --background: #f8f9fa;
+      --padding-top: 8px;
+      --padding-bottom: 8px;
+      --padding-start: 16px;
+      --padding-end: 16px;
+      border-radius: 24px;
+      margin: 8px 0;
+      
+      &::part(native) {
+        background: #f8f9fa;
+        border-radius: 24px;
+      }
+    }
+    
+    ion-button {
+      --padding-start: 12px;
+      --padding-end: 12px;
+      --border-radius: 50%;
+      margin: 0 4px;
+      height: 40px;
+      width: 40px;
+      
+      ion-icon {
+        font-size: 20px;
+      }
+    }
+  }
+}
+
+// 添加动画
+@keyframes fadeIn {
+  from {
+    opacity: 0;
+    transform: translateY(10px);
+  }
+  to {
+    opacity: 1;
+    transform: translateY(0);
+  }
+}
+
+// 教师选择器样式优化
+#select-teacher {
+  .teacher-info {
+    padding: 8px 0;
+    
+    .teacher-icon {
+      font-size: 24px;
+      color: var(--ion-color-primary);
+      margin-right: 8px;
+    }
+    
+    .teacher-name {
+      font-size: 16px;
+      font-weight: 500;
+      color: #2c3e50;
+    }
+    
+    .teacher-description {
+      font-size: 12px;
+      color: #666;
+      margin-top: 2px;
+    }
+  }
+}
+
+// Markdown 内容样式优化
+::ng-deep {
+  .message-content {
+    pre {
+      background: rgba(0, 0, 0, 0.03);
+      border-radius: 8px;
+      padding: 12px;
+      margin: 8px 0;
+      overflow-x: auto;
+    }
+    
+    code {
+      font-family: 'Fira Code', monospace;
+      font-size: 13px;
+    }
+    
+    p {
+      margin: 8px 0;
+    }
+  }
+}
+
+// 添加欢迎消息样式
+.welcome-message {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  min-height: calc(100vh - 200px); // 确保在屏幕中间
+  opacity: 0; // 初始透明
+  animation: fadeIn 0.8s ease-out forwards; // 淡入动画
+  animation-delay: 0.3s; // 延迟一点开始动画
+  
+  .welcome-text {
+    font-size: 20px;
+    color: #94a3b8;
+    font-weight: 500;
+    letter-spacing: 0.5px;
+    text-align: center;
+    padding: 20px;
+    border-radius: 16px;
+    background: rgba(255, 255, 255, 0.6);
+    backdrop-filter: blur(8px);
+    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
+    transform: translateY(20px); // 初始位置略低
+    animation: floatUp 0.8s ease-out forwards; // 向上浮动动画
+    animation-delay: 0.3s;
+  }
+}
+
+// 添加向上浮动动画
+@keyframes floatUp {
+  from {
+    opacity: 0;
+    transform: translateY(20px);
+  }
+  to {
+    opacity: 1;
+    transform: translateY(0);
+  }
+}
+
+// 修改现有的淡入动画使其更平滑
+@keyframes fadeIn {
+  from {
+    opacity: 0;
+  }
+  to {
+    opacity: 1;
+  }
+}