index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  1. <template>
  2. <view class="container">
  3. <!-- 聊天记录区域 -->
  4. <scroll-view class="chat-container" scroll-y :scroll-top="scrollTop" :scroll-with-animation="true"
  5. @scroll="onScroll" :style="{
  6. height: `calc(100vh - ${inputHeight}px)`,
  7. marginTop: '0'
  8. }">
  9. <view class="chat-list">
  10. <view v-for="(message, index) in chatMessages" :key="index" class="message-item"
  11. :class="{ 'message-ai': message.sender === 'ai', 'message-user': message.sender === 'user' }">
  12. <!-- AI消息 -->
  13. <template v-if="message.sender === 'ai'">
  14. <view class="avatar-container">
  15. <image class="avatar" src="/static/icons/ai.png" mode="aspectFill"></image>
  16. </view>
  17. <view class="message-content">
  18. <view class="message-bubble ai-bubble"
  19. :class="{'typing': message.isTyping, 'welcome': message.isWelcome || index === 0}">
  20. <view v-if="message.isTyping" class="typing-indicator">
  21. <view class="typing-dot"></view>
  22. <view class="typing-dot"></view>
  23. <view class="typing-dot"></view>
  24. </view>
  25. <text v-else class="message-text"
  26. :class="{'highlight': containsKeywords(message.content)}">
  27. {{ message.content }}
  28. </text>
  29. </view>
  30. <text class="message-time">{{ message.time }}</text>
  31. </view>
  32. </template>
  33. <!-- 用户消息 -->
  34. <template v-else>
  35. <view class="message-content user-content">
  36. <text class="message-time">{{ message.time }}</text>
  37. <view class="message-bubble user-bubble">
  38. <text class="message-text">{{ message.content }}</text>
  39. </view>
  40. </view>
  41. <view class="avatar-container">
  42. <image class="avatar" src="/static/images/user-avatar.svg" mode="aspectFill"></image>
  43. </view>
  44. </template>
  45. </view>
  46. </view>
  47. </scroll-view>
  48. <!-- 底部输入区 -->
  49. <view class="input-container" :style="{ paddingBottom: `${isIOS ? safeAreaBottom : 20}rpx` }">
  50. <!-- 问题建议区 -->
  51. <scroll-view v-if="chatMessages.length <= 3 && !inputMessage" class="suggested-questions" scroll-x>
  52. <view v-for="(question, index) in suggestedQuestions" :key="index" class="question-chip"
  53. @click="useQuestion(question)">
  54. <text>{{ question }}</text>
  55. </view>
  56. </scroll-view>
  57. <view class="input-wrapper">
  58. <textarea class="message-input" v-model="inputMessage" placeholder="请输入您的问题..." :disabled="isProcessing"
  59. auto-height :maxlength="300" :style="{ maxHeight: '120rpx' }" @focus="onInputFocus"
  60. @confirm="submitQuestion" />
  61. <view class="send-button" :class="{ 'disabled': !inputMessage.trim() || isProcessing }"
  62. @click="submitQuestion" hover-class="button-hover">
  63. <image class="send-icon-image"
  64. :src="inputMessage.trim() && !isProcessing ? '/static/icons/chat.png' : '/static/icons/chat_off.png'"
  65. mode="aspectFit"></image>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. import api from "@/config/api.js";
  73. import storage from "@/utils/storage.js";
  74. export default {
  75. data() {
  76. return {
  77. inputMessage: '', // 输入框消息
  78. chatMessages: [{
  79. sender: 'ai',
  80. content: '您好!我是农小禹,您的智能农业助手🌱 我可以帮您解答农业种植、病虫害防治、农产品管理等方面的问题。有什么可以帮助您的吗?',
  81. time: this.getFormattedTime(new Date()),
  82. timestamp: Date.now(),
  83. isWelcome: true
  84. }],
  85. scrollTop: 0,
  86. inputHeight: 110,
  87. isProcessing: false,
  88. requestTask: null,
  89. currentTypingMessage: null, // 当前正在输入的消息索引
  90. suggestedQuestions: [
  91. '水稻插秧后如何管理?',
  92. '果树夏季修剪技巧?',
  93. '如何防治蔬菜常见病虫害?',
  94. '农药使用注意事项?',
  95. '有机肥和化肥怎么搭配使用?'
  96. ],
  97. statusBarHeight: 20,
  98. safeAreaBottom: 34,
  99. isIOS: false,
  100. typingInterval: 100, // 打字速度配置
  101. typingTimers: [] // 用于存储定时器
  102. }
  103. },
  104. // 设置页面标题
  105. onNavigationBarButtonTap(e) {
  106. console.log("导航栏按钮点击:", e);
  107. },
  108. created() {
  109. this.debouncedSubmitQuestion = this.debounce(this.submitQuestion, 300)
  110. },
  111. mounted() {
  112. // 获取系统信息
  113. const systemInfo = uni.getSystemInfoSync();
  114. this.statusBarHeight = systemInfo.statusBarHeight || 20;
  115. this.isIOS = systemInfo.platform === 'ios';
  116. this.safeAreaBottom = systemInfo.safeAreaInsets ? (systemInfo.safeAreaInsets.bottom || 0) : 0;
  117. // 初始化消息
  118. this.initMessages();
  119. // 滚动到底部
  120. this.$nextTick(() => {
  121. this.scrollToBottom();
  122. });
  123. },
  124. methods: {
  125. // 处理消息发送的方法
  126. makeStreamRequest(message) {
  127. if (this.requestTask) {
  128. this.requestTask.abort();
  129. }
  130. const url = api.dify + '/dify/chat/stream';
  131. // 添加一个临时的"正在输入"消息
  132. const typingMessageIndex = this.chatMessages.push({
  133. sender: 'ai',
  134. content: '',
  135. time: this.getCurrentTime(),
  136. isTyping: true
  137. }) - 1;
  138. this.currentTypingMessage = typingMessageIndex;
  139. this.requestTask = uni.request({
  140. url: url,
  141. method: 'POST',
  142. data: message,
  143. responseType: 'text',
  144. header: {
  145. 'content-type': 'application/json'
  146. },
  147. success: (res) => {
  148. if (res.data) {
  149. const lines = res.data.split('\n');
  150. this.processSSELines(lines, typingMessageIndex);
  151. }
  152. },
  153. fail: (err) => {
  154. console.error('请求失败:', err);
  155. this.handleError(err);
  156. // 移除"正在输入"消息
  157. if (this.currentTypingMessage !== null) {
  158. this.chatMessages.splice(this.currentTypingMessage, 1);
  159. }
  160. },
  161. complete: () => {
  162. this.requestTask = null;
  163. this.isProcessing = false;
  164. this.scrollToBottom();
  165. }
  166. });
  167. },
  168. // 处理 SSE 数据行
  169. processSSELines(lines, typingMessageIndex) {
  170. let accumulatedText = this.chatMessages[typingMessageIndex]?.content || '';
  171. lines.forEach(line => {
  172. if (!line.trim()) return;
  173. if (line.startsWith('data:')) {
  174. try {
  175. const jsonData = JSON.parse(line.slice(5).trim());
  176. if (jsonData.eventType === 'AGENT_MESSAGE' && jsonData.answer) {
  177. accumulatedText += jsonData.answer;
  178. // 使用新的打字机效果更新消息内容
  179. this.typewriterEffect(accumulatedText, (text) => {
  180. this.$set(this.chatMessages[typingMessageIndex], 'content', text);
  181. // 滚动到底部,确保用户看到最新内容
  182. this.scrollToBottom();
  183. });
  184. } else if (jsonData.eventType === 'MESSAGE_END') {
  185. // 消息结束时停止打字效果
  186. this.currentTypingMessage = null;
  187. this.$set(this.chatMessages[typingMessageIndex], 'isTyping', false);
  188. // 确保完整内容显示
  189. }
  190. } catch (e) {
  191. console.error('解析数据出错:', e);
  192. }
  193. }
  194. });
  195. },
  196. // 实现打字机效果的方法
  197. typewriterEffect(text, callback) {
  198. let index = 0;
  199. const length = text.length;
  200. const interval = 50; // 打字间隔时间
  201. // 清除之前的打字机效果定时器
  202. this.typingTimers.forEach(timer => clearTimeout(timer));
  203. this.typingTimers = [];
  204. const type = () => {
  205. if (index <= length) {
  206. callback(text.slice(0, index));
  207. index++;
  208. const timer = setTimeout(type, interval);
  209. this.typingTimers.push(timer);
  210. }
  211. };
  212. type();
  213. },
  214. // 发送消息
  215. submitQuestion() {
  216. if (!storage.getHasLogin()) {
  217. // 使用 uni.showModal 显示登录提示框
  218. uni.showModal({
  219. title: '提示',
  220. content: '您还未登录,请先登录',
  221. confirmText: '去登录',
  222. cancelText: '取消',
  223. success: function(res) {
  224. if (res.confirm) {
  225. // 点击确定按钮,跳转到登录页面
  226. uni.navigateTo({
  227. url: '/pages/login/index'
  228. });
  229. }
  230. },
  231. });
  232. return;
  233. }
  234. if (!this.inputMessage.trim() || this.isProcessing) return;
  235. this.isProcessing = true;
  236. // 添加用户消息
  237. this.chatMessages.push({
  238. sender: 'user',
  239. content: this.inputMessage,
  240. time: this.getCurrentTime()
  241. });
  242. const message = {
  243. query: this.inputMessage,
  244. user: 'user_' + Date.now()
  245. };
  246. this.inputMessage = '';
  247. this.scrollToBottom();
  248. this.makeStreamRequest(message);
  249. },
  250. // 添加错误处理方法
  251. handleError(error) {
  252. let errorMessage = '发生错误'
  253. if (error.errMsg) {
  254. errorMessage = error.errMsg
  255. } else if (error.message) {
  256. errorMessage = error.message
  257. }
  258. uni.showToast({
  259. title: errorMessage,
  260. icon: 'none',
  261. duration: 2000
  262. })
  263. },
  264. // 添加防抖函数
  265. debounce(func, wait) {
  266. let timeout
  267. return (...args) => {
  268. clearTimeout(timeout)
  269. timeout = setTimeout(() => {
  270. func.apply(this, args)
  271. }, wait)
  272. }
  273. },
  274. onInputFocus() {
  275. // 输入框获取焦点时,确保滚动到底部
  276. this.$nextTick(() => {
  277. this.scrollToBottom();
  278. });
  279. },
  280. // 滚动到底部
  281. scrollToBottom() {
  282. this.$nextTick(() => {
  283. const query = uni.createSelectorQuery().in(this)
  284. query.select('.chat-list').boundingClientRect(data => {
  285. if (data) {
  286. this.scrollTop = data.height + 1000
  287. }
  288. }).exec()
  289. })
  290. },
  291. // 错误处理
  292. handleError(error) {
  293. let errorMessage = '发生错误'
  294. if (error.errMsg) {
  295. errorMessage = error.errMsg
  296. } else if (error.message) {
  297. errorMessage = error.message
  298. }
  299. uni.showToast({
  300. title: errorMessage,
  301. icon: 'none',
  302. duration: 2000
  303. })
  304. },
  305. onScroll(e) {
  306. // 可以添加滚动事件处理
  307. },
  308. getCurrentTime() {
  309. return this.getFormattedTime(new Date());
  310. },
  311. getFormattedTime(date) {
  312. const hours = date.getHours().toString().padStart(2, '0');
  313. const minutes = date.getMinutes().toString().padStart(2, '0');
  314. return `${hours}:${minutes}`;
  315. },
  316. /* submitQuestion() {
  317. if (!this.inputMessage.trim() || this.isProcessing) return;
  318. this.isProcessing = true;
  319. // 添加用户消息
  320. this.chatMessages.push({
  321. sender: 'user',
  322. content: this.inputMessage,
  323. time: this.getCurrentTime()
  324. });
  325. const userQuestion = this.inputMessage;
  326. this.inputMessage = '';
  327. // 滚动到底部
  328. this.scrollToBottom();
  329. // 先添加一个"正在输入"的消息
  330. this.chatMessages.push({
  331. sender: 'ai',
  332. content: '正在思考...',
  333. time: this.getCurrentTime(),
  334. isTyping: true
  335. });
  336. // 模拟AI回复(实际项目中替换为API调用)
  337. setTimeout(() => {
  338. // 删除"正在输入"消息
  339. this.chatMessages.pop();
  340. // 模拟回复
  341. let aiResponse = "感谢您的提问!作为您的农技助理,我很高兴能帮助您解决农业相关问题。您询问的内容我已收到,我们团队正在研究适合的解决方案。";
  342. if (userQuestion.includes('水稻')) {
  343. aiResponse = "水稻种植需要注意水肥管理和病虫害防治。目前南方地区水稻插秧时间已到,建议您选择抗病性强的品种,如'中优84'。插秧后7天开始浅水促根,分蘖期保持3-5cm水层。";
  344. } else if (userQuestion.includes('蔬菜')) {
  345. aiResponse = "夏季蔬菜种植需注意遮阳和水分管理。建议种植耐热品种如空心菜、苋菜、茄子等。可以采用遮阳网减少强光照射,早晚浇水避开高温时段。";
  346. } else if (userQuestion.includes('果树')) {
  347. aiResponse = "果树现在应注意夏季修剪和病虫害防治。柑橘类果树可以进行夏季修剪,去除徒长枝和内膛枝。同时注意柑橘黄龙病和炭疽病的预防,建议定期喷施药剂保护。";
  348. }
  349. this.chatMessages.push({
  350. sender: 'ai',
  351. content: aiResponse,
  352. time: this.getCurrentTime()
  353. });
  354. this.scrollToBottom();
  355. this.isProcessing = false;
  356. }, 2000);
  357. }, */
  358. useQuestion(question) {
  359. this.inputMessage = question;
  360. },
  361. containsKeywords(text) {
  362. const keywords = ['水稻', '小麦', '玉米', '病虫害', '农药', '化肥', '有机肥', '种植技术'];
  363. return keywords.some(keyword => text.includes(keyword));
  364. },
  365. formatMessage(text) {
  366. // 将文本中的换行符转换为<br>标签
  367. return text.replace(/\n/g, '<br>');
  368. },
  369. initMessages() {
  370. // 确保消息有时间戳
  371. this.chatMessages.forEach(msg => {
  372. if (!msg.timestamp) {
  373. msg.timestamp = new Date().getTime();
  374. }
  375. });
  376. // 按时间排序
  377. this.chatMessages.sort((a, b) => a.timestamp - b.timestamp);
  378. },
  379. showDateSeparator(index) {
  380. // 判断是否需要显示日期分割线
  381. if (index === 0) return true;
  382. const currentMsg = this.chatMessages[index];
  383. const prevMsg = this.chatMessages[index - 1];
  384. // 如果两条消息相隔超过30分钟,或者是不同日期,显示日期分割线
  385. return this.isDifferentDay(currentMsg.timestamp, prevMsg.timestamp) ||
  386. (currentMsg.timestamp - prevMsg.timestamp > 30 * 60 * 1000);
  387. },
  388. isDifferentDay(timestamp1, timestamp2) {
  389. const date1 = new Date(timestamp1);
  390. const date2 = new Date(timestamp2);
  391. return date1.getDate() !== date2.getDate() ||
  392. date1.getMonth() !== date2.getMonth() ||
  393. date1.getFullYear() !== date2.getFullYear();
  394. },
  395. formatDateSeparator(timestamp) {
  396. const now = new Date();
  397. const msgDate = new Date(timestamp);
  398. // 今天
  399. if (this.isSameDay(msgDate, now)) {
  400. return '今天 ' + this.getFormattedTime(msgDate);
  401. }
  402. // 昨天
  403. const yesterday = new Date(now);
  404. yesterday.setDate(now.getDate() - 1);
  405. if (this.isSameDay(msgDate, yesterday)) {
  406. return '昨天 ' + this.getFormattedTime(msgDate);
  407. }
  408. // 一周内
  409. const oneWeekAgo = new Date(now);
  410. oneWeekAgo.setDate(now.getDate() - 7);
  411. if (msgDate >= oneWeekAgo) {
  412. const weekdays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
  413. return weekdays[msgDate.getDay()] + ' ' + this.getFormattedTime(msgDate);
  414. }
  415. // 其他日期
  416. return msgDate.getFullYear() + '年' + (msgDate.getMonth() + 1) + '月' + msgDate.getDate() + '日 ' +
  417. this
  418. .getFormattedTime(msgDate);
  419. },
  420. isSameDay(date1, date2) {
  421. return date1.getDate() === date2.getDate() &&
  422. date1.getMonth() === date2.getMonth() &&
  423. date1.getFullYear() === date2.getFullYear();
  424. }
  425. },
  426. // 组件销毁时清理资源
  427. beforeDestroy() {
  428. // 清理所有打字机效果的定时器
  429. this.typingTimers.forEach(timer => clearTimeout(timer));
  430. // 清理请求
  431. if (this.requestTask) {
  432. this.requestTask.abort();
  433. this.requestTask = null;
  434. }
  435. }
  436. }
  437. </script>
  438. <style>
  439. /* 容器样式 */
  440. .container {
  441. position: relative;
  442. min-height: 100vh;
  443. background-color: #f5f5f5;
  444. overflow: hidden;
  445. /* 防止内容溢出 */
  446. }
  447. /* 聊天容器 */
  448. .chat-container {
  449. padding: 20rpx 30rpx;
  450. box-sizing: border-box;
  451. background-color: #f8f8f8;
  452. background-image: url('/static/images/chat-bg-pattern.png');
  453. background-size: 300rpx;
  454. background-blend-mode: overlay;
  455. background-opacity: 0.05;
  456. -webkit-overflow-scrolling: touch;
  457. /* 增强iOS滚动体验 */
  458. }
  459. .chat-list {
  460. padding-bottom: 30rpx;
  461. }
  462. /* 消息项 */
  463. .message-item {
  464. display: flex;
  465. margin-bottom: 30rpx;
  466. position: relative;
  467. }
  468. .message-ai {
  469. justify-content: flex-start;
  470. }
  471. .message-user {
  472. justify-content: flex-end;
  473. }
  474. /* 头像 */
  475. .avatar-container {
  476. width: 90rpx;
  477. height: 90rpx;
  478. flex-shrink: 0;
  479. }
  480. .avatar {
  481. width: 90rpx;
  482. height: 90rpx;
  483. border-radius: 50%;
  484. background-color: #e0e0e0;
  485. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  486. object-fit: cover;
  487. }
  488. /* 消息内容 */
  489. .message-content {
  490. max-width: 70%;
  491. margin: 0 20rpx;
  492. display: flex;
  493. flex-direction: column;
  494. }
  495. .user-content {
  496. align-items: flex-end;
  497. }
  498. .message-bubble {
  499. padding: 24rpx;
  500. border-radius: 24rpx;
  501. position: relative;
  502. margin-bottom: 10rpx;
  503. word-wrap: break-word;
  504. min-width: 80rpx;
  505. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
  506. transition: all 0.3s ease;
  507. max-width: 100%;
  508. }
  509. .ai-bubble {
  510. background-color: #e8f5e9;
  511. border-top-left-radius: 4rpx;
  512. }
  513. .user-bubble {
  514. background-color: #e3f2fd;
  515. border-top-right-radius: 4rpx;
  516. }
  517. .message-text {
  518. font-size: 28rpx;
  519. color: #333;
  520. line-height: 1.5;
  521. word-break: break-all;
  522. }
  523. .message-time {
  524. font-size: 22rpx;
  525. color: #999;
  526. }
  527. /* 输入区域 */
  528. .input-container {
  529. position: fixed;
  530. bottom: 0;
  531. left: 0;
  532. right: 0;
  533. background-color: #fff;
  534. padding: 20rpx 30rpx;
  535. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
  536. display: flex;
  537. flex-direction: column;
  538. z-index: 10;
  539. }
  540. .input-wrapper {
  541. display: flex;
  542. align-items: flex-end;
  543. }
  544. .message-input {
  545. flex: 1;
  546. min-height: 70rpx;
  547. max-height: 120rpx;
  548. border-radius: 35rpx;
  549. background-color: #f5f5f5;
  550. padding: 15rpx 30rpx;
  551. font-size: 28rpx;
  552. color: #333;
  553. border: 1rpx solid #e0e0e0;
  554. line-height: 1.4;
  555. }
  556. .send-button {
  557. margin-left: 16rpx;
  558. width: 76rpx;
  559. height: 76rpx;
  560. border-radius: 50%;
  561. background-color: transparent;
  562. background-image: none;
  563. display: flex;
  564. align-items: center;
  565. justify-content: center;
  566. transition: all 0.2s ease;
  567. position: relative;
  568. align-self: center;
  569. }
  570. .send-button.disabled {
  571. background-color: transparent;
  572. background-image: none;
  573. opacity: 1;
  574. }
  575. .button-hover {
  576. transform: scale(0.95);
  577. }
  578. @keyframes pulse {
  579. 0% {
  580. transform: scale(1);
  581. }
  582. 50% {
  583. transform: scale(0.95);
  584. }
  585. 100% {
  586. transform: scale(1);
  587. }
  588. }
  589. .send-button:active:not(.disabled) {
  590. animation: pulse 0.3s ease-in-out;
  591. }
  592. /* 删除或注释掉之前的样式 */
  593. .send-icon {
  594. display: none;
  595. }
  596. .send-icon:before {
  597. display: none;
  598. }
  599. .send-icon-text {
  600. display: none;
  601. }
  602. /* 推荐问题区域 */
  603. .suggested-questions {
  604. display: flex;
  605. white-space: nowrap;
  606. margin-bottom: 15rpx;
  607. padding: 5rpx 0;
  608. }
  609. .question-chip {
  610. display: inline-block;
  611. padding: 12rpx 20rpx;
  612. margin-right: 15rpx;
  613. background-color: #e8f5e9;
  614. color: #4CAF50;
  615. font-size: 24rpx;
  616. border-radius: 30rpx;
  617. border: 1rpx solid #a5d6a7;
  618. }
  619. /* AI正在输入的样式 */
  620. .message-bubble.ai-bubble.typing {
  621. background-color: #f0f0f0;
  622. }
  623. .typing-indicator {
  624. display: flex;
  625. align-items: center;
  626. justify-content: center;
  627. height: 40rpx;
  628. padding: 0 20rpx;
  629. }
  630. .typing-dot {
  631. width: 10rpx;
  632. height: 10rpx;
  633. margin: 0 5rpx;
  634. background-color: #4CAF50;
  635. border-radius: 50%;
  636. opacity: 0.5;
  637. animation: typingAnimation 1.4s infinite both;
  638. }
  639. .typing-dot:nth-child(2) {
  640. animation-delay: 0.2s;
  641. }
  642. .typing-dot:nth-child(3) {
  643. animation-delay: 0.4s;
  644. }
  645. @keyframes typingAnimation {
  646. 0% {
  647. opacity: 0.3;
  648. transform: translateY(0);
  649. }
  650. 50% {
  651. opacity: 1;
  652. transform: translateY(-5rpx);
  653. }
  654. 100% {
  655. opacity: 0.3;
  656. transform: translateY(0);
  657. }
  658. }
  659. /* 关键词高亮 */
  660. .message-text.highlight {
  661. color: #2E7D32;
  662. font-weight: 500;
  663. }
  664. /* 欢迎消息特殊样式 */
  665. .welcome {
  666. background-color: #e3f2fd !important;
  667. border-left: none !important;
  668. border-radius: 24rpx !important;
  669. }
  670. /* 日期分割线样式 */
  671. .date-separator {
  672. display: flex;
  673. align-items: center;
  674. justify-content: center;
  675. margin: 20rpx 0;
  676. }
  677. .date-separator text {
  678. background-color: rgba(0, 0, 0, 0.1);
  679. color: #666;
  680. font-size: 24rpx;
  681. padding: 4rpx 20rpx;
  682. border-radius: 20rpx;
  683. }
  684. /* 纸飞机图标 */
  685. .plane-svg {
  686. display: none;
  687. }
  688. .send-icon-image {
  689. width: 76rpx;
  690. height: 76rpx;
  691. }
  692. .material-icon {
  693. font-family: 'Material Icons';
  694. font-weight: normal;
  695. font-style: normal;
  696. font-size: 48rpx;
  697. line-height: 1;
  698. letter-spacing: normal;
  699. text-transform: none;
  700. display: inline-block;
  701. white-space: nowrap;
  702. word-wrap: normal;
  703. direction: ltr;
  704. -webkit-font-smoothing: antialiased;
  705. color: white;
  706. }
  707. /* 删除不需要的导航栏样式 */
  708. .custom-navbar {
  709. display: none;
  710. }
  711. .navbar-bg,
  712. .navbar-content,
  713. .navbar-left,
  714. .navbar-title,
  715. .navbar-right,
  716. .back-icon,
  717. .arrow-left {
  718. display: none;
  719. }
  720. </style>