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.

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