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.

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