// ... existing code ...
html {
font-size: calc(100vw / 375 * 16); // 假设设计稿宽度为375px,设置基础字体大小为16px
@media screen and (max-width: 375px) {
font-size: 16px; // 最小字体大小
}
@media screen and (min-width: 768px) {
font-size: 24px; // 平板或大屏设备上的字体大小
}
}
.ai-chat {
height: 98vh;
display: flex;
flex-direction: column;
background-color: #f5f5f5;
.chat-header {
background: linear-gradient(135deg, #a6ea66 0%, #ead1ff 100%);
color: white;
padding: 16px;
text-align: center;
font-size: 1rem; // 使用 rem 单位
font-weight: bold;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.connection-status {
background: #fff3cd;
border-bottom: 1px solid #ffeaa7;
padding: 8px 16px;
text-align: center;
.status-indicator {
font-size: 0.9rem;
color: #856404;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
&.offline::before {
content: '⚠️';
font-size: 1rem;
}
.reconnect-button {
margin-left: 12px;
height: 28px;
padding: 0 12px;
font-size: 0.8rem;
border-radius: 14px;
}
}
}
.chat-container {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}
.messages-container {
flex: 1;
padding: 16px;
overflow-y: auto;
scroll-behavior: smooth;
&::-webkit-scrollbar {
width: 4px;
}
&::-webkit-scrollbar-track {
background: transparent;
}
&::-webkit-scrollbar-thumb {
background: rgba(0, 0, 0, 0.2);
border-radius: 2px;
}
}
.message {
margin-bottom: 16px;
display: flex;
align-items: flex-start;
animation: fadeInUp 0.3s ease-out;
&.user {
flex-direction: row-reverse;
.message-content {
background: linear-gradient(135deg, #ff3535 0%, #FF0000 100%);
color: white;
margin-left: 0;
margin-right: 12px;
}
}
&.ai {
flex-direction: row;
.message-content {
background: white;
color: #333;
margin-left: 12px;
margin-right: 0;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
}
.avatar {
width: 60px;
height: 60px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px; // 可以保持不变或调整为 rem 单位
flex-shrink: 0;
&.user-avatar {
background: linear-gradient(135deg, #df2626 0%, #d10a0a 100%);
color: white;
}
&.ai-avatar {
background: linear-gradient(135deg, #ff6b6b 0%, #feca57 100%);
color: white;
}
}
.message-content {
max-width: 70%;
padding: 12px 16px;
border-radius: 18px;
word-wrap: break-word;
line-height: 1.5;
font-size: .8rem; // 使用 rem 单位
position: relative;
display: flex;
align-items: flex-end;
gap: 4px;
.message-text {
flex: 1;
white-space: pre-wrap;
.message-markdown {
// 通用Markdown样式
.markdown-paragraph {
margin-bottom: 8px;
}
.markdown-list-item,
.markdown-ordered-list-item {
margin-bottom: 4px;
}
.markdown-heading {
margin: 12px 0 6px 0;
&.markdown-h1 {
font-size: 1.2rem;
border-bottom: 1px solid #ddd;
padding-bottom: 2px;
}
&.markdown-h2 {
font-size: 1.1rem;
}
&.markdown-h3 {
font-size: 1rem;
}
}
// AI消息特定样式
&.ai-markdown {
.markdown-code-block {
background-color: #f8f9fa;
border: 1px solid #e9ecef;
border-radius: 4px;
padding: 8px;
margin: 8px 0;
font-size: 0.9rem;
}
.markdown-inline-code {
background-color: #f1f3f4;
padding: 2px 4px;
border-radius: 3px;
font-size: 0.9rem;
color: #d73a49;
}
.markdown-blockquote {
border-left: 3px solid #3498db;
padding-left: 8px;
margin: 8px 0;
background-color: rgba(52, 152, 219, 0.1);
}
.markdown-link {
color: #3498db;
text-decoration: underline;
}
}
// 用户消息特定样式
&.user-markdown {
.markdown-code-block {
background-color: rgba(255, 255, 255, 0.2);
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 4px;
padding: 8px;
margin: 8px 0;
font-size: 0.9rem;
}
.markdown-inline-code {
background-color: rgba(255, 255, 255, 0.2);
padding: 2px 4px;
border-radius: 3px;
font-size: 0.9rem;
color: #fff;
}
.markdown-blockquote {
border-left: 3px solid rgba(255, 255, 255, 0.5);
padding-left: 8px;
margin: 8px 0;
background-color: rgba(255, 255, 255, 0.1);
}
.markdown-link {
color: #fff;
text-decoration: underline;
}
.markdown-bold {
color: #fff;
}
.markdown-text {
color: #fff;
}
}
}
}
.typing-cursor {
color: #666;
font-weight: bold;
animation: blink 1s infinite;
margin-left: 2px;
}
.typing-indicator {
display: flex;
align-items: center;
gap: 4px;
.dot {
width: 6px;
height: 6px;
border-radius: 50%;
background-color: #999;
animation: typing 1.4s infinite ease-in-out;
&:nth-child(1) { animation-delay: -0.32s; }
&:nth-child(2) { animation-delay: -0.16s; }
&:nth-child(3) { animation-delay: 0s; }
}
}
}
}
.input-container {
background: white;
padding: 16px;
border-top: 1px solid #e0e0e0;
display: flex;
align-items: center;
gap: 12px;
box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
.input-wrapper {
flex: 1;
position: relative;
}
.message-input {
width: 100%;
padding: 10px 16px;
border: 2px solid #424242;
border-radius: 20px;
font-size: 1rem; // 使用 rem 单位
line-height: 1.8;
resize: none;
outline: none;
transition: all 0.3s ease;
&:focus {
border-color: #ffc6c6;
background: white;
box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}
&::placeholder {
color: #999;
}
}
.send-button {
width: 40px;
height: 40px;
border-radius: 50%;
background: linear-gradient(135deg, #ff0000 0%, #af1403 100%);
border: none;
color: white;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.3s ease;
flex-shrink: 0;
&:hover {
transform: scale(1.05);
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
&:active {
transform: scale(0.95);
}
&:disabled {
background: #ccc;
cursor: not-allowed;
transform: none;
box-shadow: none;
}
}
.stop-button {
min-width: 60px;
height: 60px;
border-radius: 20px;
background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
border: none;
color: white;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.3s ease;
flex-shrink: 0;
font-size: 0.8rem;
padding: 0 12px;
&:hover {
transform: scale(1.05);
box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}
&:active {
transform: scale(0.95);
}
}
}
.quick-questions {
padding: 16px;
background: white;
border-top: 1px solid #e0e0e0;
.quick-title {
font-size: .8rem; // 使用 rem 单位
color: #666;
margin-bottom: 12px;
display: flex;
align-items: center;
gap: 8px;
}
.questions-list {
display: flex;
flex-direction: column;
gap: 8px;
.question-item {
padding: 12px 16px;
background: #f9f9f9;
border: 1px solid #e0e0e0;
border-radius: 12px;
font-size: .8rem; // 使用 rem 单位
color: #333;
cursor: pointer;
transition: all 0.3s ease;
text-align: left;
&:hover {
background: #667eea;
color: white;
border-color: #667eea;
transform: translateY(-1px);
box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}
&:active {
transform: translateY(0);
}
}
}
}
.empty-state {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 40px 20px;
text-align: center;
.empty-icon {
font-size: 3rem; // 使用 rem 单位
margin-bottom: 16px;
opacity: 0.5;
}
.empty-title {
font-size: 1.5rem; // 使用 rem 单位
font-weight: bold;
color: #333;
margin-bottom: 8px;
}
.empty-desc {
font-size: .8rem; // 使用 rem 单位
color: #666;
line-height: 1.5;
}
}
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes typing {
0%, 80%, 100% {
transform: scale(0);
opacity: 0.5;
}
40% {
transform: scale(1);
opacity: 1;
}
}
@keyframes blink {
0%, 50% {
opacity: 1;
}
51%, 100% {
opacity: 0;
}
}