chat.css 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. .chat-container {
  2. display: flex;
  3. flex-direction: column;
  4. height: calc(100vh - 60px); /* 减去header高度 */
  5. background: #fcfcfd; /* 更浅的背景色,接近白色 */
  6. }
  7. .chat-messages {
  8. flex: 1;
  9. overflow-y: auto;
  10. padding: 20px;
  11. display: flex;
  12. flex-direction: column;
  13. gap: 16px;
  14. scroll-behavior: smooth;
  15. background: #fcfcfd; /* 与容器背景保持一致 */
  16. }
  17. .message {
  18. display: flex;
  19. align-items: flex-start;
  20. max-width: 85%;
  21. margin-bottom: 4px;
  22. }
  23. .message.user {
  24. margin-left: auto;
  25. }
  26. .message-content {
  27. position: relative;
  28. padding: 12px 16px;
  29. border-radius: 12px;
  30. background: #fff;
  31. box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  32. transition: all 0.3s ease;
  33. }
  34. .message.assistant .message-content {
  35. background: #f0f4f8; /* AI消息背景色 */
  36. border-top-left-radius: 4px;
  37. }
  38. .message.user .message-content {
  39. background: #e8f4ff; /* 用户消息背景色 */
  40. border-top-right-radius: 4px;
  41. }
  42. .message p {
  43. margin: 0;
  44. line-height: 1.5;
  45. color: #333;
  46. }
  47. .chat-input-container {
  48. padding: 16px;
  49. background: #fff;
  50. border-top: 1px solid #f0f0f0;
  51. }
  52. .input-wrapper {
  53. position: relative;
  54. display: flex;
  55. gap: 8px;
  56. background: #f0f4f8; /* 与AI消息框背景色保持一致 */
  57. border-radius: 8px;
  58. padding: 8px 12px;
  59. transition: all 0.2s ease;
  60. }
  61. .input-wrapper:focus-within {
  62. box-shadow: 0 0 0 1px #1a73e8;
  63. }
  64. #chat-input {
  65. flex: 1;
  66. border: none;
  67. background: transparent;
  68. resize: none;
  69. padding: 8px;
  70. font-size: 14px;
  71. line-height: 1.5;
  72. max-height: 120px;
  73. outline: none;
  74. color: #333;
  75. }
  76. .input-buttons {
  77. display: flex;
  78. align-items: center;
  79. gap: 8px;
  80. }
  81. .icon-button {
  82. position: relative;
  83. overflow: hidden;
  84. background: none;
  85. border: none;
  86. padding: 6px;
  87. cursor: pointer;
  88. color: #666;
  89. border-radius: 4px;
  90. transition: all 0.2s;
  91. }
  92. .icon-button::after {
  93. content: "";
  94. position: absolute;
  95. top: 50%;
  96. left: 50%;
  97. width: 100%;
  98. height: 100%;
  99. background: currentColor;
  100. border-radius: 50%;
  101. transform: translate(-50%, -50%) scale(0);
  102. opacity: 0;
  103. transition: all 0.2s ease;
  104. }
  105. .icon-button:hover::after {
  106. transform: translate(-50%, -50%) scale(1.5);
  107. opacity: 0.1;
  108. }
  109. /* 快捷指令面板 */
  110. .prompt-panel {
  111. position: absolute;
  112. bottom: 80px;
  113. left: 16px;
  114. right: 16px;
  115. background: #fff;
  116. border-radius: 8px;
  117. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  118. display: none;
  119. }
  120. .prompt-panel.show {
  121. display: block;
  122. animation: slideUp 0.2s ease-out;
  123. }
  124. .prompt-header {
  125. display: flex;
  126. justify-content: space-between;
  127. align-items: center;
  128. padding: 12px 16px;
  129. border-bottom: 1px solid #eee;
  130. }
  131. .prompt-header h3 {
  132. margin: 0;
  133. font-size: 16px;
  134. color: #333;
  135. }
  136. .close-prompt {
  137. background: none;
  138. border: none;
  139. font-size: 20px;
  140. color: #666;
  141. cursor: pointer;
  142. padding: 4px 8px;
  143. }
  144. .prompt-list {
  145. padding: 8px;
  146. max-height: 300px;
  147. overflow-y: auto;
  148. }
  149. .prompt-item {
  150. width: 100%;
  151. padding: 12px;
  152. text-align: left;
  153. background: none;
  154. border: none;
  155. border-radius: 6px;
  156. cursor: pointer;
  157. transition: all 0.2s;
  158. }
  159. .prompt-item:hover {
  160. background: #f5f5f5;
  161. }
  162. @keyframes slideUp {
  163. from {
  164. transform: translateY(20px);
  165. opacity: 0;
  166. }
  167. to {
  168. transform: translateY(0);
  169. opacity: 1;
  170. }
  171. }
  172. /* 滚动条样式 */
  173. .chat-messages::-webkit-scrollbar {
  174. width: 6px;
  175. }
  176. .chat-messages::-webkit-scrollbar-track {
  177. background: transparent;
  178. }
  179. .chat-messages::-webkit-scrollbar-thumb {
  180. background: #ddd;
  181. border-radius: 3px;
  182. }
  183. .chat-messages::-webkit-scrollbar-thumb:hover {
  184. background: #ccc;
  185. }
  186. /* 打字动画相关样式 */
  187. .message-content.typing {
  188. display: flex;
  189. flex-direction: column;
  190. }
  191. .message-content.typing p {
  192. display: inline;
  193. white-space: pre-wrap;
  194. word-break: break-word;
  195. }
  196. .message-content.typing p::after {
  197. content: "|";
  198. display: inline;
  199. margin-left: 1px;
  200. font-weight: bold;
  201. animation: blink 1s infinite;
  202. vertical-align: baseline;
  203. }
  204. @keyframes blink {
  205. 0%,
  206. 100% {
  207. opacity: 1;
  208. }
  209. 50% {
  210. opacity: 0;
  211. }
  212. }
  213. /* 加载动画样式 */
  214. .typing-indicator {
  215. display: flex;
  216. gap: 4px;
  217. padding: 4px 8px;
  218. }
  219. .typing-indicator span {
  220. width: 8px;
  221. height: 8px;
  222. background: #90a4ae;
  223. border-radius: 50%;
  224. animation: bounce 1.4s infinite ease-in-out;
  225. }
  226. .typing-indicator span:nth-child(1) {
  227. animation-delay: -0.32s;
  228. }
  229. .typing-indicator span:nth-child(2) {
  230. animation-delay: -0.16s;
  231. }
  232. @keyframes bounce {
  233. 0%,
  234. 80%,
  235. 100% {
  236. transform: scale(0);
  237. }
  238. 40% {
  239. transform: scale(1);
  240. }
  241. }
  242. /* 消息内容的过渡效果 */
  243. .message-content {
  244. transition: opacity 0.3s ease;
  245. }
  246. .message-content.loading {
  247. min-width: 60px;
  248. min-height: 24px;
  249. }
  250. /* 消息时间戳样式 */
  251. .message-timestamp {
  252. font-size: 12px;
  253. color: #999;
  254. line-height: 24px; /* 与按钮高度一致 */
  255. margin: 0; /* 移除可能的外边距 */
  256. padding: 0 2px; /* 添加少许水平内边距 */
  257. }
  258. /* 消息hover效果 */
  259. .message-content:hover {
  260. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  261. }
  262. /* 添加头像占位 */
  263. .message.assistant::before {
  264. content: "";
  265. width: 32px;
  266. height: 32px;
  267. min-width: 32px;
  268. margin-right: 8px;
  269. border-radius: 50%;
  270. background: #fff url("../images/icon128.png") center/cover no-repeat;
  271. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  272. transition: all 0.3s ease;
  273. }
  274. /* 头像悬停效果 */
  275. .message.assistant:hover::before {
  276. transform: scale(1.1);
  277. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  278. }
  279. /* 消息分组 */
  280. .message + .message.assistant,
  281. .message + .message.user {
  282. margin-top: 2px;
  283. }
  284. .message:not(:first-child) {
  285. margin-top: 16px;
  286. }
  287. /* 添加新消息指示器 */
  288. .new-messages-indicator {
  289. position: absolute;
  290. bottom: 80px;
  291. left: 50%;
  292. transform: translateX(-50%);
  293. background: rgba(33, 150, 243, 0.9);
  294. color: #fff;
  295. padding: 8px 16px;
  296. border-radius: 20px;
  297. font-size: 14px;
  298. cursor: pointer;
  299. opacity: 0;
  300. transition: all 0.3s ease;
  301. pointer-events: none;
  302. }
  303. .new-messages-indicator.show {
  304. opacity: 1;
  305. pointer-events: auto;
  306. }
  307. /* 消息格式化样式 */
  308. .message-content p {
  309. margin: 0;
  310. line-height: 1.5;
  311. }
  312. .message-content pre {
  313. background: #f6f8fa;
  314. padding: 12px;
  315. border-radius: 6px;
  316. overflow-x: auto;
  317. margin: 8px 0;
  318. }
  319. .message-content code {
  320. font-family: monospace;
  321. background: #f6f8fa;
  322. padding: 2px 4px;
  323. border-radius: 4px;
  324. font-size: 0.9em;
  325. }
  326. .message-content pre code {
  327. padding: 0;
  328. background: none;
  329. }
  330. .message-content a {
  331. color: #1a73e8;
  332. text-decoration: none;
  333. }
  334. .message-content a:hover {
  335. text-decoration: underline;
  336. }
  337. .message-content strong {
  338. font-weight: 600;
  339. }
  340. .message-content em {
  341. font-style: italic;
  342. }
  343. /* 消息操作栏样式 */
  344. .message-actions {
  345. display: flex;
  346. justify-content: flex-end;
  347. align-items: center; /* 确保垂直居中对齐 */
  348. gap: 8px;
  349. margin-top: 4px;
  350. min-height: 24px; /* 设置最小高度确保一致性 */
  351. }
  352. /* 复制按钮样式 */
  353. .copy-button {
  354. display: flex;
  355. align-items: center;
  356. gap: 4px;
  357. height: 24px; /* 固定高度 */
  358. padding: 0 6px; /* 调整水平内边距 */
  359. font-size: 12px;
  360. color: #666;
  361. background: none;
  362. border: none;
  363. border-radius: 4px;
  364. cursor: pointer;
  365. transition: all 0.2s ease;
  366. }
  367. .copy-button:hover {
  368. background: rgba(0, 0, 0, 0.05);
  369. color: #1a73e8;
  370. }
  371. .copy-button svg {
  372. width: 14px;
  373. height: 14px;
  374. }
  375. /* 复制成功提示 */
  376. .copy-button.copied {
  377. color: #00c853;
  378. pointer-events: none;
  379. }
  380. /* Markdown样式 */
  381. .message-content h1,
  382. .message-content h2,
  383. .message-content h3,
  384. .message-content h4,
  385. .message-content h5,
  386. .message-content h6 {
  387. margin: 16px 0 8px;
  388. font-weight: 600;
  389. line-height: 1.25;
  390. color: #333;
  391. }
  392. .message-content h1 {
  393. font-size: 1.5em;
  394. }
  395. .message-content h2 {
  396. font-size: 1.3em;
  397. }
  398. .message-content h3 {
  399. font-size: 1.2em;
  400. }
  401. .message-content h4 {
  402. font-size: 1.1em;
  403. }
  404. .message-content h5 {
  405. font-size: 1em;
  406. }
  407. .message-content h6 {
  408. font-size: 0.9em;
  409. }
  410. .message-content ul,
  411. .message-content ol {
  412. margin: 8px 0;
  413. padding-left: 20px;
  414. }
  415. .message-content li {
  416. margin: 4px 0;
  417. }
  418. .message-content blockquote {
  419. margin: 8px 0;
  420. padding: 8px 16px;
  421. border-left: 4px solid #ddd;
  422. background: rgba(0, 0, 0, 0.02);
  423. color: #666;
  424. }
  425. .message-content hr {
  426. margin: 16px 0;
  427. border: none;
  428. border-top: 1px solid #eee;
  429. }
  430. /* 调整代码块样式 */
  431. .message-content pre {
  432. background: #f6f8fa;
  433. padding: 16px;
  434. border-radius: 6px;
  435. overflow-x: auto;
  436. margin: 8px 0;
  437. }
  438. .message-content pre code {
  439. padding: 0;
  440. background: none;
  441. font-size: 0.9em;
  442. line-height: 1.5;
  443. }
  444. /* 打断按钮样式 */
  445. .stop-button {
  446. display: none; /* 默认隐藏 */
  447. padding: 6px 12px;
  448. color: #666;
  449. background: none;
  450. border: 1px solid #ddd;
  451. border-radius: 4px;
  452. cursor: pointer;
  453. font-size: 12px;
  454. transition: all 0.2s ease;
  455. }
  456. .stop-button.show {
  457. display: flex;
  458. align-items: center;
  459. gap: 4px;
  460. }
  461. .stop-button:hover {
  462. color: #d32f2f;
  463. border-color: #d32f2f;
  464. background: rgba(211, 47, 47, 0.05);
  465. }
  466. .stop-button svg {
  467. width: 14px;
  468. height: 14px;
  469. }
  470. /* 中断消息样式 */
  471. .message.assistant .message-content.interrupted {
  472. background: #fff1f0;
  473. border-left: 4px solid #ff4d4f;
  474. border-top-left-radius: 0;
  475. padding-left: 12px;
  476. color: #cf1322;
  477. }
  478. .message-content.interrupted .message-timestamp {
  479. color: rgba(207, 19, 34, 0.6);
  480. }
  481. /* 输入框禁用状态样式 */
  482. #chat-input:disabled {
  483. cursor: not-allowed;
  484. color: #999;
  485. }
  486. .input-wrapper.generating {
  487. background: #f5f5f5;
  488. }
  489. /* 修改:只禁用输入框和其他按钮 */
  490. .input-wrapper.generating #chat-input,
  491. .input-wrapper.generating .icon-button {
  492. pointer-events: none;
  493. opacity: 0.5; /* 添加透明度表示禁用状态 */
  494. }
  495. .input-wrapper.generating #chat-input::placeholder {
  496. color: #999;
  497. opacity: 0.8;
  498. }
  499. /* 确保只有停止按钮可以点击 */
  500. .input-wrapper.generating .stop-button {
  501. pointer-events: auto;
  502. opacity: 1; /* 保持完全不透明 */
  503. cursor: pointer;
  504. }