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.

1658 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
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. const cftl = StockInfo?.cftl || {};
  585. const date = StockInfo?.date || '';
  586. if (StockInfo && StockInfo.code !== 200) {
  587. const errMsg = `postStock失败(${StockInfo.code}): ${StockInfo.message || '未知错误'}`
  588. console.warn(errMsg, StockInfo)
  589. messages.value[messages.value.length - 1].isThinking = false
  590. messages.value[messages.value.length - 1].isTyping = false
  591. messages.value[messages.value.length - 1].content = errMsg
  592. isSending.value = false
  593. return
  594. }
  595. const markdown = StockInfo?.data?.markdown || '抱歉,未找到该股票';
  596. console.log('StockInfo', StockInfo);
  597. // 添加请求延迟
  598. // const toDataInfo = await getData();
  599. // console.log(toDataInfo);
  600. // dataInfo.value = toDataInfo.data;
  601. // console.log(dataInfo.value);
  602. messages.value[messages.value.length - 1].isThinking = false;
  603. // 滚动到底部
  604. nextTick(() => {
  605. scrollToBottom();
  606. });
  607. // 模拟流式响应
  608. let responseText = `我已经收到您的消息: "${userMessage}"。+"${markdown}" `;
  609. let index = 0;
  610. const botIndex = messages.value.length - 1;
  611. const baseDelay = 5; // 普通字符基础延迟(毫秒)
  612. const slowPunct = /[。!?!?;;]/; // 句号、感叹号、分号等较长停顿
  613. const midPunct = /[,、,::]/; // 逗号、顿号、冒号等中等停顿
  614. const typeWriter = () => {
  615. if (index < responseText.length) {
  616. const ch = responseText.charAt(index);
  617. const current = messages.value[botIndex];
  618. // 通过数组替换触发渲染,避免部分平台对子项属性变更不响应
  619. messages.value.splice(botIndex, 1, {
  620. ...current,
  621. content: current.content + ch,
  622. isTyping: true,
  623. });
  624. index++;
  625. scrollToBottom();
  626. const delay = slowPunct.test(ch)
  627. ? 220
  628. : midPunct.test(ch)
  629. ? 120
  630. : baseDelay;
  631. setTimeout(typeWriter, delay);
  632. } else {
  633. const current = messages.value[botIndex];
  634. messages.value.splice(botIndex, 1, { ...current, isTyping: false });
  635. isSending.value = false;
  636. nextTick(() => {
  637. scrollToBottom();
  638. });
  639. }
  640. };
  641. // 启动前稍作停顿,避免过快开始
  642. setTimeout(typeWriter, 500);
  643. console.log("messages", messages);
  644. };
  645. // 当消息出现或变化时,测量容器并滚到底部
  646. watch(messages, (arr) => {
  647. if (arr.length > 0) {
  648. nextTick(() => {
  649. measureChatContainer();
  650. scrollToBottom();
  651. });
  652. }
  653. });
  654. // 滚动到底部(仅聊天区域滚动)
  655. const scrollToBottom = () => {
  656. if (!shouldAutoScroll.value) return;
  657. const query = uni.createSelectorQuery();
  658. query.select("#messageList").boundingClientRect();
  659. query.exec((res) => {
  660. if (res[0]) {
  661. latestContentHeight.value = res[0].height;
  662. chatScrollTop.value = res[0].height; // scroll-view 会自动夹紧到最大位置
  663. }
  664. });
  665. };
  666. const scrollToTop = () => {
  667. chatScrollTop.value = 0;
  668. };
  669. // 自动滚动控制:用户向上滚动时暂停自动滚到底部
  670. const shouldAutoScroll = ref(true);
  671. const latestContentHeight = ref(0);
  672. const lastScrollTop = ref(0);
  673. const windowHeight = uni.getSystemInfoSync().windowHeight;
  674. const AUTO_SCROLL_REENABLE_THRESHOLD = 40000; // px,接近底部时恢复自动滚动
  675. const onChatScroll = (e) => {
  676. const st = e.detail?.scrollTop || 0;
  677. const delta = st - lastScrollTop.value;
  678. lastScrollTop.value = st;
  679. if (delta < 0) {
  680. shouldAutoScroll.value = false;
  681. return;
  682. }
  683. const distanceToBottom =
  684. latestContentHeight.value - st - chatContainerHeight.value;
  685. if (distanceToBottom <= AUTO_SCROLL_REENABLE_THRESHOLD) {
  686. shouldAutoScroll.value = true;
  687. }
  688. };
  689. // 回到顶部图标拖拽状态
  690. const backTopX = ref(0);
  691. const backTopY = ref(0);
  692. const backTopDragging = ref(false);
  693. const backTopDragOffset = ref({ x: 0, y: 0 });
  694. const backTopTargetX = ref(0);
  695. const backTopTargetY = ref(0);
  696. let backTopRAF = 0;
  697. const backTopSmoothing = 0.15; // 越大越跟手,越小越顺滑
  698. const backTopEpsilon = 0.5; // 收敛阈值
  699. const raf =
  700. typeof requestAnimationFrame === "function"
  701. ? requestAnimationFrame
  702. : (fn) => setTimeout(fn, 16);
  703. const caf =
  704. typeof cancelAnimationFrame === "function"
  705. ? cancelAnimationFrame
  706. : (id) => clearTimeout(id);
  707. function stepBackTop() {
  708. const dx = backTopTargetX.value - backTopX.value;
  709. const dy = backTopTargetY.value - backTopY.value;
  710. // 插值缓动,避免每帧重排
  711. backTopX.value += dx * backTopSmoothing;
  712. backTopY.value += dy * backTopSmoothing;
  713. if (Math.abs(dx) > backTopEpsilon || Math.abs(dy) > backTopEpsilon) {
  714. backTopRAF = raf(stepBackTop);
  715. } else {
  716. backTopX.value = backTopTargetX.value;
  717. backTopY.value = backTopTargetY.value;
  718. backTopRAF = 0;
  719. }
  720. }
  721. function ensureBackTopRAF() {
  722. if (!backTopRAF) {
  723. backTopRAF = raf(stepBackTop);
  724. }
  725. }
  726. const clamp = (val, min, max) => Math.max(min, Math.min(val, max));
  727. const onBackTopTouchStart = (e) => {
  728. const t = e.touches && e.touches[0];
  729. if (!t) return;
  730. backTopDragging.value = false;
  731. backTopDragOffset.value = {
  732. x: t.pageX - backTopX.value,
  733. y: t.pageY - backTopY.value,
  734. };
  735. };
  736. const onBackTopTouchMove = (e) => {
  737. const t = e.touches && e.touches[0];
  738. if (!t) return;
  739. const sys = uni.getSystemInfoSync();
  740. const iconSize = uni.upx2px(100);
  741. const reserveBottom = uni.upx2px(260);
  742. const nx = t.pageX - backTopDragOffset.value.x;
  743. const ny = t.pageY - backTopDragOffset.value.y;
  744. const clampedX = clamp(nx, 0, sys.windowWidth - iconSize);
  745. const clampedY = clamp(ny, 0, sys.windowHeight - reserveBottom - iconSize);
  746. if (
  747. Math.abs(clampedX - backTopX.value) + Math.abs(clampedY - backTopY.value) >
  748. 3
  749. ) {
  750. backTopDragging.value = true;
  751. }
  752. backTopTargetX.value = clampedX;
  753. backTopTargetY.value = clampedY;
  754. ensureBackTopRAF();
  755. };
  756. const onBackTopTouchEnd = () => {
  757. // 结束拖拽即可
  758. };
  759. const onBackTopClick = () => {
  760. if (backTopDragging.value) return; // 拖拽时不触发点击回到顶部
  761. scrollToTop();
  762. };
  763. // 历史记录详情
  764. async function itemClick(item) {
  765. const res = await postHistoryDetail({
  766. recordId: item.id,
  767. parentId: item.parentId,
  768. model: 5,
  769. });
  770. if (res.code == 200) {
  771. const message = res.data.wokeFlowData.One.markdown;
  772. messages.value = [];
  773. const botMsg = {
  774. content: message,
  775. isUser: false,
  776. isTyping: false,
  777. isThinking: false,
  778. };
  779. messages.value.push(botMsg);
  780. }
  781. }
  782. </script>
  783. <style scoped>
  784. .deepMate-page {
  785. display: flex;
  786. flex-direction: column;
  787. position: fixed;
  788. /* 充满视口,彻底禁用页面滚动 */
  789. top: 0;
  790. left: 0;
  791. right: 0;
  792. bottom: 0;
  793. height: 100vh;
  794. overflow: hidden;
  795. /* 锁定页面滚动 */
  796. background-color: #ffffff;
  797. padding: 20rpx 0rpx;
  798. }
  799. .header {
  800. display: flex;
  801. justify-content: space-between;
  802. align-items: center;
  803. padding: 20rpx 30rpx;
  804. background-color: #ffffff;
  805. box-shadow: 0 2rpx rgba(0, 0, 0, 0.1);
  806. }
  807. .header-left,
  808. .header-right {
  809. display: flex;
  810. align-items: center;
  811. }
  812. .header-left .icon,
  813. .header-right .icon {
  814. width: 40rpx;
  815. height: 40rpx;
  816. /* margin-right: 20rpx; */
  817. }
  818. .header-center .title {
  819. position: fixed;
  820. top: 10rpx;
  821. left: 50%;
  822. transform: translateX(-50%);
  823. font-size: 36rpx;
  824. font-weight: bold;
  825. color: #333333;
  826. }
  827. .new-chat-button {
  828. background-color: #ff6600;
  829. border: none;
  830. border-radius: 8rpx;
  831. padding: 10rpx 20rpx;
  832. }
  833. .new-chat-text {
  834. color: white;
  835. font-size: 24rpx;
  836. }
  837. .main-content {
  838. background-color: #fff;
  839. flex: 1;
  840. display: flex;
  841. flex-direction: column;
  842. overflow: hidden;
  843. /* 内部滚动交给聊天容器 */
  844. padding: 20rpx;
  845. margin-top: 1rpx;
  846. margin-bottom: 280rpx;
  847. }
  848. /* 聊天顶部粘性欢迎块样式 */
  849. .chat-header {
  850. position: sticky;
  851. top: 0;
  852. /* 在页面滚动时始终贴顶 */
  853. z-index: 50;
  854. background-color: #ffffff;
  855. padding: 3rpx 20rpx;
  856. }
  857. .robot-container {
  858. display: flex;
  859. align-items: center;
  860. margin-top: 30rpx;
  861. }
  862. .robot-avatar {
  863. width: 130rpx;
  864. height: 130rpx;
  865. border-radius: 50%;
  866. margin-left: 20rpx;
  867. }
  868. .welcome-message {
  869. flex: 1;
  870. }
  871. .greeting {
  872. font-size: 32rpx;
  873. margin-left: 50rpx;
  874. top: 40rpx;
  875. font-weight: bold;
  876. color: #333333;
  877. line-height: 48rpx;
  878. }
  879. .description {
  880. display: block;
  881. font-size: 24rpx;
  882. color: #666666;
  883. line-height: 36rpx;
  884. margin-top: 10rpx;
  885. margin-left: 45rpx;
  886. }
  887. .function-tabs {
  888. display: block;
  889. overflow: hidden;
  890. margin-bottom: 30rpx;
  891. }
  892. .tabs-track {
  893. display: inline-flex;
  894. white-space: nowrap;
  895. will-change: transform;
  896. }
  897. .tab-item {
  898. padding: 5rpx 20rpx;
  899. border-radius: 20rpx;
  900. font-size: 20rpx;
  901. font-weight: 700;
  902. color: #666666;
  903. background-color: #fffefe;
  904. margin-right: 20rpx;
  905. transition: all 0.3s;
  906. }
  907. .tab-item.active {
  908. color: #ff6600;
  909. background-color: #fff;
  910. border: 1rpx solid #ff6600;
  911. }
  912. .recommend-card {
  913. background: url("https://d31zlh4on95l9h.cloudfront.net/images/4da1d629a55c307c3605ca15bf15189a.svg");
  914. background-repeat: no-repeat;
  915. background-position: center bottom;
  916. background-size: contain;
  917. /* min-height: 20rpx; */
  918. /* border-radius: 20rpx; */
  919. padding: 40rpx;
  920. margin-top: 20rpx;
  921. margin-bottom: 10rpx;
  922. /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05); */
  923. }
  924. .welcome-section {
  925. /* 灰色卡片(recommend-card)之后展示背景图 */
  926. margin-top: 10rpx;
  927. display: flex;
  928. align-items: center;
  929. justify-content: center;
  930. background: url("https://d31zlh4on95l9h.cloudfront.net/images/eca84d9fb54712cb3bc6c6174773b83b.svg");
  931. background-repeat: no-repeat;
  932. background-position: center top;
  933. /* 放在容器顶部,正好在灰色卡片下方 */
  934. background-size: 80% auto;
  935. /* 缩放以适配宽度 */
  936. height: 460rpx;
  937. /* 提供可视高度,让背景图可见 */
  938. }
  939. .card-content {
  940. display: flex;
  941. align-items: center;
  942. justify-content: space-between;
  943. margin-left: 40rpx;
  944. }
  945. .logo {
  946. width: 80rpx;
  947. height: 80rpx;
  948. background-color: #ff0000;
  949. border-radius: 10rpx;
  950. display: flex;
  951. align-items: center;
  952. justify-content: center;
  953. margin-right: 20rpx;
  954. }
  955. .card-text {
  956. flex: 1;
  957. margin-left: 20rpx;
  958. }
  959. .main-question {
  960. font-size: 32rpx;
  961. color: #333333;
  962. line-height: 48rpx;
  963. }
  964. .stock-code {
  965. display: block;
  966. font-size: 24rpx;
  967. color: #ff3b30;
  968. background-color: #ffffff;
  969. padding: 2rpx 15rpx;
  970. border-radius: 12rpx;
  971. margin-top: 8rpx;
  972. width: fit-content;
  973. border: 1rpx solid #ff3b30;
  974. }
  975. .arrow-icon {
  976. background: url("https://d31zlh4on95l9h.cloudfront.net/images/40d94054644f6e3f1c366751f07f0010.svg");
  977. background-repeat: no-repeat;
  978. left: 0.5rem;
  979. top: 1.8rem;
  980. background-size: 100% 100%;
  981. width: 60rpx;
  982. height: 60rpx;
  983. }
  984. .interest-section {
  985. margin-bottom: 30rpx;
  986. }
  987. .section-title {
  988. display: block;
  989. text-align: left;
  990. font-size: 26rpx;
  991. color: #666666;
  992. margin-bottom: 20rpx;
  993. }
  994. .topics-list {
  995. display: flex;
  996. flex-direction: column;
  997. gap: 15rpx;
  998. }
  999. .topic-item {
  1000. display: flex;
  1001. align-items: center;
  1002. padding: 15rpx 20rpx;
  1003. background-color: #f0f0f0;
  1004. border-radius: 15rpx;
  1005. width: fit-content;
  1006. }
  1007. .tag-icon {
  1008. width: 24rpx;
  1009. height: 24rpx;
  1010. margin-right: 10rpx;
  1011. }
  1012. .topic-text {
  1013. font-size: 28rpx;
  1014. color: #333333;
  1015. flex: 1;
  1016. }
  1017. /* 聊天区域样式 */
  1018. .chat-container {
  1019. margin-top: 30rpx;
  1020. border-radius: 10rpx;
  1021. height: calc(100vh - 50rpx);
  1022. /* 缩短滚动区域,避免被输入框覆盖 */
  1023. overflow-y: auto;
  1024. -webkit-overflow-scrolling: touch;
  1025. }
  1026. .message-list {
  1027. background-color: #fff;
  1028. margin-bottom: 400rpx;
  1029. /* padding: 20rpx; */
  1030. }
  1031. .message {
  1032. display: flex;
  1033. align-items: flex-start;
  1034. margin-bottom: 30rpx;
  1035. }
  1036. .user-message {
  1037. flex-direction: row-reverse;
  1038. justify-content: flex-start;
  1039. }
  1040. .message-icon {
  1041. font-size: 24rpx;
  1042. margin: 0 10rpx;
  1043. padding: 10rpx;
  1044. border-radius: 50%;
  1045. background-color: #ddd;
  1046. width: 40rpx;
  1047. height: 40rpx;
  1048. display: flex;
  1049. align-items: center;
  1050. justify-content: center;
  1051. }
  1052. .user-message .message-icon {
  1053. background-color: #007aff;
  1054. border-radius: 50%;
  1055. color: #fff;
  1056. /* box-shadow: 0 0 12rpx rgba(0, 122, 255, 0.4); */
  1057. }
  1058. .bot-message .message-icon {
  1059. background: url("/static/images/机器人 (1).svg");
  1060. color: white;
  1061. }
  1062. .message-content {
  1063. max-width: 70%;
  1064. position: relative;
  1065. word-wrap: break-word;
  1066. word-break: break-all;
  1067. overflow-wrap: break-word;
  1068. }
  1069. .user-message .message-content {
  1070. /* background-color: #007aff; */
  1071. border: 2rpx solid #f3908f;
  1072. border-radius: 20rpx;
  1073. padding: 10rpx;
  1074. }
  1075. .bot-message .message-content {
  1076. background-color: #f0f0f0;
  1077. border-radius: 10rpx;
  1078. padding: 15rpx;
  1079. }
  1080. .message-text {
  1081. font-size: 28rpx;
  1082. line-height: 40rpx;
  1083. }
  1084. .user-message .message-text {
  1085. color: black;
  1086. }
  1087. .bot-message .message-text {
  1088. color: #333;
  1089. }
  1090. .loading-dots {
  1091. display: flex;
  1092. align-items: center;
  1093. /* padding-top: 10rpx; */
  1094. }
  1095. .dot {
  1096. width: 10rpx;
  1097. height: 10rpx;
  1098. background-color: #666;
  1099. border-radius: 50%;
  1100. margin: 0 4rpx;
  1101. animation: loading 1.4s infinite ease-in-out both;
  1102. }
  1103. .user-message .dot {
  1104. background-color: white;
  1105. }
  1106. .dot:nth-child(1) {
  1107. animation-delay: -0.32s;
  1108. }
  1109. .dot:nth-child(2) {
  1110. animation-delay: -0.16s;
  1111. }
  1112. @keyframes loading {
  1113. 0%,
  1114. 80%,
  1115. 100% {
  1116. transform: scale(0);
  1117. }
  1118. 40% {
  1119. transform: scale(1);
  1120. }
  1121. }
  1122. .input-area {
  1123. position: fixed;
  1124. margin-top: 20rpx;
  1125. bottom: 70rpx;
  1126. left: 0;
  1127. right: 0;
  1128. padding: 0 40rpx 80rpx 40rpx;
  1129. background-color: #ffffff;
  1130. }
  1131. .input-wrapper {
  1132. position: relative;
  1133. display: flex;
  1134. align-items: center;
  1135. padding: 15rpx 20rpx;
  1136. background-color: rgb(220, 31, 29);
  1137. border-radius: 100rpx;
  1138. display: flex;
  1139. align-items: center;
  1140. justify-content: center;
  1141. height: 50rpx;
  1142. }
  1143. .mic-icon {
  1144. width: 36rpx;
  1145. height: 36rpx;
  1146. margin-right: 20rpx;
  1147. }
  1148. .input-field {
  1149. flex: 1;
  1150. font-size: 28rpx;
  1151. color: #fff;
  1152. display: flex;
  1153. align-items: center;
  1154. justify-content: center;
  1155. margin-left: 60rpx;
  1156. background: none;
  1157. border: none;
  1158. outline: none;
  1159. }
  1160. .input-field::placeholder {
  1161. color: #ffffff !important;
  1162. opacity: 1;
  1163. }
  1164. /* .uni-scroll-view{
  1165. height: 92%;
  1166. } */
  1167. .send-button {
  1168. background: url("https://d31zlh4on95l9h.cloudfront.net/images/95f1ea2262e9157db13c93c0dc1c5d96.svg");
  1169. background-repeat: no-repeat;
  1170. background-size: 100% 100%;
  1171. height: 50rpx;
  1172. width: 50rpx;
  1173. padding: 0;
  1174. border: 1rpx solid transparent;
  1175. margin-left: 20rpx;
  1176. }
  1177. .send-icon {
  1178. width: 36rpx;
  1179. height: 36rpx;
  1180. }
  1181. .disclaimer {
  1182. font-size: 15rpx;
  1183. color: #4d4c4c;
  1184. display: flex;
  1185. align-items: center;
  1186. justify-content: center;
  1187. margin-top: 15rpx;
  1188. }
  1189. .banner-panel {
  1190. position: relative;
  1191. height: 480rpx;
  1192. /* 拉长容器,灰色背景跟随变高 */
  1193. overflow: hidden;
  1194. /* 让圆角和内部层剪裁一致 */
  1195. border-radius: 15rpx;
  1196. }
  1197. .panelShow {
  1198. height: 12%;
  1199. }
  1200. .pray-banner {
  1201. position: absolute;
  1202. /* background-size: 100% 100%; */
  1203. inset: 0;
  1204. /* 顶部、底部、左、右都贴合容器 */
  1205. width: 100%;
  1206. height: 81%;
  1207. border-radius: 15rpx;
  1208. z-index: 1;
  1209. /* 在灰底之上、内容之下 */
  1210. }
  1211. .contain {
  1212. margin: 0 20rpx;
  1213. gap: 5rpx;
  1214. }
  1215. .banner-panel .robot-container,
  1216. .banner-panel .function-tabs,
  1217. .banner-panel .recommend-card {
  1218. position: relative;
  1219. z-index: 2;
  1220. }
  1221. .back-to-top {
  1222. position: fixed;
  1223. left: 0;
  1224. top: 0;
  1225. width: 100rpx;
  1226. height: 100rpx;
  1227. z-index: 1000;
  1228. }
  1229. .back-to-top:active {
  1230. transform: scale(0.96);
  1231. }
  1232. .static-footer {
  1233. position: fixed;
  1234. bottom: 0;
  1235. }
  1236. /* 搜索历史侧拉框样式 */
  1237. .drawer-overlay {
  1238. position: fixed;
  1239. left: 0;
  1240. top: 0;
  1241. right: 0;
  1242. bottom: 0;
  1243. background-color: rgba(0, 0, 0, 0.35);
  1244. z-index: 900;
  1245. }
  1246. .drawer-panel {
  1247. position: fixed;
  1248. left: 0;
  1249. right: 0;
  1250. bottom: 0;
  1251. height: 75vh;
  1252. max-height: 80vh;
  1253. width: 100%;
  1254. background: #ffffff;
  1255. box-shadow: 0 -8rpx 20rpx rgba(0, 0, 0, 0.06);
  1256. z-index: 1000;
  1257. display: flex;
  1258. flex-direction: column;
  1259. border-top-left-radius: 20rpx;
  1260. border-top-right-radius: 20rpx;
  1261. transition: transform 0.22s ease;
  1262. }
  1263. .drawer-back {
  1264. position: absolute;
  1265. left: 50%;
  1266. top: -14px;
  1267. transform: translateX(-50%);
  1268. width: 28px;
  1269. height: 48px;
  1270. border-radius: 12px;
  1271. background: #fff;
  1272. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  1273. display: flex;
  1274. align-items: center;
  1275. justify-content: center;
  1276. }
  1277. .drawer-back-icon {
  1278. font-size: 16px;
  1279. color: #8a8a8a;
  1280. }
  1281. .drawer-actions {
  1282. display: flex;
  1283. align-items: center;
  1284. gap: 40rpx;
  1285. }
  1286. .delete-all-container {
  1287. display: flex;
  1288. align-items: center;
  1289. gap: 14rpx;
  1290. }
  1291. .delete-icon {
  1292. width: 45rpx;
  1293. height: 40rpx;
  1294. }
  1295. .delete-all {
  1296. font-size: 28rpx;
  1297. }
  1298. .drawer-close {
  1299. background: url("/static/icons/关闭2.svg");
  1300. width: 48rpx;
  1301. height: 48rpx;
  1302. border-radius: 24rpx;
  1303. /* background: #f5f5f5; */
  1304. /* box-shadow: 0 2px 8px rgba(0,0,0,0.08); */
  1305. display: flex;
  1306. align-items: center;
  1307. justify-content: center;
  1308. }
  1309. .drawer-close-icon {
  1310. font-size: 24rpx;
  1311. color: #8a8a8a;
  1312. }
  1313. .drawer-header {
  1314. display: flex;
  1315. align-items: center;
  1316. justify-content: space-between;
  1317. padding: 52rpx 28rpx 0rpx 28rpx;
  1318. /* border-bottom: 2rpx solid #f0f0f0; */
  1319. }
  1320. .drawer-title {
  1321. font-size: 32rpx;
  1322. font-weight: 600;
  1323. color: #333333;
  1324. }
  1325. /* .drawer-close {
  1326. font-size: 42rpx;
  1327. color: #999999;
  1328. } */
  1329. .drawer-content {
  1330. flex: 1;
  1331. min-height: 0;
  1332. /* 让 flex 子元素可在容器内收缩以启用滚动 */
  1333. height: 100%;
  1334. overscroll-behavior-y: contain;
  1335. /* 防止滚动串联到页面 */
  1336. -webkit-overflow-scrolling: touch;
  1337. /* iOS 惯性滚动 */
  1338. touch-action: pan-y;
  1339. /* 优化触控滚动,仅垂直 */
  1340. }
  1341. .drawer-inner {
  1342. padding: 20rpx 24rpx 20rpx 24rpx;
  1343. }
  1344. .history-section {
  1345. margin-bottom: 20rpx;
  1346. /* margin: 0 24rpx; */
  1347. }
  1348. .section-title {
  1349. font-size: 26rpx;
  1350. color: #888;
  1351. margin: 10rpx 6rpx 16rpx;
  1352. }
  1353. .history-item {
  1354. display: flex;
  1355. align-items: center;
  1356. padding: 19rpx 18rpx;
  1357. background-color: #f6f7f9;
  1358. border-radius: 12rpx;
  1359. margin-bottom: 12rpx;
  1360. }
  1361. .history-left {
  1362. margin-right: 12rpx;
  1363. }
  1364. .flag-circle {
  1365. width: 36rpx;
  1366. height: 36rpx;
  1367. border-radius: 50%;
  1368. background: #fff;
  1369. border: 2rpx solid #eee;
  1370. display: flex;
  1371. align-items: center;
  1372. justify-content: center;
  1373. }
  1374. .flag-emoji {
  1375. font-size: 24rpx;
  1376. }
  1377. .history-main {
  1378. flex: 1;
  1379. }
  1380. .history-query {
  1381. font-size: 28rpx;
  1382. color: #333;
  1383. }
  1384. .history-time {
  1385. font-size: 22rpx;
  1386. color: #999;
  1387. }
  1388. .history-card {
  1389. background-color: #fff;
  1390. border: 2rpx solid #f2f2f2;
  1391. border-left: 8rpx solid rgb(220, 31, 29);
  1392. border-radius: 12rpx;
  1393. padding: 18rpx 20rpx;
  1394. margin-bottom: 16rpx;
  1395. box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.03);
  1396. }
  1397. .history-query {
  1398. font-size: 28rpx;
  1399. color: #333333;
  1400. font-weight: 500;
  1401. }
  1402. .history-time {
  1403. margin-top: 8rpx;
  1404. font-size: 22rpx;
  1405. color: #888888;
  1406. }
  1407. .empty-history {
  1408. padding: 40rpx;
  1409. color: #999999;
  1410. text-align: center;
  1411. }
  1412. .thinking-process {
  1413. margin: 10rpx 0;
  1414. border: 2rpx solid #e5e5e5;
  1415. border-radius: 20rpx;
  1416. background-color: #f9f9f9;
  1417. }
  1418. .thinking-header {
  1419. display: flex;
  1420. align-items: center;
  1421. padding: 20rpx 30rpx;
  1422. cursor: pointer;
  1423. background-color: #fff;
  1424. border-radius: 20rpx;
  1425. border-bottom: 2rpx solid #e5e5e5;
  1426. }
  1427. .thinking-icon {
  1428. font-size: 32rpx;
  1429. margin-right: 16rpx;
  1430. color: #d47c45;
  1431. }
  1432. .thinking-title {
  1433. font-size: 28rpx;
  1434. font-weight: 500;
  1435. color: #d47c45;
  1436. margin-right: 16rpx;
  1437. }
  1438. .thinking-count {
  1439. font-size: 24rpx;
  1440. color: #666;
  1441. margin-right: 16rpx;
  1442. }
  1443. .thinking-toggle {
  1444. font-size: 24rpx;
  1445. color: #999;
  1446. }
  1447. .thinking-content {
  1448. padding: 20rpx 30rpx;
  1449. }
  1450. .thinking-item {
  1451. display: flex;
  1452. align-items: center;
  1453. margin-bottom: 16rpx;
  1454. padding: 8rpx 0;
  1455. }
  1456. .item-status {
  1457. width: 32rpx;
  1458. height: 32rpx;
  1459. border-radius: 50%;
  1460. background-color: #f0f0f0;
  1461. display: flex;
  1462. justify-content: center;
  1463. align-items: center;
  1464. margin-right: 16rpx;
  1465. }
  1466. .checkmark {
  1467. font-size: 20rpx;
  1468. color: #ff0000;
  1469. }
  1470. .item-text {
  1471. font-size: 24rpx;
  1472. color: #333;
  1473. }
  1474. </style>