You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1654 lines
40 KiB

4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
  1. <template>
  2. <view class="deepMate-page">
  3. <!-- 顶部导航栏 -->
  4. <view class="header" :style="{ paddingTop: safeAreaInsets?.top + 'px' }">
  5. <view class="header-left">
  6. <image
  7. src="https://d31zlh4on95l9h.cloudfront.net/images/f91e09b5987802185e7679055dafd272.svg"
  8. class="icon"
  9. >
  10. </image>
  11. </view>
  12. <view class="header-center">
  13. <text class="title" :style="{ paddingTop: safeAreaInsets?.top + 'px' }"
  14. >DeepMate</text
  15. >
  16. </view>
  17. <view class="header-right">
  18. <image
  19. src="https://d31zlh4on95l9h.cloudfront.net/images/d7c4e74201213a25dd9574e908233928.svg"
  20. class="icon"
  21. >
  22. </image>
  23. <image
  24. style="margin-left: 10px"
  25. src="https://d31zlh4on95l9h.cloudfront.net/images/099903c4aabf5713488b5cb60815e3f7.svg"
  26. class="icon"
  27. @click="openHistoryDrawer"
  28. ></image>
  29. <!-- 新增新会话按钮
  30. <button class="new-chat-button" @click="newChat">
  31. <text class="new-chat-text">新会话</text>
  32. </button> -->
  33. </view>
  34. </view>
  35. <!-- 主要内容区域 -->
  36. <view class="main-content">
  37. <view class="banner-panel" v-if="messages.length === 0">
  38. <image
  39. src="https://d31zlh4on95l9h.cloudfront.net/images/42e18bd7fe97d4f4f37aa70439a0990b.svg"
  40. class="pray-banner"
  41. ></image>
  42. <view class="contain">
  43. <!-- 机器人头像和欢迎语 -->
  44. <view class="robot-container" v-if="messages.length === 0">
  45. <image src="/static/icons/机器人.svg" class="robot-avatar"></image>
  46. <view class="welcome-message">
  47. <text class="greeting">Hi, 我是您的股市随身顾问~</text>
  48. <text class="description"
  49. >个股诊断市场情绪解读都可以找我</text
  50. >
  51. </view>
  52. </view>
  53. <!-- 功能标签栏 -->
  54. <!-- <view class="function-tabs" v-if="messages.length === 0">
  55. <view ref="tabsTrack" class="tabs-track" :style="{ transform: 'translate3d(-' + marqueeOffset + 'px,0,0)' }">
  56. <view class="tab-item" v-for="(tab, idx) in marqueeList" :key="idx">{{ tab }}</view>
  57. </view>
  58. </view> -->
  59. <!-- 特斯拉推荐卡片 -->
  60. <view
  61. class="recommend-card"
  62. v-if="messages.length === 0"
  63. @click="goBlank"
  64. >
  65. <view class="arrow" v-if="messages.length === 0"></view>
  66. <view class="card-content">
  67. <image
  68. src="../../static/images/tesla-logo.png"
  69. class="logo"
  70. ></image>
  71. <view class="card-text">
  72. <text class="main-question">当前特斯拉该如何布局</text>
  73. <text class="stock-code">TSLA</text>
  74. </view>
  75. <image
  76. src="https://d31zlh4on95l9h.cloudfront.net/images/40d94054644f6e3f1c366751f07f0010.svg"
  77. class="arrow-icon"
  78. @click="goBlank"
  79. ></image>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. <!-- 可能感兴趣的话题 -->
  85. <!-- <view v-if="messages.length === 0" class="interest-section">
  86. <text class="section-title">- 您可能感兴趣 -</text>
  87. <view class="topics-list">
  88. <view class="topic-item" v-for="topic in hotTopics" :key="topic.id">
  89. <image :src="topic.icon" class="tag-icon"></image>
  90. <text class="topic-text" @click="sendMessageList(topic.text)">{{
  91. topic.text
  92. }}</text>
  93. </view>
  94. </view>
  95. </view> -->
  96. <view v-if="messages.length === 0" class="welcome-section"> </view>
  97. <!-- 聊天区域 -->
  98. <!-- 顶部粘性欢迎块始终保留在聊天上方 -->
  99. <view class="chat-header" v-if="messages.length > 0">
  100. <view class="robot-container">
  101. <image src="/static/icons/机器人.svg" class="robot-avatar"></image>
  102. <view class="welcome-message">
  103. <text class="greeting">Hi, 我是您的股市随身顾问~</text>
  104. </view>
  105. </view>
  106. </view>
  107. <scroll-view
  108. class="chat-container"
  109. scroll-y="true"
  110. :scroll-top="chatScrollTop"
  111. :scroll-with-animation="!isSending"
  112. @scroll="onChatScroll"
  113. v-if="messages.length > 0"
  114. >
  115. <view class="message-list" id="messageList">
  116. <view
  117. v-for="(message, index) in messages"
  118. :key="index"
  119. :class="
  120. message.isUser ? 'message user-message' : 'message bot-message'
  121. "
  122. >
  123. <!-- 会话图标 -->
  124. <text
  125. :class="
  126. message.isUser
  127. ? 'fa-solid fa-user message-icon'
  128. : 'fa-solid fa-robot message-icon'
  129. "
  130. ></text>
  131. <!-- 会话内容 -->
  132. <view class="message-content">
  133. <!-- <text class="message-text">{{ message.content }}</text> -->
  134. <!-- loading -->
  135. <view
  136. class="loading-dots"
  137. v-if="message.isThinking || !message.isUser"
  138. >
  139. <view class="thinking-process">
  140. <view class="thinking-header">
  141. <view class="thinking-icon"></view>
  142. <view class="thinking-title">{{
  143. message.isTyping ? "正在思考" : "思考完成"
  144. }}</view>
  145. <view class="thinking-count"> </view>
  146. <view
  147. class="thinking-toggle"
  148. @click="message.isThinking = !message.isThinking"
  149. >
  150. <span v-if="message.isThinking"></span>
  151. <span v-else></span>
  152. </view>
  153. </view>
  154. <view v-show="message.isThinking" class="thinking-content">
  155. <view class="thinking-item">
  156. <view class="item-status">
  157. <span class="checkmark"></span>
  158. </view>
  159. <view class="item-text">问题分析完成</view>
  160. </view>
  161. <view class="thinking-item">
  162. <view class="item-status">
  163. <span class="checkmark"></span>
  164. </view>
  165. <view class="item-text">收集相关信息</view>
  166. </view>
  167. </view>
  168. </view>
  169. </view>
  170. <!-- 使用 rich-text 渲染 Markdown 内容 -->
  171. <rich-text
  172. v-if="!message.isUser"
  173. class="message-text"
  174. :nodes="renderMarkdown(message.content)"
  175. ></rich-text>
  176. <text v-else class="message-text">{{ message.content }}</text>
  177. </view>
  178. </view>
  179. </view>
  180. </scroll-view>
  181. </view>
  182. <!-- 输入框区域 -->
  183. <view class="input-area">
  184. <view class="input-wrapper">
  185. <input
  186. type="text"
  187. placeholder="请输入股票代码/名称,获取AI洞察"
  188. placeholder-style="color:#fff;opacity:1"
  189. class="input-field"
  190. v-model="inputMessage"
  191. @confirm="sendMessage"
  192. />
  193. <image class="send-button" @click="sendMessage" :disabled="isSending">
  194. <!-- <image
  195. src="https://d31zlh4on95l9h.cloudfront.net/images/95f1ea2262e9157db13c93c0dc1c5d96.svg"
  196. class="send-icon"
  197. ></image> -->
  198. </image>
  199. </view>
  200. <text class="disclaimer"
  201. >以上数据由AI生成不作为最终投资建议决策需独立</text
  202. >
  203. </view>
  204. <image
  205. class="back-to-top"
  206. src="https://d31zlh4on95l9h.cloudfront.net/images/ba357635d2bb480241952bb1cabacd73.svg"
  207. :style="{
  208. transform: 'translate3d(' + backTopX + 'px,' + backTopY + 'px,0)',
  209. }"
  210. @touchstart="onBackTopTouchStart"
  211. @touchmove="onBackTopTouchMove"
  212. @touchend="onBackTopTouchEnd"
  213. @click="onBackTopClick"
  214. ></image>
  215. <!-- 搜索历史侧拉框 -->
  216. <view class="drawer-overlay" v-show="showHistoryDrawer"></view>
  217. <!-- <view class="drawer-panel" v-show="showHistoryDrawer" @click.stop @touchmove.stop.prevent
  218. :style="{ transform: 'translateY(' + drawerOffsetY + 'px)' }">
  219. <view class="drawer-header">
  220. <text class="drawer-title">历史对话</text>
  221. <view class="drawer-actions">
  222. <view class="delete-all-container">
  223. <image class="delete-icon" src="/static/icons/Group_48095481.svg"></image>
  224. <text class="delete-all" @click="clearAllHistory">删除全部</text>
  225. </view>
  226. <view class="drawer-close" @click="onDrawerBackClick"><text class="drawer-close-icon"></text></view>
  227. </view>
  228. </view>
  229. <scroll-view scroll-y="true" class="drawer-content">
  230. <view class="drawer-inner">
  231. <view v-if="groupedHistory.length === 0" class="empty-history">
  232. <text>暂无历史记录</text>
  233. </view>
  234. <view v-for="(section, sIdx) in groupedHistory" :key="sIdx" class="history-section">
  235. <text class="section-title">{{ section.title }}</text>
  236. <view v-for="(item, idx) in section.items" :key="idx" class="history-item">
  237. <view class="history-left">
  238. <view class="flag-circle"><text class="flag-emoji">🇺🇸</text></view>
  239. </view>
  240. <view class="history-main">
  241. <text class="history-query">{{ item.query }}</text>
  242. </view>
  243. <text class="history-time">{{ formatTime(item.time) }}</text>
  244. </view>
  245. </view>
  246. </view>
  247. </scroll-view>
  248. </view> -->
  249. <view
  250. class="drawer-panel"
  251. v-show="showHistoryDrawer"
  252. @click.stop
  253. @touchmove.stop.prevent
  254. :style="{ transform: 'translateY(' + drawerOffsetY + 'px)' }"
  255. >
  256. <view class="drawer-header">
  257. <text class="drawer-title">历史对话</text>
  258. <view class="drawer-actions">
  259. <view class="delete-all-container">
  260. <image
  261. class="delete-icon"
  262. src="/static/icons/Group_48095481.svg"
  263. ></image>
  264. <text class="delete-all" @click="clearAllHistory">删除全部</text>
  265. </view>
  266. <view class="drawer-close" @click="onDrawerBackClick"
  267. ><text class="drawer-close-icon"></text
  268. ></view>
  269. </view>
  270. </view>
  271. <scroll-view scroll-y="true" class="drawer-content">
  272. <view class="drawer-inner">
  273. <view v-if="historyList.length === 0" class="empty-history">
  274. <text>暂无历史记录</text>
  275. </view>
  276. <view
  277. v-for="(section, sIdx) in historyList"
  278. :key="sIdx"
  279. class="history-section"
  280. >
  281. <text class="section-title">{{ section.title }}</text>
  282. <view
  283. v-for="(item, idx) in section.items"
  284. :key="idx"
  285. class="history-item"
  286. >
  287. <view class="history-left">
  288. <view class="flag-circle"
  289. ><text class="flag-emoji">🇺🇸</text></view
  290. >
  291. </view>
  292. <view class="history-main" @click="itemClick(item)">
  293. <text class="history-query">{{ item.stockName }}</text>
  294. <text class="history-query">{{ item.stockCode }}</text>
  295. </view>
  296. <text class="history-time">{{ item.createdTime }}</text>
  297. </view>
  298. </view>
  299. </view>
  300. </scroll-view>
  301. </view>
  302. <footerBar class="static-footer" :type="type"></footerBar>
  303. </view>
  304. </template>
  305. <script setup>
  306. const { safeAreaInsets } = uni.getSystemInfoSync();
  307. import { ref, computed, onMounted, onUnmounted, watch, nextTick } from "vue";
  308. import footerBar from "../../components/footerBar";
  309. import marked from "marked"; // 引入 marked 库
  310. import { onPageScroll } from "@dcloudio/uni-app";
  311. import {
  312. postStock,
  313. postIntent,
  314. postHistory,
  315. postHistoryDetail,
  316. } from "../../api/deepMate/deepMate";
  317. // 设置 marked 选项
  318. marked.setOptions({
  319. renderer: new marked.Renderer(),
  320. highlight: null, // 如果需要代码高亮,可以设置适当的函数
  321. langPrefix: "language-",
  322. pedantic: false,
  323. gfm: true,
  324. breaks: false,
  325. sanitize: false,
  326. smartLists: true,
  327. smartypants: false,
  328. xhtml: false,
  329. });
  330. // 创建一个用于渲染 Markdown 的函数
  331. const renderMarkdown = (content) => {
  332. if (!content) return "";
  333. return marked.parse(content);
  334. };
  335. const type = ref("member");
  336. const inputMessage = ref("");
  337. const showThinking = ref(true);
  338. const isSending = ref(false);
  339. const chatScrollTop = ref(0);
  340. const chatContainerHeight = ref(0);
  341. const uuid = ref("");
  342. const messages = ref([]);
  343. const showHistoryDrawer = ref(false);
  344. const drawerOffsetY = ref(0);
  345. const searchHistory = ref([]);
  346. const historyList = ref([]);
  347. const hotTopics = ref([
  348. {
  349. id: 1,
  350. text: "英伟达(NVDA)股票情绪温度?",
  351. icon: "https://d31zlh4on95l9h.cloudfront.net/images/7ed58be0f4b81aeb398d9ba2534a624b.svg",
  352. },
  353. {
  354. id: 2,
  355. text: "博通(AVGO)明天还能涨吗?",
  356. icon: "https://d31zlh4on95l9h.cloudfront.net/images/7ed58be0f4b81aeb398d9ba2534a624b.svg",
  357. },
  358. {
  359. id: 3,
  360. text: "为什么Fluence Energy(FLNC)会暴涨?",
  361. icon: "https://d31zlh4on95l9h.cloudfront.net/images/7ed58be0f4b81aeb398d9ba2534a624b.svg",
  362. },
  363. {
  364. id: 4,
  365. text: "为什么Fluence Energy(FLNC)会暴涨?",
  366. icon: "https://d31zlh4on95l9h.cloudfront.net/images/7ed58be0f4b81aeb398d9ba2534a624b.svg",
  367. },
  368. ]);
  369. // 初始化
  370. onMounted(() => {
  371. const sys = uni.getSystemInfoSync();
  372. const iconSize = uni.upx2px(100); // 和样式保持一致
  373. const reserveBottom = uni.upx2px(260); // 预留底部输入区域空间
  374. const initX = Math.max(0, sys.windowWidth - iconSize - uni.upx2px(30));
  375. const initY = Math.max(0, Math.floor(sys.windowHeight * 0.65) - iconSize);
  376. backTopTargetX.value = initX;
  377. backTopTargetY.value = initY;
  378. backTopX.value = initX;
  379. backTopY.value = initY;
  380. initUUID();
  381. if (messages.value.length === 0) {
  382. // nextTick(startTabsMarquee);
  383. }
  384. if (messages.value.length > 0) {
  385. nextTick(() => {
  386. measureChatContainer();
  387. scrollToBottom();
  388. });
  389. }
  390. // 载入历史
  391. const hist = uni.getStorageSync("search_history") || [];
  392. searchHistory.value = Array.isArray(hist) ? hist : [];
  393. // 缓存今天日期(YYYY-MM-DD)
  394. const todayStr = new Date().toISOString().slice(0, 10);
  395. uni.setStorageSync("today_date", todayStr);
  396. });
  397. // 初始化 UUID
  398. const initUUID = () => {
  399. let storedUUID = uni.getStorageSync("user_uuid");
  400. if (!storedUUID) {
  401. storedUUID = generateUUID();
  402. uni.setStorageSync("user_uuid", storedUUID);
  403. }
  404. uuid.value = storedUUID;
  405. };
  406. // 生成简单UUID
  407. const generateUUID = () => {
  408. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
  409. var r = (Math.random() * 16) | 0,
  410. v = c == "x" ? r : (r & 0x3) | 0x8;
  411. return v.toString(16);
  412. });
  413. };
  414. // 计算聊天容器可视高度
  415. const measureChatContainer = () => {
  416. const q = uni.createSelectorQuery();
  417. q.select(".chat-container").boundingClientRect();
  418. q.exec((res) => {
  419. chatContainerHeight.value = res[0]?.height || 0;
  420. });
  421. };
  422. // 新会话
  423. const newChat = () => {
  424. messages.value = [];
  425. uni.removeStorageSync("user_uuid");
  426. initUUID();
  427. };
  428. // 跳转到空白页
  429. const goBlank = () => {
  430. uni.navigateTo({
  431. url: "/pages/blank/blank",
  432. });
  433. };
  434. // 历史抽屉控制
  435. const openHistoryDrawer = () => {
  436. const res = postHistory({
  437. model: 5,
  438. });
  439. if (res.code === 200) {
  440. historyList.value = res.data;
  441. }
  442. console.log("historyList.value", historyList.value);
  443. const hideDistance = uni.upx2px(900);
  444. drawerOffsetY.value = hideDistance;
  445. showHistoryDrawer.value = true;
  446. setTimeout(() => {
  447. drawerOffsetY.value = 0;
  448. }, 10);
  449. };
  450. const closeHistoryDrawer = () => {
  451. showHistoryDrawer.value = false;
  452. };
  453. const onDrawerBackClick = () => {
  454. const hideDistance = uni.upx2px(900);
  455. drawerOffsetY.value = hideDistance;
  456. setTimeout(() => {
  457. closeHistoryDrawer();
  458. drawerOffsetY.value = 0;
  459. }, 180);
  460. };
  461. // 时间格式化:YYYY-MM-DD HH:mm
  462. const pad2 = (n) => (n < 10 ? "0" + n : "" + n);
  463. const formatTime = (t) => {
  464. const d = new Date(t);
  465. const y = d.getFullYear();
  466. const m = pad2(d.getMonth() + 1);
  467. const day = pad2(d.getDate());
  468. const hh = pad2(d.getHours());
  469. const mm = pad2(d.getMinutes());
  470. return `${y}-${m}-${day} ${hh}:${mm}`;
  471. };
  472. // // 历史分组(今天/昨天/近一周/按月)
  473. // const groupedHistory = computed(() => {
  474. // const sections = [];
  475. // // 从缓存获取今天日期,如果没有则使用当前日期
  476. // const cachedTodayStr = uni.getStorageSync('today_date');
  477. // const now = cachedTodayStr ? new Date(cachedTodayStr + 'T00:00:00') : new Date();
  478. // const startOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
  479. // const isSameDay = (a, b) => startOfDay(a).getTime() === startOfDay(b).getTime();
  480. // const isYesterday = (d) => {
  481. // const y = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);
  482. // return isSameDay(d, y);
  483. // };
  484. // const isToday = (d) => isSameDay(d, now);
  485. // const withinLast7Days = (d) => {
  486. // const seven = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 7);
  487. // return d >= seven && !isToday(d) && !isYesterday(d);
  488. // };
  489. // const monthLabel = (d) => `${d.getMonth() + 1}月`;
  490. // const today = [];
  491. // const yesterday = [];
  492. // const last7 = [];
  493. // const byMonth = new Map();
  494. // searchHistory.value.forEach((item) => {
  495. // const dt = new Date(item.time);
  496. // if (isToday(dt)) {
  497. // today.push(item);
  498. // } else if (isYesterday(dt)) {
  499. // yesterday.push(item);
  500. // } else if (withinLast7Days(dt)) {
  501. // last7.push(item);
  502. // } else {
  503. // const year = dt.getFullYear();
  504. // const month = dt.getMonth() + 1;
  505. // const key = `${year}-${month}`;
  506. // if (!byMonth.has(key)) byMonth.set(key, { title: `${month}月`, year, month, items: [] });
  507. // byMonth.get(key).items.push(item);
  508. // }
  509. // });
  510. // if (today.length) sections.push({ title: '今天', items: today });
  511. // if (yesterday.length) sections.push({ title: '昨天', items: yesterday });
  512. // if (last7.length) sections.push({ title: '近一周', items: last7 });
  513. // const monthSections = Array.from(byMonth.values()).sort((a, b) => {
  514. // if (a.year !== b.year) return b.year - a.year;
  515. // return b.month - a.month; // 月份倒序,如 10月 在 9月 之前
  516. // });
  517. // sections.push(...monthSections);
  518. // return sections;
  519. // });
  520. const clearAllHistory = () => {
  521. searchHistory.value = [];
  522. uni.setStorageSync("search_history", []);
  523. };
  524. // 发送消息
  525. const sendMessage = () => {
  526. if (inputMessage.value.trim() === "" || isSending.value) return;
  527. const userMessage = {
  528. content: inputMessage.value,
  529. isUser: true,
  530. isThinking: false,
  531. isTyping: false,
  532. };
  533. messages.value.push(userMessage);
  534. inputMessage.value = "";
  535. // 记录搜索历史
  536. const entry = { query: userMessage.content, time: Date.now() };
  537. searchHistory.value.unshift(entry);
  538. uni.setStorageSync("search_history", searchHistory.value);
  539. // 发送后强制恢复并滚到底部
  540. shouldAutoScroll.value = true;
  541. nextTick(() => {
  542. scrollToBottom();
  543. });
  544. // 模拟机器人回复
  545. simulateBotResponse(userMessage.content);
  546. };
  547. // 模拟机器人回复
  548. const simulateBotResponse = async (userMessage) => {
  549. // 添加机器人加载消息
  550. const botMsg = {
  551. content: "",
  552. isUser: false,
  553. isTyping: true,
  554. isThinking: true,
  555. };
  556. messages.value.push(botMsg);
  557. isSending.value = true;
  558. // 首先进行意图识别
  559. const res = await postIntent({
  560. content: userMessage,
  561. language: 'cn',
  562. marketList: 'hk,cn,usa,my,sg,vi,in,gb',
  563. token: "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
  564. });
  565. console.log("res" + res);
  566. // 意图识别不通过
  567. if (res.code !== 200) {
  568. return;
  569. }
  570. // 获取意图识别结果
  571. const recordId = res.data.recordId;
  572. const parentId = res.data.parentId;
  573. const stockId = res.data.stockId;
  574. // 获取股票信息
  575. const StockInfo = await postStock({
  576. language: 'cn',
  577. token: 'pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q',
  578. recordId: Number(recordId),
  579. parentId: Number(parentId),
  580. stockId: Number(stockId),
  581. });
  582. console.log('postStock payload', { language: 'cn', token: '790750702588f1ea79f24dc56ccd5d8a', recordId, parentId, stockId });
  583. console.log('StockInfo', StockInfo);
  584. if (StockInfo && StockInfo.code !== 200) {
  585. const errMsg = `postStock失败(${StockInfo.code}): ${StockInfo.message || '未知错误'}`
  586. console.warn(errMsg, StockInfo)
  587. messages.value[messages.value.length - 1].isThinking = false
  588. messages.value[messages.value.length - 1].isTyping = false
  589. messages.value[messages.value.length - 1].content = errMsg
  590. isSending.value = false
  591. return
  592. }
  593. const markdown = StockInfo.markdown;
  594. console.log("StockInfo", StockInfo);
  595. // 添加请求延迟
  596. // const toDataInfo = await getData();
  597. // console.log(toDataInfo);
  598. // dataInfo.value = toDataInfo.data;
  599. // console.log(dataInfo.value);
  600. messages.value[messages.value.length - 1].isThinking = false;
  601. // 滚动到底部
  602. nextTick(() => {
  603. scrollToBottom();
  604. });
  605. // 模拟流式响应
  606. let responseText = `我已经收到您的消息: "${userMessage}"。+"${markdown}" `;
  607. let index = 0;
  608. const botIndex = messages.value.length - 1;
  609. const baseDelay = 5; // 普通字符基础延迟(毫秒)
  610. const slowPunct = /[。!?!?;;]/; // 句号、感叹号、分号等较长停顿
  611. const midPunct = /[,、,::]/; // 逗号、顿号、冒号等中等停顿
  612. const typeWriter = () => {
  613. if (index < responseText.length) {
  614. const ch = responseText.charAt(index);
  615. const current = messages.value[botIndex];
  616. // 通过数组替换触发渲染,避免部分平台对子项属性变更不响应
  617. messages.value.splice(botIndex, 1, {
  618. ...current,
  619. content: current.content + ch,
  620. isTyping: true,
  621. });
  622. index++;
  623. scrollToBottom();
  624. const delay = slowPunct.test(ch)
  625. ? 220
  626. : midPunct.test(ch)
  627. ? 120
  628. : baseDelay;
  629. setTimeout(typeWriter, delay);
  630. } else {
  631. const current = messages.value[botIndex];
  632. messages.value.splice(botIndex, 1, { ...current, isTyping: false });
  633. isSending.value = false;
  634. nextTick(() => {
  635. scrollToBottom();
  636. });
  637. }
  638. };
  639. // 启动前稍作停顿,避免过快开始
  640. setTimeout(typeWriter, 500);
  641. console.log("messages", messages);
  642. };
  643. // 当消息出现或变化时,测量容器并滚到底部
  644. watch(messages, (arr) => {
  645. if (arr.length > 0) {
  646. nextTick(() => {
  647. measureChatContainer();
  648. scrollToBottom();
  649. });
  650. }
  651. });
  652. // 滚动到底部(仅聊天区域滚动)
  653. const scrollToBottom = () => {
  654. if (!shouldAutoScroll.value) return;
  655. const query = uni.createSelectorQuery();
  656. query.select("#messageList").boundingClientRect();
  657. query.exec((res) => {
  658. if (res[0]) {
  659. latestContentHeight.value = res[0].height;
  660. chatScrollTop.value = res[0].height; // scroll-view 会自动夹紧到最大位置
  661. }
  662. });
  663. };
  664. const scrollToTop = () => {
  665. chatScrollTop.value = 0;
  666. };
  667. // 自动滚动控制:用户向上滚动时暂停自动滚到底部
  668. const shouldAutoScroll = ref(true);
  669. const latestContentHeight = ref(0);
  670. const lastScrollTop = ref(0);
  671. const windowHeight = uni.getSystemInfoSync().windowHeight;
  672. const AUTO_SCROLL_REENABLE_THRESHOLD = 40000; // px,接近底部时恢复自动滚动
  673. const onChatScroll = (e) => {
  674. const st = e.detail?.scrollTop || 0;
  675. const delta = st - lastScrollTop.value;
  676. lastScrollTop.value = st;
  677. if (delta < 0) {
  678. shouldAutoScroll.value = false;
  679. return;
  680. }
  681. const distanceToBottom =
  682. latestContentHeight.value - st - chatContainerHeight.value;
  683. if (distanceToBottom <= AUTO_SCROLL_REENABLE_THRESHOLD) {
  684. shouldAutoScroll.value = true;
  685. }
  686. };
  687. // 回到顶部图标拖拽状态
  688. const backTopX = ref(0);
  689. const backTopY = ref(0);
  690. const backTopDragging = ref(false);
  691. const backTopDragOffset = ref({ x: 0, y: 0 });
  692. const backTopTargetX = ref(0);
  693. const backTopTargetY = ref(0);
  694. let backTopRAF = 0;
  695. const backTopSmoothing = 0.15; // 越大越跟手,越小越顺滑
  696. const backTopEpsilon = 0.5; // 收敛阈值
  697. const raf =
  698. typeof requestAnimationFrame === "function"
  699. ? requestAnimationFrame
  700. : (fn) => setTimeout(fn, 16);
  701. const caf =
  702. typeof cancelAnimationFrame === "function"
  703. ? cancelAnimationFrame
  704. : (id) => clearTimeout(id);
  705. function stepBackTop() {
  706. const dx = backTopTargetX.value - backTopX.value;
  707. const dy = backTopTargetY.value - backTopY.value;
  708. // 插值缓动,避免每帧重排
  709. backTopX.value += dx * backTopSmoothing;
  710. backTopY.value += dy * backTopSmoothing;
  711. if (Math.abs(dx) > backTopEpsilon || Math.abs(dy) > backTopEpsilon) {
  712. backTopRAF = raf(stepBackTop);
  713. } else {
  714. backTopX.value = backTopTargetX.value;
  715. backTopY.value = backTopTargetY.value;
  716. backTopRAF = 0;
  717. }
  718. }
  719. function ensureBackTopRAF() {
  720. if (!backTopRAF) {
  721. backTopRAF = raf(stepBackTop);
  722. }
  723. }
  724. const clamp = (val, min, max) => Math.max(min, Math.min(val, max));
  725. const onBackTopTouchStart = (e) => {
  726. const t = e.touches && e.touches[0];
  727. if (!t) return;
  728. backTopDragging.value = false;
  729. backTopDragOffset.value = {
  730. x: t.pageX - backTopX.value,
  731. y: t.pageY - backTopY.value,
  732. };
  733. };
  734. const onBackTopTouchMove = (e) => {
  735. const t = e.touches && e.touches[0];
  736. if (!t) return;
  737. const sys = uni.getSystemInfoSync();
  738. const iconSize = uni.upx2px(100);
  739. const reserveBottom = uni.upx2px(260);
  740. const nx = t.pageX - backTopDragOffset.value.x;
  741. const ny = t.pageY - backTopDragOffset.value.y;
  742. const clampedX = clamp(nx, 0, sys.windowWidth - iconSize);
  743. const clampedY = clamp(ny, 0, sys.windowHeight - reserveBottom - iconSize);
  744. if (
  745. Math.abs(clampedX - backTopX.value) + Math.abs(clampedY - backTopY.value) >
  746. 3
  747. ) {
  748. backTopDragging.value = true;
  749. }
  750. backTopTargetX.value = clampedX;
  751. backTopTargetY.value = clampedY;
  752. ensureBackTopRAF();
  753. };
  754. const onBackTopTouchEnd = () => {
  755. // 结束拖拽即可
  756. };
  757. const onBackTopClick = () => {
  758. if (backTopDragging.value) return; // 拖拽时不触发点击回到顶部
  759. scrollToTop();
  760. };
  761. // 历史记录详情
  762. async function itemClick(item) {
  763. const res = await postHistoryDetail({
  764. recordId: item.id,
  765. parentId: item.parentId,
  766. model: 5,
  767. });
  768. if (res.code == 200) {
  769. const message = res.data.wokeFlowData.One.markdown;
  770. messages.value = [];
  771. const botMsg = {
  772. content: message,
  773. isUser: false,
  774. isTyping: false,
  775. isThinking: false,
  776. };
  777. messages.value.push(botMsg);
  778. }
  779. }
  780. </script>
  781. <style scoped>
  782. .deepMate-page {
  783. display: flex;
  784. flex-direction: column;
  785. position: fixed;
  786. /* 充满视口,彻底禁用页面滚动 */
  787. top: 0;
  788. left: 0;
  789. right: 0;
  790. bottom: 0;
  791. height: 100vh;
  792. overflow: hidden;
  793. /* 锁定页面滚动 */
  794. background-color: #ffffff;
  795. padding: 20rpx 0rpx;
  796. }
  797. .header {
  798. display: flex;
  799. justify-content: space-between;
  800. align-items: center;
  801. padding: 20rpx 30rpx;
  802. background-color: #ffffff;
  803. box-shadow: 0 2rpx rgba(0, 0, 0, 0.1);
  804. }
  805. .header-left,
  806. .header-right {
  807. display: flex;
  808. align-items: center;
  809. }
  810. .header-left .icon,
  811. .header-right .icon {
  812. width: 40rpx;
  813. height: 40rpx;
  814. /* margin-right: 20rpx; */
  815. }
  816. .header-center .title {
  817. position: fixed;
  818. top: 10rpx;
  819. left: 50%;
  820. transform: translateX(-50%);
  821. font-size: 36rpx;
  822. font-weight: bold;
  823. color: #333333;
  824. }
  825. .new-chat-button {
  826. background-color: #ff6600;
  827. border: none;
  828. border-radius: 8rpx;
  829. padding: 10rpx 20rpx;
  830. }
  831. .new-chat-text {
  832. color: white;
  833. font-size: 24rpx;
  834. }
  835. .main-content {
  836. background-color: #fff;
  837. flex: 1;
  838. display: flex;
  839. flex-direction: column;
  840. overflow: hidden;
  841. /* 内部滚动交给聊天容器 */
  842. padding: 20rpx;
  843. margin-top: 1rpx;
  844. margin-bottom: 280rpx;
  845. }
  846. /* 聊天顶部粘性欢迎块样式 */
  847. .chat-header {
  848. position: sticky;
  849. top: 0;
  850. /* 在页面滚动时始终贴顶 */
  851. z-index: 50;
  852. background-color: #ffffff;
  853. padding: 3rpx 20rpx;
  854. }
  855. .robot-container {
  856. display: flex;
  857. align-items: center;
  858. margin-top: 30rpx;
  859. }
  860. .robot-avatar {
  861. width: 130rpx;
  862. height: 130rpx;
  863. border-radius: 50%;
  864. margin-left: 20rpx;
  865. }
  866. .welcome-message {
  867. flex: 1;
  868. }
  869. .greeting {
  870. font-size: 32rpx;
  871. margin-left: 50rpx;
  872. top: 40rpx;
  873. font-weight: bold;
  874. color: #333333;
  875. line-height: 48rpx;
  876. }
  877. .description {
  878. display: block;
  879. font-size: 24rpx;
  880. color: #666666;
  881. line-height: 36rpx;
  882. margin-top: 10rpx;
  883. margin-left: 45rpx;
  884. }
  885. .function-tabs {
  886. display: block;
  887. overflow: hidden;
  888. margin-bottom: 30rpx;
  889. }
  890. .tabs-track {
  891. display: inline-flex;
  892. white-space: nowrap;
  893. will-change: transform;
  894. }
  895. .tab-item {
  896. padding: 5rpx 20rpx;
  897. border-radius: 20rpx;
  898. font-size: 20rpx;
  899. font-weight: 700;
  900. color: #666666;
  901. background-color: #fffefe;
  902. margin-right: 20rpx;
  903. transition: all 0.3s;
  904. }
  905. .tab-item.active {
  906. color: #ff6600;
  907. background-color: #fff;
  908. border: 1rpx solid #ff6600;
  909. }
  910. .recommend-card {
  911. background: url("https://d31zlh4on95l9h.cloudfront.net/images/4da1d629a55c307c3605ca15bf15189a.svg");
  912. background-repeat: no-repeat;
  913. background-position: center bottom;
  914. background-size: contain;
  915. /* min-height: 20rpx; */
  916. /* border-radius: 20rpx; */
  917. padding: 40rpx;
  918. margin-top: 20rpx;
  919. margin-bottom: 10rpx;
  920. /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05); */
  921. }
  922. .welcome-section {
  923. /* 灰色卡片(recommend-card)之后展示背景图 */
  924. margin-top: 10rpx;
  925. display: flex;
  926. align-items: center;
  927. justify-content: center;
  928. background: url("https://d31zlh4on95l9h.cloudfront.net/images/eca84d9fb54712cb3bc6c6174773b83b.svg");
  929. background-repeat: no-repeat;
  930. background-position: center top;
  931. /* 放在容器顶部,正好在灰色卡片下方 */
  932. background-size: 80% auto;
  933. /* 缩放以适配宽度 */
  934. height: 460rpx;
  935. /* 提供可视高度,让背景图可见 */
  936. }
  937. .card-content {
  938. display: flex;
  939. align-items: center;
  940. justify-content: space-between;
  941. margin-left: 40rpx;
  942. }
  943. .logo {
  944. width: 80rpx;
  945. height: 80rpx;
  946. background-color: #ff0000;
  947. border-radius: 10rpx;
  948. display: flex;
  949. align-items: center;
  950. justify-content: center;
  951. margin-right: 20rpx;
  952. }
  953. .card-text {
  954. flex: 1;
  955. margin-left: 20rpx;
  956. }
  957. .main-question {
  958. font-size: 32rpx;
  959. color: #333333;
  960. line-height: 48rpx;
  961. }
  962. .stock-code {
  963. display: block;
  964. font-size: 24rpx;
  965. color: #ff3b30;
  966. background-color: #ffffff;
  967. padding: 2rpx 15rpx;
  968. border-radius: 12rpx;
  969. margin-top: 8rpx;
  970. width: fit-content;
  971. border: 1rpx solid #ff3b30;
  972. }
  973. .arrow-icon {
  974. background: url("https://d31zlh4on95l9h.cloudfront.net/images/40d94054644f6e3f1c366751f07f0010.svg");
  975. background-repeat: no-repeat;
  976. left: 0.5rem;
  977. top: 1.8rem;
  978. background-size: 100% 100%;
  979. width: 60rpx;
  980. height: 60rpx;
  981. }
  982. .interest-section {
  983. margin-bottom: 30rpx;
  984. }
  985. .section-title {
  986. display: block;
  987. text-align: left;
  988. font-size: 26rpx;
  989. color: #666666;
  990. margin-bottom: 20rpx;
  991. }
  992. .topics-list {
  993. display: flex;
  994. flex-direction: column;
  995. gap: 15rpx;
  996. }
  997. .topic-item {
  998. display: flex;
  999. align-items: center;
  1000. padding: 15rpx 20rpx;
  1001. background-color: #f0f0f0;
  1002. border-radius: 15rpx;
  1003. width: fit-content;
  1004. }
  1005. .tag-icon {
  1006. width: 24rpx;
  1007. height: 24rpx;
  1008. margin-right: 10rpx;
  1009. }
  1010. .topic-text {
  1011. font-size: 28rpx;
  1012. color: #333333;
  1013. flex: 1;
  1014. }
  1015. /* 聊天区域样式 */
  1016. .chat-container {
  1017. margin-top: 30rpx;
  1018. border-radius: 10rpx;
  1019. height: calc(100vh - 50rpx);
  1020. /* 缩短滚动区域,避免被输入框覆盖 */
  1021. overflow-y: auto;
  1022. -webkit-overflow-scrolling: touch;
  1023. }
  1024. .message-list {
  1025. background-color: #fff;
  1026. margin-bottom: 400rpx;
  1027. /* padding: 20rpx; */
  1028. }
  1029. .message {
  1030. display: flex;
  1031. align-items: flex-start;
  1032. margin-bottom: 30rpx;
  1033. }
  1034. .user-message {
  1035. flex-direction: row-reverse;
  1036. justify-content: flex-start;
  1037. }
  1038. .message-icon {
  1039. font-size: 24rpx;
  1040. margin: 0 10rpx;
  1041. padding: 10rpx;
  1042. border-radius: 50%;
  1043. background-color: #ddd;
  1044. width: 40rpx;
  1045. height: 40rpx;
  1046. display: flex;
  1047. align-items: center;
  1048. justify-content: center;
  1049. }
  1050. .user-message .message-icon {
  1051. background-color: #007aff;
  1052. border-radius: 50%;
  1053. color: #fff;
  1054. /* box-shadow: 0 0 12rpx rgba(0, 122, 255, 0.4); */
  1055. }
  1056. .bot-message .message-icon {
  1057. background: url("/static/images/机器人 (1).svg");
  1058. color: white;
  1059. }
  1060. .message-content {
  1061. max-width: 70%;
  1062. position: relative;
  1063. word-wrap: break-word;
  1064. word-break: break-all;
  1065. overflow-wrap: break-word;
  1066. }
  1067. .user-message .message-content {
  1068. /* background-color: #007aff; */
  1069. border: 2rpx solid #f3908f;
  1070. border-radius: 20rpx;
  1071. padding: 10rpx;
  1072. }
  1073. .bot-message .message-content {
  1074. background-color: #f0f0f0;
  1075. border-radius: 10rpx;
  1076. padding: 15rpx;
  1077. }
  1078. .message-text {
  1079. font-size: 28rpx;
  1080. line-height: 40rpx;
  1081. }
  1082. .user-message .message-text {
  1083. color: black;
  1084. }
  1085. .bot-message .message-text {
  1086. color: #333;
  1087. }
  1088. .loading-dots {
  1089. display: flex;
  1090. align-items: center;
  1091. /* padding-top: 10rpx; */
  1092. }
  1093. .dot {
  1094. width: 10rpx;
  1095. height: 10rpx;
  1096. background-color: #666;
  1097. border-radius: 50%;
  1098. margin: 0 4rpx;
  1099. animation: loading 1.4s infinite ease-in-out both;
  1100. }
  1101. .user-message .dot {
  1102. background-color: white;
  1103. }
  1104. .dot:nth-child(1) {
  1105. animation-delay: -0.32s;
  1106. }
  1107. .dot:nth-child(2) {
  1108. animation-delay: -0.16s;
  1109. }
  1110. @keyframes loading {
  1111. 0%,
  1112. 80%,
  1113. 100% {
  1114. transform: scale(0);
  1115. }
  1116. 40% {
  1117. transform: scale(1);
  1118. }
  1119. }
  1120. .input-area {
  1121. position: fixed;
  1122. margin-top: 20rpx;
  1123. bottom: 70rpx;
  1124. left: 0;
  1125. right: 0;
  1126. padding: 0 40rpx 80rpx 40rpx;
  1127. background-color: #ffffff;
  1128. }
  1129. .input-wrapper {
  1130. position: relative;
  1131. display: flex;
  1132. align-items: center;
  1133. padding: 15rpx 20rpx;
  1134. background-color: rgb(220, 31, 29);
  1135. border-radius: 100rpx;
  1136. display: flex;
  1137. align-items: center;
  1138. justify-content: center;
  1139. height: 50rpx;
  1140. }
  1141. .mic-icon {
  1142. width: 36rpx;
  1143. height: 36rpx;
  1144. margin-right: 20rpx;
  1145. }
  1146. .input-field {
  1147. flex: 1;
  1148. font-size: 28rpx;
  1149. color: #fff;
  1150. display: flex;
  1151. align-items: center;
  1152. justify-content: center;
  1153. margin-left: 60rpx;
  1154. background: none;
  1155. border: none;
  1156. outline: none;
  1157. }
  1158. .input-field::placeholder {
  1159. color: #ffffff !important;
  1160. opacity: 1;
  1161. }
  1162. /* .uni-scroll-view{
  1163. height: 92%;
  1164. } */
  1165. .send-button {
  1166. background: url("https://d31zlh4on95l9h.cloudfront.net/images/95f1ea2262e9157db13c93c0dc1c5d96.svg");
  1167. background-repeat: no-repeat;
  1168. background-size: 100% 100%;
  1169. height: 50rpx;
  1170. width: 50rpx;
  1171. padding: 0;
  1172. border: 1rpx solid transparent;
  1173. margin-left: 20rpx;
  1174. }
  1175. .send-icon {
  1176. width: 36rpx;
  1177. height: 36rpx;
  1178. }
  1179. .disclaimer {
  1180. font-size: 15rpx;
  1181. color: #4d4c4c;
  1182. display: flex;
  1183. align-items: center;
  1184. justify-content: center;
  1185. margin-top: 15rpx;
  1186. }
  1187. .banner-panel {
  1188. position: relative;
  1189. height: 480rpx;
  1190. /* 拉长容器,灰色背景跟随变高 */
  1191. overflow: hidden;
  1192. /* 让圆角和内部层剪裁一致 */
  1193. border-radius: 15rpx;
  1194. }
  1195. .panelShow {
  1196. height: 12%;
  1197. }
  1198. .pray-banner {
  1199. position: absolute;
  1200. /* background-size: 100% 100%; */
  1201. inset: 0;
  1202. /* 顶部、底部、左、右都贴合容器 */
  1203. width: 100%;
  1204. height: 81%;
  1205. border-radius: 15rpx;
  1206. z-index: 1;
  1207. /* 在灰底之上、内容之下 */
  1208. }
  1209. .contain {
  1210. margin: 0 20rpx;
  1211. gap: 5rpx;
  1212. }
  1213. .banner-panel .robot-container,
  1214. .banner-panel .function-tabs,
  1215. .banner-panel .recommend-card {
  1216. position: relative;
  1217. z-index: 2;
  1218. }
  1219. .back-to-top {
  1220. position: fixed;
  1221. left: 0;
  1222. top: 0;
  1223. width: 100rpx;
  1224. height: 100rpx;
  1225. z-index: 1000;
  1226. }
  1227. .back-to-top:active {
  1228. transform: scale(0.96);
  1229. }
  1230. .static-footer {
  1231. position: fixed;
  1232. bottom: 0;
  1233. }
  1234. /* 搜索历史侧拉框样式 */
  1235. .drawer-overlay {
  1236. position: fixed;
  1237. left: 0;
  1238. top: 0;
  1239. right: 0;
  1240. bottom: 0;
  1241. background-color: rgba(0, 0, 0, 0.35);
  1242. z-index: 900;
  1243. }
  1244. .drawer-panel {
  1245. position: fixed;
  1246. left: 0;
  1247. right: 0;
  1248. bottom: 0;
  1249. height: 75vh;
  1250. max-height: 80vh;
  1251. width: 100%;
  1252. background: #ffffff;
  1253. box-shadow: 0 -8rpx 20rpx rgba(0, 0, 0, 0.06);
  1254. z-index: 1000;
  1255. display: flex;
  1256. flex-direction: column;
  1257. border-top-left-radius: 20rpx;
  1258. border-top-right-radius: 20rpx;
  1259. transition: transform 0.22s ease;
  1260. }
  1261. .drawer-back {
  1262. position: absolute;
  1263. left: 50%;
  1264. top: -14px;
  1265. transform: translateX(-50%);
  1266. width: 28px;
  1267. height: 48px;
  1268. border-radius: 12px;
  1269. background: #fff;
  1270. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  1271. display: flex;
  1272. align-items: center;
  1273. justify-content: center;
  1274. }
  1275. .drawer-back-icon {
  1276. font-size: 16px;
  1277. color: #8a8a8a;
  1278. }
  1279. .drawer-actions {
  1280. display: flex;
  1281. align-items: center;
  1282. gap: 40rpx;
  1283. }
  1284. .delete-all-container {
  1285. display: flex;
  1286. align-items: center;
  1287. gap: 14rpx;
  1288. }
  1289. .delete-icon {
  1290. width: 45rpx;
  1291. height: 40rpx;
  1292. }
  1293. .delete-all {
  1294. font-size: 28rpx;
  1295. }
  1296. .drawer-close {
  1297. background: url("/static/icons/关闭2.svg");
  1298. width: 48rpx;
  1299. height: 48rpx;
  1300. border-radius: 24rpx;
  1301. /* background: #f5f5f5; */
  1302. /* box-shadow: 0 2px 8px rgba(0,0,0,0.08); */
  1303. display: flex;
  1304. align-items: center;
  1305. justify-content: center;
  1306. }
  1307. .drawer-close-icon {
  1308. font-size: 24rpx;
  1309. color: #8a8a8a;
  1310. }
  1311. .drawer-header {
  1312. display: flex;
  1313. align-items: center;
  1314. justify-content: space-between;
  1315. padding: 52rpx 28rpx 0rpx 28rpx;
  1316. /* border-bottom: 2rpx solid #f0f0f0; */
  1317. }
  1318. .drawer-title {
  1319. font-size: 32rpx;
  1320. font-weight: 600;
  1321. color: #333333;
  1322. }
  1323. /* .drawer-close {
  1324. font-size: 42rpx;
  1325. color: #999999;
  1326. } */
  1327. .drawer-content {
  1328. flex: 1;
  1329. min-height: 0;
  1330. /* 让 flex 子元素可在容器内收缩以启用滚动 */
  1331. height: 100%;
  1332. overscroll-behavior-y: contain;
  1333. /* 防止滚动串联到页面 */
  1334. -webkit-overflow-scrolling: touch;
  1335. /* iOS 惯性滚动 */
  1336. touch-action: pan-y;
  1337. /* 优化触控滚动,仅垂直 */
  1338. }
  1339. .drawer-inner {
  1340. padding: 20rpx 24rpx 20rpx 24rpx;
  1341. }
  1342. .history-section {
  1343. margin-bottom: 20rpx;
  1344. /* margin: 0 24rpx; */
  1345. }
  1346. .section-title {
  1347. font-size: 26rpx;
  1348. color: #888;
  1349. margin: 10rpx 6rpx 16rpx;
  1350. }
  1351. .history-item {
  1352. display: flex;
  1353. align-items: center;
  1354. padding: 19rpx 18rpx;
  1355. background-color: #f6f7f9;
  1356. border-radius: 12rpx;
  1357. margin-bottom: 12rpx;
  1358. }
  1359. .history-left {
  1360. margin-right: 12rpx;
  1361. }
  1362. .flag-circle {
  1363. width: 36rpx;
  1364. height: 36rpx;
  1365. border-radius: 50%;
  1366. background: #fff;
  1367. border: 2rpx solid #eee;
  1368. display: flex;
  1369. align-items: center;
  1370. justify-content: center;
  1371. }
  1372. .flag-emoji {
  1373. font-size: 24rpx;
  1374. }
  1375. .history-main {
  1376. flex: 1;
  1377. }
  1378. .history-query {
  1379. font-size: 28rpx;
  1380. color: #333;
  1381. }
  1382. .history-time {
  1383. font-size: 22rpx;
  1384. color: #999;
  1385. }
  1386. .history-card {
  1387. background-color: #fff;
  1388. border: 2rpx solid #f2f2f2;
  1389. border-left: 8rpx solid rgb(220, 31, 29);
  1390. border-radius: 12rpx;
  1391. padding: 18rpx 20rpx;
  1392. margin-bottom: 16rpx;
  1393. box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.03);
  1394. }
  1395. .history-query {
  1396. font-size: 28rpx;
  1397. color: #333333;
  1398. font-weight: 500;
  1399. }
  1400. .history-time {
  1401. margin-top: 8rpx;
  1402. font-size: 22rpx;
  1403. color: #888888;
  1404. }
  1405. .empty-history {
  1406. padding: 40rpx;
  1407. color: #999999;
  1408. text-align: center;
  1409. }
  1410. .thinking-process {
  1411. margin: 10rpx 0;
  1412. border: 2rpx solid #e5e5e5;
  1413. border-radius: 20rpx;
  1414. background-color: #f9f9f9;
  1415. }
  1416. .thinking-header {
  1417. display: flex;
  1418. align-items: center;
  1419. padding: 20rpx 30rpx;
  1420. cursor: pointer;
  1421. background-color: #fff;
  1422. border-radius: 20rpx;
  1423. border-bottom: 2rpx solid #e5e5e5;
  1424. }
  1425. .thinking-icon {
  1426. font-size: 32rpx;
  1427. margin-right: 16rpx;
  1428. color: #d47c45;
  1429. }
  1430. .thinking-title {
  1431. font-size: 28rpx;
  1432. font-weight: 500;
  1433. color: #d47c45;
  1434. margin-right: 16rpx;
  1435. }
  1436. .thinking-count {
  1437. font-size: 24rpx;
  1438. color: #666;
  1439. margin-right: 16rpx;
  1440. }
  1441. .thinking-toggle {
  1442. font-size: 24rpx;
  1443. color: #999;
  1444. }
  1445. .thinking-content {
  1446. padding: 20rpx 30rpx;
  1447. }
  1448. .thinking-item {
  1449. display: flex;
  1450. align-items: center;
  1451. margin-bottom: 16rpx;
  1452. padding: 8rpx 0;
  1453. }
  1454. .item-status {
  1455. width: 32rpx;
  1456. height: 32rpx;
  1457. border-radius: 50%;
  1458. background-color: #f0f0f0;
  1459. display: flex;
  1460. justify-content: center;
  1461. align-items: center;
  1462. margin-right: 16rpx;
  1463. }
  1464. .checkmark {
  1465. font-size: 20rpx;
  1466. color: #ff0000;
  1467. }
  1468. .item-text {
  1469. font-size: 24rpx;
  1470. color: #333;
  1471. }
  1472. </style>