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.

1759 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. // 聊天区存在:控制 scroll-view 回到顶部
  746. if (messages.value.length > 0) {
  747. chatScrollTop.value = 0;
  748. return;
  749. }
  750. // 未发起对话:页面级滚动回到顶部
  751. try {
  752. uni.pageScrollTo({ scrollTop: 0, duration: 200 });
  753. } catch (e) {
  754. // 兜底,无需处理
  755. }
  756. };
  757. // 自动滚动控制:用户向上滚动时暂停自动滚到底部
  758. const shouldAutoScroll = ref(true);
  759. const latestContentHeight = ref(0);
  760. const lastScrollTop = ref(0);
  761. const windowHeight = uni.getSystemInfoSync().windowHeight;
  762. const AUTO_SCROLL_REENABLE_THRESHOLD = 40000; // px,接近底部时恢复自动滚动
  763. const onChatScroll = (e) => {
  764. const st = e.detail?.scrollTop || 0;
  765. const delta = st - lastScrollTop.value;
  766. lastScrollTop.value = st;
  767. // 同步当前滚动位置,确保点击回顶能产生数值变化
  768. chatScrollTop.value = st;
  769. if (delta < 0) {
  770. shouldAutoScroll.value = false;
  771. return;
  772. }
  773. const distanceToBottom =
  774. latestContentHeight.value - st - chatContainerHeight.value;
  775. if (distanceToBottom <= AUTO_SCROLL_REENABLE_THRESHOLD) {
  776. shouldAutoScroll.value = true;
  777. }
  778. };
  779. // 回到顶部图标拖拽状态
  780. const backTopX = ref(0);
  781. const backTopY = ref(0);
  782. const backTopDragging = ref(false);
  783. const backTopDragOffset = ref({ x: 0, y: 0 });
  784. const backTopTargetX = ref(0);
  785. const backTopTargetY = ref(0);
  786. let backTopRAF = 0;
  787. const backTopSmoothing = 0.15; // 越大越跟手,越小越顺滑
  788. const backTopEpsilon = 0.5; // 收敛阈值
  789. const raf =
  790. typeof requestAnimationFrame === "function"
  791. ? requestAnimationFrame
  792. : (fn) => setTimeout(fn, 16);
  793. const caf =
  794. typeof cancelAnimationFrame === "function"
  795. ? cancelAnimationFrame
  796. : (id) => clearTimeout(id);
  797. function stepBackTop() {
  798. const dx = backTopTargetX.value - backTopX.value;
  799. const dy = backTopTargetY.value - backTopY.value;
  800. // 插值缓动,避免每帧重排
  801. backTopX.value += dx * backTopSmoothing;
  802. backTopY.value += dy * backTopSmoothing;
  803. if (Math.abs(dx) > backTopEpsilon || Math.abs(dy) > backTopEpsilon) {
  804. backTopRAF = raf(stepBackTop);
  805. } else {
  806. backTopX.value = backTopTargetX.value;
  807. backTopY.value = backTopTargetY.value;
  808. backTopRAF = 0;
  809. }
  810. }
  811. function ensureBackTopRAF() {
  812. if (!backTopRAF) {
  813. backTopRAF = raf(stepBackTop);
  814. }
  815. }
  816. const clamp = (val, min, max) => Math.max(min, Math.min(val, max));
  817. const onBackTopTouchStart = (e) => {
  818. const t = e.touches && e.touches[0];
  819. if (!t) return;
  820. backTopDragging.value = false;
  821. backTopDragOffset.value = {
  822. x: t.pageX - backTopX.value,
  823. y: t.pageY - backTopY.value,
  824. };
  825. };
  826. const onBackTopTouchMove = (e) => {
  827. const t = e.touches && e.touches[0];
  828. if (!t) return;
  829. const sys = uni.getSystemInfoSync();
  830. const iconSize = uni.upx2px(100);
  831. const reserveBottom = uni.upx2px(260);
  832. const nx = t.pageX - backTopDragOffset.value.x;
  833. const ny = t.pageY - backTopDragOffset.value.y;
  834. const clampedX = clamp(nx, 0, sys.windowWidth - iconSize);
  835. const clampedY = clamp(ny, 0, sys.windowHeight - reserveBottom - iconSize);
  836. if (
  837. Math.abs(clampedX - backTopX.value) + Math.abs(clampedY - backTopY.value) >
  838. 3
  839. ) {
  840. backTopDragging.value = true;
  841. }
  842. backTopTargetX.value = clampedX;
  843. backTopTargetY.value = clampedY;
  844. ensureBackTopRAF();
  845. };
  846. const onBackTopTouchEnd = () => {
  847. // 结束拖拽即可
  848. };
  849. const onBackTopClick = () => {
  850. if (backTopDragging.value) return; // 拖拽时不触发点击回到顶部
  851. scrollToTop();
  852. };
  853. // 历史记录详情
  854. async function itemClick(item) {
  855. const res = await postHistoryDetail({
  856. recordId: item.id,
  857. parentId: item.parentId,
  858. model: 5,
  859. });
  860. if (res.code == 200) {
  861. const message = res.data.wokeFlowData.One.markdown;
  862. messages.value = [];
  863. const botMsg = {
  864. content: message,
  865. isUser: false,
  866. isTyping: false,
  867. isThinking: false,
  868. };
  869. messages.value.push(botMsg);
  870. }
  871. }
  872. </script>
  873. <style scoped>
  874. .deepMate-page {
  875. display: flex;
  876. flex-direction: column;
  877. position: fixed;
  878. /* 充满视口,彻底禁用页面滚动 */
  879. top: 0;
  880. left: 0;
  881. right: 0;
  882. bottom: 0;
  883. height: 100vh;
  884. overflow: hidden;
  885. /* 锁定页面滚动 */
  886. background-color: #ffffff;
  887. padding: 20rpx 0rpx;
  888. }
  889. .header {
  890. display: flex;
  891. justify-content: space-between;
  892. align-items: center;
  893. padding: 20rpx 30rpx;
  894. background-color: #ffffff;
  895. box-shadow: 0 2rpx rgba(0, 0, 0, 0.1);
  896. }
  897. .header-left,
  898. .header-right {
  899. display: flex;
  900. align-items: center;
  901. }
  902. .header-left .icon,
  903. .header-right .icon {
  904. width: 40rpx;
  905. height: 40rpx;
  906. /* margin-right: 20rpx; */
  907. }
  908. .header-center .title {
  909. position: fixed;
  910. top: 10rpx;
  911. left: 50%;
  912. transform: translateX(-50%);
  913. font-size: 36rpx;
  914. font-weight: bold;
  915. color: #333333;
  916. }
  917. .new-chat-button {
  918. background-color: #ff6600;
  919. border: none;
  920. border-radius: 8rpx;
  921. padding: 10rpx 20rpx;
  922. }
  923. .new-chat-text {
  924. color: white;
  925. font-size: 24rpx;
  926. }
  927. .main-content {
  928. background-color: #fff;
  929. flex: 1;
  930. display: flex;
  931. flex-direction: column;
  932. overflow: hidden;
  933. /* 内部滚动交给聊天容器 */
  934. padding: 20rpx;
  935. margin-top: 1rpx;
  936. margin-bottom: 280rpx;
  937. }
  938. /* 聊天顶部粘性欢迎块样式 */
  939. .chat-header {
  940. position: sticky;
  941. top: 0;
  942. /* 在页面滚动时始终贴顶 */
  943. z-index: 50;
  944. background-color: #ffffff;
  945. padding: 3rpx 20rpx;
  946. }
  947. .robot-container {
  948. display: flex;
  949. align-items: center;
  950. margin-top: 30rpx;
  951. }
  952. .robot-avatar {
  953. width: 130rpx;
  954. height: 130rpx;
  955. border-radius: 50%;
  956. margin-left: 20rpx;
  957. }
  958. .welcome-message {
  959. flex: 1;
  960. }
  961. .greeting {
  962. font-size: 32rpx;
  963. margin-left: 50rpx;
  964. top: 40rpx;
  965. font-weight: bold;
  966. color: #333333;
  967. line-height: 48rpx;
  968. }
  969. .description {
  970. display: block;
  971. font-size: 24rpx;
  972. color: #666666;
  973. line-height: 36rpx;
  974. margin-top: 10rpx;
  975. margin-left: 45rpx;
  976. }
  977. .function-tabs {
  978. display: block;
  979. overflow: hidden;
  980. margin-bottom: 30rpx;
  981. }
  982. .tabs-track {
  983. display: inline-flex;
  984. white-space: nowrap;
  985. will-change: transform;
  986. }
  987. .tab-item {
  988. padding: 5rpx 20rpx;
  989. border-radius: 20rpx;
  990. font-size: 20rpx;
  991. font-weight: 700;
  992. color: #666666;
  993. background-color: #fffefe;
  994. margin-right: 20rpx;
  995. transition: all 0.3s;
  996. }
  997. .tab-item.active {
  998. color: #ff6600;
  999. background-color: #fff;
  1000. border: 1rpx solid #ff6600;
  1001. }
  1002. .recommend-card {
  1003. background: url("https://d31zlh4on95l9h.cloudfront.net/images/4da1d629a55c307c3605ca15bf15189a.svg");
  1004. background-repeat: no-repeat;
  1005. background-position: center bottom;
  1006. background-size: contain;
  1007. /* min-height: 20rpx; */
  1008. /* border-radius: 20rpx; */
  1009. padding: 40rpx;
  1010. margin-top: 20rpx;
  1011. margin-bottom: 10rpx;
  1012. /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05); */
  1013. }
  1014. .welcome-section {
  1015. /* 灰色卡片(recommend-card)之后展示背景图 */
  1016. margin-top: 2rem;
  1017. display: flex;
  1018. align-items: center;
  1019. justify-content: center;
  1020. background: url("https://d31zlh4on95l9h.cloudfront.net/images/eca84d9fb54712cb3bc6c6174773b83b.svg");
  1021. background-repeat: no-repeat;
  1022. background-position: center top;
  1023. /* 放在容器顶部,正好在灰色卡片下方 */
  1024. background-size: 80% auto;
  1025. /* 缩放以适配宽度 */
  1026. height: 460rpx;
  1027. /* 提供可视高度,让背景图可见 */
  1028. }
  1029. .card-content {
  1030. display: flex;
  1031. align-items: center;
  1032. justify-content: space-between;
  1033. margin-left: 40rpx;
  1034. }
  1035. .logo {
  1036. width: 80rpx;
  1037. height: 80rpx;
  1038. background-color: #ff0000;
  1039. border-radius: 10rpx;
  1040. display: flex;
  1041. align-items: center;
  1042. justify-content: center;
  1043. margin-right: 20rpx;
  1044. }
  1045. .card-text {
  1046. flex: 1;
  1047. margin-left: 20rpx;
  1048. }
  1049. .main-question {
  1050. font-size: 32rpx;
  1051. color: #333333;
  1052. line-height: 48rpx;
  1053. }
  1054. .stock-code {
  1055. display: block;
  1056. font-size: 24rpx;
  1057. color: #ff3b30;
  1058. background-color: #ffffff;
  1059. padding: 2rpx 15rpx;
  1060. border-radius: 12rpx;
  1061. margin-top: 8rpx;
  1062. width: fit-content;
  1063. border: 1rpx solid #ff3b30;
  1064. }
  1065. .arrow-icon {
  1066. background: url("https://d31zlh4on95l9h.cloudfront.net/images/40d94054644f6e3f1c366751f07f0010.svg");
  1067. background-repeat: no-repeat;
  1068. left: 0.5rem;
  1069. top: 1.8rem;
  1070. background-size: 100% 100%;
  1071. width: 60rpx;
  1072. height: 60rpx;
  1073. }
  1074. .interest-section {
  1075. margin-bottom: 30rpx;
  1076. }
  1077. .section-title {
  1078. display: block;
  1079. text-align: left;
  1080. font-size: 26rpx;
  1081. color: #666666;
  1082. margin-bottom: 20rpx;
  1083. }
  1084. .topics-list {
  1085. display: flex;
  1086. flex-direction: column;
  1087. gap: 15rpx;
  1088. }
  1089. .topic-item {
  1090. display: flex;
  1091. align-items: center;
  1092. padding: 15rpx 20rpx;
  1093. background-color: #f0f0f0;
  1094. border-radius: 15rpx;
  1095. width: fit-content;
  1096. }
  1097. .tag-icon {
  1098. width: 24rpx;
  1099. height: 24rpx;
  1100. margin-right: 10rpx;
  1101. }
  1102. .topic-text {
  1103. font-size: 28rpx;
  1104. color: #333333;
  1105. flex: 1;
  1106. }
  1107. /* 聊天区域样式 */
  1108. .chat-container {
  1109. margin-top: 30rpx;
  1110. border-radius: 10rpx;
  1111. height: calc(100vh - 50rpx);
  1112. /* 缩短滚动区域,避免被输入框覆盖 */
  1113. overflow-y: auto;
  1114. -webkit-overflow-scrolling: touch;
  1115. }
  1116. .message-list {
  1117. background-color: #fff;
  1118. margin-bottom: 400rpx;
  1119. /* padding: 20rpx; */
  1120. }
  1121. .message {
  1122. display: flex;
  1123. align-items: flex-start;
  1124. margin-bottom: 30rpx;
  1125. }
  1126. .user-message {
  1127. flex-direction: row-reverse;
  1128. justify-content: flex-start;
  1129. }
  1130. .message-icon {
  1131. font-size: 24rpx;
  1132. margin: 0 10rpx;
  1133. padding: 10rpx;
  1134. border-radius: 50%;
  1135. background-color: #ddd;
  1136. width: 40rpx;
  1137. height: 40rpx;
  1138. display: flex;
  1139. align-items: center;
  1140. justify-content: center;
  1141. }
  1142. .user-message .message-icon {
  1143. background-color: #007aff;
  1144. border-radius: 50%;
  1145. color: #fff;
  1146. /* box-shadow: 0 0 12rpx rgba(0, 122, 255, 0.4); */
  1147. }
  1148. .bot-message .message-icon {
  1149. background: url("/static/images/robot (1).svg");
  1150. color: white;
  1151. }
  1152. .message-content {
  1153. max-width: 70%;
  1154. position: relative;
  1155. word-wrap: break-word;
  1156. word-break: break-all;
  1157. overflow-wrap: break-word;
  1158. }
  1159. .user-message .message-content {
  1160. /* background-color: #007aff; */
  1161. border: 2rpx solid #f3908f;
  1162. border-radius: 20rpx;
  1163. padding: 10rpx;
  1164. }
  1165. .bot-message .message-content {
  1166. background-color: #f0f0f0;
  1167. border-radius: 10rpx;
  1168. padding: 15rpx;
  1169. }
  1170. .message-text {
  1171. font-size: 28rpx;
  1172. line-height: 40rpx;
  1173. }
  1174. .user-message .message-text {
  1175. color: black;
  1176. }
  1177. .bot-message .message-text {
  1178. color: #333;
  1179. }
  1180. .loading-dots {
  1181. display: flex;
  1182. align-items: center;
  1183. /* padding-top: 10rpx; */
  1184. }
  1185. .dot {
  1186. width: 10rpx;
  1187. height: 10rpx;
  1188. background-color: #666;
  1189. border-radius: 50%;
  1190. margin: 0 4rpx;
  1191. animation: loading 1.4s infinite ease-in-out both;
  1192. }
  1193. .user-message .dot {
  1194. background-color: white;
  1195. }
  1196. .dot:nth-child(1) {
  1197. animation-delay: -0.32s;
  1198. }
  1199. .dot:nth-child(2) {
  1200. animation-delay: -0.16s;
  1201. }
  1202. @keyframes loading {
  1203. 0%,
  1204. 80%,
  1205. 100% {
  1206. transform: scale(0);
  1207. }
  1208. 40% {
  1209. transform: scale(1);
  1210. }
  1211. }
  1212. .input-area {
  1213. position: fixed;
  1214. margin-top: 20rpx;
  1215. bottom: 70rpx;
  1216. left: 0;
  1217. right: 0;
  1218. padding: 0 40rpx 80rpx 40rpx;
  1219. background-color: #ffffff;
  1220. }
  1221. .input-wrapper {
  1222. position: relative;
  1223. display: flex;
  1224. align-items: center;
  1225. padding: 15rpx 20rpx;
  1226. background-color: rgb(220, 31, 29);
  1227. border-radius: 100rpx;
  1228. display: flex;
  1229. align-items: center;
  1230. justify-content: center;
  1231. height: 50rpx;
  1232. }
  1233. .mic-icon {
  1234. width: 36rpx;
  1235. height: 36rpx;
  1236. margin-right: 20rpx;
  1237. }
  1238. .input-field {
  1239. flex: 1;
  1240. font-size: 28rpx;
  1241. color: #fff;
  1242. display: flex;
  1243. align-items: center;
  1244. justify-content: center;
  1245. margin-left: 60rpx;
  1246. background: none;
  1247. border: none;
  1248. outline: none;
  1249. }
  1250. .input-field::placeholder {
  1251. color: #ffffff !important;
  1252. opacity: 1;
  1253. }
  1254. /* .uni-scroll-view{
  1255. height: 92%;
  1256. } */
  1257. .send-button {
  1258. background: url("https://d31zlh4on95l9h.cloudfront.net/images/95f1ea2262e9157db13c93c0dc1c5d96.svg");
  1259. background-repeat: no-repeat;
  1260. background-size: 100% 100%;
  1261. height: 50rpx;
  1262. width: 50rpx;
  1263. padding: 0;
  1264. border: 1rpx solid transparent;
  1265. margin-left: 20rpx;
  1266. }
  1267. .send-icon {
  1268. width: 36rpx;
  1269. height: 36rpx;
  1270. }
  1271. .disclaimer {
  1272. font-size: 15rpx;
  1273. color: #4d4c4c;
  1274. display: flex;
  1275. align-items: center;
  1276. justify-content: center;
  1277. margin-top: 15rpx;
  1278. }
  1279. .banner-panel {
  1280. position: relative;
  1281. height: 480rpx;
  1282. /* 拉长容器,灰色背景跟随变高 */
  1283. overflow: hidden;
  1284. /* 让圆角和内部层剪裁一致 */
  1285. border-radius: 15rpx;
  1286. }
  1287. .panelShow {
  1288. height: 12%;
  1289. }
  1290. .pray-banner {
  1291. position: absolute;
  1292. /* background-size: 100% 100%; */
  1293. inset: 0;
  1294. /* 顶部、底部、左、右都贴合容器 */
  1295. width: 100%;
  1296. height: 81%;
  1297. border-radius: 15rpx;
  1298. z-index: 1;
  1299. /* 在灰底之上、内容之下 */
  1300. }
  1301. .contain {
  1302. margin: 0 20rpx;
  1303. gap: 5rpx;
  1304. }
  1305. .banner-panel .robot-container,
  1306. .banner-panel .function-tabs,
  1307. .banner-panel .recommend-card {
  1308. position: relative;
  1309. z-index: 2;
  1310. }
  1311. .back-to-top {
  1312. position: fixed;
  1313. left: 0;
  1314. top: 0;
  1315. width: 100rpx;
  1316. height: 100rpx;
  1317. z-index: 1000;
  1318. }
  1319. .back-to-top:active {
  1320. transform: scale(0.96);
  1321. }
  1322. .static-footer {
  1323. position: fixed;
  1324. bottom: 0;
  1325. }
  1326. /* 搜索历史侧拉框样式 */
  1327. .drawer-overlay {
  1328. position: fixed;
  1329. left: 0;
  1330. top: 0;
  1331. right: 0;
  1332. bottom: 0;
  1333. background-color: rgba(0, 0, 0, 0.35);
  1334. z-index: 900;
  1335. }
  1336. .drawer-panel {
  1337. position: fixed;
  1338. left: 0;
  1339. right: 0;
  1340. bottom: 0;
  1341. height: 75vh;
  1342. max-height: 80vh;
  1343. width: 100%;
  1344. background: #ffffff;
  1345. box-shadow: 0 -8rpx 20rpx rgba(0, 0, 0, 0.06);
  1346. z-index: 1000;
  1347. display: flex;
  1348. flex-direction: column;
  1349. border-top-left-radius: 20rpx;
  1350. border-top-right-radius: 20rpx;
  1351. transition: transform 0.22s ease;
  1352. }
  1353. .drawer-back {
  1354. position: absolute;
  1355. left: 50%;
  1356. top: -14px;
  1357. transform: translateX(-50%);
  1358. width: 28px;
  1359. height: 48px;
  1360. border-radius: 12px;
  1361. background: #fff;
  1362. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  1363. display: flex;
  1364. align-items: center;
  1365. justify-content: center;
  1366. }
  1367. .drawer-back-icon {
  1368. font-size: 16px;
  1369. color: #8a8a8a;
  1370. }
  1371. .drawer-actions {
  1372. display: flex;
  1373. align-items: center;
  1374. gap: 40rpx;
  1375. }
  1376. .delete-all-container {
  1377. display: flex;
  1378. align-items: center;
  1379. gap: 14rpx;
  1380. }
  1381. .delete-icon {
  1382. width: 45rpx;
  1383. height: 40rpx;
  1384. }
  1385. .delete-all {
  1386. font-size: 28rpx;
  1387. }
  1388. .drawer-close {
  1389. background: url("/static/icons/close-two.svg");
  1390. width: 48rpx;
  1391. height: 48rpx;
  1392. border-radius: 24rpx;
  1393. /* background: #f5f5f5; */
  1394. /* box-shadow: 0 2px 8px rgba(0,0,0,0.08); */
  1395. display: flex;
  1396. align-items: center;
  1397. justify-content: center;
  1398. }
  1399. .drawer-close-icon {
  1400. font-size: 24rpx;
  1401. color: #8a8a8a;
  1402. }
  1403. .drawer-header {
  1404. display: flex;
  1405. align-items: center;
  1406. justify-content: space-between;
  1407. padding: 52rpx 28rpx 0rpx 28rpx;
  1408. /* border-bottom: 2rpx solid #f0f0f0; */
  1409. }
  1410. .drawer-title {
  1411. font-size: 32rpx;
  1412. font-weight: 600;
  1413. color: #333333;
  1414. }
  1415. /* .drawer-close {
  1416. font-size: 42rpx;
  1417. color: #999999;
  1418. } */
  1419. .drawer-content {
  1420. flex: 1;
  1421. min-height: 0;
  1422. /* 让 flex 子元素可在容器内收缩以启用滚动 */
  1423. height: 100%;
  1424. overscroll-behavior-y: contain;
  1425. /* 防止滚动串联到页面 */
  1426. -webkit-overflow-scrolling: touch;
  1427. /* iOS 惯性滚动 */
  1428. touch-action: pan-y;
  1429. /* 优化触控滚动,仅垂直 */
  1430. }
  1431. .drawer-inner {
  1432. padding: 20rpx 24rpx 20rpx 24rpx;
  1433. }
  1434. .history-section {
  1435. margin-bottom: 20rpx;
  1436. /* margin: 0 24rpx; */
  1437. }
  1438. .section-title {
  1439. font-size: 26rpx;
  1440. color: #888;
  1441. margin: 10rpx 6rpx 16rpx;
  1442. }
  1443. .history-item {
  1444. display: flex;
  1445. align-items: center;
  1446. padding: 19rpx 18rpx;
  1447. background-color: #f6f7f9;
  1448. border-radius: 12rpx;
  1449. margin-bottom: 12rpx;
  1450. }
  1451. .history-left {
  1452. margin-right: 12rpx;
  1453. }
  1454. .flag-circle {
  1455. width: 36rpx;
  1456. height: 36rpx;
  1457. border-radius: 50%;
  1458. background: #fff;
  1459. border: 2rpx solid #eee;
  1460. display: flex;
  1461. align-items: center;
  1462. justify-content: center;
  1463. }
  1464. .flag-emoji {
  1465. font-size: 24rpx;
  1466. }
  1467. .history-main {
  1468. flex: 1;
  1469. }
  1470. .history-query {
  1471. font-size: 28rpx;
  1472. color: #333;
  1473. }
  1474. .history-time {
  1475. font-size: 22rpx;
  1476. color: #999;
  1477. }
  1478. .history-card {
  1479. background-color: #fff;
  1480. border: 2rpx solid #f2f2f2;
  1481. border-left: 8rpx solid rgb(220, 31, 29);
  1482. border-radius: 12rpx;
  1483. padding: 18rpx 20rpx;
  1484. margin-bottom: 16rpx;
  1485. box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.03);
  1486. }
  1487. .history-query {
  1488. font-size: 28rpx;
  1489. color: #333333;
  1490. font-weight: 500;
  1491. }
  1492. .history-time {
  1493. margin-top: 8rpx;
  1494. font-size: 22rpx;
  1495. color: #888888;
  1496. }
  1497. .empty-history {
  1498. padding: 40rpx;
  1499. color: #999999;
  1500. text-align: center;
  1501. }
  1502. .thinking-process {
  1503. margin: 10rpx 0;
  1504. border: 2rpx solid #e5e5e5;
  1505. border-radius: 20rpx;
  1506. background-color: #f9f9f9;
  1507. }
  1508. .thinking-header {
  1509. display: flex;
  1510. align-items: center;
  1511. padding: 20rpx 30rpx;
  1512. cursor: pointer;
  1513. background-color: #fff;
  1514. border-radius: 20rpx;
  1515. border-bottom: 2rpx solid #e5e5e5;
  1516. }
  1517. .thinking-icon {
  1518. font-size: 32rpx;
  1519. margin-right: 16rpx;
  1520. color: #d47c45;
  1521. }
  1522. .thinking-title {
  1523. font-size: 28rpx;
  1524. font-weight: 500;
  1525. color: #d47c45;
  1526. margin-right: 16rpx;
  1527. }
  1528. .thinking-count {
  1529. font-size: 24rpx;
  1530. color: #666;
  1531. margin-right: 16rpx;
  1532. }
  1533. .thinking-toggle {
  1534. font-size: 24rpx;
  1535. color: #999;
  1536. }
  1537. .thinking-content {
  1538. padding: 20rpx 30rpx;
  1539. }
  1540. .thinking-item {
  1541. display: flex;
  1542. align-items: center;
  1543. margin-bottom: 16rpx;
  1544. padding: 8rpx 0;
  1545. }
  1546. .item-status {
  1547. width: 32rpx;
  1548. height: 32rpx;
  1549. border-radius: 50%;
  1550. background-color: #f0f0f0;
  1551. display: flex;
  1552. justify-content: center;
  1553. align-items: center;
  1554. margin-right: 16rpx;
  1555. }
  1556. .checkmark {
  1557. font-size: 20rpx;
  1558. color: #ff0000;
  1559. }
  1560. .item-text {
  1561. font-size: 24rpx;
  1562. color: #333;
  1563. }
  1564. </style>