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.

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