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.

1732 lines
41 KiB

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