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.

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