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.

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