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.

5257 lines
153 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
6 days ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <template>
  2. <!-- 顶部锚点 -->
  3. <div id="top-anchor" class="top-anchor"></div>
  4. <!-- 主容器包含对话框和main容器 -->
  5. <div class="page-container">
  6. <!-- 对话框区域 -->
  7. <div class="ai-emotion-container" ref="userInputDisplayRef">
  8. <!-- 金轮 -->
  9. <div class="golden-wheel">
  10. <img
  11. src="@/assets/img/AiEmotion/金轮.png"
  12. class="golden-wheel-img"
  13. alt="金轮图标"
  14. :class="{ 'rotating-image': isRotating }"
  15. />
  16. </div>
  17. <!-- 对话消息显示区域 -->
  18. <div
  19. class="conversation-area"
  20. v-if="messages.length > 0 && !isHistoryMode"
  21. >
  22. <div class="message-list">
  23. <div
  24. v-for="(message, index) in messages"
  25. :key="index"
  26. class="message-item"
  27. :class="{
  28. 'user-message-item': message.sender === 'user',
  29. 'ai-message-item': message.sender === 'ai',
  30. }"
  31. >
  32. <!-- 用户消息 -->
  33. <div v-if="message.sender === 'user'" class="user-message-wrapper">
  34. <div class="message-bubble user-message">
  35. {{ message.text }}
  36. </div>
  37. </div>
  38. <!-- AI消息包括思考过程 -->
  39. <div v-else class="ai-message-wrapper">
  40. <div class="ai-message-container">
  41. <img
  42. v-if="message.gif"
  43. :src="message.gif"
  44. alt="思考过程"
  45. class="thinking-gif"
  46. />
  47. <div class="message-bubble ai-message">
  48. <div v-if="message.flag">
  49. <span>{{ message.text }}</span>
  50. <span class="loading-dots">
  51. <span class="dot">.</span>
  52. <span class="dot">.</span>
  53. <span class="dot">.</span>
  54. <span class="dot">.</span>
  55. <span class="dot">.</span>
  56. <span class="dot">.</span>
  57. </span>
  58. </div>
  59. <div v-else>
  60. <div v-if="message.isHtml" v-html="message.text"></div>
  61. <div v-else>{{ message.text }}</div>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. <!-- 加载提示 -->
  71. <div v-if="isLoading" class="loading-container">
  72. <div class="loading-content">
  73. <div class="loading-spinner"></div>
  74. <div class="loading-text">AI情绪大模型正在努力为您加载请稍候...</div>
  75. </div>
  76. </div>
  77. <!-- main容器区域 -->
  78. <!-- 移除股票标签页改为对话形式展示 -->
  79. <!-- 渲染整个页面 - 遍历过滤后的股票列表显示所有股票 -->
  80. <div
  81. class="master"
  82. v-for="(stock, stockIndex) in filteredStockList"
  83. :key="`stock-${stockIndex}-${stock.timestamp}`"
  84. v-if="isPageLoaded"
  85. >
  86. <!-- 对应股票的消息显示区域 -->
  87. <div class="user-input-display">
  88. <div class="message-container">
  89. <!-- 显示该股票对应的用户输入内容 -->
  90. <div class="user-message-container">
  91. <div class="user-content">
  92. <img
  93. :src="
  94. isVoice && getStockAudioState(stock).isPlaying
  95. ? voice
  96. : voiceNoActive
  97. "
  98. class="user-message-speaker"
  99. :class="{
  100. 'speaker-active':
  101. isVoice && getStockAudioState(stock).isPlaying,
  102. }"
  103. @click="() => toggleVoiceForUser(stock)"
  104. alt="喇叭"
  105. />
  106. <div class="message-bubble user-message">
  107. {{ stock.queryText }}
  108. </div>
  109. </div>
  110. <div class="user-sendTime" v-if="isHistoryMode">
  111. {{ moment(stock.timestamp).format("YYYY-MM-DD HH:mm:ss") }}
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. <div class="main">
  117. <div class="main-content-wrapper">
  118. <!-- 四维矩阵图 -->
  119. <div class="matrix-header">
  120. <!-- <img class="item" :src="item" alt="思维矩阵图片" /> -->
  121. <div class="market-temperature-label">
  122. {{ stock.stockInfo.name
  123. }}{{ stock.stockInfo.name ? "量子四维矩阵图" : "" }}
  124. </div>
  125. <div class="market-temperature-value">
  126. {{ getDisplayDate(stock) }}
  127. </div>
  128. </div>
  129. <div
  130. class="market-temperature-icon"
  131. v-if="chartVisibility.marketTemperature"
  132. >
  133. <img src="@/assets/img/AiEmotion/L1.png" alt="情绪监控图标" />
  134. </div>
  135. <!-- 温度计图表 -->
  136. <div
  137. class="market-temperature-section"
  138. v-if="chartVisibility.marketTemperature"
  139. >
  140. <div class="temperature-content">
  141. <div class="content1">
  142. <img src="@/assets/img/AiEmotion/温度计.png" alt="温度计图标" />
  143. <span class="matrix-main-title">股市温度计</span>
  144. </div>
  145. <div class="temperature-display">
  146. <div class="temperature-cold">
  147. 股票温度{{ getStockData2(stock) ?? "NA" }}
  148. </div>
  149. <div class="temperature-hot">
  150. 市场温度{{ getStockData1(stock) }}
  151. </div>
  152. </div>
  153. </div>
  154. <marketTemperature
  155. :ref="(el) => (marketTemperatureRef[stockIndex] = el)"
  156. :companyName="stock.stockInfo.name"
  157. :stockCode="stock.stockInfo.code"
  158. />
  159. </div>
  160. </div>
  161. <div class="emotion-decoder-icon" v-if="chartVisibility.emotionDecod">
  162. <img src="@/assets/img/AiEmotion/L2.png" alt="情绪解码图标" />
  163. </div>
  164. <!-- 情绪解码器图表 -->
  165. <div
  166. class="emotion-decoder-section"
  167. v-if="chartVisibility.emotionDecod"
  168. >
  169. <div class="emotion-decoder-header">
  170. <img
  171. src="@/assets/img/AiEmotion/emotionDecod.png"
  172. alt="情绪解码器图标"
  173. />
  174. <span class="emotion-decoder-text">情绪解码器</span>
  175. </div>
  176. <div class="emotion-decoder-content">
  177. <emotionDecod
  178. :ref="(el) => (emotionDecodRef[stockIndex] = el)"
  179. ></emotionDecod>
  180. </div>
  181. </div>
  182. <div
  183. class="bottom-radar-icon"
  184. v-if="chartVisibility.emotionalBottomRadar"
  185. >
  186. <img src="@/assets/img/AiEmotion/L3.png" alt="情绪推演图标" />
  187. </div>
  188. <!-- 情绪探底雷达图表 -->
  189. <div
  190. class="bottom-radar-section"
  191. v-if="chartVisibility.emotionalBottomRadar"
  192. >
  193. <div class="bottom-radar-header">
  194. <img src="@/assets/img/AiEmotion/探底雷达.png" alt="探底雷达图表" />
  195. <span class="bottom-radar-text">情绪探底雷达</span>
  196. </div>
  197. <div class="bottom-radar-content">
  198. <emotionalBottomRadar
  199. :ref="(el) => (emotionalBottomRadarRef[stockIndex] = el)"
  200. ></emotionalBottomRadar>
  201. </div>
  202. </div>
  203. <div
  204. class="energy-converter-icon"
  205. v-if="chartVisibility.emoEnergyConverter"
  206. >
  207. <img src="@/assets/img/AiEmotion/L4.png" alt="情绪套利" />
  208. </div>
  209. <!-- 情绪能量转化器图表 -->
  210. <div
  211. class="energy-converter-section"
  212. v-if="chartVisibility.emoEnergyConverter"
  213. >
  214. <div class="energy-converter-header">
  215. <img
  216. src="@/assets/img/AiEmotion/能量转化器.png"
  217. alt="能量转化器图标"
  218. />
  219. <span class="energy-converter-text">情绪能量转化器</span>
  220. </div>
  221. <div class="energy-converter-content">
  222. <emoEnergyConverter
  223. :ref="(el) => (emoEnergyConverterRef[stockIndex] = el)"
  224. ></emoEnergyConverter>
  225. </div>
  226. </div>
  227. <!-- 核心看点 -->
  228. <div class="core-highlights-header">
  229. <img src="@/assets/img/AiEmotion/核心看点.png" alt="核心看点字样" />
  230. </div>
  231. <div class="bk-image">
  232. <div class="text-container">
  233. <p>
  234. <span class="title">情绪监控-金融宇宙的量子检测网络</span>
  235. <span class="content"
  236. >核心任务:构建全市场情绪引力场雷达实时监测资金流向和情绪波动</span
  237. >
  238. </p>
  239. <p>
  240. <span class="title">情绪解码-主力思维的神经破译矩阵</span>
  241. <span class="content"
  242. >核心任务:解构资金行为的量子密码破译主力操盘意图和策略布局</span
  243. >
  244. </p>
  245. <p>
  246. <span class="title">情绪推演-未来战争的时空推演舱</span>
  247. <span class="content"
  248. >核心任务:基于情绪数据推演未来走势预测市场转折点和机会窗口</span
  249. >
  250. </p>
  251. <p>
  252. <span class="title">情绪套利-财富裂变的粒子对撞机</span>
  253. <span class="content"
  254. >核心任务:将情绪差转化为收益粒子流实现情绪能量的价值转换</span
  255. >
  256. </p>
  257. </div>
  258. </div>
  259. <!-- 核心逻辑 -->
  260. <div class="core-logic-header">
  261. <img src="@/assets/img/AiEmotion/核心逻辑.png" alt="核心逻辑字样" />
  262. </div>
  263. <div class="decision-tree-section">
  264. <div class="lz-img">
  265. <img src="@/assets/img/AiEmotion/量子神经决策树.png" alt="树标题" />
  266. </div>
  267. <div class="scaled-img">
  268. <!-- <img src="@/assets/img/AiEmotion/tree02.jpg" alt="树图片"> -->
  269. </div>
  270. </div>
  271. <!-- 场景应用 -->
  272. <div class="scenario-application-section" ref="scenarioApplicationRef">
  273. <img src="@/assets/img/AiEmotion/场景应用.png" alt="场景应用标题" />
  274. <div class="bk-image">
  275. <!-- 只有在状态准备好时才显示结论内容 -->
  276. <div class="conclusion-container" v-if="isStockStateReady(stock)">
  277. <!-- 使用当前股票项的结论数据显示内容支持打字机效果 -->
  278. <!-- L1: 情绪监控 -->
  279. <div class="conclusion-item" v-if="(getStockTypewriterVisibility(stock) && getStockTypewriterVisibility(stock).one) || (getStockConclusion(stock) && !getStockTypewriterTexts(stock) && (getStockConclusion(stock).one1 || getStockConclusion(stock).one2))">
  280. <h4 class="conclusion-title">L1: 情绪监控</h4>
  281. <!-- 打字机效果文本 -->
  282. <p class="conclusion-text" v-if="getStockTypewriterTexts(stock) && getStockTypewriterTexts(stock).one1">
  283. {{ getStockTypewriterTexts(stock).one1 }}
  284. </p>
  285. <p class="conclusion-text" v-if="getStockTypewriterTexts(stock) && getStockTypewriterTexts(stock).one2">
  286. {{ getStockTypewriterTexts(stock).one2 }}
  287. </p>
  288. <!-- 完整文本 -->
  289. <p class="conclusion-text" v-if="!getStockTypewriterTexts(stock) && getStockConclusion(stock) && getStockConclusion(stock).one1">
  290. {{ getStockConclusion(stock).one1 }}
  291. </p>
  292. <p class="conclusion-text" v-if="!getStockTypewriterTexts(stock) && getStockConclusion(stock) && getStockConclusion(stock).one2">
  293. {{ getStockConclusion(stock).one2 }}
  294. </p>
  295. </div>
  296. <!-- L2: 情绪解码 -->
  297. <div class="conclusion-item" v-if="(getStockTypewriterVisibility(stock) && getStockTypewriterVisibility(stock).two) || (getStockConclusion(stock) && !getStockTypewriterTexts(stock) && getStockConclusion(stock).two)">
  298. <h4 class="conclusion-title">L2: 情绪解码</h4>
  299. <!-- 打字机效果文本 -->
  300. <p class="conclusion-text" v-if="getStockTypewriterTexts(stock) && getStockTypewriterTexts(stock).two">
  301. {{ getStockTypewriterTexts(stock).two }}
  302. </p>
  303. <!-- 完整文本 -->
  304. <p class="conclusion-text" v-if="!getStockTypewriterTexts(stock) && getStockConclusion(stock) && getStockConclusion(stock).two">
  305. {{ getStockConclusion(stock).two }}
  306. </p>
  307. </div>
  308. <!-- L3: 情绪推演 -->
  309. <div class="conclusion-item" v-if="(getStockTypewriterVisibility(stock) && getStockTypewriterVisibility(stock).three) || (getStockConclusion(stock) && !getStockTypewriterTexts(stock) && getStockConclusion(stock).three)">
  310. <h4 class="conclusion-title">L3: 情绪推演</h4>
  311. <!-- 打字机效果文本 -->
  312. <p class="conclusion-text" v-if="getStockTypewriterTexts(stock) && getStockTypewriterTexts(stock).three">
  313. {{ getStockTypewriterTexts(stock).three }}
  314. </p>
  315. <!-- 完整文本 -->
  316. <p class="conclusion-text" v-if="!getStockTypewriterTexts(stock) && getStockConclusion(stock) && getStockConclusion(stock).three">
  317. {{ getStockConclusion(stock).three }}
  318. </p>
  319. </div>
  320. <!-- L4: 情绪套利 -->
  321. <div class="conclusion-item" v-if="(getStockTypewriterVisibility(stock) && getStockTypewriterVisibility(stock).four) || (getStockConclusion(stock) && !getStockTypewriterTexts(stock) && getStockConclusion(stock).four)">
  322. <h4 class="conclusion-title">L4: 情绪套利</h4>
  323. <!-- 打字机效果文本 -->
  324. <p class="conclusion-text" v-if="getStockTypewriterTexts(stock) && getStockTypewriterTexts(stock).four">
  325. {{ getStockTypewriterTexts(stock).four }}
  326. </p>
  327. <!-- 完整文本 -->
  328. <p class="conclusion-text" v-if="!getStockTypewriterTexts(stock) && getStockConclusion(stock) && getStockConclusion(stock).four">
  329. {{ getStockConclusion(stock).four }}
  330. </p>
  331. </div>
  332. </div>
  333. <!-- 状态准备中的提示 -->
  334. <div class="conclusion-placeholder" v-if="!isStockStateReady(stock) && getStockConclusion(stock)">
  335. <p>请稍候...</p>
  336. </div>
  337. <!-- 等待数据加载的提示 -->
  338. <div
  339. class="conclusion-placeholder"
  340. v-if="!getStockConclusion(stock) || (!getStockConclusion(stock).one1 && !getStockConclusion(stock).one2 && !getStockConclusion(stock).two && !getStockConclusion(stock).three && !getStockConclusion(stock).four)"
  341. >
  342. <p>等待股票分析结论...</p>
  343. </div>
  344. </div>
  345. <!-- AI生成内容免责声明 -->
  346. <div class="disclaimer-item" v-if="(getStockTypewriterVisibility(stock) && getStockTypewriterVisibility(stock).disclaimer) || (getStockConclusion(stock) && !getStockTypewriterTexts(stock))">
  347. <!-- 打字机效果文本 -->
  348. <p class="disclaimer-text" v-if="getStockTypewriterTexts(stock) && getStockTypewriterTexts(stock).disclaimer">
  349. {{ getStockTypewriterTexts(stock).disclaimer }}
  350. </p>
  351. <!-- 完整文本 -->
  352. <p class="disclaimer-text" v-if="!getStockTypewriterTexts(stock) && getStockConclusion(stock)">
  353. 该内容由AI生成请注意甄别
  354. </p>
  355. </div>
  356. </div>
  357. </div>
  358. </div>
  359. <!-- 全局返回顶部按钮 -->
  360. <div class="back-to-top" @click="scrollToTop" v-if="(filteredStockList.length > 0 || messages.length > 0)">
  361. <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
  362. <path d="M12 4L12 20M12 4L6 10M12 4L18 10" stroke="currentColor" stroke-width="2" stroke-linecap="round"
  363. stroke-linejoin="round" />
  364. </svg>
  365. </div>
  366. </div>
  367. </template>
  368. <script setup>
  369. import { ref, computed, watch, nextTick, onMounted, onUnmounted } from "vue";
  370. import { getReplyAPI, getConclusionAPI } from "@/api/AiEmotionApi.js"; // 导入工作流接口方法
  371. import axios from "axios";
  372. import moment from "moment";
  373. import item from "@/assets/img/AiEmotion/bk01.png"; // 导入思维矩阵图片
  374. import emotionDecod from "@/views/components/emotionDecod.vue"; // 导入情绪解码组件
  375. import emotionalBottomRadar from "@/views/components/emotionalBottomRadar.vue"; // 导入情绪探底雷达图组件
  376. import emoEnergyConverter from "@/views/components/emoEnergyConverter.vue"; // 导入情绪能量转化器组件
  377. import marketTemperature from "@/views/components/marketTemperature.vue";
  378. import StockTabs from "@/views/components/StockTabs.vue"; // 导入股票标签页组件
  379. import blueBorderImg from "@/assets/img/AiEmotion/blueBorder.png"; //导入蓝色背景框图片
  380. import { ElMessage } from "element-plus"; // 接口失败提示已改为对话形式,保留用于输入验证
  381. import { useEmotionStore } from "@/store/emotion"; // 导入Pinia store
  382. import { useEmotionAudioStore } from "@/store/emotionAudio.js"; // 导入音频store
  383. import { useChatStore } from "@/store/chat.js"; // 导入聊天store
  384. // 导入思考过程GIF
  385. import thinkingGif from "@/assets/img/gif/思考.gif";
  386. import analyzeGif from "@/assets/img/gif/解析.gif";
  387. import generateGif from "@/assets/img/gif/生成.gif";
  388. import getCountAll from "../assets/img/homePage/get-count-all.png";
  389. import voice from "../assets/img/homePage/tail/voice.png";
  390. import voiceNoActive from "../assets/img/homePage/tail/voice-no-active.png";
  391. import { Howl, Howler } from "howler"; // 导入音频播放库
  392. import { reactive } from "vue";
  393. import { marked } from "marked"; // 引入marked库
  394. import { useUserStore } from "../store/userPessionCode";
  395. const APIurl = import.meta.env.VITE_APP_API_BASE_URL;
  396. // 使用Pinia store
  397. const emotionStore = useEmotionStore();
  398. const emotionAudioStore = useEmotionAudioStore();
  399. // 语音播放控制函数
  400. const toggleVoiceForUser = (stock) => {
  401. if (!emotionAudioStore.isVoiceEnabled) {
  402. // 如果语音功能关闭,先开启语音功能
  403. emotionAudioStore.toggleVoice();
  404. } else {
  405. // 获取该股票的结论数据和当前状态
  406. const stockConclusion = getStockConclusion(stock);
  407. const currentState = getStockAudioState(stock);
  408. // 检查是否有任何音频正在播放(包括全局播放状态和当前股票状态)
  409. const isAnyAudioPlaying =
  410. emotionAudioStore.isPlaying || currentState.isPlaying;
  411. // 如果当前点击的股票正在播放,则暂停播放(不重置打字机状态)
  412. if (currentState.isPlaying) {
  413. console.log("暂停当前股票音频:", stock.stockInfo?.name);
  414. // 暂停音频播放但不重置打字机状态
  415. if (emotionAudioStore.nowSound && emotionAudioStore.nowSound.playing()) {
  416. emotionAudioStore.nowSound.pause();
  417. emotionAudioStore.isPaused = true;
  418. emotionAudioStore.isPlaying = false;
  419. }
  420. setStockAudioState(stock, { isPlaying: false, isPaused: true });
  421. } else if (currentState.isPaused) {
  422. // 如果当前股票处于暂停状态,则继续播放(不重置打字机状态)
  423. console.log("继续播放当前股票音频:", stock.stockInfo?.name);
  424. if (emotionAudioStore.nowSound) {
  425. // 从暂停位置继续播放,不重新开始
  426. if (emotionAudioStore.playbackPosition > 0) {
  427. emotionAudioStore.nowSound.seek(emotionAudioStore.playbackPosition);
  428. }
  429. emotionAudioStore.nowSound.play();
  430. emotionAudioStore.isPaused = false;
  431. emotionAudioStore.isPlaying = true;
  432. }
  433. setStockAudioState(stock, { isPlaying: true, isPaused: false });
  434. } else {
  435. // 如果有其他音频正在播放,先停止
  436. if (isAnyAudioPlaying) {
  437. console.log(
  438. "停止其他正在播放的音频,准备播放新音频:",
  439. stock.stockInfo?.name
  440. );
  441. stopAudio();
  442. emotionAudioStore.resetAudioState();
  443. }
  444. // 清除所有股票的播放状态
  445. clearAllStockAudioStates();
  446. // 如果有音频数据,开始播放
  447. if (
  448. stockConclusion &&
  449. (stockConclusion.one1_url ||
  450. stockConclusion.two_url ||
  451. stockConclusion.three_url ||
  452. stockConclusion.four_url)
  453. ) {
  454. console.log("开始播放股票音频:", stock.stockInfo?.name);
  455. setStockAudioState(stock, { isPlaying: true, isPaused: false });
  456. // 播放音频队列
  457. playAudioQueue(stockConclusion, false, () => {
  458. // 音频播放完成后重置状态
  459. setStockAudioState(stock, { isPlaying: false, isPaused: false });
  460. });
  461. } else {
  462. console.log("该股票没有可播放的音频数据");
  463. }
  464. }
  465. }
  466. };
  467. // 计算属性:判断语音是否启用
  468. const isVoice = computed(() => {
  469. return emotionAudioStore.isVoiceEnabled;
  470. });
  471. const chatStore = useChatStore();
  472. // 获取权限
  473. const userStore = useUserStore();
  474. // 处理refuse数据的函数
  475. function processRefuseMessage(refuseData) {
  476. if (!refuseData) return "未知错误";
  477. // 如果refuse数据包含Markdown格式,进行转换
  478. try {
  479. // 配置marked选项
  480. marked.setOptions({
  481. breaks: true, // 支持换行符转换为 <br>
  482. gfm: true, // 启用 GitHub Flavored Markdown
  483. sanitize: false, // 不清理 HTML
  484. smartLists: true, // 智能列表
  485. smartypants: true, // 智能标点符号
  486. xhtml: false, // 不使用 XHTML 输出
  487. });
  488. // 将Markdown转换为HTML
  489. const htmlContent = marked(refuseData);
  490. // 移除HTML标签,只保留纯文本用于ElMessage显示
  491. const tempDiv = document.createElement("div");
  492. tempDiv.innerHTML = htmlContent;
  493. return tempDiv.textContent || tempDiv.innerText || refuseData;
  494. } catch (error) {
  495. console.error("处理refuse消息时出错:", error);
  496. return refuseData;
  497. }
  498. }
  499. // 组件引用 - 修改为数组形式支持多个股票
  500. const marketTemperatureRef = ref([]); // 引用市场温度计组件数组
  501. const emoEnergyConverterRef = ref([]);
  502. const emotionDecodRef = ref([]);
  503. const emotionalBottomRadarRef = ref([]);
  504. const userInputDisplayRef = ref(null); //消息区域的引用
  505. // 响应式数据
  506. const messages = ref([]);
  507. // 从emotion store中恢复对话记录
  508. const loadConversationsFromStore = () => {
  509. const storedConversations = emotionStore.getConversations();
  510. messages.value = storedConversations.map((conv) => ({
  511. sender: conv.sender,
  512. text: conv.text,
  513. isHtml: conv.isHtml || false,
  514. }));
  515. };
  516. // 记录已经添加到对话中的股票,避免重复添加
  517. const addedStocks = ref(new Set());
  518. // 从stockList生成对话历史
  519. const loadConversationsFromStockList = () => {
  520. // 如果当前正在处理用户发送的消息,跳过加载以避免重复
  521. if (isRotating.value) {
  522. console.log("正在处理用户消息,跳过对话历史加载");
  523. return;
  524. }
  525. // 检查是否有新的股票需要添加到对话中
  526. emotionStore.stockList.forEach((stock) => {
  527. // 验证股票数据完整性
  528. if (!stock?.stockInfo?.code || !stock?.timestamp || !stock?.queryText) {
  529. console.warn('股票数据不完整,跳过添加:', stock);
  530. return;
  531. }
  532. // 使用统一的唯一标识生成方法
  533. const stockKey = getStockUniqueId(stock);
  534. if (!stockKey) {
  535. console.warn('无法生成股票唯一标识,跳过添加:', stock);
  536. return;
  537. }
  538. // 多重检查避免重复添加
  539. if (!addedStocks.value.has(stockKey)) {
  540. const existingInMessages = messages.value.find(
  541. (msg) => msg.sender === "user" && msg.text === stock.queryText
  542. );
  543. const storeConversations = emotionStore.getConversations();
  544. const existingInStore = storeConversations.find(
  545. (conv) => conv.sender === "user" && conv.text === stock.queryText
  546. );
  547. // if (!existingInMessages && !existingInStore) {
  548. // const userMessage = {
  549. // sender: "user",
  550. // text: stock.queryText,
  551. // };
  552. // messages.value.push(userMessage);
  553. // emotionStore.addConversation(userMessage);
  554. // }
  555. addedStocks.value.add(stockKey);
  556. }
  557. });
  558. };
  559. // 清空对话记录
  560. const clearConversations = () => {
  561. messages.value = [];
  562. emotionStore.clearConversations();
  563. // 清空已添加股票的记录
  564. addedStocks.value.clear();
  565. };
  566. // 添加股票数据的包装方法
  567. const addStock = (stockData) => {
  568. console.log("AiEmotion组件接收到股票数据:", stockData);
  569. // 验证股票数据完整性
  570. if (!stockData || !stockData.stockInfo || !stockData.stockInfo.code) {
  571. console.error('addStock: 股票数据不完整', stockData);
  572. emit('enableInput');
  573. return;
  574. }
  575. // 设置为历史记录模式,并重置用户主动搜索标志
  576. isHistoryMode.value = true;
  577. isUserInitiated.value = false;
  578. // 历史记录恢复场景,不启用自动滚动
  579. shouldEnableAutoScroll.value = false;
  580. // 1. 先清空页面显示节点和stockList中的数据
  581. isPageLoaded.value = false; // 隐藏页面显示节点
  582. emotionStore.clearAllStocks(); // 清空stockList中的数据
  583. emotionStore.clearConversations(); // 清空对话记录
  584. messages.value = []; // 清空页面对话显示
  585. // 清理已添加股票的记录
  586. addedStocks.value.clear();
  587. // 停止音频播放和清理状态
  588. stopAudio();
  589. audioUrl.value = "";
  590. emotionAudioStore.resetAudioState();
  591. clearTypewriterTimers();
  592. hasTriggeredAudio.value = false;
  593. hasTriggeredTypewriter.value = false;
  594. stockTypewriterShown.value.clear();
  595. stockAudioPlayed.value.clear();
  596. // 清理状态变量(保留用于其他功能的变量)
  597. // 隐藏所有图表组件
  598. chartVisibility.value = {
  599. marketTemperature: false,
  600. emotionDecod: false,
  601. emotionalBottomRadar: false,
  602. emoEnergyConverter: false,
  603. };
  604. // 2. 将新的数据存储到stockList中
  605. emotionStore.addStock(stockData);
  606. // 3. 设置页面为已加载状态,重新渲染页面
  607. isPageLoaded.value = true;
  608. // 4. 标记历史记录股票已显示过,避免重复触发
  609. if (stockData.conclusionData) {
  610. const stockUniqueId = getStockUniqueId(stockData);
  611. if (stockUniqueId) {
  612. stockTypewriterShown.value.set(stockUniqueId, true);
  613. stockAudioPlayed.value.set(stockUniqueId, true);
  614. }
  615. console.log("历史记录股票已标记为已显示");
  616. }
  617. // 5. 使用nextTick确保DOM更新后完成历史记录恢复
  618. nextTick(() => {
  619. // 历史记录恢复时不启动内部滚动监听器,完全依赖父组件管理
  620. // 历史记录恢复时不滚动到底部,保持在顶部
  621. // 6. 历史记录加载完成后,通知父组件重新启用输入框
  622. emit('enableInput');
  623. });
  624. };
  625. // 暴露方法给父组件
  626. defineExpose({
  627. handleSendMessage,
  628. clearConversations,
  629. addStock,
  630. });
  631. const isPageLoaded = ref(false); // 控制页面是否显示
  632. const isHistoryMode = ref(false); // 控制是否为历史记录模式
  633. // const isLoading = ref(false); // 控制加载状态
  634. const isRotating = ref(false); //控制旋转
  635. const version1 = ref(1); // 版本号
  636. const conclusionData = ref(""); // 存储第二个工作流接口返回的结论数据
  637. // 自动滚动相关数据
  638. const isAutoScrolling = ref(false);
  639. const currentSection = ref(0);
  640. const sectionRefs = ref([]);
  641. const scenarioApplicationRef = ref(null); // 场景应用部分的引用
  642. const hasTriggeredAudio = ref(false); // 是否已触发音频播放
  643. const hasTriggeredTypewriter = ref(false); // 是否已触发打字机效果
  644. const intersectionObserver = ref(null); // 存储observer实例
  645. const isUserInitiated = ref(false); // 标记是否为用户主动搜索
  646. const shouldEnableAutoScroll = ref(false); // 标记是否应该启动自动滚动(仅在搜索新数据成功后为true)
  647. const isUserScrolling = ref(false); // 标记用户是否正在手动滚动
  648. const userScrollTimer = ref(null); // 用户滚动检测定时器
  649. // 打字机效果相关的变量已移除,现在直接使用parsedConclusion显示内容
  650. // 图表组件显示状态
  651. const chartVisibility = ref({
  652. marketTemperature: true,
  653. emotionDecod: true,
  654. emotionalBottomRadar: true,
  655. emoEnergyConverter: true,
  656. });
  657. const typewriterTimers = ref([]);
  658. // 记录每个股票是否已经显示过打字机效果
  659. const stockTypewriterShown = ref(new Map());
  660. // 记录每个股票的打字机显示状态
  661. const stockTypewriterTexts = ref(new Map());
  662. // 记录每个股票的打字机模块可见性
  663. const stockTypewriterVisibility = ref(new Map());
  664. // 记录每个股票是否已经播放过音频
  665. const stockAudioPlayed = ref(new Map());
  666. // 跟踪每个股票的音频播放状态
  667. const stockAudioStates = ref(new Map());
  668. // 生成股票唯一标识符的辅助函数
  669. const getStockUniqueId = (stock) => {
  670. // 验证输入参数
  671. if (!stock || typeof stock !== 'object') {
  672. console.warn('getStockUniqueId: 无效的股票对象');
  673. return null;
  674. }
  675. // 优先使用预设的uniqueId
  676. if (stock.uniqueId) {
  677. return stock.uniqueId;
  678. }
  679. // 兼容旧的生成方式
  680. const stockCode = stock.stockInfo?.code || stock.stockInfo?.symbol;
  681. const timestamp = stock.timestamp;
  682. if (!stockCode || !timestamp) {
  683. console.warn('getStockUniqueId: 缺少必要字段', { stockCode, timestamp });
  684. return null;
  685. }
  686. return `${stockCode}_${timestamp}`;
  687. };
  688. // 存储当前的完成回调函数
  689. const currentOnCompleteCallback = ref(null);
  690. // 音频播放相关数据
  691. const audioUrl = ref("");
  692. const isAudioPlaying = ref(false);
  693. // 获取股票的音频播放状态
  694. const getStockAudioState = (stock) => {
  695. const stockUniqueId = getStockUniqueId(stock);
  696. if (!stockUniqueId) {
  697. console.warn('getStockAudioState: 无法获取股票唯一标识');
  698. return { isPlaying: false, isPaused: false };
  699. }
  700. return (
  701. stockAudioStates.value.get(stockUniqueId) || {
  702. isPlaying: false,
  703. isPaused: false,
  704. }
  705. );
  706. };
  707. // 设置股票的音频播放状态
  708. const setStockAudioState = (stock, state) => {
  709. const stockUniqueId = getStockUniqueId(stock);
  710. if (!stockUniqueId) {
  711. console.warn('setStockAudioState: 无法获取股票唯一标识');
  712. return;
  713. }
  714. if (!state || typeof state !== 'object') {
  715. console.warn('setStockAudioState: 无效的状态对象');
  716. return;
  717. }
  718. stockAudioStates.value.set(stockUniqueId, { ...state });
  719. };
  720. // 清除所有股票的播放状态(当开始播放新音频时)
  721. const clearAllStockAudioStates = () => {
  722. for (const [key, value] of stockAudioStates.value.entries()) {
  723. stockAudioStates.value.set(key, { isPlaying: false, isPaused: false });
  724. }
  725. };
  726. // 返回顶部按钮相关数据
  727. const showBackToTop = ref(false);
  728. // 计算属性 - 从store获取当前股票数据
  729. const currentStock = computed(() => emotionStore.activeStock);
  730. const stockName = computed(() => currentStock.value?.stockInfo.name || "");
  731. const stockCode = computed(
  732. () =>
  733. currentStock.value?.stockInfo.code ||
  734. currentStock.value?.stockInfo.symbol ||
  735. ""
  736. );
  737. const currentStockUniqueId = computed(() => {
  738. if (!currentStock.value) return "";
  739. return getStockUniqueId(currentStock.value);
  740. });
  741. const displayDate = computed(() => {
  742. if (!currentStock.value?.apiData) return "";
  743. const lastData = currentStock.value.apiData.GSWDJ?.at(-1);
  744. if (!lastData || !lastData[0]) return "";
  745. const dateStr = lastData[0];
  746. // 假设原格式为 YYYY-MM-DD 或 YYYY/MM/DD
  747. const dateMatch = dateStr.match(/(\d{4})[\-\/](\d{1,2})[\-\/](\d{1,2})/);
  748. if (dateMatch) {
  749. const [, year, month, day] = dateMatch;
  750. // 转换为 DD/MM/YYYY 格式
  751. return `更新时间:${day.padStart(2, "0")}/${month.padStart(
  752. 2,
  753. "0"
  754. )}/${year}`;
  755. }
  756. // 如果不匹配预期格式,返回原始值
  757. return dateStr;
  758. });
  759. const data1 = computed(() => {
  760. if (!currentStock.value?.apiData) return null;
  761. const lastData = currentStock.value.apiData.GSWDJ?.at(-1);
  762. return lastData ? Math.round(lastData[1]) : null;
  763. });
  764. const data2 = computed(() => {
  765. if (!currentStock.value?.apiData) return null;
  766. const lastData = currentStock.value.apiData.GSWDJ?.at(-1);
  767. return lastData ? Math.round(lastData[2]) : null;
  768. });
  769. const currentConclusion = computed(() => {
  770. return currentStock.value?.conclusionData || "";
  771. });
  772. const parsedConclusion = computed(() => {
  773. if (!currentConclusion.value) return null;
  774. // 如果conclusionData已经是对象,直接返回
  775. if (typeof currentConclusion.value === "object") {
  776. return currentConclusion.value;
  777. }
  778. // 如果是字符串,尝试解析JSON
  779. try {
  780. return JSON.parse(currentConclusion.value);
  781. } catch (error) {
  782. console.error("解析结论数据失败:", error);
  783. return null;
  784. }
  785. });
  786. // 多股票数据显示的计算属性
  787. // 过滤和排序后的股票列表
  788. const filteredStockList = computed(() => {
  789. return emotionStore.stockList
  790. .filter((stock) => {
  791. // 过滤掉数据不完整的股票
  792. return stock.stockInfo?.name && stock.apiData && stock.queryText;
  793. })
  794. .sort((a, b) => {
  795. // 按时间戳降序排序,最新的在前
  796. return new Date(a.timestamp) - new Date(b.timestamp);
  797. });
  798. });
  799. // 辅助函数:获取股票的显示日期
  800. const getDisplayDate = (stock) => {
  801. if (!stock?.apiData) return "";
  802. const lastData = stock.apiData.GSWDJ?.at(-1);
  803. if (!lastData || !lastData[0]) return "";
  804. const dateStr = lastData[0];
  805. // 假设原格式为 YYYY-MM-DD 或 YYYY/MM/DD
  806. const dateMatch = dateStr.match(/(\d{4})[\-\/](\d{1,2})[\-\/](\d{1,2})/);
  807. if (dateMatch) {
  808. const [, year, month, day] = dateMatch;
  809. // 转换为 DD/MM/YYYY 格式
  810. return `更新时间:${day.padStart(2, "0")}/${month.padStart(
  811. 2,
  812. "0"
  813. )}/${year}`;
  814. }
  815. // 如果不匹配预期格式,返回原始值
  816. return dateStr;
  817. };
  818. // 辅助函数:获取股票的市场温度数据
  819. const getStockData1 = (stock) => {
  820. if (!stock?.apiData) return null;
  821. const lastData = stock.apiData.GSWDJ?.at(-1);
  822. return lastData ? Math.round(lastData[1]) : null;
  823. };
  824. // 辅助函数:获取股票的股票温度数据
  825. const getStockData2 = (stock) => {
  826. if (!stock?.apiData) return null;
  827. const lastData = stock.apiData.GSWDJ?.at(-1);
  828. return lastData ? Math.round(lastData[2]) : null;
  829. };
  830. // 辅助函数:获取股票的结论数据
  831. const getStockConclusion = (stock) => {
  832. if (!stock?.conclusionData) return null;
  833. // 如果conclusionData已经是对象,直接返回
  834. if (typeof stock.conclusionData === "object") {
  835. return stock.conclusionData;
  836. }
  837. // 如果是字符串,尝试解析JSON
  838. try {
  839. return JSON.parse(stock.conclusionData);
  840. } catch (error) {
  841. console.error("解析股票结论数据失败:", error);
  842. return null;
  843. }
  844. };
  845. // 辅助函数:获取股票的打字机文本状态
  846. const getStockTypewriterTexts = (stock) => {
  847. const stockUniqueId = getStockUniqueId(stock);
  848. if (!stockUniqueId) {
  849. console.warn('getStockTypewriterTexts: 无法获取股票唯一标识');
  850. return null;
  851. }
  852. const texts = stockTypewriterTexts.value.get(stockUniqueId);
  853. return texts || null;
  854. };
  855. // 辅助函数:获取股票的打字机可见性状态
  856. const getStockTypewriterVisibility = (stock) => {
  857. const stockUniqueId = getStockUniqueId(stock);
  858. if (!stockUniqueId) {
  859. console.warn('getStockTypewriterVisibility: 无法获取股票唯一标识');
  860. return null;
  861. }
  862. return stockTypewriterVisibility.value.get(stockUniqueId) || null;
  863. };
  864. // 辅助函数:检查股票是否正在进行打字机效果
  865. const isStockTypewriting = (stock) => {
  866. const stockUniqueId = getStockUniqueId(stock);
  867. if (!stockUniqueId) {
  868. console.warn('isStockTypewriting: 无法获取股票唯一标识');
  869. return false;
  870. }
  871. return stockTypewriterShown.value.has(stockUniqueId) && !stockTypewriterTexts.value.has(stockUniqueId);
  872. };
  873. // 辅助函数:检查股票状态是否准备好显示
  874. const isStockStateReady = (stock) => {
  875. const stockUniqueId = getStockUniqueId(stock);
  876. if (!stockUniqueId) {
  877. return false;
  878. }
  879. const conclusion = getStockConclusion(stock);
  880. if (!conclusion) {
  881. return false;
  882. }
  883. const isFirstTime = !stockTypewriterShown.value.has(stockUniqueId);
  884. // 如果是第一次且用户主动搜索,提前初始化状态并返回true
  885. if (isFirstTime && isUserInitiated.value) {
  886. // 提前初始化打字机状态,避免渲染时的状态闪烁
  887. if (!stockTypewriterTexts.value.has(stockUniqueId)) {
  888. stockTypewriterTexts.value.set(stockUniqueId, {
  889. one1: "", one2: "", two: "", three: "", four: "", disclaimer: ""
  890. });
  891. }
  892. if (!stockTypewriterVisibility.value.has(stockUniqueId)) {
  893. stockTypewriterVisibility.value.set(stockUniqueId, {
  894. one: false, two: false, three: false, four: false, disclaimer: false
  895. });
  896. }
  897. return true;
  898. }
  899. // 其他情况下,只要有结论数据就可以显示
  900. return true;
  901. };
  902. // 监听股票列表变化,当列表为空时隐藏页面数据
  903. watch(
  904. () => emotionStore.stockList,
  905. (newStockList) => {
  906. if (newStockList.length === 0) {
  907. // 当股票列表为空时,隐藏页面数据
  908. isPageLoaded.value = false;
  909. // 停止音频播放
  910. stopAudio();
  911. // 清理音频URL
  912. audioUrl.value = "";
  913. emotionAudioStore.resetAudioState();
  914. // 清理打字机效果
  915. clearTypewriterTimers();
  916. // 重置所有状态
  917. hasTriggeredAudio.value = false;
  918. hasTriggeredTypewriter.value = false;
  919. stockTypewriterShown.value.clear();
  920. stockAudioPlayed.value.clear();
  921. // 清理已添加股票的记录
  922. addedStocks.value.clear();
  923. // 隐藏所有图表组件
  924. chartVisibility.value = {
  925. marketTemperature: false,
  926. emotionDecod: false,
  927. emotionalBottomRadar: false,
  928. emoEnergyConverter: false,
  929. };
  930. console.log("股票列表已清空,页面数据已隐藏");
  931. } else {
  932. // 当stockList有数据时,更新对话记录
  933. loadConversationsFromStockList();
  934. }
  935. },
  936. { deep: true }
  937. );
  938. // 监听当前股票变化,重新渲染图表和显示对应结论
  939. watch(
  940. currentStock,
  941. (newStock) => {
  942. if (newStock && newStock.apiData) {
  943. // 页面加载状态现在由 handleSendMessage 统一控制
  944. // 停止当前播放的音频
  945. stopAudio();
  946. // 清理音频URL,确保不会播放之前股票的音频
  947. audioUrl.value = "";
  948. // 清理store中的音频URL,确保不会播放之前股票的音频
  949. emotionAudioStore.resetAudioState();
  950. // 清理正在进行的打字机效果定时器
  951. clearTypewriterTimers();
  952. // 重置触发状态,让每个股票都能独立触发效果
  953. hasTriggeredAudio.value = false;
  954. hasTriggeredTypewriter.value = false;
  955. // 获取股票唯一标识(使用预设的uniqueId)
  956. const stockUniqueId = getStockUniqueId(newStock);
  957. // 处理当前股票的音频URL
  958. if (newStock.conclusionData) {
  959. try {
  960. // 如果conclusionData已经是对象,直接使用;否则解析JSON
  961. const conclusion =
  962. typeof newStock.conclusionData === "object"
  963. ? newStock.conclusionData
  964. : JSON.parse(newStock.conclusionData);
  965. // 基于预设状态处理音频URL
  966. const shouldShowTypewriter = stockUniqueId && stockTypewriterTexts.value.has(stockUniqueId);
  967. if (!shouldShowTypewriter) {
  968. // 提取音频URL但不自动播放,等待用户手动点击
  969. let voiceUrl = null;
  970. // 优先使用one1_url,如果没有则尝试其他音频URL
  971. if (conclusion.one1_url) {
  972. voiceUrl = conclusion.one1_url
  973. .toString()
  974. .trim()
  975. .replace(/[`\s]/g, "");
  976. } else if (conclusion.one2_url) {
  977. voiceUrl = conclusion.one2_url
  978. .toString()
  979. .trim()
  980. .replace(/[`\s]/g, "");
  981. } else if (conclusion.two_url) {
  982. voiceUrl = conclusion.two_url
  983. .toString()
  984. .trim()
  985. .replace(/[`\s]/g, "");
  986. } else if (conclusion.three_url) {
  987. voiceUrl = conclusion.three_url
  988. .toString()
  989. .trim()
  990. .replace(/[`\s]/g, "");
  991. } else if (conclusion.four_url) {
  992. voiceUrl = conclusion.four_url
  993. .toString()
  994. .trim()
  995. .replace(/[`\s]/g, "");
  996. } else if (conclusion.url) {
  997. voiceUrl = conclusion.url.toString().trim().replace(/[`\s]/g, "");
  998. } else if (conclusion.audioUrl) {
  999. voiceUrl = conclusion.audioUrl
  1000. .toString()
  1001. .trim()
  1002. .replace(/[`\s]/g, "");
  1003. } else if (conclusion.voice_url) {
  1004. voiceUrl = conclusion.voice_url
  1005. .toString()
  1006. .trim()
  1007. .replace(/[`\s]/g, "");
  1008. } else if (conclusion.audio) {
  1009. voiceUrl = conclusion.audio
  1010. .toString()
  1011. .trim()
  1012. .replace(/[`\s]/g, "");
  1013. } else if (conclusion.tts_url) {
  1014. voiceUrl = conclusion.tts_url
  1015. .toString()
  1016. .trim()
  1017. .replace(/[`\s]/g, "");
  1018. }
  1019. if (voiceUrl && voiceUrl.startsWith("http")) {
  1020. console.log(
  1021. "切换到已显示股票,准备音频URL但不自动播放:",
  1022. voiceUrl
  1023. );
  1024. audioUrl.value = voiceUrl;
  1025. // 同时更新store中的音频URL
  1026. emotionAudioStore.setCurrentAudioUrl(voiceUrl);
  1027. // 不自动播放,等待用户手动点击
  1028. }
  1029. }
  1030. } catch (error) {
  1031. console.error("解析股票结论数据失败:", error);
  1032. }
  1033. } else {
  1034. // 如果没有结论数据,清空音频URL
  1035. audioUrl.value = "";
  1036. emotionAudioStore.resetAudioState();
  1037. console.log("当前股票没有结论数据,已清空音频");
  1038. }
  1039. // 只有在页面已加载的情况下才渲染图表
  1040. if (isPageLoaded.value) {
  1041. nextTick(() => {
  1042. renderCharts(newStock.apiData);
  1043. console.log("图表数据已准备完成,开始渲染:", newStock.apiData);
  1044. // 检查场景应用部分是否已经在视口中,如果是则立即触发效果
  1045. setTimeout(() => {
  1046. // 检查 scenarioApplicationRef.value 是否存在且是有效的 DOM 元素
  1047. if (
  1048. !scenarioApplicationRef.value ||
  1049. !(scenarioApplicationRef.value instanceof Element)
  1050. ) {
  1051. console.warn(
  1052. "scenarioApplicationRef.value 不是有效的 DOM 元素,跳过处理"
  1053. );
  1054. return;
  1055. }
  1056. if (parsedConclusion.value) {
  1057. // 如果该股票已经显示过,不需要再处理
  1058. if (stockUniqueId && stockTypewriterShown.value.has(stockUniqueId)) {
  1059. return;
  1060. }
  1061. const rect = scenarioApplicationRef.value.getBoundingClientRect();
  1062. const isInViewport =
  1063. rect.top < window.innerHeight && rect.bottom > 0;
  1064. if (isInViewport) {
  1065. console.log("股票切换后检测到场景应用部分在视口中");
  1066. if (stockUniqueId) {
  1067. // 检查该股票是否是第一次触发
  1068. if (!stockTypewriterShown.value.has(stockUniqueId)) {
  1069. // 如果是用户主动搜索,启动打字机效果和音频播放
  1070. if (isUserInitiated.value && audioUrl.value) {
  1071. console.log(
  1072. "用户主动搜索,该股票第一次进入场景应用,开始打字机效果和音频播放"
  1073. );
  1074. hasTriggeredTypewriter.value = true;
  1075. hasTriggeredAudio.value = true;
  1076. if (!stockAudioPlayed.value.has(stockUniqueId)) {
  1077. console.log("开始音频播放和打字机效果");
  1078. stockAudioPlayed.value.set(stockUniqueId, true);
  1079. playAudioQueue(parsedConclusion.value, true);
  1080. } else {
  1081. // 如果音频已播放过,只启动打字机效果
  1082. startTypewriterEffect(parsedConclusion.value, stockUniqueId);
  1083. }
  1084. stockTypewriterShown.value.set(stockUniqueId, true);
  1085. } else if (isUserInitiated.value && !audioUrl.value) {
  1086. console.log(
  1087. "音频尚未准备好,等待音频加载完成后再触发效果(股票切换后)"
  1088. );
  1089. return;
  1090. } else {
  1091. // 非用户主动搜索(如历史记录恢复),直接显示完整内容
  1092. console.log(
  1093. "非用户主动搜索,该股票第一次进入场景应用,直接显示完整内容"
  1094. );
  1095. const conclusion = parsedConclusion.value;
  1096. // 结论内容现在直接通过parsedConclusion计算属性显示
  1097. stockTypewriterShown.value.set(stockUniqueId, true);
  1098. stockAudioPlayed.value.set(stockUniqueId, true);
  1099. }
  1100. } else {
  1101. // 非第一次或已经触发过:直接显示完整内容,不播放音频和打字机效果
  1102. console.log("非第一次股票切换或已触发过,直接显示完整内容");
  1103. // 直接显示完整内容
  1104. const conclusion = parsedConclusion.value;
  1105. displayedTexts.value = {
  1106. one1: conclusion.one1 || "",
  1107. one2: conclusion.one2 || "",
  1108. two: conclusion.two || "",
  1109. three: conclusion.three || "",
  1110. four: conclusion.four || "",
  1111. disclaimer: "该内容由AI生成,请注意甄别",
  1112. };
  1113. displayedTitles.value = {
  1114. one: "L1: 情绪监控",
  1115. two: "L2: 情绪解码",
  1116. three: "L3: 情绪推演",
  1117. four: "L4: 情绪套利",
  1118. };
  1119. moduleVisibility.value = {
  1120. one: !!(conclusion.one1 || conclusion.one2),
  1121. two: !!conclusion.two,
  1122. three: !!conclusion.three,
  1123. four: !!conclusion.four,
  1124. disclaimer: true,
  1125. };
  1126. }
  1127. }
  1128. }
  1129. }
  1130. }, 500); // 延迟500ms确保数据完全加载
  1131. });
  1132. } else {
  1133. console.log("页面尚未加载完成,等待数据加载完成后再渲染图表");
  1134. }
  1135. } else {
  1136. console.log("股票数据不存在或API数据未加载");
  1137. // 隐藏所有图表组件
  1138. chartVisibility.value = {
  1139. marketTemperature: false,
  1140. emotionDecod: false,
  1141. emotionalBottomRadar: false,
  1142. emoEnergyConverter: false,
  1143. };
  1144. }
  1145. },
  1146. { immediate: true }
  1147. );
  1148. // 监听parsedConclusion变化,准备数据但不立即触发打字机效果
  1149. watch(
  1150. parsedConclusion,
  1151. (newConclusion) => {
  1152. if (newConclusion) {
  1153. console.log("场景应用结论数据:", newConclusion);
  1154. // 不再立即开始打字机效果,等待滚动到场景应用部分时触发
  1155. // 尝试多种可能的语音URL字段名,优先使用新的数据结构
  1156. let voiceUrl = null;
  1157. if (newConclusion.one1_url) {
  1158. voiceUrl = newConclusion.one1_url
  1159. .toString()
  1160. .trim()
  1161. .replace(/[`\s]/g, "");
  1162. } else if (newConclusion.one2_url) {
  1163. voiceUrl = newConclusion.one2_url
  1164. .toString()
  1165. .trim()
  1166. .replace(/[`\s]/g, "");
  1167. } else if (newConclusion.two_url) {
  1168. voiceUrl = newConclusion.two_url
  1169. .toString()
  1170. .trim()
  1171. .replace(/[`\s]/g, "");
  1172. } else if (newConclusion.three_url) {
  1173. voiceUrl = newConclusion.three_url
  1174. .toString()
  1175. .trim()
  1176. .replace(/[`\s]/g, "");
  1177. } else if (newConclusion.four_url) {
  1178. voiceUrl = newConclusion.four_url
  1179. .toString()
  1180. .trim()
  1181. .replace(/[`\s]/g, "");
  1182. } else if (newConclusion.url) {
  1183. // 清理URL字符串,去除空格、反引号等特殊字符
  1184. voiceUrl = newConclusion.url.toString().trim().replace(/[`\s]/g, "");
  1185. } else if (newConclusion.audioUrl) {
  1186. voiceUrl = newConclusion.audioUrl
  1187. .toString()
  1188. .trim()
  1189. .replace(/[`\s]/g, "");
  1190. } else if (newConclusion.voice_url) {
  1191. voiceUrl = newConclusion.voice_url
  1192. .toString()
  1193. .trim()
  1194. .replace(/[`\s]/g, "");
  1195. } else if (newConclusion.audio) {
  1196. voiceUrl = newConclusion.audio.toString().trim().replace(/[`\s]/g, "");
  1197. } else if (newConclusion.tts_url) {
  1198. voiceUrl = newConclusion.tts_url
  1199. .toString()
  1200. .trim()
  1201. .replace(/[`\s]/g, "");
  1202. }
  1203. if (voiceUrl && voiceUrl.startsWith("http")) {
  1204. console.log("找到并清理后的语音URL:", voiceUrl);
  1205. audioUrl.value = voiceUrl;
  1206. // 同时更新store中的音频URL
  1207. emotionAudioStore.setCurrentAudioUrl(voiceUrl);
  1208. console.log("音频URL已准备,检查是否需要立即触发效果");
  1209. // 音频准备好后,只有在用户主动搜索时才自动触发效果
  1210. // 数据恢复时不自动播放音频和打字机效果
  1211. console.log("音频URL已准备完成,等待用户手动触发播放");
  1212. } else {
  1213. console.log("未找到有效的语音URL,原始URL:", newConclusion.url);
  1214. console.log("结论数据中的所有字段:", Object.keys(newConclusion));
  1215. }
  1216. }
  1217. },
  1218. { immediate: true }
  1219. );
  1220. // 打字机效果函数
  1221. function startTypewriterEffect(conclusion, stockId, onComplete) {
  1222. // 如果没有传入stockId,使用当前活跃股票的唯一标识符
  1223. if (!stockId && emotionStore.activeStock) {
  1224. stockId = getStockUniqueId(emotionStore.activeStock);
  1225. }
  1226. if (!stockId) {
  1227. console.warn("无法确定股票ID,跳过打字机效果");
  1228. return;
  1229. }
  1230. console.log("开始打字机效果,结论数据:", conclusion, "股票ID:", stockId);
  1231. // 保存当前的完成回调函数
  1232. currentOnCompleteCallback.value = onComplete;
  1233. // 详细调试各个字段
  1234. console.log("L1字段 - one1:", conclusion.one1);
  1235. console.log("L1字段 - one2:", conclusion.one2);
  1236. console.log("L2字段 - two:", conclusion.two);
  1237. console.log("L3字段 - three:", conclusion.three);
  1238. console.log("L4字段 - four:", conclusion.four);
  1239. // 清除之前的定时器
  1240. typewriterTimers.value.forEach((timer) => clearTimeout(timer));
  1241. typewriterTimers.value = [];
  1242. // 初始化该股票的打字机状态
  1243. if (!stockTypewriterTexts.value.has(stockId)) {
  1244. stockTypewriterTexts.value.set(stockId, {
  1245. one1: "",
  1246. one2: "",
  1247. two: "",
  1248. three: "",
  1249. four: "",
  1250. disclaimer: "",
  1251. });
  1252. }
  1253. if (!stockTypewriterVisibility.value.has(stockId)) {
  1254. stockTypewriterVisibility.value.set(stockId, {
  1255. one: false,
  1256. two: false,
  1257. three: false,
  1258. four: false,
  1259. disclaimer: false,
  1260. });
  1261. }
  1262. // 重置该股票的显示文本和状态
  1263. stockTypewriterTexts.value.set(stockId, {
  1264. one1: "",
  1265. one2: "",
  1266. two: "",
  1267. three: "",
  1268. four: "",
  1269. disclaimer: "",
  1270. });
  1271. stockTypewriterVisibility.value.set(stockId, {
  1272. one: false,
  1273. two: false,
  1274. three: false,
  1275. four: false,
  1276. disclaimer: false,
  1277. });
  1278. // 定义打字速度(毫秒)
  1279. const typeSpeed = 200;
  1280. let totalDelay = 0;
  1281. // 定义模块配置
  1282. const modules = [
  1283. {
  1284. key: "one",
  1285. title: "L1: 情绪监控",
  1286. contents: [
  1287. { key: "one1", text: conclusion.one1 },
  1288. { key: "one2", text: conclusion.one2 },
  1289. ],
  1290. },
  1291. {
  1292. key: "two",
  1293. title: "L2: 情绪解码",
  1294. contents: [{ key: "two", text: conclusion.two }],
  1295. },
  1296. {
  1297. key: "three",
  1298. title: "L3: 情绪推演",
  1299. contents: [{ key: "three", text: conclusion.three }],
  1300. },
  1301. {
  1302. key: "four",
  1303. title: "L4: 情绪套利",
  1304. contents: [{ key: "four", text: conclusion.four }],
  1305. },
  1306. ];
  1307. // 按模块顺序处理
  1308. modules.forEach((module) => {
  1309. // 检查模块是否有内容
  1310. const hasContent = module.contents.some(
  1311. (content) => content.text && content.text.trim()
  1312. );
  1313. console.log(
  1314. `模块 ${module.key} 是否有内容:`,
  1315. hasContent,
  1316. "内容:",
  1317. module.contents.map((c) => c.text)
  1318. );
  1319. if (!hasContent) return;
  1320. console.log(`开始显示模块 ${module.key}`);
  1321. // 显示模块
  1322. const showModuleTimer = setTimeout(() => {
  1323. const visibility = stockTypewriterVisibility.value.get(stockId);
  1324. if (visibility) {
  1325. visibility[module.key] = true;
  1326. stockTypewriterVisibility.value.set(stockId, { ...visibility });
  1327. }
  1328. }, totalDelay);
  1329. typewriterTimers.value.push(showModuleTimer);
  1330. totalDelay += 100;
  1331. // 为每个内容项添加打字机效果
  1332. module.contents.forEach((content) => {
  1333. if (content.text && content.text.trim()) {
  1334. for (let i = 0; i <= content.text.length; i++) {
  1335. const timer = setTimeout(() => {
  1336. const texts = stockTypewriterTexts.value.get(stockId);
  1337. if (texts) {
  1338. texts[content.key] = content.text.substring(0, i);
  1339. stockTypewriterTexts.value.set(stockId, { ...texts });
  1340. }
  1341. }, totalDelay + i * typeSpeed);
  1342. typewriterTimers.value.push(timer);
  1343. }
  1344. totalDelay += content.text.length * typeSpeed + 200; // 内容间间隔
  1345. }
  1346. });
  1347. totalDelay += 800; // 模块间间隔
  1348. });
  1349. // 添加免责声明的打字机效果(在所有模块显示完成后)
  1350. const disclaimerText = "该内容由AI生成,请注意甄别";
  1351. // 显示免责声明模块
  1352. const showDisclaimerTimer = setTimeout(() => {
  1353. const visibility = stockTypewriterVisibility.value.get(stockId);
  1354. if (visibility) {
  1355. visibility.disclaimer = true;
  1356. stockTypewriterVisibility.value.set(stockId, { ...visibility });
  1357. }
  1358. }, totalDelay);
  1359. typewriterTimers.value.push(showDisclaimerTimer);
  1360. totalDelay += 100;
  1361. // 打字机效果显示免责声明
  1362. for (let i = 0; i <= disclaimerText.length; i++) {
  1363. const timer = setTimeout(() => {
  1364. const texts = stockTypewriterTexts.value.get(stockId);
  1365. if (texts) {
  1366. texts.disclaimer = disclaimerText.substring(0, i);
  1367. stockTypewriterTexts.value.set(stockId, { ...texts });
  1368. }
  1369. // 在免责声明打字机效果完成后调用回调函数
  1370. if (i === disclaimerText.length) {
  1371. console.log("打字机效果完成,调用onComplete回调");
  1372. if (onComplete && typeof onComplete === "function") {
  1373. onComplete();
  1374. // 清除保存的回调函数
  1375. currentOnCompleteCallback.value = null;
  1376. }
  1377. }
  1378. }, totalDelay + i * typeSpeed);
  1379. typewriterTimers.value.push(timer);
  1380. }
  1381. }
  1382. // 清理定时器的函数
  1383. function clearTypewriterTimers() {
  1384. typewriterTimers.value.forEach((timer) => clearTimeout(timer));
  1385. typewriterTimers.value = [];
  1386. }
  1387. // 音频队列管理
  1388. const audioQueue = ref([]);
  1389. const isPlayingQueueAudio = ref(false);
  1390. let currentPlayIndex = 0;
  1391. let isCallingPlayNext = false;
  1392. // 音频队列顺序管理
  1393. const audioQueueOrder = {
  1394. one1_url: 1,
  1395. one2_url: 2,
  1396. two_url: 3,
  1397. three_url: 4,
  1398. four_url: 5,
  1399. url: 6,
  1400. audioUrl: 7,
  1401. voice_url: 8,
  1402. audio: 9,
  1403. tts_url: 10,
  1404. };
  1405. // 播放音频队列中的下一个音频
  1406. const playNextAudio = () => {
  1407. console.log("=== playNextAudio 被调用 ===");
  1408. console.log("当前队列状态:", {
  1409. queueLength: audioQueue.value.length,
  1410. queueItems: audioQueue.value.map((item) => item.name),
  1411. currentPlayIndex: currentPlayIndex,
  1412. isPlayingQueueAudio: isPlayingQueueAudio.value,
  1413. isCallingPlayNext: isCallingPlayNext,
  1414. audioStoreIsPlaying: emotionAudioStore.isPlaying,
  1415. });
  1416. if (
  1417. audioQueue.value.length === 0 ||
  1418. isPlayingQueueAudio.value ||
  1419. isCallingPlayNext
  1420. ) {
  1421. console.log(
  1422. "❌ 播放条件不满足 - 队列长度:",
  1423. audioQueue.value.length,
  1424. "正在播放:",
  1425. isPlayingQueueAudio.value,
  1426. "正在调用:",
  1427. isCallingPlayNext
  1428. );
  1429. return;
  1430. }
  1431. // 检查是否已播放完所有音频
  1432. if (
  1433. currentPlayIndex >= audioQueue.value.length &&
  1434. audioQueue.value.length > 0
  1435. ) {
  1436. console.log("🔄 所有音频播放完成,重置索引从第一个开始");
  1437. currentPlayIndex = 0;
  1438. isCallingPlayNext = false; // 重置调用标志
  1439. }
  1440. isCallingPlayNext = true;
  1441. isPlayingQueueAudio.value = true;
  1442. const audioInfo = audioQueue.value[currentPlayIndex];
  1443. console.log(
  1444. `✅ 开始播放${audioInfo.name}音频 (索引:${currentPlayIndex}),队列总长度:`,
  1445. audioQueue.value.length
  1446. );
  1447. // 停止之前的音频
  1448. if (emotionAudioStore.nowSound && emotionAudioStore.nowSound.playing()) {
  1449. emotionAudioStore.nowSound.stop();
  1450. }
  1451. // 创建新的音频实例
  1452. const audio = new Howl({
  1453. src: [audioInfo.url],
  1454. html5: false,
  1455. format: ["mp3", "wav"],
  1456. onplay: () => {
  1457. isAudioPlaying.value = true;
  1458. isPlayingQueueAudio.value = true;
  1459. emotionAudioStore.isPlaying = true;
  1460. console.log(`开始播放${audioInfo.name}音频`);
  1461. // 设置当前股票的音频播放状态为播放中
  1462. const currentStock = emotionStore.activeStock;
  1463. if (currentStock) {
  1464. setStockAudioState(currentStock, { isPlaying: true, isPaused: false });
  1465. console.log('设置当前股票音频状态为播放中:', currentStock.stockInfo?.name);
  1466. }
  1467. // 如果是第一个音频且需要启动打字机效果,且不是从暂停状态恢复播放,则启动
  1468. if (
  1469. currentPlayIndex === 0 &&
  1470. audioInfo.shouldStartTypewriter &&
  1471. parsedConclusion.value &&
  1472. !emotionAudioStore.isPaused && // 不是从暂停状态恢复
  1473. emotionAudioStore.playbackPosition === 0 // 从头开始播放
  1474. ) {
  1475. console.log("🎬 第一个音频开始播放,同时启动打字机效果");
  1476. const stockId = currentStock ? getStockUniqueId(currentStock) : null;
  1477. startTypewriterEffect(parsedConclusion.value, stockId, audioInfo.onComplete);
  1478. } else if (currentPlayIndex === 0 && audioInfo.shouldStartTypewriter) {
  1479. console.log("🔄 从暂停状态恢复播放,不重新启动打字机效果");
  1480. }
  1481. },
  1482. onpause: () => {
  1483. emotionAudioStore.isPlaying = false;
  1484. emotionAudioStore.isPaused = true;
  1485. // 保存当前播放位置
  1486. if (audio && audio.seek) {
  1487. emotionAudioStore.playbackPosition = audio.seek() || 0;
  1488. }
  1489. console.log(`${audioInfo.name}音频暂停播放,位置:`, emotionAudioStore.playbackPosition);
  1490. // 设置当前股票的音频播放状态为暂停
  1491. const currentStock = emotionStore.activeStock;
  1492. if (currentStock) {
  1493. setStockAudioState(currentStock, { isPlaying: false, isPaused: true });
  1494. console.log('设置当前股票音频状态为暂停:', currentStock.stockInfo?.name);
  1495. }
  1496. },
  1497. onresume: () => {
  1498. emotionAudioStore.isPlaying = true;
  1499. emotionAudioStore.isPaused = false;
  1500. // 如果有保存的播放位置,从该位置继续播放
  1501. if (emotionAudioStore.playbackPosition > 0 && audio && audio.seek) {
  1502. audio.seek(emotionAudioStore.playbackPosition);
  1503. }
  1504. console.log(`${audioInfo.name}音频继续播放,位置:`, emotionAudioStore.playbackPosition);
  1505. // 设置当前股票的音频播放状态为播放中
  1506. const currentStock = emotionStore.activeStock;
  1507. if (currentStock) {
  1508. setStockAudioState(currentStock, { isPlaying: true, isPaused: false });
  1509. console.log('设置当前股票音频状态为播放中:', currentStock.stockInfo?.name);
  1510. }
  1511. },
  1512. onend: () => {
  1513. console.log(`${audioInfo.name}音频播放完成,准备播放下一个`);
  1514. emotionAudioStore.isPaused = false;
  1515. emotionAudioStore.playbackPosition = 0;
  1516. // 移动到下一个音频索引
  1517. currentPlayIndex++;
  1518. // 确保只有在音频真正播放完成时才播放下一个
  1519. if (currentPlayIndex < audioQueue.value.length) {
  1520. console.log(
  1521. `队列中还有音频,500ms后播放下一个 (索引:${currentPlayIndex})`
  1522. );
  1523. // 重置调用标志,但保持播放状态,直到所有音频播放完成
  1524. setTimeout(() => {
  1525. isCallingPlayNext = false;
  1526. isPlayingQueueAudio.value = false; // 重置队列播放状态,允许播放下一个音频
  1527. // 保持emotionAudioStore.isPlaying为true,确保喇叭图片保持voice状态
  1528. emotionAudioStore.isPlaying = true;
  1529. // 设置下一个音频的URL,确保togglePlayPause能正确工作
  1530. const nextAudioInfo = audioQueue.value[currentPlayIndex];
  1531. if (nextAudioInfo && nextAudioInfo.url) {
  1532. emotionAudioStore.setCurrentAudioUrl(nextAudioInfo.url);
  1533. }
  1534. playNextAudio();
  1535. }, 500);
  1536. } else {
  1537. console.log("🎉 所有音频播放完成");
  1538. emotionAudioStore.nowSound = null;
  1539. isCallingPlayNext = false;
  1540. // 重置音频store的播放状态
  1541. emotionAudioStore.isPlaying = false;
  1542. emotionAudioStore.isPaused = false;
  1543. emotionAudioStore.playbackPosition = 0;
  1544. isAudioPlaying.value = false;
  1545. isPlayingQueueAudio.value = false;
  1546. // 重置当前股票的音频播放状态(所有音频播放完成后按钮应该变暗)
  1547. const currentStock = emotionStore.activeStock;
  1548. if (currentStock) {
  1549. console.log('所有音频播放完成,重置当前股票音频状态:', currentStock.stockInfo?.name);
  1550. setStockAudioState(currentStock, { isPlaying: false, isPaused: false });
  1551. }
  1552. // 调用完成回调(如果有的话)
  1553. if (
  1554. audioInfo.onComplete &&
  1555. typeof audioInfo.onComplete === "function"
  1556. ) {
  1557. console.log("调用音频播放完成回调");
  1558. audioInfo.onComplete();
  1559. }
  1560. }
  1561. },
  1562. onstop: () => {
  1563. console.log(`${audioInfo.name}音频被停止`);
  1564. emotionAudioStore.isPlaying = false;
  1565. emotionAudioStore.isPaused = false;
  1566. emotionAudioStore.playbackPosition = 0;
  1567. isAudioPlaying.value = false;
  1568. isPlayingQueueAudio.value = false;
  1569. // 重置当前股票的音频播放状态(音频被停止时按钮应该变暗)
  1570. const currentStock = emotionStore.activeStock;
  1571. if (currentStock) {
  1572. console.log('音频被停止,重置当前股票音频状态:', currentStock.stockInfo?.name);
  1573. setStockAudioState(currentStock, { isPlaying: false, isPaused: false });
  1574. }
  1575. },
  1576. onerror: (error) => {
  1577. console.error(`${audioInfo.name}音频播放失败:`, error);
  1578. isAudioPlaying.value = false;
  1579. isPlayingQueueAudio.value = false;
  1580. isCallingPlayNext = false;
  1581. // 播放下一个音频
  1582. setTimeout(() => {
  1583. playNextAudio();
  1584. }, 100);
  1585. },
  1586. onload: () => {
  1587. emotionAudioStore.duration = audio.duration();
  1588. console.log(
  1589. `${audioInfo.name}音频加载完成,时长:`,
  1590. emotionAudioStore.duration
  1591. );
  1592. },
  1593. });
  1594. // 设置当前音频URL到store
  1595. emotionAudioStore.setCurrentAudioUrl(audioInfo.url);
  1596. emotionAudioStore.nowSound = audio;
  1597. emotionAudioStore.setAudioInstance(audio);
  1598. console.log(`尝试播放${audioInfo.name}音频`);
  1599. audio.play();
  1600. };
  1601. // 添加音频到播放队列
  1602. const addToAudioQueue = (
  1603. url,
  1604. name,
  1605. shouldStartTypewriter = false,
  1606. onComplete = null
  1607. ) => {
  1608. console.log(`=== 添加音频到队列 ===`);
  1609. console.log("URL:", url);
  1610. console.log("Name:", name);
  1611. console.log("是否启动打字机效果:", shouldStartTypewriter);
  1612. console.log("音频启用状态:", emotionAudioStore.isVoiceEnabled);
  1613. if (url && emotionAudioStore.isVoiceEnabled) {
  1614. const audioItem = {
  1615. url,
  1616. name,
  1617. order: audioQueueOrder[name] || 999,
  1618. shouldStartTypewriter, // 添加打字机效果标志
  1619. onComplete, // 添加完成回调
  1620. };
  1621. audioQueue.value.push(audioItem);
  1622. // 按顺序排序队列
  1623. audioQueue.value.sort((a, b) => a.order - b.order);
  1624. console.log(`音频${name}已添加到播放队列,顺序:${audioItem.order}`);
  1625. console.log(
  1626. "当前队列顺序:",
  1627. audioQueue.value.map((item) => `${item.name}(${item.order})`)
  1628. );
  1629. // 只有在确实没有音频在播放且这是第一个音频时才开始播放
  1630. if (
  1631. !isPlayingQueueAudio.value &&
  1632. !emotionAudioStore.isPlaying &&
  1633. audioQueue.value.length === 1
  1634. ) {
  1635. console.log("✅ 条件满足:没有音频在播放且这是第一个音频,立即开始播放");
  1636. playNextAudio();
  1637. } else {
  1638. console.log("⏳ 等待条件:", {
  1639. isPlayingQueueAudio: isPlayingQueueAudio.value,
  1640. audioStoreIsPlaying: emotionAudioStore.isPlaying,
  1641. queueLength: audioQueue.value.length,
  1642. reason:
  1643. audioQueue.value.length > 1 ? "队列中已有其他音频" : "有音频正在播放",
  1644. });
  1645. }
  1646. } else {
  1647. console.log("❌ 跳过添加音频:", {
  1648. hasUrl: !!url,
  1649. voiceEnabled: emotionAudioStore.isVoiceEnabled,
  1650. });
  1651. }
  1652. };
  1653. // 修改后的音频播放函数 - 支持多音频播放和同步打字机效果
  1654. function playAudioQueue(
  1655. conclusionData,
  1656. shouldStartTypewriter = false,
  1657. onComplete = null
  1658. ) {
  1659. if (!conclusionData) {
  1660. console.log("没有结论数据,跳过播放");
  1661. return;
  1662. }
  1663. // 检查是否启用了语音功能
  1664. console.log("语音功能状态:", emotionAudioStore.isVoiceEnabled);
  1665. if (!emotionAudioStore.isVoiceEnabled) {
  1666. console.log("语音功能已关闭,跳过播放");
  1667. return;
  1668. }
  1669. console.log(
  1670. "开始处理多音频播放...",
  1671. shouldStartTypewriter ? "同时启动打字机效果" : ""
  1672. );
  1673. try {
  1674. // 解析结论数据
  1675. const conclusion =
  1676. typeof conclusionData === "object"
  1677. ? conclusionData
  1678. : JSON.parse(conclusionData);
  1679. // 清空之前的音频队列
  1680. audioQueue.value = [];
  1681. currentPlayIndex = 0;
  1682. isCallingPlayNext = false;
  1683. isPlayingQueueAudio.value = false;
  1684. // 按优先级顺序检查并添加所有可用的音频URL
  1685. const audioSources = [
  1686. { key: "one1_url", name: "one1_url" },
  1687. { key: "one2_url", name: "one2_url" },
  1688. { key: "two_url", name: "two_url" },
  1689. { key: "three_url", name: "three_url" },
  1690. { key: "four_url", name: "four_url" },
  1691. { key: "url", name: "url" },
  1692. { key: "audioUrl", name: "audioUrl" },
  1693. { key: "voice_url", name: "voice_url" },
  1694. { key: "audio", name: "audio" },
  1695. { key: "tts_url", name: "tts_url" },
  1696. ];
  1697. audioSources.forEach((source) => {
  1698. if (conclusion[source.key]) {
  1699. const voiceUrl = conclusion[source.key]
  1700. .toString()
  1701. .trim()
  1702. .replace(/[`\s]/g, "");
  1703. if (voiceUrl && voiceUrl.startsWith("http")) {
  1704. console.log(`找到音频URL: ${source.name} = ${voiceUrl}`);
  1705. addToAudioQueue(
  1706. voiceUrl,
  1707. source.name,
  1708. shouldStartTypewriter && audioQueue.value.length === 0,
  1709. onComplete
  1710. );
  1711. }
  1712. }
  1713. });
  1714. if (audioQueue.value.length === 0) {
  1715. console.log("未找到有效的音频URL");
  1716. // 如果没有音频但需要启动打字机效果,直接启动
  1717. if (shouldStartTypewriter) {
  1718. console.log("没有音频但需要启动打字机效果");
  1719. const currentStock = emotionStore.activeStock;
  1720. const stockId = currentStock ? getStockUniqueId(currentStock) : null;
  1721. startTypewriterEffect(conclusion, stockId, onComplete);
  1722. }
  1723. } else {
  1724. console.log(`总共找到 ${audioQueue.value.length} 个音频,准备播放`);
  1725. // 设置当前股票的音频播放状态为播放中(自动播放时按钮应该是亮的)
  1726. const currentStock = emotionStore.activeStock;
  1727. if (currentStock) {
  1728. console.log('设置当前股票音频状态为播放中:', currentStock.stockInfo?.name);
  1729. setStockAudioState(currentStock, { isPlaying: true, isPaused: false });
  1730. }
  1731. }
  1732. } catch (error) {
  1733. console.error("处理音频播放失败:", error);
  1734. }
  1735. }
  1736. // 原有的单音频播放函数(保持兼容性)
  1737. function playAudio(url) {
  1738. console.log("尝试播放音频:", url);
  1739. if (!url) {
  1740. console.warn("音频URL为空,跳过播放");
  1741. isAudioPlaying.value = false;
  1742. return;
  1743. }
  1744. // 检查是否启用了语音功能
  1745. console.log("语音功能状态:", emotionAudioStore.isVoiceEnabled);
  1746. if (!emotionAudioStore.isVoiceEnabled) {
  1747. console.log("语音功能已关闭,跳过播放");
  1748. return;
  1749. }
  1750. console.log("开始创建音频实例...");
  1751. try {
  1752. // 设置当前音频URL
  1753. emotionAudioStore.setCurrentAudioUrl(url);
  1754. // 停止之前的音频
  1755. if (emotionAudioStore.nowSound && emotionAudioStore.nowSound.playing()) {
  1756. emotionAudioStore.nowSound.stop();
  1757. }
  1758. // 创建新的音频实例
  1759. const newSound = new Howl({
  1760. src: [url],
  1761. html5: true,
  1762. format: ["mp3", "wav"],
  1763. onplay: () => {
  1764. isAudioPlaying.value = true;
  1765. emotionAudioStore.isPlaying = true;
  1766. console.log("开始播放场景应用语音");
  1767. // 设置当前股票的音频播放状态为播放中
  1768. const currentStock = emotionStore.activeStock;
  1769. if (currentStock) {
  1770. setStockAudioState(currentStock, { isPlaying: true, isPaused: false });
  1771. console.log('设置当前股票音频状态为播放中:', currentStock.stockInfo?.name);
  1772. }
  1773. // 音频开始播放时的自动滚动已移除
  1774. },
  1775. onend: () => {
  1776. isAudioPlaying.value = false;
  1777. emotionAudioStore.isPlaying = false;
  1778. emotionAudioStore.isPaused = false;
  1779. emotionAudioStore.playbackPosition = 0;
  1780. console.log("场景应用语音播放结束");
  1781. // 重置当前股票的音频播放状态
  1782. const currentStock = emotionStore.activeStock;
  1783. if (currentStock) {
  1784. setStockAudioState(currentStock, { isPlaying: false, isPaused: false });
  1785. console.log('重置当前股票音频状态:', currentStock.stockInfo?.name);
  1786. }
  1787. },
  1788. onstop: () => {
  1789. isAudioPlaying.value = false;
  1790. emotionAudioStore.isPlaying = false;
  1791. console.log("场景应用语音播放停止");
  1792. // 重置当前股票的音频播放状态
  1793. const currentStock = emotionStore.activeStock;
  1794. if (currentStock) {
  1795. setStockAudioState(currentStock, { isPlaying: false, isPaused: false });
  1796. console.log('重置当前股票音频状态:', currentStock.stockInfo?.name);
  1797. }
  1798. },
  1799. onpause: () => {
  1800. isAudioPlaying.value = false;
  1801. emotionAudioStore.isPlaying = false;
  1802. console.log("场景应用语音播放暂停");
  1803. // 设置当前股票的音频播放状态为暂停
  1804. const currentStock = emotionStore.activeStock;
  1805. if (currentStock) {
  1806. setStockAudioState(currentStock, { isPlaying: false, isPaused: true });
  1807. console.log('设置当前股票音频状态为暂停:', currentStock.stockInfo?.name);
  1808. }
  1809. },
  1810. onerror: (error) => {
  1811. isAudioPlaying.value = false;
  1812. emotionAudioStore.isPlaying = false;
  1813. console.error("音频播放错误:", error);
  1814. },
  1815. onload: () => {
  1816. // 音频加载完成,获取时长
  1817. emotionAudioStore.duration = newSound.duration();
  1818. console.log("音频加载完成,时长:", emotionAudioStore.duration);
  1819. },
  1820. });
  1821. // 保存音频实例到store
  1822. emotionAudioStore.nowSound = newSound;
  1823. emotionAudioStore.setAudioInstance(newSound);
  1824. // 播放音频
  1825. newSound.play();
  1826. } catch (error) {
  1827. console.error("创建音频实例失败:", error);
  1828. isAudioPlaying.value = false;
  1829. }
  1830. }
  1831. // 停止音频播放
  1832. function stopAudio() {
  1833. if (emotionAudioStore.nowSound) {
  1834. emotionAudioStore.nowSound.stop();
  1835. }
  1836. isAudioPlaying.value = false;
  1837. }
  1838. // 触发图片旋转的方法
  1839. function startImageRotation() {
  1840. isRotating.value = true;
  1841. // 如果你想在一段时间后停止旋转,可以添加以下代码
  1842. setTimeout(() => {
  1843. isRotating.value = false;
  1844. }, 5000); // 5 秒后停止旋转
  1845. }
  1846. // 显示思考过程
  1847. async function showThinkingProcess(stockName = null) {
  1848. // 第一步:正在思考
  1849. const thinkingMessage1 = reactive({
  1850. sender: "ai",
  1851. text: "AI情绪大模型正在思考",
  1852. gif: thinkingGif,
  1853. flag: true, // 添加flag属性以显示动态加载点
  1854. });
  1855. messages.value.push(thinkingMessage1);
  1856. await new Promise((resolve) => setTimeout(resolve, 1500));
  1857. messages.value.pop();
  1858. // 第二步:正在解析关键数据(持续显示直到获取到股票名称)
  1859. const thinkingMessage2 = reactive({
  1860. sender: "ai",
  1861. text: "正在解析关键数据",
  1862. gif: analyzeGif,
  1863. flag: true, // 添加flag属性以显示动态加载点
  1864. });
  1865. messages.value.push(thinkingMessage2);
  1866. // 如果没有股票名称,保持第二步显示
  1867. if (!stockName) {
  1868. return thinkingMessage2; // 返回消息引用,以便后续更新
  1869. }
  1870. // 有股票名称后,继续后续步骤
  1871. await new Promise((resolve) => setTimeout(resolve, 1500));
  1872. messages.value.pop();
  1873. // 第三步:生成具体股票的量子四维矩阵图
  1874. const thinkingMessage3 = reactive({
  1875. sender: "ai",
  1876. text: `正在生成${stockName}量子四维矩阵图`,
  1877. gif: generateGif,
  1878. flag: true, // 添加flag属性以显示动态加载点
  1879. });
  1880. messages.value.push(thinkingMessage3);
  1881. await new Promise((resolve) => setTimeout(resolve, 1500));
  1882. messages.value.pop();
  1883. // 第四步:报告已生成
  1884. const thinkingMessage4 = reactive({ sender: "ai", text: "报告已生成!" });
  1885. messages.value.push(thinkingMessage4);
  1886. await new Promise((resolve) => setTimeout(resolve, 1500));
  1887. messages.value.pop();
  1888. return null;
  1889. }
  1890. // 继续思考过程(当获取到股票名称后调用)
  1891. async function continueThinkingProcess(thinkingMessageRef, stockName) {
  1892. if (!thinkingMessageRef || !stockName) return;
  1893. // 等待一段时间后继续
  1894. await new Promise((resolve) => setTimeout(resolve, 1500));
  1895. // 移除第二步消息
  1896. const index = messages.value.indexOf(thinkingMessageRef);
  1897. if (index > -1) {
  1898. messages.value.splice(index, 1);
  1899. }
  1900. // 第三步:生成具体股票的量子四维矩阵图
  1901. const thinkingMessage3 = reactive({
  1902. sender: "ai",
  1903. text: `正在生成${stockName}量子四维矩阵图`,
  1904. gif: generateGif,
  1905. flag: true, // 添加flag属性以显示动态加载点
  1906. });
  1907. messages.value.push(thinkingMessage3);
  1908. // 返回第三步消息的引用,以便后续处理
  1909. return thinkingMessage3;
  1910. }
  1911. // 完成思考过程(当第二个工作流接口成功后调用)
  1912. async function finishThinkingProcess(thinkingMessage3Ref) {
  1913. if (!thinkingMessage3Ref) return;
  1914. // 等待一段时间
  1915. await new Promise((resolve) => setTimeout(resolve, 1500));
  1916. // 移除第三步消息
  1917. const index = messages.value.indexOf(thinkingMessage3Ref);
  1918. if (index > -1) {
  1919. messages.value.splice(index, 1);
  1920. }
  1921. // 第四步:报告已生成
  1922. const thinkingMessage4 = reactive({ sender: "ai", text: "报告已生成!" });
  1923. messages.value.push(thinkingMessage4);
  1924. await new Promise((resolve) => setTimeout(resolve, 1500));
  1925. messages.value.pop();
  1926. }
  1927. // 发送消息方法
  1928. async function handleSendMessage(input, onComplete) {
  1929. console.log("发送内容:", input);
  1930. // 标记为用户主动搜索
  1931. isUserInitiated.value = true;
  1932. // 重置历史记录模式状态,确保正常对话时显示conversation-area
  1933. isHistoryMode.value = false;
  1934. // 检查用户输入内容是否为空
  1935. if (!input || !input.trim()) {
  1936. ElMessage.warning("输入内容不能为空");
  1937. // 调用完成回调,重新启用输入框
  1938. if (onComplete && typeof onComplete === "function") {
  1939. onComplete();
  1940. // 清除保存的回调函数
  1941. currentOnCompleteCallback.value = null;
  1942. }
  1943. return;
  1944. }
  1945. // 用户输入不为空,立即清空页面内容并触发图片旋转逻辑
  1946. isPageLoaded.value = false; // 立即隐藏页面内容
  1947. isRotating.value = true;
  1948. const previousMessages = [...messages.value]; // 保存历史消息
  1949. messages.value = []; // 清空历史数据
  1950. // 添加用户消息(只添加一次)
  1951. const userMessage = reactive({ sender: "user", text: input });
  1952. messages.value.push(userMessage);
  1953. // 将用户消息添加到emotion store中
  1954. emotionStore.addConversation({
  1955. sender: "user",
  1956. text: input,
  1957. timestamp: new Date().toISOString(),
  1958. });
  1959. // 检查用户剩余次数
  1960. // await chatStore.getUserCount(); // 获取最新的用户次数
  1961. // if (chatStore.UserCount <= 0) {
  1962. // const aiMessage = reactive({
  1963. // sender: "ai",
  1964. // text: "您的剩余次数为0,无法使用情绪大模型,请联系客服或购买服务包。",
  1965. // });
  1966. // messages.value.push(aiMessage);
  1967. // // 将AI消息添加到emotion store中
  1968. // emotionStore.addConversation({
  1969. // sender: "ai",
  1970. // text: "您的剩余次数为0,无法使用情绪大模型,请联系客服或购买服务包。",
  1971. // timestamp: new Date().toISOString(),
  1972. // });
  1973. // // 停止图片旋转,恢复历史数据
  1974. // isRotating.value = false;
  1975. // messages.value = [...previousMessages, ...messages.value];
  1976. // // 调用完成回调,重新启用输入框
  1977. // if (onComplete && typeof onComplete === "function") {
  1978. // onComplete();
  1979. // // 清除保存的回调函数
  1980. // currentOnCompleteCallback.value = null;
  1981. // }
  1982. // return;
  1983. // }
  1984. // 开始思考过程(不带股票名称)
  1985. const thinkingMessageRef = await showThinkingProcess();
  1986. let thinkingMessage3Ref = null;
  1987. try {
  1988. // 第一步:调用第一个接口验证用户输入内容是否合法
  1989. // const params = {
  1990. // content: userMessage.text,
  1991. // userData: {
  1992. // token: localStorage.getItem('localToken'),
  1993. // language: "cn",
  1994. // brainPrivilegeState: '1',
  1995. // swordPrivilegeState: '1',
  1996. // stockForecastPrivilegeState: '1',
  1997. // spaceForecastPrivilegeState: '1',
  1998. // aibullPrivilegeState: '1',
  1999. // aigoldBullPrivilegeState: '1',
  2000. // airadarPrivilegeState: '1',
  2001. // marketList: "hk,cn,usa,my,sg,vi,in,gb",
  2002. // },
  2003. // };
  2004. const result = await getReplyAPI({
  2005. token: localStorage.getItem("localToken"),
  2006. language: "cn",
  2007. marketList: "hk,cn,usa,my,sg,vi,in,gb",
  2008. content: userMessage.text,
  2009. });
  2010. const parsedData = result.data;
  2011. console.log("第一个接口返回的完整数据:", parsedData);
  2012. // 根据状态码判断并处理不同情况
  2013. if (result.code === 400) {
  2014. // 状态码400:用户输入内容不合法
  2015. if (thinkingMessageRef) {
  2016. const index = messages.value.indexOf(thinkingMessageRef);
  2017. if (index > -1) {
  2018. messages.value.splice(index, 1);
  2019. }
  2020. }
  2021. isPageLoaded.value = false;
  2022. const refuseMessage = result.msg || "用户输入内容不合法,请重新输入";
  2023. const aiMessage = reactive({
  2024. sender: "ai",
  2025. text: processRefuseMessage(refuseMessage),
  2026. });
  2027. messages.value.push(aiMessage);
  2028. emotionStore.addConversation({
  2029. sender: "ai",
  2030. text: processRefuseMessage(refuseMessage),
  2031. timestamp: new Date().toISOString(),
  2032. });
  2033. isRotating.value = false;
  2034. messages.value = [...previousMessages, ...messages.value];
  2035. nextTick(() => {
  2036. scrollToBottom();
  2037. });
  2038. if (onComplete && typeof onComplete === "function") {
  2039. onComplete();
  2040. currentOnCompleteCallback.value = null;
  2041. }
  2042. return;
  2043. } else if (result.code === 406) {
  2044. // 状态码406:token为0
  2045. if (thinkingMessageRef) {
  2046. const index = messages.value.indexOf(thinkingMessageRef);
  2047. if (index > -1) {
  2048. messages.value.splice(index, 1);
  2049. }
  2050. }
  2051. isPageLoaded.value = false;
  2052. const refuseMessage = result.msg || "您的使用次数已用完,请联系客服或购买服务包";
  2053. // 处理消息中的"获取token次数"文字,将其转换为可点击的链接
  2054. const processedMessage = processRefuseMessage(refuseMessage).replace(
  2055. /获取token次数/g,
  2056. '<span class="token-link" style="color: blue; cursor: pointer; text-decoration: underline;" onclick="window.handleTokenClick()">获取token次数</span>'
  2057. );
  2058. const aiMessage = reactive({
  2059. sender: "ai",
  2060. text: processedMessage,
  2061. isHtml: true, // 标记这是HTML内容
  2062. });
  2063. messages.value.push(aiMessage);
  2064. emotionStore.addConversation({
  2065. sender: "ai",
  2066. text: processedMessage,
  2067. isHtml: true, // 保存HTML标记
  2068. timestamp: new Date().toISOString(),
  2069. });
  2070. isRotating.value = false;
  2071. messages.value = [...previousMessages, ...messages.value];
  2072. nextTick(() => {
  2073. scrollToBottom();
  2074. });
  2075. if (onComplete && typeof onComplete === "function") {
  2076. onComplete();
  2077. currentOnCompleteCallback.value = null;
  2078. }
  2079. return;
  2080. } else if (result.code !== 200) {
  2081. // 其他非200状态码,显示通用错误信息
  2082. if (thinkingMessageRef) {
  2083. const index = messages.value.indexOf(thinkingMessageRef);
  2084. if (index > -1) {
  2085. messages.value.splice(index, 1);
  2086. }
  2087. }
  2088. isPageLoaded.value = false;
  2089. const refuseMessage = result.msg || "系统异常,请稍后再试";
  2090. const aiMessage = reactive({
  2091. sender: "ai",
  2092. text: processRefuseMessage(refuseMessage),
  2093. });
  2094. messages.value.push(aiMessage);
  2095. emotionStore.addConversation({
  2096. sender: "ai",
  2097. text: processRefuseMessage(refuseMessage),
  2098. timestamp: new Date().toISOString(),
  2099. });
  2100. isRotating.value = false;
  2101. messages.value = [...previousMessages, ...messages.value];
  2102. nextTick(() => {
  2103. scrollToBottom();
  2104. });
  2105. if (onComplete && typeof onComplete === "function") {
  2106. onComplete();
  2107. currentOnCompleteCallback.value = null;
  2108. }
  2109. return;
  2110. }
  2111. // 状态码200:用户输入内容合法,检查数据完整性
  2112. if (!parsedData || !parsedData.market || !parsedData.code) {
  2113. // 输入不合法,先清理思考过程消息
  2114. if (thinkingMessageRef) {
  2115. const index = messages.value.indexOf(thinkingMessageRef);
  2116. if (index > -1) {
  2117. messages.value.splice(index, 1);
  2118. }
  2119. }
  2120. // 关闭加载状态和等待提示,返回refuse信息,停止图片旋转,恢复历史数据
  2121. // isLoading.value = false;
  2122. isPageLoaded.value = false;
  2123. const refuseMessage = result && result.msg ? result.msg : "系统正在为您努力加载中,请稍后再试";
  2124. const aiMessage = reactive({
  2125. sender: "ai",
  2126. text: processRefuseMessage(refuseMessage),
  2127. });
  2128. messages.value.push(aiMessage);
  2129. // 将AI消息添加到emotion store中
  2130. emotionStore.addConversation({
  2131. sender: "ai",
  2132. text: processRefuseMessage(refuseMessage),
  2133. timestamp: new Date().toISOString(),
  2134. });
  2135. isRotating.value = false;
  2136. messages.value = [...previousMessages, ...messages.value];
  2137. // 第一个接口请求失败后触发自动滚动
  2138. nextTick(() => {
  2139. scrollToBottom();
  2140. });
  2141. // 调用完成回调,重新启用输入框
  2142. if (onComplete && typeof onComplete === "function") {
  2143. onComplete();
  2144. // 清除保存的回调函数
  2145. currentOnCompleteCallback.value = null;
  2146. }
  2147. return;
  2148. }
  2149. // 输入合法,继续执行后续处理
  2150. // 获取到股票名称后,继续思考过程
  2151. if (thinkingMessageRef && parsedData.name) {
  2152. thinkingMessage3Ref = await continueThinkingProcess(
  2153. thinkingMessageRef,
  2154. parsedData.name
  2155. );
  2156. }
  2157. // 设置加载状态,隐藏图表页面
  2158. // isLoading.value = true;
  2159. isPageLoaded.value = false;
  2160. // 调用第二个工作流接口
  2161. const conclusionParams = {
  2162. recordId: parsedData.recordId,
  2163. parentId: parsedData.parentId,
  2164. stockId: parsedData.stockId,
  2165. token: localStorage.getItem("localToken"),
  2166. language: "cn",
  2167. };
  2168. console.log("第二个接口参数:", conclusionParams);
  2169. // 在Promise.all调用前添加股票唯一标识生成和判断逻辑
  2170. const stockUniqueId = `${parsedData.code}_${parsedData.market}_${new Date().toISOString()}`;
  2171. const isFirstTime = !stockTypewriterShown.value.has(stockUniqueId);
  2172. // 提前设置打字机状态,避免渲染时机问题
  2173. if (isFirstTime && isUserInitiated.value) {
  2174. // 预设为打字机模式
  2175. console.log('预设股票为打字机模式:', parsedData.name);
  2176. stockTypewriterTexts.value.set(stockUniqueId, {
  2177. one1: "", one2: "", two: "", three: "", four: "", disclaimer: ""
  2178. });
  2179. stockTypewriterVisibility.value.set(stockUniqueId, {
  2180. one: false, two: false, three: false, four: false, disclaimer: false
  2181. });
  2182. } else {
  2183. // 预设为完整显示模式
  2184. console.log('预设股票为完整显示模式:', parsedData.name);
  2185. stockTypewriterTexts.value.delete(stockUniqueId);
  2186. stockTypewriterVisibility.value.delete(stockUniqueId);
  2187. // 如果是第一次但非用户主动搜索,标记为已显示
  2188. if (isFirstTime) {
  2189. stockTypewriterShown.value.set(stockUniqueId, true);
  2190. stockAudioPlayed.value.set(stockUniqueId, true);
  2191. }
  2192. }
  2193. // 同时调用第二个数据流接口和fetchData方法
  2194. const [conclusionResult, fetchDataResult] = await Promise.all([
  2195. getConclusionAPI(conclusionParams),
  2196. fetchData(
  2197. parsedData.code,
  2198. parsedData.market,
  2199. parsedData.name || "未知股票",
  2200. input.trim(),
  2201. parsedData.stockId,
  2202. stockUniqueId // 传递预生成的唯一标识
  2203. ),
  2204. ]);
  2205. // 处理结论接口返回的数据
  2206. const conclusionResponse = conclusionResult;
  2207. // 检查getConclusionAPI是否成功
  2208. if (conclusionResponse && conclusionResponse.code !== 200) {
  2209. // getConclusionAPI失败,清理第三步思考过程消息
  2210. if (thinkingMessage3Ref) {
  2211. const index = messages.value.indexOf(thinkingMessage3Ref);
  2212. if (index > -1) {
  2213. messages.value.splice(index, 1);
  2214. }
  2215. }
  2216. // 使用getConclusionAPI返回的msg在对话界面中输出
  2217. const errorMsg = conclusionResponse.msg || "系统正在为您努力加载中,请稍后再试";
  2218. const aiMessage = reactive({
  2219. sender: "ai",
  2220. text: errorMsg,
  2221. });
  2222. messages.value.push(aiMessage);
  2223. // 停止图片旋转,恢复历史数据
  2224. isRotating.value = false;
  2225. messages.value = [...previousMessages, ...messages.value];
  2226. // 如果有之前的股票数据且页面已加载,重新渲染图表
  2227. // if (
  2228. // isPageLoaded.value &&
  2229. // emotionStore.activeStock &&
  2230. // emotionStore.activeStock.apiData
  2231. // ) {
  2232. // nextTick(() => {
  2233. // renderCharts(emotionStore.activeStock.apiData);
  2234. // console.log(
  2235. // "第二个接口失败,恢复显示之前股票的图表:",
  2236. // emotionStore.activeStock.stockInfo.name
  2237. // );
  2238. // });
  2239. // }
  2240. // 调用完成回调,重新启用输入框
  2241. if (onComplete && typeof onComplete === "function") {
  2242. onComplete();
  2243. currentOnCompleteCallback.value = null;
  2244. }
  2245. return;
  2246. }
  2247. // 检查所有数据是否都加载成功
  2248. if (conclusionResponse && conclusionResponse.data && fetchDataResult) {
  2249. // 第二个工作流接口成功,完成思考过程
  2250. if (thinkingMessage3Ref) {
  2251. await finishThinkingProcess(thinkingMessage3Ref);
  2252. }
  2253. // 将结论数据存储到响应式变量和store中
  2254. conclusionData.value = conclusionResponse.data;
  2255. console.log("第二个接口返回的完整数据结构:", conclusionResponse.data);
  2256. // 将结论数据存储到store中的当前激活股票
  2257. emotionStore.updateActiveStockConclusion(conclusionResponse.data);
  2258. // 状态初始化现在由isStockStateReady方法自动处理,避免重复设置
  2259. const stockUniqueId = getStockUniqueId(parsedData);
  2260. if (stockUniqueId) {
  2261. // 强制触发响应式更新,确保状态准备就绪
  2262. nextTick(() => {
  2263. console.log('数据加载完成,股票状态准备就绪:', parsedData.name, 'isReady:', isStockStateReady(parsedData));
  2264. });
  2265. }
  2266. // 所有数据加载完成,关闭加载状态,显示页面
  2267. // isLoading.value = false;
  2268. isPageLoaded.value = true;
  2269. // 使用nextTick确保DOM更新后清空对话显示
  2270. nextTick(() => {
  2271. messages.value = [];
  2272. // 清空已添加股票的记录,避免重复添加
  2273. addedStocks.value.clear();
  2274. // 搜索新数据成功,但不启用内部自动滚动监听器,避免与父组件冲突
  2275. shouldEnableAutoScroll.value = false;
  2276. // 只通知父组件滚动到底部,不启动内部监听器
  2277. scrollToBottom();
  2278. });
  2279. // 数据获取成功后,重新获取用户次数以实现实时更新
  2280. try {
  2281. await chatStore.getUserCount();
  2282. console.log("数据获取成功后,用户次数已更新");
  2283. } catch (error) {
  2284. console.error("更新用户次数失败:", error);
  2285. }
  2286. // 重新调用获取历史记录的接口
  2287. try {
  2288. chatStore.searchRecord = true;
  2289. console.log("getConclusionAPI成功后,已触发历史记录更新");
  2290. } catch (error) {
  2291. console.error("触发历史记录更新失败:", error);
  2292. }
  2293. // 确保页面状态更新后触发图表渲染和音频文本
  2294. nextTick(() => {
  2295. if (currentStock.value && currentStock.value.apiData) {
  2296. renderCharts(currentStock.value.apiData);
  2297. // 只有在用户主动搜索时才自动触发音频和文本
  2298. if (
  2299. isUserInitiated.value &&
  2300. parsedConclusion.value &&
  2301. audioUrl.value
  2302. ) {
  2303. const stockUniqueId = getStockUniqueId(currentStock.value);
  2304. if (stockUniqueId && !stockTypewriterShown.value.has(stockUniqueId)) {
  2305. if (!stockAudioPlayed.value.has(stockUniqueId)) {
  2306. stockAudioPlayed.value.set(stockUniqueId, true);
  2307. playAudioQueue(parsedConclusion.value, true, onComplete);
  2308. } else {
  2309. // 如果音频已播放过,只启动打字机效果
  2310. startTypewriterEffect(parsedConclusion.value, stockUniqueId, onComplete);
  2311. }
  2312. stockTypewriterShown.value.set(stockUniqueId, true);
  2313. } else {
  2314. // 如果不需要打字机效果,直接调用完成回调
  2315. if (onComplete && typeof onComplete === "function") {
  2316. onComplete();
  2317. // 清除保存的回调函数
  2318. currentOnCompleteCallback.value = null;
  2319. }
  2320. }
  2321. }
  2322. // 重置用户主动搜索标志
  2323. isUserInitiated.value = false;
  2324. }
  2325. });
  2326. } else {
  2327. // 数据加载失败,清理第三步思考过程消息
  2328. if (thinkingMessage3Ref) {
  2329. const index = messages.value.indexOf(thinkingMessage3Ref);
  2330. if (index > -1) {
  2331. messages.value.splice(index, 1);
  2332. }
  2333. }
  2334. // 数据加载失败,停止图片旋转,恢复历史数据
  2335. // isLoading.value = false;
  2336. // 如果 fetchDataResult 为 false,说明数据不完整的错误信息已经在 fetchData 中添加到 messages
  2337. // 只有在 conclusionResponse 有问题时才添加通用错误信息
  2338. if (!conclusionResponse || !conclusionResponse.data) {
  2339. const aiMessage = reactive({
  2340. sender: "ai",
  2341. text: "系统正在为您努力加载中,请稍后再试",
  2342. });
  2343. messages.value.push(aiMessage);
  2344. }
  2345. isRotating.value = false;
  2346. messages.value = [...previousMessages, ...messages.value];
  2347. // 如果有之前的股票数据且页面已加载,重新渲染图表
  2348. if (
  2349. isPageLoaded.value &&
  2350. emotionStore.activeStock &&
  2351. emotionStore.activeStock.apiData
  2352. ) {
  2353. nextTick(() => {
  2354. renderCharts(emotionStore.activeStock.apiData);
  2355. console.log(
  2356. "搜索失败,恢复显示之前股票的图表:",
  2357. emotionStore.activeStock.stockInfo.name
  2358. );
  2359. });
  2360. }
  2361. // 调用完成回调,重新启用输入框
  2362. if (onComplete && typeof onComplete === "function") {
  2363. onComplete();
  2364. // 清除保存的回调函数
  2365. currentOnCompleteCallback.value = null;
  2366. }
  2367. return;
  2368. }
  2369. } catch (error) {
  2370. // 请求失败,清理第三步思考过程消息
  2371. if (thinkingMessage3Ref) {
  2372. const index = messages.value.indexOf(thinkingMessage3Ref);
  2373. if (index > -1) {
  2374. messages.value.splice(index, 1);
  2375. }
  2376. }
  2377. // 请求失败时关闭加载状态
  2378. // isLoading.value = false;
  2379. // 如果有之前的股票数据,恢复显示状态;否则设置为false
  2380. if (emotionStore.stockList.length > 0 && emotionStore.activeStock) {
  2381. isPageLoaded.value = true;
  2382. // 使用nextTick确保DOM更新后清空对话显示并启动高度监听器
  2383. nextTick(() => {
  2384. messages.value = [];
  2385. // 搜索失败恢复场景,不启用自动滚动
  2386. shouldEnableAutoScroll.value = false;
  2387. // 不启动内部滚动监听器,避免与父组件冲突
  2388. // 只通知父组件滚动到底部
  2389. scrollToBottom();
  2390. });
  2391. console.log("请求工作流接口失败,但恢复显示之前的股票数据");
  2392. // 立即渲染之前股票的图表,提升用户体验
  2393. nextTick(() => {
  2394. renderCharts(emotionStore.activeStock.apiData);
  2395. console.log(
  2396. "立即恢复显示之前股票的图表:",
  2397. emotionStore.activeStock.stockInfo.name
  2398. );
  2399. });
  2400. } else {
  2401. isPageLoaded.value = false;
  2402. }
  2403. // 请求失败时停止图片旋转,恢复历史数据
  2404. isRotating.value = false;
  2405. messages.value = [...previousMessages, ...messages.value];
  2406. // 如果有之前的股票数据且页面已加载,重新渲染图表
  2407. if (
  2408. isPageLoaded.value &&
  2409. emotionStore.activeStock &&
  2410. emotionStore.activeStock.apiData
  2411. ) {
  2412. nextTick(() => {
  2413. renderCharts(emotionStore.activeStock.apiData);
  2414. console.log(
  2415. "请求失败,恢复显示之前股票的图表:",
  2416. emotionStore.activeStock.stockInfo.name
  2417. );
  2418. });
  2419. }
  2420. // 调用完成回调,重新启用输入框
  2421. if (onComplete && typeof onComplete === "function") {
  2422. onComplete();
  2423. // 清除保存的回调函数
  2424. currentOnCompleteCallback.value = null;
  2425. }
  2426. return;
  2427. } finally {
  2428. // 停止图片旋转(只有在设置了旋转状态时才需要停止)
  2429. if (isRotating.value) {
  2430. isRotating.value = false;
  2431. }
  2432. }
  2433. }
  2434. // 请求数据接口
  2435. async function fetchData(code, market, stockName, queryText, stockId, presetUniqueId = null) {
  2436. try {
  2437. const stockDataParams = {
  2438. stockId: stockId,
  2439. };
  2440. const stockDataResult = await axios.post(
  2441. // "http://39.101.133.168:8828/link/api/aiEmotion/client/getAiEmotionData",
  2442. `${APIurl}/api/workflow/getStockData`,
  2443. stockDataParams,
  2444. {
  2445. headers: {
  2446. "Content-Type": "application/json",
  2447. },
  2448. }
  2449. );
  2450. const stockDataResponse = stockDataResult.data; // 获取返回所有的数据
  2451. if (stockDataResponse.code === 200 && stockDataResponse.data) {
  2452. // 检查关键数据字段是否完整
  2453. const validation = validateRequiredFields(stockDataResponse.data);
  2454. // 如果有关键数据缺失,返回失败,不添加到StockTabs
  2455. if (!validation.isValid) {
  2456. console.log("API返回数据不完整,缺失字段:", validation.missingFields);
  2457. // 关闭加载状态
  2458. // isLoading.value = false;
  2459. // 如果有之前的股票数据,恢复显示状态;否则设置为false
  2460. if (emotionStore.stockList.length > 0 && emotionStore.activeStock) {
  2461. isPageLoaded.value = true;
  2462. // 使用nextTick确保DOM更新后清空对话显示并启动高度监听器
  2463. nextTick(() => {
  2464. messages.value = [];
  2465. // 数据验证失败恢复场景,不启用自动滚动
  2466. shouldEnableAutoScroll.value = false;
  2467. // 不启动内部滚动监听器,避免与父组件冲突
  2468. // 只通知父组件滚动到底部
  2469. scrollToBottom();
  2470. });
  2471. console.log("数据验证失败,但恢复显示之前的股票数据");
  2472. // 立即渲染之前股票的图表,提升用户体验
  2473. nextTick(() => {
  2474. renderCharts(emotionStore.activeStock.apiData);
  2475. console.log(
  2476. "立即恢复显示之前股票的图表:",
  2477. emotionStore.activeStock.stockInfo.name
  2478. );
  2479. });
  2480. } else {
  2481. isPageLoaded.value = false;
  2482. }
  2483. const aiMessage = reactive({
  2484. sender: "ai",
  2485. text: `系统正在为您努力加载中,请稍后再试`,
  2486. });
  2487. messages.value.push(aiMessage);
  2488. // 将AI消息添加到emotion store中
  2489. emotionStore.addConversation({
  2490. sender: "ai",
  2491. text: "系统正在为您努力加载中,请稍后再试",
  2492. timestamp: new Date().toISOString(),
  2493. });
  2494. return false; // 返回失败标识,不添加股票到标签
  2495. }
  2496. // 只有数据完整时才创建股票数据对象并添加到store
  2497. const stockData = {
  2498. queryText: queryText,
  2499. stockInfo: {
  2500. name: stockName,
  2501. code: code,
  2502. market: market,
  2503. },
  2504. apiData: stockDataResponse.data,
  2505. conclusionData: conclusionData.value, // 包含结论数据
  2506. timestamp: new Date().toISOString(),
  2507. uniqueId: presetUniqueId || `${code}_${market}_${new Date().toISOString()}`, // 添加唯一标识
  2508. };
  2509. // 将股票数据添加到store中,显示在StockTabs中
  2510. emotionStore.addStock(stockData);
  2511. return true; // 返回成功标识
  2512. } else {
  2513. // 关闭加载状态
  2514. // isLoading.value = false;
  2515. // 如果有之前的股票数据,恢复显示状态;否则设置为false
  2516. if (emotionStore.stockList.length > 0 && emotionStore.activeStock) {
  2517. isPageLoaded.value = true;
  2518. // 使用nextTick确保DOM更新后清空对话显示并启动高度监听器
  2519. nextTick(() => {
  2520. messages.value = [];
  2521. // API请求失败恢复场景,不启用自动滚动
  2522. shouldEnableAutoScroll.value = false;
  2523. // 不启动内部滚动监听器,避免与父组件冲突
  2524. // 只通知父组件滚动到底部
  2525. scrollToBottom();
  2526. });
  2527. console.log("API请求失败,但恢复显示之前的股票数据");
  2528. // 立即渲染之前股票的图表,提升用户体验
  2529. nextTick(() => {
  2530. renderCharts(emotionStore.activeStock.apiData);
  2531. console.log(
  2532. "立即恢复显示之前股票的图表:",
  2533. emotionStore.activeStock.stockInfo.name
  2534. );
  2535. });
  2536. } else {
  2537. isPageLoaded.value = false;
  2538. }
  2539. const aiMessage = reactive({
  2540. sender: "ai",
  2541. text: "系统正在为您努力加载中,请稍后再试",
  2542. });
  2543. messages.value.push(aiMessage);
  2544. // 将AI消息添加到emotion store中
  2545. emotionStore.addConversation({
  2546. sender: "ai",
  2547. text: "系统正在为您努力加载中,请稍后再试",
  2548. timestamp: new Date().toISOString(),
  2549. });
  2550. return false; // 返回失败标识
  2551. }
  2552. } catch (error) {
  2553. // 关闭加载状态
  2554. // isLoading.value = false;
  2555. // 如果有之前的股票数据,恢复显示状态;否则设置为false
  2556. if (emotionStore.stockList.length > 0 && emotionStore.activeStock) {
  2557. isPageLoaded.value = true;
  2558. // 使用nextTick确保DOM更新后清空对话显示并启动高度监听器
  2559. nextTick(() => {
  2560. messages.value = [];
  2561. // 网络异常恢复场景,不启用自动滚动
  2562. shouldEnableAutoScroll.value = false;
  2563. // 不启动内部滚动监听器,避免与父组件冲突
  2564. // 只通知父组件滚动到底部
  2565. scrollToBottom();
  2566. });
  2567. console.log("网络异常,但恢复显示之前的股票数据");
  2568. // 立即渲染之前股票的图表,提升用户体验
  2569. nextTick(() => {
  2570. renderCharts(emotionStore.activeStock.apiData);
  2571. console.log(
  2572. "立即恢复显示之前股票的图表:",
  2573. emotionStore.activeStock.stockInfo.name
  2574. );
  2575. });
  2576. } else {
  2577. isPageLoaded.value = false;
  2578. }
  2579. const aiMessage = reactive({
  2580. sender: "ai",
  2581. text: "系统正在为您努力加载中,请稍后再试",
  2582. });
  2583. messages.value.push(aiMessage);
  2584. // 将AI消息添加到emotion store中
  2585. emotionStore.addConversation({
  2586. sender: "ai",
  2587. text: "系统正在为您努力加载中,请稍后再试",
  2588. timestamp: new Date().toISOString(),
  2589. });
  2590. return false; // 返回失败标识
  2591. }
  2592. }
  2593. // 检查关键数据字段是否完整的函数
  2594. function validateRequiredFields(data) {
  2595. const requiredFields = ["GSWDJ", "KLine20", "QXJMQ", "QXTDLD", "WDRL"];
  2596. const missingFields = [];
  2597. for (const field of requiredFields) {
  2598. if (
  2599. !data[field] ||
  2600. (Array.isArray(data[field]) && data[field].length === 0) ||
  2601. (typeof data[field] === "object" && !hasValidData(data[field]))
  2602. ) {
  2603. missingFields.push(field);
  2604. }
  2605. }
  2606. return {
  2607. isValid: missingFields.length === 0,
  2608. missingFields: missingFields,
  2609. };
  2610. }
  2611. // 检查对象是否包含有效数据的辅助函数
  2612. function hasValidData(obj) {
  2613. if (!obj || typeof obj !== "object") {
  2614. return false;
  2615. }
  2616. // 定义可以为空的数组字段
  2617. const allowedEmptyArrays = ["lowxh", "qixh", "topxh"];
  2618. // 检查对象的所有属性值
  2619. for (const key in obj) {
  2620. if (obj.hasOwnProperty(key)) {
  2621. const value = obj[key];
  2622. // 如果是字符串字段
  2623. if (typeof value === "string") {
  2624. // 字符串字段必须有内容,为空则表示异常
  2625. if (value.trim() !== "") {
  2626. return true;
  2627. }
  2628. }
  2629. // 如果是数组字段
  2630. else if (Array.isArray(value)) {
  2631. // 数组字段可以为空,但如果有内容则表示有效
  2632. if (value.length > 0) {
  2633. return true;
  2634. }
  2635. }
  2636. // 如果是数字且不为0
  2637. else if (typeof value === "number" && value !== 0) {
  2638. return true;
  2639. }
  2640. // 如果是布尔值且为true
  2641. else if (typeof value === "boolean" && value === true) {
  2642. return true;
  2643. }
  2644. // 如果是对象且包含有效数据(递归检查)
  2645. else if (typeof value === "object" && value !== null) {
  2646. if (hasValidData(value)) {
  2647. return true;
  2648. }
  2649. }
  2650. }
  2651. }
  2652. return false;
  2653. }
  2654. // 依次渲染图表的方法 - 支持多个股票
  2655. async function renderChartsSequentially(clonedData, stockIndex = 0) {
  2656. console.log(`开始渲染第${stockIndex}个股票的图表`);
  2657. // 定义图表渲染顺序和配置
  2658. const chartConfigs = [
  2659. {
  2660. name: "股市温度计",
  2661. ref: marketTemperatureRef.value[stockIndex],
  2662. visibility: chartVisibility.value.marketTemperature,
  2663. method: "initChart",
  2664. params: [clonedData.GSWDJ, clonedData.KLine20, clonedData.WDRL],
  2665. },
  2666. {
  2667. name: "情绪解码器",
  2668. ref: emotionDecodRef.value[stockIndex],
  2669. visibility: chartVisibility.value.emotionDecod,
  2670. method: "initQXNLZHEcharts",
  2671. params: [clonedData.KLine20, clonedData.QXJMQ],
  2672. },
  2673. {
  2674. name: "情绪探底雷达",
  2675. ref: emotionalBottomRadarRef.value[stockIndex],
  2676. visibility: chartVisibility.value.emotionalBottomRadar,
  2677. method: "initEmotionalBottomRadar",
  2678. params: [clonedData.KLine20, clonedData.QXTDLD],
  2679. },
  2680. {
  2681. name: "情绪能量转化器",
  2682. ref: emoEnergyConverterRef.value[stockIndex],
  2683. visibility: chartVisibility.value.emoEnergyConverter,
  2684. method: "initQXNLZHEcharts",
  2685. params: [clonedData.KLine20, clonedData.QXNLZHQ],
  2686. },
  2687. ];
  2688. // 依次渲染每个图表
  2689. for (const config of chartConfigs) {
  2690. if (config.ref && config.visibility) {
  2691. console.log(`开始渲染第${stockIndex}个股票的${config.name}图表`);
  2692. console.log(`${config.name}Ref方法:`, typeof config.ref[config.method]);
  2693. if (typeof config.ref[config.method] === "function") {
  2694. try {
  2695. // 增加延迟时间,特别是对于第2个及后续股票
  2696. const delay = stockIndex === 0 ? 100 : 300 + (stockIndex * 100);
  2697. await new Promise((resolve) => setTimeout(resolve, delay));
  2698. config.ref[config.method](...config.params);
  2699. console.log(`${stockIndex}个股票的${config.name}图表渲染成功`);
  2700. // 每个图表渲染完成后等待一段时间再渲染下一个
  2701. await new Promise((resolve) => setTimeout(resolve, 800));
  2702. } catch (error) {
  2703. console.error(
  2704. `${stockIndex}个股票的${config.name}图表渲染失败:`,
  2705. error
  2706. );
  2707. }
  2708. } else {
  2709. console.error(
  2710. `${stockIndex}个股票的${config.name}Ref.${config.method} 方法不存在`
  2711. );
  2712. }
  2713. } else {
  2714. console.log(
  2715. `${stockIndex}个股票的${config.name}图表未渲染,ref存在:`,
  2716. !!config.ref,
  2717. "数据存在:",
  2718. config.visibility
  2719. );
  2720. }
  2721. }
  2722. console.log(`${stockIndex}个股票的所有图表依次渲染完成`);
  2723. }
  2724. // 渲染组件图表的方法
  2725. function renderCharts(data) {
  2726. console.log("开始渲染图表,数据:", data);
  2727. // 深拷贝数据避免污染原始数据
  2728. const clonedData = JSON.parse(JSON.stringify(data));
  2729. // 检查关键数据字段是否完整
  2730. const validation = validateRequiredFields(clonedData);
  2731. // 如果有任何关键数据缺失,不渲染页面并返回提示
  2732. if (!validation.isValid) {
  2733. console.log("关键数据缺失:", validation.missingFields);
  2734. const aiMessage = reactive({
  2735. sender: "ai",
  2736. text: `数据不完整,缺少以下关键数据:${validation.missingFields.join(
  2737. "、"
  2738. )}请稍后重试或联系客服`,
  2739. });
  2740. messages.value.push(aiMessage);
  2741. // 将AI消息添加到emotion store中
  2742. emotionStore.addConversation({
  2743. sender: "ai",
  2744. text: `数据不完整,缺少以下关键数据:${validation.missingFields.join(
  2745. "、"
  2746. )}请稍后重试或联系客服`,
  2747. timestamp: new Date().toISOString(),
  2748. });
  2749. // 隐藏页面内容
  2750. isPageLoaded.value = false;
  2751. // isLoading.value = false;
  2752. return; // 直接返回,不进行后续渲染
  2753. }
  2754. // 先设置图表组件显示状态
  2755. chartVisibility.value = {
  2756. marketTemperature: !!(clonedData.GSWDJ && clonedData.GSWDJ.length > 0),
  2757. emotionDecod: !!(clonedData.QXJMQ && clonedData.QXJMQ.length > 0),
  2758. emotionalBottomRadar: !!(clonedData.QXTDLD && clonedData.QXTDLD.length > 0),
  2759. emoEnergyConverter: !!(
  2760. clonedData.QXNLZHQ &&
  2761. (Array.isArray(clonedData.QXNLZHQ)
  2762. ? clonedData.QXNLZHQ.length > 0
  2763. : hasValidData(clonedData.QXNLZHQ))
  2764. ),
  2765. };
  2766. console.log("图表显示状态:", chartVisibility.value);
  2767. console.log("数据检查:", {
  2768. GSWDJ: !!(clonedData.GSWDJ && clonedData.GSWDJ.length > 0),
  2769. QXJMQ: !!(clonedData.QXJMQ && clonedData.QXJMQ.length > 0),
  2770. QXTDLD: !!(clonedData.QXTDLD && clonedData.QXTDLD.length > 0),
  2771. QXNLZHQ: !!(
  2772. clonedData.QXNLZHQ &&
  2773. (Array.isArray(clonedData.QXNLZHQ)
  2774. ? clonedData.QXNLZHQ.length > 0
  2775. : hasValidData(clonedData.QXNLZHQ))
  2776. ),
  2777. });
  2778. console.log("QXNLZHQ数据详情:", clonedData.QXNLZHQ);
  2779. nextTick(() => {
  2780. // 增加延迟确保DOM完全更新和组件完全挂载
  2781. setTimeout(() => {
  2782. try {
  2783. console.log("图表组件ref状态:", {
  2784. marketTemperatureRef: !!marketTemperatureRef.value,
  2785. emotionDecodRef: !!emotionDecodRef.value,
  2786. emotionalBottomRadarRef: !!emotionalBottomRadarRef.value,
  2787. emoEnergyConverterRef: !!emoEnergyConverterRef.value,
  2788. });
  2789. // 检查DOM元素是否存在
  2790. console.log("DOM元素检查:", {
  2791. marketTemperatureDOM: !!document.querySelector(
  2792. ".market-temperature-section"
  2793. ),
  2794. emotionDecodDOM: !!document.querySelector(".emotion-decoder-section"),
  2795. emotionalBottomRadarDOM: !!document.querySelector(
  2796. ".bottom-radar-section"
  2797. ),
  2798. emoEnergyConverterDOM: !!document.querySelector(
  2799. ".energy-converter-section"
  2800. ),
  2801. });
  2802. // 检查具体的组件元素
  2803. const emoEnergyElement = document.querySelector("emo-energy-converter");
  2804. console.log("emoEnergyConverter元素:", emoEnergyElement);
  2805. // 等待更长时间再次检查ref
  2806. setTimeout(() => {
  2807. console.log(
  2808. "延迟检查emoEnergyConverterRef:",
  2809. !!emoEnergyConverterRef.value
  2810. );
  2811. if (emoEnergyConverterRef.value) {
  2812. console.log(
  2813. "emoEnergyConverter方法:",
  2814. typeof emoEnergyConverterRef.value.initQXNLZHEcharts
  2815. );
  2816. }
  2817. }, 1000);
  2818. // 开始依次渲染图表 - 为每个股票渲染
  2819. emotionStore.stockList.forEach((stock, index) => {
  2820. if (stock.apiData) {
  2821. renderChartsSequentially(stock.apiData, index);
  2822. }
  2823. });
  2824. console.log("图表渲染完成");
  2825. } catch (error) {
  2826. console.error("图表渲染错误:", error);
  2827. const aiMessage = reactive({
  2828. sender: "ai",
  2829. text: "图表渲染失败,请重试",
  2830. });
  2831. messages.value.push(aiMessage);
  2832. // 将AI消息添加到emotion store中
  2833. emotionStore.addConversation({
  2834. sender: "ai",
  2835. text: "系统正在为您努力加载中,请稍后再试",
  2836. timestamp: new Date().toISOString(),
  2837. });
  2838. }
  2839. }, 500); // 增加延迟到500ms确保DOM和组件完全稳定
  2840. });
  2841. }
  2842. // scrollToBottom函数已移除
  2843. // 处理用户滚动事件
  2844. const handleUserScroll = () => {
  2845. // 标记用户正在滚动
  2846. isUserScrolling.value = true;
  2847. // 清除之前的定时器
  2848. if (userScrollTimer.value) {
  2849. clearTimeout(userScrollTimer.value);
  2850. }
  2851. // 设置定时器,2秒后恢复自动滚动
  2852. userScrollTimer.value = setTimeout(() => {
  2853. isUserScrolling.value = false;
  2854. console.log("用户滚动检测:恢复自动滚动");
  2855. }, 2000);
  2856. };
  2857. // 处理滚轮事件
  2858. const handleWheel = (event) => {
  2859. handleUserScroll();
  2860. };
  2861. // 处理触摸滚动事件
  2862. const handleTouchMove = (event) => {
  2863. handleUserScroll();
  2864. };
  2865. // 检查数据是否已加载完成
  2866. function isDataLoaded() {
  2867. // 检查页面是否已加载
  2868. if (!isPageLoaded.value) {
  2869. console.log("页面数据尚未加载完成");
  2870. return false;
  2871. }
  2872. // 检查当前股票数据是否存在
  2873. if (!currentStock.value || !currentStock.value.apiData) {
  2874. console.log("股票数据尚未加载完成");
  2875. return false;
  2876. }
  2877. // 检查图表组件是否已渲染 - 检查所有股票的组件
  2878. const stockCount = emotionStore.stockList.length;
  2879. if (stockCount === 0) {
  2880. console.log("没有股票数据");
  2881. return false;
  2882. }
  2883. // 检查每个股票的图表组件是否都已加载
  2884. for (let i = 0; i < stockCount; i++) {
  2885. const requiredRefs = [
  2886. marketTemperatureRef.value[i],
  2887. emotionDecodRef.value[i],
  2888. emotionalBottomRadarRef.value[i],
  2889. emoEnergyConverterRef.value[i],
  2890. ];
  2891. const allRefsLoaded = requiredRefs.every((ref) => ref !== null);
  2892. if (!allRefsLoaded) {
  2893. console.log(`${i}个股票的图表组件尚未完全加载`);
  2894. return false;
  2895. }
  2896. }
  2897. console.log("所有数据和组件已加载完成");
  2898. return true;
  2899. }
  2900. // 自动滚动函数已移除
  2901. // 设置Intersection Observer监听场景应用部分
  2902. function setupIntersectionObserver() {
  2903. // 检查 scenarioApplicationRef.value 是否存在且是有效的 DOM 元素
  2904. if (
  2905. !scenarioApplicationRef.value ||
  2906. !(scenarioApplicationRef.value instanceof Element)
  2907. ) {
  2908. console.warn(
  2909. "scenarioApplicationRef.value 不是有效的 DOM 元素,跳过 IntersectionObserver 设置"
  2910. );
  2911. return;
  2912. }
  2913. const observer = new IntersectionObserver(
  2914. (entries) => {
  2915. entries.forEach((entry) => {
  2916. if (entry.isIntersecting) {
  2917. console.log("场景应用部分进入视口");
  2918. // 获取当前股票唯一标识
  2919. const stockUniqueId = currentStock.value ? getStockUniqueId(currentStock.value) : null;
  2920. if (parsedConclusion.value && stockUniqueId) {
  2921. // 检查该股票是否是第一次触发
  2922. if (!stockTypewriterShown.value.has(stockUniqueId)) {
  2923. // 如果是用户主动搜索,启动打字机效果和音频播放
  2924. if (isUserInitiated.value && audioUrl.value) {
  2925. console.log(
  2926. "用户主动搜索,该股票第一次进入场景应用,开始打字机效果和音频播放"
  2927. );
  2928. // 用户主动搜索时,每次都播放音频和打字机效果
  2929. console.log("开始音频播放和打字机效果");
  2930. stockAudioPlayed.value.set(stockUniqueId, true);
  2931. playAudioQueue(parsedConclusion.value, true);
  2932. stockTypewriterShown.value.set(stockUniqueId, true);
  2933. } else {
  2934. // 非用户主动搜索(如历史记录恢复),直接显示完整内容
  2935. console.log(
  2936. "非用户主动搜索,该股票第一次进入场景应用,直接显示完整内容"
  2937. );
  2938. // 结论内容现在直接通过parsedConclusion计算属性显示
  2939. // 记录该股票已显示过
  2940. stockTypewriterShown.value.set(stockUniqueId, true);
  2941. stockAudioPlayed.value.set(stockUniqueId, true);
  2942. }
  2943. } else {
  2944. // 非第一次或已经触发过:直接显示完整内容,不播放音频和打字机效果
  2945. console.log("非第一次进入场景应用或已触发过,直接显示完整内容");
  2946. // 结论内容现在直接通过parsedConclusion计算属性显示
  2947. }
  2948. }
  2949. }
  2950. });
  2951. },
  2952. {
  2953. threshold: 0.3, // 当30%的元素进入视口时触发
  2954. rootMargin: "0px 0px -100px 0px", // 提前100px触发
  2955. }
  2956. );
  2957. observer.observe(scenarioApplicationRef.value);
  2958. intersectionObserver.value = observer;
  2959. }
  2960. // 手动触发自动滚动函数已移除
  2961. // 返回顶部功能
  2962. const scrollToTop = () => {
  2963. const topAnchor = document.getElementById("top-anchor");
  2964. if (topAnchor) {
  2965. topAnchor.scrollIntoView({
  2966. behavior: "smooth",
  2967. block: "start",
  2968. inline: "nearest",
  2969. });
  2970. } else {
  2971. window.scrollTo({ top: 0, behavior: "smooth" });
  2972. }
  2973. // 备用方案:直接滚动到页面顶部
  2974. setTimeout(() => {
  2975. const currentScrollTop =
  2976. window.pageYOffset || document.documentElement.scrollTop;
  2977. if (currentScrollTop > 50) {
  2978. document.documentElement.scrollTop = 0;
  2979. document.body.scrollTop = 0;
  2980. }
  2981. }, 1000);
  2982. };
  2983. // 页面高度监听器
  2984. const heightObserver = ref(null);
  2985. const isAutoScrollEnabled = ref(false);
  2986. // 滚动到底部功能 - 通过emit通知父组件进行容器滚动
  2987. const scrollToBottom = () => {
  2988. // 使用nextTick确保DOM已更新
  2989. nextTick(() => {
  2990. // 通过emit事件通知父组件进行滚动
  2991. emit('scrollToBottom');
  2992. });
  2993. };
  2994. // 防抖滚动函数
  2995. const debouncedScrollToBottom = (() => {
  2996. let timeoutId = null;
  2997. return () => {
  2998. if (timeoutId) {
  2999. clearTimeout(timeoutId);
  3000. }
  3001. timeoutId = setTimeout(() => {
  3002. // 只有在自动滚动启用、页面已加载且用户未手动滚动时才执行自动滚动
  3003. if (isAutoScrollEnabled.value && isPageLoaded.value && !isUserScrolling.value) {
  3004. scrollToBottom();
  3005. }
  3006. }, 150);
  3007. };
  3008. })();
  3009. // 启动页面高度监听器
  3010. const startHeightObserver = () => {
  3011. // 先停止之前的监听器
  3012. stopHeightObserver();
  3013. // 只有在应该启用自动滚动时才启动监听器
  3014. if (!shouldEnableAutoScroll.value) {
  3015. console.log("跳过启动自动滚动监听器:非搜索新数据场景");
  3016. return;
  3017. }
  3018. isAutoScrollEnabled.value = true;
  3019. // 创建ResizeObserver监听页面内容变化
  3020. heightObserver.value = new ResizeObserver((entries) => {
  3021. if (isAutoScrollEnabled.value && isPageLoaded.value) {
  3022. debouncedScrollToBottom();
  3023. }
  3024. });
  3025. // 监听document.body的尺寸变化
  3026. if (document.body) {
  3027. heightObserver.value.observe(document.body);
  3028. }
  3029. // 创建MutationObserver监听DOM结构变化
  3030. const mutationObserver = new MutationObserver((mutations) => {
  3031. let shouldScroll = false;
  3032. mutations.forEach((mutation) => {
  3033. if (mutation.type === "childList" && mutation.addedNodes.length > 0) {
  3034. // 检查新增的节点是否包含实际内容
  3035. const hasContent = Array.from(mutation.addedNodes).some((node) => {
  3036. if (node.nodeType === Node.ELEMENT_NODE) {
  3037. return node.offsetHeight > 0 || node.scrollHeight > 0;
  3038. }
  3039. return (
  3040. node.nodeType === Node.TEXT_NODE &&
  3041. node.textContent.trim().length > 0
  3042. );
  3043. });
  3044. if (hasContent) {
  3045. shouldScroll = true;
  3046. }
  3047. }
  3048. });
  3049. if (shouldScroll && isAutoScrollEnabled.value && isPageLoaded.value) {
  3050. debouncedScrollToBottom();
  3051. }
  3052. });
  3053. // 监听主要内容区域的DOM变化
  3054. const mainContainer = document.querySelector(".main") || document.body;
  3055. if (mainContainer) {
  3056. mutationObserver.observe(mainContainer, {
  3057. childList: true,
  3058. subtree: true,
  3059. attributes: false,
  3060. characterData: true,
  3061. });
  3062. }
  3063. // 保存mutationObserver引用以便清理
  3064. heightObserver.value.mutationObserver = mutationObserver;
  3065. console.log("页面高度监听器已启动");
  3066. };
  3067. // 停止页面高度监听器
  3068. const stopHeightObserver = () => {
  3069. isAutoScrollEnabled.value = false;
  3070. if (heightObserver.value) {
  3071. // 清理ResizeObserver
  3072. heightObserver.value.disconnect();
  3073. // 清理MutationObserver
  3074. if (heightObserver.value.mutationObserver) {
  3075. heightObserver.value.mutationObserver.disconnect();
  3076. heightObserver.value.mutationObserver = null;
  3077. }
  3078. heightObserver.value = null;
  3079. }
  3080. console.log("页面高度监听器已停止");
  3081. };
  3082. // 监听页面滚动,控制返回顶部按钮显示
  3083. const handlePageScroll = () => {
  3084. const scrollTop =
  3085. window.pageYOffset ||
  3086. document.documentElement.scrollTop ||
  3087. document.body.scrollTop;
  3088. showBackToTop.value = scrollTop > 200;
  3089. };
  3090. // 监听容器滚动(备用方案)
  3091. const handleContainerScroll = () => {
  3092. const container = userInputDisplayRef.value;
  3093. if (container) {
  3094. const scrollTop = container.scrollTop;
  3095. if (scrollTop > 200) {
  3096. showBackToTop.value = true;
  3097. }
  3098. }
  3099. };
  3100. // 页面挂载完成后触发图片旋转和设置滚动监听
  3101. onMounted(async () => {
  3102. // 设置全局点击处理函数
  3103. window.handleTokenClick = () => {
  3104. emit('showCount');
  3105. };
  3106. // 恢复对话记录
  3107. loadConversationsFromStore();
  3108. // 从stockList加载对话记录
  3109. loadConversationsFromStockList();
  3110. // 确保获取用户次数
  3111. // try {
  3112. // await chatStore.getUserCount();
  3113. // console.log('情绪大模型页面:用户次数获取成功');
  3114. // } catch (error) {
  3115. // console.error('情绪大模型页面:获取用户次数失败', error);
  3116. // }
  3117. // 添加全局resize监听器,确保所有图表和容器响应页面宽度变化
  3118. const globalResizeHandler = debounce(() => {
  3119. console.log("AiEmotion页面:窗口大小变化,触发容器和图表resize");
  3120. // 强制重新计算容器布局
  3121. const mainContainer = document.querySelector(".main");
  3122. if (mainContainer) {
  3123. // 触发重排,确保容器尺寸正确更新
  3124. mainContainer.style.display = "none";
  3125. mainContainer.offsetHeight; // 强制重排
  3126. mainContainer.style.display = "";
  3127. }
  3128. // 触发所有图表组件的resize
  3129. const resizeHandlers = [
  3130. window.emoEnergyConverterResizeHandler,
  3131. window.marketTempResizeHandler,
  3132. window.emotionalBottomRadarResizeHandler,
  3133. window.emotionDecodResizeHandler,
  3134. ];
  3135. resizeHandlers.forEach((handler) => {
  3136. if (typeof handler === "function") {
  3137. try {
  3138. handler();
  3139. } catch (error) {
  3140. console.error("AiEmotion页面:图表resize失败", error);
  3141. }
  3142. }
  3143. });
  3144. // 延迟再次触发图表resize,确保容器尺寸稳定后图表能正确适配
  3145. setTimeout(() => {
  3146. resizeHandlers.forEach((handler) => {
  3147. if (typeof handler === "function") {
  3148. try {
  3149. handler();
  3150. } catch (error) {
  3151. console.error("AiEmotion页面:延迟图表resize失败", error);
  3152. }
  3153. }
  3154. });
  3155. }, 100);
  3156. }, 150); // 150ms防抖延迟
  3157. // 移除之前的监听器(如果存在)
  3158. if (window.aiEmotionGlobalResizeHandler) {
  3159. window.removeEventListener("resize", window.aiEmotionGlobalResizeHandler);
  3160. }
  3161. // 添加新的监听器
  3162. window.addEventListener("resize", globalResizeHandler);
  3163. window.aiEmotionGlobalResizeHandler = globalResizeHandler;
  3164. // 添加滚动事件监听器
  3165. const container = userInputDisplayRef.value;
  3166. if (container) {
  3167. container.addEventListener("wheel", handleWheel, { passive: true });
  3168. container.addEventListener("touchmove", handleTouchMove, { passive: true });
  3169. container.addEventListener("scroll", handleUserScroll, { passive: true });
  3170. // 添加容器滚动监听器用于返回顶部按钮
  3171. container.addEventListener("scroll", handleContainerScroll, {
  3172. passive: true,
  3173. });
  3174. }
  3175. // 添加页面滚动监听器,控制返回顶部按钮显示
  3176. window.addEventListener("scroll", handlePageScroll, { passive: true });
  3177. // 添加document滚动监听器(备用方案)
  3178. document.addEventListener("scroll", handlePageScroll, { passive: true });
  3179. // 防抖函数定义
  3180. function debounce(func, wait) {
  3181. let timeout;
  3182. return function executedFunction(...args) {
  3183. const later = () => {
  3184. clearTimeout(timeout);
  3185. func(...args);
  3186. };
  3187. clearTimeout(timeout);
  3188. timeout = setTimeout(later, wait);
  3189. };
  3190. }
  3191. startImageRotation();
  3192. // 检查是否有已保存的股票数据需要恢复
  3193. if (emotionStore.stockList.length > 0 && emotionStore.activeStock) {
  3194. console.log("检测到已保存的股票数据,开始恢复页面状态(不自动播放音频)");
  3195. // 恢复页面加载状态
  3196. isPageLoaded.value = true;
  3197. // 使用nextTick确保DOM更新后清空对话显示
  3198. nextTick(() => {
  3199. messages.value = [];
  3200. // 组件挂载时恢复数据场景,不启用自动滚动,完全依赖父组件管理
  3201. shouldEnableAutoScroll.value = false;
  3202. // 不启动内部滚动监听器,避免与父组件冲突
  3203. // 组件挂载时恢复数据不滚动到底部,保持在顶部
  3204. });
  3205. // 等待DOM渲染后恢复图表和数据
  3206. nextTick(() => {
  3207. const currentStockData = emotionStore.activeStock;
  3208. if (currentStockData && currentStockData.apiData) {
  3209. console.log("恢复图表数据:", currentStockData.stockInfo.name);
  3210. renderCharts(currentStockData.apiData);
  3211. // 恢复结论数据并显示内容
  3212. if (currentStockData.conclusionData) {
  3213. conclusionData.value = currentStockData.conclusionData;
  3214. // 结论内容现在直接通过parsedConclusion计算属性显示
  3215. conclusionData.value = currentStockData.conclusionData;
  3216. // 标记该股票的打字机效果和音频已经显示过,避免后续自动触发
  3217. const stockUniqueId = getStockUniqueId(currentStockData);
  3218. if (stockUniqueId) {
  3219. stockTypewriterShown.value.set(stockUniqueId, true);
  3220. stockAudioPlayed.value.set(stockUniqueId, true);
  3221. }
  3222. }
  3223. }
  3224. setupIntersectionObserver();
  3225. });
  3226. } else {
  3227. // 没有保存的数据,正常设置监听器
  3228. nextTick(() => {
  3229. setupIntersectionObserver();
  3230. });
  3231. }
  3232. });
  3233. // 组件卸载时清理定时器、音频和observer
  3234. onUnmounted(() => {
  3235. clearTypewriterTimers();
  3236. // 如果有未完成的回调函数,调用它来重新启用输入框
  3237. if (
  3238. currentOnCompleteCallback.value &&
  3239. typeof currentOnCompleteCallback.value === "function"
  3240. ) {
  3241. currentOnCompleteCallback.value();
  3242. currentOnCompleteCallback.value = null;
  3243. }
  3244. stopAudio();
  3245. // 重置触发状态
  3246. hasTriggeredAudio.value = false;
  3247. hasTriggeredTypewriter.value = false;
  3248. // 清理页面高度监听器
  3249. stopHeightObserver();
  3250. // 清理用户滚动检测定时器
  3251. if (userScrollTimer.value) {
  3252. clearTimeout(userScrollTimer.value);
  3253. userScrollTimer.value = null;
  3254. }
  3255. // 清理Intersection Observer
  3256. if (intersectionObserver.value) {
  3257. intersectionObserver.value.disconnect();
  3258. intersectionObserver.value = null;
  3259. }
  3260. // 清理全局resize监听器
  3261. if (window.aiEmotionGlobalResizeHandler) {
  3262. window.removeEventListener("resize", window.aiEmotionGlobalResizeHandler);
  3263. window.aiEmotionGlobalResizeHandler = null;
  3264. }
  3265. // 清理滚动事件监听器
  3266. const container = userInputDisplayRef.value;
  3267. if (container) {
  3268. container.removeEventListener("wheel", handleWheel);
  3269. container.removeEventListener("touchmove", handleTouchMove);
  3270. container.removeEventListener("scroll", handleUserScroll);
  3271. container.removeEventListener("scroll", handleContainerScroll);
  3272. }
  3273. // 清理页面滚动监听器
  3274. window.removeEventListener("scroll", handlePageScroll);
  3275. document.removeEventListener("scroll", handlePageScroll);
  3276. // 滚动相关清理已简化
  3277. });
  3278. // 声明组件可以触发的事件
  3279. const emit = defineEmits(["updateMessage", "sendMessage", "ensureAIchat", "enableInput", "scrollToBottom", "showCount"]);
  3280. // 导出方法供外部使用(已在上方定义)
  3281. </script>
  3282. <style scoped>
  3283. .disclaimer-text {
  3284. font-size: 24px;
  3285. color: #EEEEEE;
  3286. font-weight: bold;
  3287. text-align: center;
  3288. }
  3289. /* 股票统计概览样式 */
  3290. .stock-statistics-overview {
  3291. background: rgba(255, 255, 255, 0.95);
  3292. border-radius: 15px;
  3293. padding: 20px;
  3294. margin-bottom: 20px;
  3295. box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  3296. backdrop-filter: blur(10px);
  3297. border: 1px solid rgba(255, 255, 255, 0.2);
  3298. }
  3299. .statistics-header {
  3300. display: flex;
  3301. justify-content: space-between;
  3302. align-items: center;
  3303. margin-bottom: 15px;
  3304. padding-bottom: 10px;
  3305. border-bottom: 2px solid #f0f0f0;
  3306. }
  3307. .statistics-header h3 {
  3308. margin: 0;
  3309. color: #333;
  3310. font-size: 18px;
  3311. font-weight: 600;
  3312. }
  3313. .stock-count {
  3314. background: linear-gradient(45deg, #667eea, #764ba2);
  3315. color: white;
  3316. padding: 5px 12px;
  3317. border-radius: 20px;
  3318. font-size: 12px;
  3319. font-weight: 500;
  3320. }
  3321. .statistics-content {
  3322. display: grid;
  3323. grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  3324. gap: 15px;
  3325. margin-bottom: 20px;
  3326. }
  3327. .stat-item {
  3328. display: flex;
  3329. justify-content: space-between;
  3330. align-items: center;
  3331. padding: 10px 15px;
  3332. background: rgba(102, 126, 234, 0.1);
  3333. border-radius: 8px;
  3334. border-left: 4px solid #667eea;
  3335. }
  3336. .stat-label {
  3337. color: #666;
  3338. font-size: 14px;
  3339. font-weight: 500;
  3340. }
  3341. .stat-value {
  3342. color: #333;
  3343. font-size: 16px;
  3344. font-weight: 600;
  3345. }
  3346. .stat-value.hot-temp {
  3347. color: #ff4757;
  3348. }
  3349. .stat-value.cold-temp {
  3350. color: #3742fa;
  3351. }
  3352. .temperature-distribution {
  3353. display: flex;
  3354. flex-wrap: wrap;
  3355. gap: 10px;
  3356. }
  3357. .distribution-item {
  3358. display: flex;
  3359. align-items: center;
  3360. gap: 8px;
  3361. padding: 8px 12px;
  3362. background: rgba(255, 255, 255, 0.8);
  3363. border-radius: 20px;
  3364. border: 1px solid #e0e0e0;
  3365. }
  3366. .temp-level {
  3367. font-size: 12px;
  3368. font-weight: 500;
  3369. padding: 2px 8px;
  3370. border-radius: 10px;
  3371. color: white;
  3372. }
  3373. .temp-level.hot {
  3374. background: #ff4757;
  3375. }
  3376. .temp-level.warm {
  3377. background: #ff6b35;
  3378. }
  3379. .temp-level.normal {
  3380. background: #26de81;
  3381. }
  3382. .temp-level.cool {
  3383. background: #45aaf2;
  3384. }
  3385. .temp-level.cold {
  3386. background: #3742fa;
  3387. }
  3388. .temp-count {
  3389. color: #666;
  3390. font-size: 12px;
  3391. font-weight: 500;
  3392. }
  3393. .matrix-header {
  3394. width: 100%;
  3395. display: flex;
  3396. align-items: center;
  3397. }
  3398. /* .disclaimer-item p {
  3399. color: #ffffff !important;
  3400. font-size: 24px;
  3401. font-weight: bold;
  3402. } */
  3403. .temperature-content {
  3404. padding-top: 8%;
  3405. display: flex;
  3406. align-items: center;
  3407. justify-content: center;
  3408. gap: 10rem;
  3409. }
  3410. .temperature-content .content1 {
  3411. display: flex;
  3412. flex-direction: column;
  3413. align-items: center;
  3414. }
  3415. .temperature-content .content1 img {
  3416. scale: 0.5;
  3417. }
  3418. .temperature-display {
  3419. display: flex;
  3420. flex-direction: column;
  3421. /* 竖向排列元素 */
  3422. /* margin-left: 15%; */
  3423. gap: 30px;
  3424. /* margin-top: -12%; */
  3425. /* width: 100%; */
  3426. /* height: auto; */
  3427. }
  3428. .temperature-display::after {
  3429. content: "";
  3430. display: table;
  3431. clear: both;
  3432. }
  3433. .temperature-content .temperature-hot {
  3434. background-image: url("@/assets/img/AiEmotion/redBorder.png");
  3435. background-repeat: no-repeat;
  3436. background-size: 100% 100%;
  3437. /* width: 50%; */
  3438. width: 22vw;
  3439. max-width: 400px;
  3440. min-width: 200px;
  3441. text-align: center;
  3442. font-size: 24px;
  3443. color: white;
  3444. display: flex;
  3445. justify-content: center;
  3446. align-items: center;
  3447. flex-shrink: 0;
  3448. }
  3449. .temperature-content .temperature-cold {
  3450. background-image: url("@/assets/img/AiEmotion/blueBorder.png");
  3451. background-repeat: no-repeat;
  3452. background-size: 100% 100%;
  3453. /* width: 35%; */
  3454. width: 22vw;
  3455. max-width: 400px;
  3456. min-width: 200px;
  3457. text-align: center;
  3458. font-size: 24px;
  3459. color: white;
  3460. display: flex;
  3461. justify-content: center;
  3462. align-items: center;
  3463. flex-shrink: 0;
  3464. }
  3465. .golden-wheel {
  3466. width: 100%;
  3467. display: flex;
  3468. justify-content: center;
  3469. }
  3470. .golden-wheel-img {
  3471. width: 30%;
  3472. max-width: 500px;
  3473. height: auto;
  3474. }
  3475. /* 定义旋转动画 */
  3476. @keyframes rotate {
  3477. from {
  3478. transform: rotate(0deg);
  3479. }
  3480. to {
  3481. transform: rotate(360deg);
  3482. }
  3483. }
  3484. /* 应用动画到图片 */
  3485. .rotating-image {
  3486. animation: rotate 5s linear;
  3487. /* 5 秒完成一次旋转,线性速度*/
  3488. will-change: transform;
  3489. /* 优化动画性能 */
  3490. }
  3491. .bk-image {
  3492. background-image: url("@/assets/img/AiEmotion/bk00000.png");
  3493. background-size: 100% 100%;
  3494. background-repeat: no-repeat;
  3495. width: 50vw;
  3496. height: auto;
  3497. margin: 0 auto;
  3498. margin-top: 20px;
  3499. }
  3500. .bk-image .conclusion-container {
  3501. padding: 45px;
  3502. border-radius: 15px;
  3503. margin: 20px;
  3504. }
  3505. .bk-image .conclusion-container .conclusion-item {
  3506. border-radius: 12px;
  3507. transition: all 0.3s ease;
  3508. overflow: hidden;
  3509. }
  3510. .bk-image .conclusion-container .conclusion-item:last-child {
  3511. margin-bottom: 0;
  3512. }
  3513. .bk-image .conclusion-container .conclusion-item .conclusion-title {
  3514. color: #ffd700;
  3515. font-size: 22px;
  3516. font-weight: bold;
  3517. margin: 0 0 15px 0;
  3518. text-align: center;
  3519. letter-spacing: 2px;
  3520. margin-top: 22px;
  3521. }
  3522. .bk-image .conclusion-container .conclusion-item .conclusion-text {
  3523. color: #ffffff;
  3524. font-size: 20px;
  3525. line-height: 1.8;
  3526. margin: 0 0 12px 0;
  3527. text-align: center;
  3528. word-wrap: break-word;
  3529. position: relative;
  3530. }
  3531. .bk-image .conclusion-container .conclusion-item .conclusion-text:last-child {
  3532. margin-bottom: 0;
  3533. }
  3534. .bk-image .conclusion-placeholder {
  3535. padding: 30px;
  3536. text-align: center;
  3537. border-radius: 12px;
  3538. }
  3539. .bk-image .conclusion-placeholder p {
  3540. color: #999999;
  3541. font-size: 16px;
  3542. margin: 0;
  3543. font-style: italic;
  3544. }
  3545. /* 最后文字的颜色 */
  3546. .text-container {
  3547. position: relative;
  3548. color: white;
  3549. text-align: left;
  3550. padding: 45px;
  3551. border-radius: 15px;
  3552. }
  3553. /* .text-container p {
  3554. margin: 0 auto;
  3555. font-size: 40px;
  3556. margin-left: 0%;
  3557. border-radius: 12px;
  3558. transition: all 0.3s ease;
  3559. overflow: hidden;
  3560. letter-spacing: 2px;
  3561. } */
  3562. .text-container .title {
  3563. display: block;
  3564. color: #ffd700;
  3565. font-weight: bold;
  3566. margin-top: 0px;
  3567. margin-bottom: 20px;
  3568. font-size: 22px;
  3569. text-align: center;
  3570. }
  3571. .text-container .content {
  3572. display: block;
  3573. color: white;
  3574. text-align: center;
  3575. font-size: 22px;
  3576. }
  3577. .core-logic-section {
  3578. background-image: url("@/assets/img/AiEmotion/bk00000.png");
  3579. background-size: cover;
  3580. background-repeat: no-repeat;
  3581. width: 95%;
  3582. height: auto;
  3583. min-height: 70rem;
  3584. margin: 0 auto;
  3585. }
  3586. .core-logic-header {
  3587. margin: 0 auto;
  3588. width: fit-content;
  3589. margin-top: 2%;
  3590. margin-bottom: 1%;
  3591. }
  3592. .core-highlights-header {
  3593. margin: 0 auto;
  3594. /* width: fit-content; */
  3595. margin-top: 2%;
  3596. margin-bottom: 1%;
  3597. display: flex;
  3598. align-items: center;
  3599. justify-content: center;
  3600. }
  3601. .emotion-decoder-content {
  3602. /* width: 80vw; */
  3603. margin: 0 auto;
  3604. }
  3605. .energy-converter-content {
  3606. min-width: 100%;
  3607. margin-top: 3%;
  3608. }
  3609. .bottom-radar-header {
  3610. display: flex;
  3611. justify-content: center;
  3612. align-items: center;
  3613. flex-direction: column;
  3614. }
  3615. .bottom-radar-header img {
  3616. scale: 0.5;
  3617. }
  3618. .energy-converter-header {
  3619. display: flex;
  3620. justify-content: center;
  3621. align-items: center;
  3622. flex-direction: column;
  3623. }
  3624. .energy-converter-header img {
  3625. scale: 0.5;
  3626. }
  3627. .bottom-radar-icon {
  3628. width: fit-content;
  3629. height: auto;
  3630. margin: 0 auto;
  3631. margin-top: 2%;
  3632. margin-bottom: 1%;
  3633. display: flex;
  3634. align-items: center;
  3635. justify-content: center;
  3636. }
  3637. .energy-converter-icon {
  3638. width: fit-content;
  3639. height: auto;
  3640. margin: 0 auto;
  3641. margin-top: 2%;
  3642. margin-bottom: 1%;
  3643. display: flex;
  3644. align-items: center;
  3645. justify-content: center;
  3646. }
  3647. .core-logic-content {
  3648. margin: 0 auto;
  3649. width: fit-content;
  3650. }
  3651. .market-temperature-icon {
  3652. width: fit-content;
  3653. height: auto;
  3654. margin: 0 auto;
  3655. margin-top: 2%;
  3656. margin-bottom: 1%;
  3657. display: flex;
  3658. align-items: center;
  3659. justify-content: center;
  3660. }
  3661. .bottom-radar-title {
  3662. margin: 0 auto;
  3663. width: fit-content;
  3664. margin-top: 2%;
  3665. margin-bottom: 1%;
  3666. }
  3667. .emotion-decoder-title {
  3668. margin: 0 auto;
  3669. width: fit-content;
  3670. margin-top: 2%;
  3671. margin-bottom: 1%;
  3672. }
  3673. .temperature-title {
  3674. margin: 0 auto;
  3675. width: fit-content;
  3676. margin-top: 2%;
  3677. margin-bottom: 1%;
  3678. }
  3679. .matrix-title {
  3680. margin: 0 auto;
  3681. width: fit-content;
  3682. margin-bottom: 1%;
  3683. }
  3684. .emotion-decoder-header {
  3685. display: flex;
  3686. flex-direction: column;
  3687. justify-content: center;
  3688. align-items: center;
  3689. }
  3690. .emotion-decoder-header img {
  3691. scale: 0.5;
  3692. }
  3693. .emotion-decoder-icon {
  3694. width: fit-content;
  3695. height: auto;
  3696. margin: 0 auto;
  3697. margin-top: 2%;
  3698. margin-bottom: 1%;
  3699. display: flex;
  3700. align-items: center;
  3701. justify-content: center;
  3702. }
  3703. .emotion-decoder-text {
  3704. color: white;
  3705. font-size: 20px;
  3706. font-weight: bold;
  3707. /* margin-left: 45%; */
  3708. }
  3709. .bottom-radar-text {
  3710. color: white;
  3711. font-size: 20px;
  3712. font-weight: bold;
  3713. /* margin-left: 44.6%; */
  3714. }
  3715. .energy-converter-text {
  3716. color: white;
  3717. font-size: 20px;
  3718. font-weight: bold;
  3719. /* margin-left: 44%; */
  3720. }
  3721. .scenario-application-section {
  3722. text-align: center;
  3723. margin-top: 2%;
  3724. margin-bottom: 1%;
  3725. }
  3726. /* 为需要放大的图片添加样式 */
  3727. .scaled-img {
  3728. background-image: url("@/assets/img/AiEmotion/tree00000.jpg");
  3729. background-size: 100% 100%;
  3730. background-position: center;
  3731. background-repeat: no-repeat;
  3732. width: 80%;
  3733. height: 350px;
  3734. margin: 0 auto;
  3735. margin-top: 2%;
  3736. margin-bottom: 3%;
  3737. }
  3738. .lz-img {
  3739. text-align: center;
  3740. padding-top: 30px;
  3741. }
  3742. .decision-tree-section {
  3743. background-image: url("@/assets/img/AiEmotion/bk00000.png");
  3744. background-size: 100% 100%;
  3745. background-repeat: no-repeat;
  3746. width: 50vw;
  3747. height: auto;
  3748. min-height: 30rem;
  3749. margin: 0 auto;
  3750. }
  3751. .energy-converter-section {
  3752. background-image: url("@/assets/img/AiEmotion/bk00000.png");
  3753. background-size: 100% 100%;
  3754. background-repeat: no-repeat;
  3755. width: 50vw;
  3756. height: auto;
  3757. margin: 0 auto;
  3758. box-sizing: border-box;
  3759. transition: all 0.3s ease;
  3760. min-height: 85vh;
  3761. }
  3762. .bottom-radar-section {
  3763. background-image: url("@/assets/img/AiEmotion/bk00000.png");
  3764. background-size: 100% 100%;
  3765. background-repeat: no-repeat;
  3766. width: 50vw;
  3767. max-width: 100%;
  3768. height: auto;
  3769. margin: 0 auto;
  3770. box-sizing: border-box;
  3771. transition: all 0.3s ease;
  3772. }
  3773. .emotion-decoder-section {
  3774. background-image: url("@/assets/img/AiEmotion/bk00000.png");
  3775. background-size: 100% 100%;
  3776. background-repeat: no-repeat;
  3777. width: 50vw;
  3778. max-width: 100%;
  3779. height: auto;
  3780. margin: 0 auto;
  3781. box-sizing: border-box;
  3782. transition: all 0.3s ease;
  3783. padding-bottom: 1rem;
  3784. }
  3785. .market-temperature-section {
  3786. background-image: url("@/assets/img/AiEmotion/bk00000.png");
  3787. background-size: 100% 100%;
  3788. background-repeat: no-repeat;
  3789. width: 50vw;
  3790. max-width: 100%;
  3791. height: auto;
  3792. min-height: 70rem;
  3793. margin: 0 auto;
  3794. box-sizing: border-box;
  3795. transition: all 0.3s ease;
  3796. }
  3797. .main-content-wrapper {
  3798. background-size: 100% 100%;
  3799. background-repeat: no-repeat;
  3800. width: 77vw;
  3801. max-width: 100%;
  3802. height: auto;
  3803. margin: 0 auto;
  3804. box-sizing: border-box;
  3805. transition: all 0.3s ease;
  3806. }
  3807. .matrix-content {
  3808. display: flex;
  3809. flex-direction: column;
  3810. align-items: center;
  3811. /* 竖向排列元素 */
  3812. /* gap: 1rem; */
  3813. /* margin-left: 10%; */
  3814. }
  3815. .matrix-main-title {
  3816. color: white;
  3817. font-size: 20px;
  3818. font-weight: bold;
  3819. margin-left: 0%;
  3820. }
  3821. .market-temperature-value {
  3822. font-size: 1.5rem;
  3823. font-weight: bold;
  3824. color: white;
  3825. margin-left: auto;
  3826. }
  3827. .market-temperature-label {
  3828. background-image: url("@/assets/img/AiEmotion/bk01.png");
  3829. background-size: 100% 100%;
  3830. background-repeat: no-repeat;
  3831. padding: 10px;
  3832. color: #fff;
  3833. font-size: 20px;
  3834. font-weight: bold;
  3835. text-align: center;
  3836. margin-left: 0;
  3837. width: 30%;
  3838. min-width: 200px;
  3839. max-width: 50%;
  3840. height: auto;
  3841. overflow: hidden;
  3842. text-overflow: ellipsis;
  3843. white-space: nowrap;
  3844. box-sizing: border-box;
  3845. }
  3846. .main {
  3847. width: 83%;
  3848. max-width: 1400px;
  3849. min-width: 320px;
  3850. min-height: 100px;
  3851. height: auto;
  3852. padding: 1rem;
  3853. box-sizing: border-box;
  3854. background-color: #2b378d;
  3855. margin: 0 auto;
  3856. transition: width 0.3s ease;
  3857. margin-bottom: 10rem;
  3858. }
  3859. .ai-emotion-container {
  3860. display: flex;
  3861. flex-direction: column;
  3862. align-items: center;
  3863. justify-content: center;
  3864. padding: 20px;
  3865. position: relative;
  3866. }
  3867. .user-input-display {
  3868. margin-top: 20px;
  3869. display: flex;
  3870. flex-direction: column;
  3871. width: 100%;
  3872. }
  3873. .message-container {
  3874. display: flex;
  3875. margin-bottom: 30px;
  3876. width: 100%;
  3877. }
  3878. /* 用户消息容器样式 */
  3879. .user-message-container {
  3880. align-items: center;
  3881. margin-left: auto;
  3882. gap: 10px;
  3883. margin-right: 5px;
  3884. }
  3885. .user-content {
  3886. display: flex;
  3887. height: 100%;
  3888. align-items: center;
  3889. margin-right: 5px;
  3890. }
  3891. /* 确保历史记录模式下用户消息也能正确换行 */
  3892. .user-content .user-message {
  3893. white-space: pre-wrap;
  3894. word-wrap: break-word;
  3895. word-break: break-word;
  3896. overflow-wrap: break-word;
  3897. }
  3898. .user-message-speaker {
  3899. width: 32px;
  3900. height: 32px;
  3901. object-fit: contain;
  3902. margin-right: 5px;
  3903. cursor: pointer;
  3904. transition: all 0.3s ease;
  3905. }
  3906. .user-sendTime {
  3907. width: 100%;
  3908. text-align: center;
  3909. color: rgba(255, 255, 255, 0.6);
  3910. font-size: 0.8rem;
  3911. }
  3912. .user-message-speaker:hover {
  3913. transform: scale(1.1);
  3914. }
  3915. .user-message-speaker.speaker-active {
  3916. animation: pulse 1.5s infinite;
  3917. }
  3918. @keyframes pulse {
  3919. 0% {
  3920. transform: scale(1);
  3921. }
  3922. 50% {
  3923. transform: scale(1.1);
  3924. }
  3925. 100% {
  3926. transform: scale(1);
  3927. }
  3928. }
  3929. .user-message {
  3930. color: #6d22f8;
  3931. background: white;
  3932. font-weight: bold;
  3933. padding: 15px 20px;
  3934. border-radius: 15px;
  3935. max-width: 80%;
  3936. text-align: left;
  3937. box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  3938. margin: 0;
  3939. word-wrap: break-word;
  3940. word-break: break-word;
  3941. white-space: pre-wrap;
  3942. overflow-wrap: break-word;
  3943. /* 将用户消息推到右边 */
  3944. }
  3945. /* AI消息容器样式 */
  3946. .ai-message-container {
  3947. background-color: #f1f1f1;
  3948. border-radius: 10px;
  3949. align-items: flex-start;
  3950. margin-right: auto;
  3951. width: 100%;
  3952. white-space: normal;
  3953. overflow: visible;
  3954. align-items: center;
  3955. display: flex;
  3956. }
  3957. /* 思考过程动图样式 */
  3958. .thinking-gif {
  3959. width: 40px;
  3960. height: 40px;
  3961. object-fit: contain;
  3962. margin-top: 5px;
  3963. margin-left: 10px;
  3964. border-radius: 8px;
  3965. animation: float 2s ease-in-out infinite;
  3966. }
  3967. @keyframes float {
  3968. 0%,
  3969. 100% {
  3970. transform: translateY(0px);
  3971. }
  3972. 50% {
  3973. transform: translateY(-5px);
  3974. }
  3975. }
  3976. /* 动态加载点样式 */
  3977. .loading-dots {
  3978. display: inline-block;
  3979. }
  3980. .dot {
  3981. opacity: 0.4;
  3982. animation: loading 1.4s infinite;
  3983. }
  3984. .dot:nth-child(1) {
  3985. animation-delay: 0s;
  3986. }
  3987. .dot:nth-child(2) {
  3988. animation-delay: 0.2s;
  3989. }
  3990. .dot:nth-child(3) {
  3991. animation-delay: 0.4s;
  3992. }
  3993. .dot:nth-child(4) {
  3994. animation-delay: 0.6s;
  3995. }
  3996. .dot:nth-child(5) {
  3997. animation-delay: 0.8s;
  3998. }
  3999. .dot:nth-child(6) {
  4000. animation-delay: 1s;
  4001. }
  4002. @keyframes loading {
  4003. 0%,
  4004. 60%,
  4005. 100% {
  4006. opacity: 0.4;
  4007. }
  4008. 30% {
  4009. opacity: 1;
  4010. }
  4011. }
  4012. .ai-message {
  4013. color: #000000;
  4014. font-weight: bold;
  4015. padding: 10px 10px;
  4016. border-radius: 15px;
  4017. text-align: left;
  4018. margin-right: auto;
  4019. width: 100%;
  4020. overflow: visible;
  4021. align-items: center;
  4022. display: flex;
  4023. margin: 20px 10px;
  4024. }
  4025. .input-container {
  4026. display: flex;
  4027. align-items: center;
  4028. gap: 10px;
  4029. }
  4030. .fixed-bottom {
  4031. position: fixed;
  4032. bottom: 100px;
  4033. left: 0;
  4034. width: 100%;
  4035. background-color: #f8f9fa;
  4036. padding: 10px 20px;
  4037. box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
  4038. }
  4039. .input-box {
  4040. padding: 10px;
  4041. font-size: 16px;
  4042. border: 1px solid #ccc;
  4043. border-radius: 5px;
  4044. width: calc(100% - 120px);
  4045. }
  4046. .send-button {
  4047. padding: 10px 20px;
  4048. font-size: 16px;
  4049. color: #fff;
  4050. background-color: #007bff;
  4051. border: none;
  4052. border-radius: 5px;
  4053. cursor: pointer;
  4054. }
  4055. .send-button:hover {
  4056. background-color: #0056b3;
  4057. }
  4058. /* 响应式布局媒体查询 */
  4059. @media only screen and (max-width: 1200px) {
  4060. .main {
  4061. width: 95%;
  4062. padding: 0.8rem;
  4063. }
  4064. .market-temperature-label {
  4065. width: 40%;
  4066. min-width: 170px;
  4067. max-width: 60%;
  4068. font-size: 1.3rem;
  4069. overflow: hidden;
  4070. text-overflow: ellipsis;
  4071. white-space: nowrap;
  4072. }
  4073. .market-temperature-value {
  4074. font-size: 1.3rem;
  4075. }
  4076. /* 调整图表容器高度 */
  4077. /* .class00 {
  4078. min-height: 45rem;
  4079. } */
  4080. .market-temperature-section {
  4081. min-height: 60rem;
  4082. }
  4083. .decision-tree-section {
  4084. min-height: 42rem;
  4085. }
  4086. .scaled-img {
  4087. height: 350px;
  4088. min-height: 30rem;
  4089. }
  4090. }
  4091. @media only screen and (max-width: 992px) {
  4092. .main {
  4093. width: 98%;
  4094. padding: 0.6rem;
  4095. }
  4096. /* 调整图表容器高度 */
  4097. /* .class00 {
  4098. min-height: 40rem;
  4099. } */
  4100. .market-temperature-section {
  4101. min-height: 55rem;
  4102. }
  4103. .decision-tree-section {
  4104. min-height: 35rem;
  4105. }
  4106. .scaled-img {
  4107. height: 300px;
  4108. min-height: 25rem;
  4109. background-size: contain;
  4110. }
  4111. }
  4112. /* 手机端适配样式 */
  4113. @media only screen and (max-width: 768px) {
  4114. .disclaimer-text {
  4115. font-size: 18px;
  4116. color: #EEEEEE;
  4117. font-weight: bold;
  4118. text-align: center;
  4119. }
  4120. .text-container .content {
  4121. display: block;
  4122. color: white;
  4123. text-align: center;
  4124. font-size: 20px;
  4125. }
  4126. .market-temperature-icon {
  4127. width: auto;
  4128. height: auto;
  4129. display: flex;
  4130. align-items: center;
  4131. justify-content: center;
  4132. scale: 0.5;
  4133. }
  4134. .matrix-header {
  4135. display: flex;
  4136. align-items: center;
  4137. }
  4138. .main {
  4139. width: 90%;
  4140. padding: 0.5rem;
  4141. margin-bottom: 5rem;
  4142. background-color: #2b378d;
  4143. border-radius: 0px 0px 10px 10px;
  4144. }
  4145. .energy-converter-text {
  4146. color: white;
  4147. font-size: 20px;
  4148. font-weight: bold;
  4149. margin-left: 28%;
  4150. }
  4151. .energy-converter-content {
  4152. min-width: 100%;
  4153. /* margin-top: 25%; */
  4154. }
  4155. .scaled-img {
  4156. background-image: url("@/assets/img/AiEmotion/tree00000.jpg");
  4157. background-size: 100% 100%;
  4158. background-position: center;
  4159. background-repeat: no-repeat;
  4160. background-size: contain;
  4161. text-align: center;
  4162. width: 90%;
  4163. margin-top: 4%;
  4164. height: 200px;
  4165. min-height: 200px;
  4166. }
  4167. .bottom-radar-text {
  4168. color: white;
  4169. font-size: 20px;
  4170. font-weight: bold;
  4171. margin-left: 30%;
  4172. }
  4173. .emotion-decoder-text {
  4174. color: white;
  4175. font-size: 20px;
  4176. font-weight: bold;
  4177. margin-left: 30%;
  4178. }
  4179. /* 图片样式 */
  4180. .golden-wheel-img {
  4181. width: 50%;
  4182. }
  4183. .matrix-title img {
  4184. width: 100%;
  4185. }
  4186. .temperature-title img {
  4187. width: 100%;
  4188. margin: 10px 10px;
  4189. }
  4190. .emotion-decoder-title img {
  4191. width: 100%;
  4192. margin: 10px 10px;
  4193. }
  4194. .bottom-radar-title img {
  4195. width: 100%;
  4196. margin: 10px 10px;
  4197. }
  4198. .core-highlights-header img {
  4199. scale: 0.5;
  4200. }
  4201. .core-logic-header img {
  4202. width: 100%;
  4203. margin: 10px 10px;
  4204. }
  4205. .scaled-img img {
  4206. width: 30%;
  4207. height: auto;
  4208. }
  4209. .scenario-application-section img {
  4210. width: 100%;
  4211. margin: 10px 10px;
  4212. }
  4213. .matrix-main-title {
  4214. font-size: 20px;
  4215. margin-left: 5%;
  4216. }
  4217. /* .span01 {
  4218. width: 50%;
  4219. min-width: 150px;
  4220. max-width: 70%;
  4221. font-size: 16px;
  4222. overflow: hidden;
  4223. text-overflow: ellipsis;
  4224. white-space: nowrap;
  4225. padding: 8px;
  4226. } */
  4227. .matrix-header .market-temperature-value {
  4228. font-size: 14px;
  4229. color: white;
  4230. float: right;
  4231. }
  4232. .market-temperature-section {
  4233. background-image: url("@/assets/img/AiEmotion/bk00000.png");
  4234. background-size: 100% 100%;
  4235. background-repeat: no-repeat;
  4236. width: 100%;
  4237. /* margin-left: -45px; */
  4238. height: auto;
  4239. }
  4240. /* .main {
  4241. min-height: 100px;
  4242. height: auto;
  4243. box-sizing: border-box;
  4244. background-color: #02107d;
  4245. margin-bottom: 10rem;
  4246. } */
  4247. .emotion-decoder-section {
  4248. width: 80vw;
  4249. height: auto;
  4250. margin: 0 auto;
  4251. /* min-height: 38rem; */
  4252. /* min-height: 51rem; */
  4253. /* margin-left: -39px; */
  4254. /* min-height: 38rem; */
  4255. }
  4256. /* 调整其他图表容器高度 */
  4257. /* .class00 {
  4258. min-height: 35rem;
  4259. } */
  4260. .market-temperature-section {
  4261. min-height: 45rem;
  4262. }
  4263. .matrix-header img {
  4264. width: 68%;
  4265. height: auto;
  4266. /* margin-top: 5%; */
  4267. margin-left: 0%;
  4268. }
  4269. .emotion-decoder-icon {
  4270. width: 25%;
  4271. height: auto;
  4272. scale: 0.5;
  4273. }
  4274. .bottom-radar-icon,
  4275. .energy-converter-icon {
  4276. width: 25%;
  4277. height: auto;
  4278. scale: 0.5;
  4279. }
  4280. .lz-img {
  4281. margin-bottom: 0;
  4282. padding-top: 0;
  4283. img {
  4284. width: 30%;
  4285. height: auto;
  4286. margin-top: 5%;
  4287. }
  4288. }
  4289. .decision-tree-section {
  4290. background-size: 100% 100%;
  4291. background-repeat: no-repeat;
  4292. width: 80vw;
  4293. height: auto;
  4294. min-height: 20rem;
  4295. margin: 0 auto;
  4296. }
  4297. .bk-image {
  4298. .conclusion-container {
  4299. padding: 15px;
  4300. border-radius: 8px;
  4301. margin: 8px;
  4302. .conclusion-item {
  4303. &:last-child {
  4304. margin-bottom: 40px;
  4305. }
  4306. .conclusion-title {
  4307. color: #ffd700;
  4308. font-size: 16px;
  4309. font-weight: bold;
  4310. margin: 0 0 8px 0;
  4311. text-align: center;
  4312. }
  4313. .conclusion-text {
  4314. color: #ffffff;
  4315. font-size: 14px;
  4316. line-height: 1.5;
  4317. margin: 0 0 6px 0;
  4318. text-align: left;
  4319. word-wrap: break-word;
  4320. &:last-child {
  4321. margin-bottom: 0;
  4322. }
  4323. }
  4324. }
  4325. }
  4326. .conclusion-placeholder {
  4327. padding: 15px;
  4328. text-align: center;
  4329. p {
  4330. color: #999999;
  4331. font-size: 12px;
  4332. margin: 0;
  4333. }
  4334. }
  4335. }
  4336. .bk-image {
  4337. background-size: 100% 100%;
  4338. background-repeat: no-repeat;
  4339. width: 80vw;
  4340. height: auto;
  4341. margin: 0 auto;
  4342. .conclusion-container {
  4343. padding-top: 20px;
  4344. border-radius: 15px;
  4345. margin: 20px;
  4346. .conclusion-item {
  4347. border-radius: 12px;
  4348. transition: all 0.3s ease;
  4349. overflow: hidden;
  4350. }
  4351. .conclusion-item:last-child {
  4352. margin-bottom: 40;
  4353. }
  4354. .conclusion-item .conclusion-title {
  4355. color: #ffd700;
  4356. font-size: 22px;
  4357. font-weight: bold;
  4358. text-align: center;
  4359. letter-spacing: 2px;
  4360. margin-top: 22px;
  4361. }
  4362. .conclusion-item .conclusion-text {
  4363. color: #ffffff;
  4364. font-size: 20px;
  4365. line-height: 1.8;
  4366. margin: 0 0 12px 0;
  4367. text-align: center;
  4368. word-wrap: break-word;
  4369. position: relative;
  4370. }
  4371. .conclusion-item .conclusion-text:last-child {
  4372. margin-bottom: 0;
  4373. }
  4374. }
  4375. .conclusion-placeholder {
  4376. padding: 30px;
  4377. text-align: center;
  4378. border-radius: 12px;
  4379. background: rgba(255, 255, 255, 0.05);
  4380. border: 1px dashed rgba(153, 153, 153, 0.3);
  4381. }
  4382. .conclusion-placeholder p {
  4383. color: #999999;
  4384. font-size: 16px;
  4385. margin: 0;
  4386. font-style: italic;
  4387. }
  4388. .disclaimer-item {
  4389. /* margin-top: 30px; */
  4390. padding-bottom: 15%;
  4391. text-align: center;
  4392. }
  4393. .disclaimer-item p {
  4394. color: #ffffff !important;
  4395. font-size: 18px;
  4396. margin: 0;
  4397. letter-spacing: 1px;
  4398. }
  4399. }
  4400. .bottom-radar-section {
  4401. background-size: 100% 100%;
  4402. background-repeat: no-repeat;
  4403. width: 80vw;
  4404. height: auto;
  4405. /* min-height: 48rem; */
  4406. }
  4407. .energy-converter-section {
  4408. background-size: 100% 100%;
  4409. background-repeat: no-repeat;
  4410. width: 80vw;
  4411. height: auto;
  4412. margin: 0 auto;
  4413. min-height: 55vh;
  4414. }
  4415. .temperature-display {
  4416. display: flex;
  4417. flex-direction: column;
  4418. /* margin-left: 5rem; */
  4419. gap: 0;
  4420. /* margin-top: -6rem; */
  4421. /* width: 100%; */
  4422. height: auto;
  4423. }
  4424. .temperature-content .temperature-cold,
  4425. .temperature-content .temperature-hot {
  4426. min-width: 200px;
  4427. font-size: 16px;
  4428. }
  4429. .temperature-content {
  4430. padding-top: 8%;
  4431. display: flex;
  4432. align-items: center;
  4433. justify-content: center;
  4434. gap: 0rem;
  4435. }
  4436. .market-temperature-label {
  4437. background-image: url("@/assets/img/AiEmotion/bk01.png");
  4438. background-size: 100% 100%;
  4439. background-repeat: no-repeat;
  4440. display: inline-block;
  4441. padding: 10px;
  4442. color: #fff;
  4443. font-size: 14px;
  4444. text-align: center;
  4445. width: 50%;
  4446. }
  4447. .temperature-display {
  4448. flex-direction: column;
  4449. gap: 1rem;
  4450. align-items: center;
  4451. }
  4452. /* .span01 {
  4453. width: 60%;
  4454. font-size: 1.2rem;
  4455. padding: 8px;
  4456. } */
  4457. .market-temperature-value {
  4458. font-size: 1.2rem;
  4459. }
  4460. .matrix-main-title,
  4461. .emotion-decoder-text,
  4462. .bottom-radar-text,
  4463. .energy-converter-text {
  4464. font-size: 18px;
  4465. margin-left: 0;
  4466. }
  4467. }
  4468. /* 超小屏幕设备 */
  4469. @media only screen and (max-width: 480px) {
  4470. .main {
  4471. width: 90%;
  4472. padding: 0.3rem;
  4473. margin-bottom: 3rem;
  4474. }
  4475. .temperature-display {
  4476. flex-direction: column;
  4477. gap: 0.8rem;
  4478. align-items: center;
  4479. margin-right: 30px;
  4480. }
  4481. .temperature-content .temperature-cold,
  4482. .temperature-content .temperature-hot {
  4483. /* width: 90%; */
  4484. width: 10vw;
  4485. min-width: 100px;
  4486. font-size: 14px;
  4487. }
  4488. /* .span01 {
  4489. width: 50%;
  4490. font-size: 1rem;
  4491. padding: 6px;
  4492. } */
  4493. .market-temperature-value {
  4494. font-size: 1rem;
  4495. }
  4496. .golden-wheel-img {
  4497. width: 80%;
  4498. }
  4499. /* 调整图表容器高度适配超小屏幕 */
  4500. /* .class00 {
  4501. min-height: 25rem;
  4502. } */
  4503. .market-temperature-section {
  4504. min-height: 35rem;
  4505. }
  4506. .decision-tree-section {
  4507. min-height: 15rem;
  4508. }
  4509. .scaled-img {
  4510. height: 150px;
  4511. min-height: 150px;
  4512. }
  4513. }
  4514. /* 加载提示样式 */
  4515. /* .loading-container {
  4516. display: flex;
  4517. justify-content: center;
  4518. align-items: center;
  4519. min-height: 20vh;
  4520. padding: 20px 10px;
  4521. } */
  4522. /* .loading-content {
  4523. text-align: center;
  4524. background: linear-gradient(135deg, rgba(0, 212, 255, 0.15) 0%, rgba(0, 100, 200, 0.15) 100%);
  4525. border: 2px solid rgba(0, 212, 255, 0.4);
  4526. border-radius: 20px;
  4527. padding: 40px;
  4528. box-shadow: 0 8px 25px rgba(0, 212, 255, 0.3);
  4529. } */
  4530. /* .loading-spinner {
  4531. width: 60px;
  4532. height: 60px;
  4533. border: 4px solid rgba(0, 212, 255, 0.3);
  4534. border-top: 4px solid #00d4ff;
  4535. border-radius: 50%;
  4536. animation: spin 1s linear infinite;
  4537. margin: 0 auto 20px;
  4538. } */
  4539. @keyframes spin {
  4540. 0% {
  4541. transform: rotate(0deg);
  4542. }
  4543. 100% {
  4544. transform: rotate(360deg);
  4545. }
  4546. }
  4547. /* .loading-text {
  4548. color: #00d4ff;
  4549. font-size: 18px;
  4550. font-weight: bold;
  4551. text-shadow: 0 2px 8px rgba(0, 212, 255, 0.5);
  4552. letter-spacing: 1px;
  4553. } */
  4554. /* 对话区域样式 */
  4555. .conversation-area {
  4556. width: 100%;
  4557. padding: 0 20px;
  4558. }
  4559. .message-list {
  4560. display: flex;
  4561. flex-direction: column;
  4562. gap: 15px;
  4563. }
  4564. .message-item {
  4565. width: 100%;
  4566. display: flex;
  4567. }
  4568. .user-message-item {
  4569. justify-content: flex-end;
  4570. }
  4571. .ai-message-item {
  4572. justify-content: flex-start;
  4573. }
  4574. .user-message-wrapper {
  4575. display: flex;
  4576. justify-content: flex-end;
  4577. max-width: 70%;
  4578. }
  4579. .ai-message-wrapper {
  4580. display: flex;
  4581. justify-content: flex-start;
  4582. }
  4583. /* 顶部锚点样式 */
  4584. .top-anchor {
  4585. position: relative;
  4586. top: 0;
  4587. left: 0;
  4588. width: 100%;
  4589. height: 1px;
  4590. display: block;
  4591. visibility: visible;
  4592. opacity: 0;
  4593. pointer-events: none;
  4594. }
  4595. /* 返回顶部按钮样式 */
  4596. .back-to-top {
  4597. position: sticky !important;
  4598. bottom: 20px !important;
  4599. left: calc(100% - 70px) !important;
  4600. width: 50px !important;
  4601. height: 50px !important;
  4602. background: linear-gradient(135deg, #00d4ff 0%, #0066cc 100%) !important;
  4603. border-radius: 50% !important;
  4604. display: flex !important;
  4605. align-items: center !important;
  4606. justify-content: center !important;
  4607. cursor: pointer !important;
  4608. transition: all 0.3s ease !important;
  4609. z-index: 100 !important;
  4610. color: white !important;
  4611. opacity: 1 !important;
  4612. visibility: visible !important;
  4613. margin-top: 20px !important;
  4614. margin-bottom: 20px !important;
  4615. }
  4616. .back-to-top:hover {
  4617. transform: translateY(-3px);
  4618. box-shadow: 0 6px 20px rgba(0, 212, 255, 0.5);
  4619. background: linear-gradient(135deg, #00e6ff 0%, #0077dd 100%);
  4620. }
  4621. .back-to-top:active {
  4622. transform: translateY(-1px);
  4623. }
  4624. /* 页面主容器样式 */
  4625. .page-container {
  4626. position: relative;
  4627. width: 100%;
  4628. }
  4629. .master:last-child {
  4630. border-bottom: none;
  4631. margin-bottom: 0;
  4632. }
  4633. /* class01容器样式 */
  4634. .main {
  4635. position: relative;
  4636. }
  4637. /* 移动端适配 */
  4638. @media only screen and (max-width: 768px) {
  4639. .back-to-top {
  4640. left: calc(100% - 65px) !important;
  4641. width: 45px !important;
  4642. height: 45px !important;
  4643. }
  4644. }
  4645. @media only screen and (max-width: 480px) {
  4646. .back-to-top {
  4647. left: calc(100% - 60px) !important;
  4648. width: 40px !important;
  4649. height: 40px !important;
  4650. }
  4651. .back-to-top svg {
  4652. width: 20px;
  4653. height: 20px;
  4654. }
  4655. }
  4656. </style>