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.

1742 lines
42 KiB

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