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.

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