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.

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