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.

4513 lines
139 KiB

4 months ago
4 months ago
4 months ago
4 months ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
4 months ago
4 months ago
4 months ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
4 months ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
2 weeks ago
2 weeks ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
4 months ago
4 months ago
4 months ago
2 weeks ago
2 weeks ago
2 weeks ago
4 months ago
  1. <script setup>
  2. import { ref, onMounted, watch, nextTick, reactive, onUnmounted } from "vue";
  3. import { ElDialog } from "element-plus";
  4. import {
  5. getReplyStreamAPI,
  6. getReplyAPI,
  7. TTSAPI,
  8. qsArpAamClickAPI,
  9. dbqbFirstAPI,
  10. dbqbSecondOneAPI,
  11. dbqbSecondTwoAPI,
  12. dbqbSecondThreeAPI,
  13. dbqbSecondFourAPI,
  14. dataListAPI,
  15. } from "../api/AIxiaocaishen";
  16. import { useUserStore } from "../store/userPessionCode";
  17. import { useChatStore } from "../store/chat";
  18. import { useAudioStore } from "../store/audio";
  19. import { useDataStore } from "@/store/dataList.js";
  20. import { marked } from "marked"; // 引入marked库
  21. import katex from "katex"; // 引入 KaTeX 库
  22. import { htmlToText } from "html-to-text";
  23. import { Howl, Howler } from "howler";
  24. import * as echarts from "echarts";
  25. import _, { add } from "lodash";
  26. import moment from "moment";
  27. import title1 from "@/assets/img/AIchat/核心价值评估标题.png";
  28. import title2 from "@/assets/img/AIchat/主力作战.png";
  29. import title3 from "@/assets/img/AIchat/攻防三维.png";
  30. import title4 from "@/assets/img/AIchat/综合作战.png";
  31. import logo1 from "@/assets/img/AIchat/夺宝奇兵logo.png";
  32. import logo2 from "@/assets/img/AIchat/开启无限财富.png";
  33. import bgc from "@/assets/img/AIchat/圈.png";
  34. import bgc1 from "@/assets/img/AIchat/圈1.png";
  35. const chatStore = useChatStore();
  36. const audioStore = useAudioStore();
  37. const dataStore = useDataStore();
  38. // 随机GIF
  39. const currentGif = ref("");
  40. const renderer = new marked.Renderer();
  41. // 重写 del 方法,让删除线不生效
  42. renderer.del = function (text) {
  43. // 处理各种数据类型
  44. console.log("text", text);
  45. return "~" + text.tokens[0].raw + "<br>" + text.tokens[2].raw + "~";
  46. };
  47. // 定义自定义事件
  48. const emit = defineEmits(["updateMessage", "sendMessage"]);
  49. // 音频播放方法
  50. const playAudio = (url) => {
  51. // 添加空值校验
  52. if (!url) {
  53. console.warn("音频URL为空,跳过播放");
  54. audioStore.isPlaying = false;
  55. return;
  56. }
  57. const handlePlay = () => {
  58. // if (audioStore.soundInstance) {
  59. // Howler.unload(); // 添加清理旧实例
  60. // // audioStore.soundInstance.stop()
  61. // }
  62. if (audioStore.isNewInstance) {
  63. const newSound = new Howl({
  64. src: [url],
  65. html5: true, // 强制HTML5 Audio解决iOS兼容问题
  66. format: ["mp3", "acc"],
  67. rate: 1.2, // 调整播放速度
  68. onplay: () => {
  69. audioStore.isPlaying = true; // 改为更新store状态
  70. newSound.volume(1); // 添加音量设置
  71. },
  72. onend: () => (audioStore.isPlaying = false),
  73. onstop: () => (audioStore.isPlaying = false),
  74. onloaderror: (id, err) => {
  75. console.error("音频加载失败:", err);
  76. ElMessage.error("音频播放失败,请检查网络连接");
  77. },
  78. });
  79. if (audioStore.nowSound) {
  80. audioStore.nowSound.stop();
  81. }
  82. audioStore.nowSound = newSound;
  83. audioStore.isNewInstance = false;
  84. console.log("新音频");
  85. } else {
  86. console.log("已经有音频");
  87. }
  88. const newSound = audioStore.nowSound;
  89. // 添加立即播放逻辑
  90. newSound.play();
  91. audioStore.setAudioInstance(newSound);
  92. Howler._howls.push(newSound); // 强制注册到全局管理
  93. // // 处理浏览器自动播放策略
  94. // if (Howler.autoUnlock) {
  95. // Howler.autoUnlock();
  96. // }
  97. };
  98. // if (/iPhone|iPad|iPod/.test(navigator.userAgent)) {
  99. // document.addEventListener('touchstart', handlePlay, { once: true });
  100. // ElMessage.info('请轻触屏幕以启用音频播放');
  101. // } else {
  102. // handlePlay();
  103. // }
  104. handlePlay();
  105. // Howler.volume(1.0) // 添加全局音量设置
  106. };
  107. // 新增暂停方法
  108. const pauseAudio = () => {
  109. if (audioStore.soundInstance) {
  110. // 添加移动端特殊处理
  111. // if (/iPhone|iPad|iPod/.test(navigator.userAgent)) {
  112. // Howler.pause(); // iOS需要强制停止音频上下文
  113. // } else {
  114. // audioStore.soundInstance.pause();
  115. // }
  116. audioStore.soundInstance.pause();
  117. audioStore.isPlaying = false;
  118. // // 添加状态同步
  119. // nextTick(() => {
  120. // Howler.unload();
  121. // audioStore.soundInstance = null;
  122. // });
  123. }
  124. };
  125. // 音频轮流播放方法
  126. const playAudioSequence = (audioUrls) => {
  127. console.log("playAudioSequence被调用,参数:", audioUrls);
  128. if (!audioUrls || audioUrls.length === 0) {
  129. console.warn("音频URL列表为空,跳过播放");
  130. return;
  131. }
  132. let currentIndex = 0;
  133. let audioSequence = [...audioUrls]; // 保存音频序列
  134. const playNext = () => {
  135. if (currentIndex >= audioSequence.length) {
  136. console.log("所有音频播放完成,重置到第一个音频");
  137. // 播放完成后重置到第一个音频,但不自动播放
  138. currentIndex = 0;
  139. audioStore.isPlaying = false;
  140. audioStore.isPaused = false;
  141. audioStore.playbackPosition = 0;
  142. // 清除音频实例,确保下次点击从头开始
  143. audioStore.soundInstance = null;
  144. audioStore.nowSound = null;
  145. if (audioSequence.length > 0) {
  146. audioStore.setCurrentAudioUrl(audioSequence[0]);
  147. }
  148. return;
  149. }
  150. const currentUrl = audioSequence[currentIndex];
  151. console.log(`正在播放第${currentIndex + 1}个音频:`, currentUrl);
  152. console.log(
  153. "音频URL有效性检查:",
  154. !!currentUrl,
  155. "长度:",
  156. currentUrl?.length
  157. );
  158. // 增强URL验证
  159. if (
  160. !currentUrl ||
  161. typeof currentUrl !== "string" ||
  162. currentUrl.trim() === ""
  163. ) {
  164. console.error(`音频 ${currentIndex + 1} URL无效,跳过该音频`);
  165. currentIndex++;
  166. setTimeout(() => {
  167. playNext();
  168. }, 100);
  169. return;
  170. }
  171. // 检查URL格式
  172. try {
  173. new URL(currentUrl);
  174. } catch (e) {
  175. console.error(`音频 ${currentIndex + 1} URL格式错误:`, currentUrl);
  176. currentIndex++;
  177. setTimeout(() => {
  178. playNext();
  179. }, 100);
  180. return;
  181. }
  182. // 设置当前音频URL
  183. audioStore.setCurrentAudioUrl(currentUrl);
  184. // 停止当前播放的音频
  185. if (audioStore.nowSound) {
  186. audioStore.nowSound.stop();
  187. }
  188. const sound = new Howl({
  189. src: [currentUrl],
  190. html5: true,
  191. format: ["mp3", "acc"],
  192. rate: 1.2,
  193. onplay: () => {
  194. audioStore.isPlaying = true;
  195. audioStore.isPaused = false;
  196. console.log(`开始播放音频 ${currentIndex + 1}`);
  197. console.log("音频播放状态:", {
  198. duration: sound.duration(),
  199. state: sound.state(),
  200. playing: sound.playing(),
  201. });
  202. },
  203. onpause: () => {
  204. audioStore.isPlaying = false;
  205. audioStore.isPaused = true;
  206. audioStore.playbackPosition = sound.seek() || 0;
  207. console.log(`音频 ${currentIndex + 1} 已暂停`);
  208. },
  209. onend: () => {
  210. audioStore.isPlaying = false;
  211. audioStore.isPaused = false;
  212. audioStore.playbackPosition = 0;
  213. console.log(`音频 ${currentIndex + 1} 播放完成`);
  214. currentIndex++;
  215. // 如果是最后一个音频播放完成,立即清除实例
  216. if (currentIndex >= audioSequence.length) {
  217. console.log("最后一个音频播放完成,清除音频实例");
  218. audioStore.soundInstance = null;
  219. audioStore.nowSound = null;
  220. currentIndex = 0; // 立即重置索引
  221. }
  222. // 播放下一个音频
  223. setTimeout(() => {
  224. playNext();
  225. }, 500); // 间隔500ms播放下一个
  226. },
  227. onstop: () => {
  228. audioStore.isPlaying = false;
  229. audioStore.isPaused = false;
  230. audioStore.playbackPosition = 0;
  231. console.log(`音频 ${currentIndex + 1} 已停止`);
  232. },
  233. onloaderror: (id, err) => {
  234. console.error(`音频 ${currentIndex + 1} 加载失败:`, err);
  235. console.error("失败的音频URL:", currentUrl);
  236. console.error("错误详情:", { id, err });
  237. // 增加重试机制
  238. if (!sound.retryCount) {
  239. sound.retryCount = 0;
  240. }
  241. if (sound.retryCount < 2) {
  242. sound.retryCount++;
  243. console.log(
  244. `音频 ${currentIndex + 1}${sound.retryCount}次重试加载`
  245. );
  246. setTimeout(() => {
  247. sound.load();
  248. }, 1000 * sound.retryCount); // 递增延时重试
  249. } else {
  250. console.warn(`音频 ${currentIndex + 1} 重试失败,跳过该音频`);
  251. currentIndex++;
  252. // 跳过失败的音频,播放下一个
  253. setTimeout(() => {
  254. playNext();
  255. }, 100);
  256. }
  257. },
  258. });
  259. audioStore.nowSound = sound;
  260. audioStore.setAudioInstance(sound);
  261. // 添加播放超时检测
  262. const playTimeout = setTimeout(() => {
  263. if (!audioStore.isPlaying && sound.state() === "loading") {
  264. console.warn(`音频 ${currentIndex + 1} 播放超时,可能网络问题`);
  265. sound.stop();
  266. currentIndex++;
  267. playNext();
  268. }
  269. }, 10000); // 10秒超时
  270. // 播放成功后清除超时
  271. sound.once("play", () => {
  272. clearTimeout(playTimeout);
  273. });
  274. console.log(`尝试播放音频 ${currentIndex + 1},URL: ${currentUrl}`);
  275. sound.play();
  276. };
  277. // 重写togglePlayPause方法以支持音频序列控制
  278. const originalTogglePlayPause = audioStore.togglePlayPause;
  279. audioStore.togglePlayPause = () => {
  280. console.log("音频控制按钮被点击");
  281. console.log("当前播放状态:", audioStore.isPlaying);
  282. console.log("当前暂停状态:", audioStore.isPaused);
  283. console.log("当前音频实例:", audioStore.soundInstance);
  284. console.log(
  285. "当前索引:",
  286. currentIndex,
  287. "音频序列长度:",
  288. audioSequence.length
  289. );
  290. if (audioStore.soundInstance) {
  291. if (audioStore.isPlaying) {
  292. // 暂停当前音频
  293. console.log("暂停当前音频");
  294. audioStore.pause();
  295. } else if (audioStore.isPaused) {
  296. // 从暂停位置继续播放
  297. console.log("从暂停位置继续播放");
  298. audioStore.play();
  299. } else {
  300. // 重新开始播放当前音频或从头开始播放序列
  301. console.log("重新开始播放,当前索引:", currentIndex);
  302. if (currentIndex >= audioSequence.length) {
  303. console.log("所有音频已播放完成,从头开始");
  304. currentIndex = 0; // 重置到第一个音频
  305. }
  306. playNext();
  307. }
  308. } else {
  309. // 没有音频实例时,从头开始播放
  310. console.log("没有音频实例,从头开始播放");
  311. currentIndex = 0;
  312. playNext();
  313. }
  314. };
  315. // 开始播放第一个音频
  316. playNext();
  317. };
  318. // 获取消息
  319. const chatMsg = computed(() => chatStore.messages);
  320. const props = defineProps({
  321. messages: Array,
  322. chartData: {
  323. type: Object,
  324. default: null,
  325. },
  326. index: {
  327. type: Number,
  328. required: true,
  329. },
  330. });
  331. // 打字机效果
  332. const typewriterContent = ref("");
  333. const isTyping = ref(false);
  334. const typeWriter = (text, callback) => {
  335. let index = 0;
  336. isTyping.value = true;
  337. typewriterContent.value = "";
  338. const typingInterval = setInterval(() => {
  339. if (index < text.length) {
  340. typewriterContent.value += text.charAt(index);
  341. index++;
  342. // 自动滚动到底部
  343. nextTick(() => {
  344. const container = document.querySelector(".message-area");
  345. if (container) container.scrollTop = container.scrollHeight;
  346. });
  347. } else {
  348. clearInterval(typingInterval);
  349. isTyping.value = false;
  350. if (callback) callback();
  351. }
  352. }, 50); // 调整速度(毫秒)
  353. };
  354. const fnGetData = (data) => {
  355. const YaLiZhiChengLuoPan = data.YaLiZhiChengLuoPan;
  356. let sz = ref(5.5); // 进行判断
  357. const yl = YaLiZhiChengLuoPan.Yali; // 压力位
  358. const zc = YaLiZhiChengLuoPan.ZhiCheng; // 支撑位
  359. console.log("yl", yl, "zc", zc);
  360. if (yl == "较大" && zc == "较弱") {
  361. sz.value = 0.5; // 极高风险
  362. } else if (yl == "一般" && zc == "较弱") {
  363. sz.value = 1.5; // 弱撑中压区
  364. } else if (yl == "较弱" && zc == "较弱") {
  365. sz.value = 2.5; // 弱撑弱压区
  366. } else if (yl == "较大" && zc == "较大") {
  367. sz.value = 3.5; // 强撑强压区
  368. } else if (yl == "一般" && zc == "较大") {
  369. sz.value = 4.5; // 强撑中压
  370. } else if (yl == "较弱" && zc == "较大") {
  371. sz.value = 5.5; // 强撑弱压区
  372. } else if (yl == "较大" && zc == "一般") {
  373. sz.value = 0.2;
  374. } else if (yl == "一般" && zc == "一般") {
  375. sz.value = 3;
  376. } else if (yl == "较弱" && zc == "一般") {
  377. sz.value = 5.8;
  378. }
  379. return sz.value;
  380. };
  381. const typingQueue = ref([]);
  382. const isTypingInProgress = ref(false);
  383. // 创建打字机效果的Promise函数
  384. const createTypingEffect = (message, content, speed) => {
  385. return new Promise((resolve) => {
  386. chatStore.messages.push(message);
  387. if (Array.isArray(content) && content.length > 0) {
  388. message.content = "";
  389. message.isTyping = true;
  390. let currentIndex = 0;
  391. const processNextElement = () => {
  392. if (currentIndex >= content.length) {
  393. if (message.isEnd) {
  394. if (message.isEnd == "1") {
  395. apiStatus.one.isEnd = true;
  396. } else if (message.isEnd == "2") {
  397. apiStatus.two.isEnd = true;
  398. } else if (message.isEnd == "3") {
  399. apiStatus.three.isEnd = true;
  400. } else if (message.isEnd == "4") {
  401. apiStatus.four.isEnd = true;
  402. }
  403. }
  404. if (message.error) {
  405. chatStore.messages.push({
  406. class: "ing",
  407. type: "ing",
  408. flag: false,
  409. content: "工作流返回出错,请稍后重试",
  410. });
  411. chatStore.isLoading = false;
  412. if (message.error == "2") {
  413. apiStatus.two.isError = true;
  414. } else if (message.error == "3") {
  415. apiStatus.three.isError = true;
  416. } else if (message.error == "4") {
  417. apiStatus.four.isError = true;
  418. }
  419. }
  420. if (message.end) {
  421. chatStore.getUserCount();
  422. chatStore.isLoading = false;
  423. }
  424. message.isTyping = false;
  425. nextTick(() => {
  426. resolve(); // 完成后resolve
  427. });
  428. return;
  429. }
  430. if (currentIndex % 2 === 0) {
  431. // 偶数下标:直接加入
  432. message.content += content[currentIndex];
  433. currentIndex++;
  434. processNextElement(); // 立即处理下一个元素
  435. } else {
  436. // 奇数下标:打字机效果
  437. const text = content[currentIndex];
  438. let charIndex = 0;
  439. const typingInterval = setInterval(() => {
  440. if (charIndex < text.length) {
  441. message.content += text.charAt(charIndex);
  442. charIndex++;
  443. } else {
  444. clearInterval(typingInterval);
  445. currentIndex++;
  446. processNextElement(); // 处理下一个元素
  447. }
  448. }, speed);
  449. }
  450. };
  451. processNextElement(); // 开始处理
  452. } else {
  453. if (message.kline) {
  454. if (message.klineType == 1) {
  455. console.log("六色罗盘消息已添加到聊天列表");
  456. // 在渲染完成后初始化图表
  457. nextTick(() => {
  458. console.log("nextTick开始 - 准备渲染图表");
  459. console.log("消息列表:", chatStore.messages);
  460. // 寻找最新添加的K线消息索引
  461. let klineIndex = -1;
  462. for (let i = 0; i < chatStore.messages.length; i++) {
  463. if (chatStore.messages[i].messageId === message.messageId) {
  464. klineIndex = i;
  465. break;
  466. }
  467. }
  468. console.log("找到的K线消息索引:", klineIndex);
  469. if (klineIndex !== -1) {
  470. const containerId = `kline-container-${klineIndex}`;
  471. console.log("图表容器ID:", containerId);
  472. // 确保DOM已经渲染完成
  473. setTimeout(() => {
  474. console.log("延时执行,确保DOM已渲染");
  475. KlineCanvsEcharts(containerId);
  476. }, 100); // 短暂延时确保DOM已渲染
  477. } else {
  478. console.warn("未找到K线消息");
  479. }
  480. });
  481. } else {
  482. console.log("K线消息已添加到聊天列表");
  483. // 在渲染完成后初始化图表
  484. nextTick(() => {
  485. console.log("nextTick开始 - 准备渲染图表");
  486. console.log("消息列表:", chatStore.messages);
  487. // 寻找最新添加的K线消息索引
  488. let klineIndex = -1;
  489. for (let i = 0; i < chatStore.messages.length; i++) {
  490. if (chatStore.messages[i].messageId === message.messageId) {
  491. klineIndex = i;
  492. break;
  493. }
  494. }
  495. console.log("找到的K线消息索引:", klineIndex);
  496. if (klineIndex !== -1) {
  497. const containerId = `kline-container-${klineIndex}`;
  498. console.log("图表容器ID:", containerId);
  499. // 确保DOM已经渲染完成
  500. setTimeout(() => {
  501. console.log("延时执行,确保DOM已渲染");
  502. KlineCanvsEcharts(containerId);
  503. }, 100); // 短暂延时确保DOM已渲染
  504. } else {
  505. console.warn("未找到K线消息");
  506. }
  507. });
  508. }
  509. if (message.isEnd) {
  510. if (message.isEnd == "1") {
  511. apiStatus.one.isEnd = true;
  512. } else if (message.isEnd == "2") {
  513. apiStatus.two.isEnd = true;
  514. } else if (message.isEnd == "3") {
  515. apiStatus.three.isEnd = true;
  516. } else if (message.isEnd == "4") {
  517. apiStatus.four.isEnd = true;
  518. }
  519. }
  520. if (message.error) {
  521. chatStore.messages.push({
  522. class: "ing",
  523. type: "ing",
  524. flag: false,
  525. content: "工作流返回出错,请稍后重试",
  526. });
  527. chatStore.isLoading = false;
  528. if (message.error == "2") {
  529. apiStatus.two.isError = true;
  530. } else if (message.error == "3") {
  531. apiStatus.three.isError = true;
  532. } else if (message.error == "4") {
  533. apiStatus.four.isError = true;
  534. }
  535. }
  536. // 延时1秒后resolve
  537. setTimeout(() => {
  538. resolve();
  539. }, 1000);
  540. } else {
  541. if (message.isEnd) {
  542. if (message.isEnd == "1") {
  543. apiStatus.one.isEnd = true;
  544. } else if (message.isEnd == "2") {
  545. apiStatus.two.isEnd = true;
  546. } else if (message.isEnd == "3") {
  547. apiStatus.three.isEnd = true;
  548. } else if (message.isEnd == "4") {
  549. apiStatus.four.isEnd = true;
  550. }
  551. }
  552. if (message.error) {
  553. chatStore.messages.push({
  554. class: "ing",
  555. type: "ing",
  556. flag: false,
  557. content: "工作流返回出错,请稍后重试",
  558. });
  559. chatStore.isLoading = false;
  560. if (message.error == "2") {
  561. apiStatus.two.isError = true;
  562. } else if (message.error == "3") {
  563. apiStatus.three.isError = true;
  564. } else if (message.error == "4") {
  565. apiStatus.four.isError = true;
  566. }
  567. }
  568. // 延时1秒后resolve
  569. setTimeout(() => {
  570. resolve();
  571. }, 1000);
  572. }
  573. }
  574. });
  575. };
  576. let apiStatus = {};
  577. // 队列处理函数
  578. const processTypingQueue = async () => {
  579. if (isTypingInProgress.value || typingQueue.value.length === 0) {
  580. return;
  581. }
  582. isTypingInProgress.value = true;
  583. while (typingQueue.value.length > 0) {
  584. const task = typingQueue.value.shift();
  585. await createTypingEffect(task.message, task.content, task.speed);
  586. }
  587. isTypingInProgress.value = false;
  588. };
  589. // 添加打字机任务到队列
  590. const addTypingTask = (message, content, speed) => {
  591. typingQueue.value.push({ message, content, speed });
  592. processTypingQueue();
  593. };
  594. const hasValidData = ref(false);
  595. // 创建一个非响应式的对象来存储图表实例
  596. const chartInstancesMap = {};
  597. // 存储上一次的消息的length
  598. const previousMessagesLength = ref(0);
  599. watch(
  600. () => props.messages,
  601. async (newVal, oldVal) => {
  602. // console.log(newVal, 'newVal')
  603. // console.log(oldVal, 'oldVal')
  604. // console.log(previousMessagesLength.value, 'previousMessagesLength')
  605. // console.log(newVal.length, 'newVal.length')
  606. // // 添加空值判断
  607. if (!newVal?.length || newVal === previousMessagesLength.value) return;
  608. previousMessagesLength.value = newVal.length;
  609. if (newVal.length > 0) {
  610. console.log("消息列表已更新,最新消息:", newVal[newVal.length - 1]);
  611. chatStore.messages.push(newVal[newVal.length - 1]);
  612. console.log("消息列表已更新,最新消息:", chatMsg[chatMsg.length - 1]);
  613. console.log("token", localStorage.getItem("localToken"));
  614. // 获取权限
  615. const userStore = useUserStore();
  616. const params1 = {
  617. content: newVal[newVal.length - 1].content,
  618. language: "cn",
  619. marketList: "usa,sg,my,hk,cn,can,vi,th,in",
  620. token: localStorage.getItem("localToken"),
  621. // language: "cn",
  622. // marketList: "hk,cn,usa,my,sg,vi,in,gb"
  623. // token: "+SsksARQgUHIbIG3rRnnbZi0+fEeMx8pywnIlrmTxo5EOPR/wjWDV7w7+ZUseiBtf9kFa/atmNx6QfSpv5w",
  624. };
  625. // 标志
  626. let flag = true;
  627. const codeData = ref();
  628. // 第一阶段,意图识别
  629. try {
  630. // 调用工作流获取回复
  631. const result = await dbqbFirstAPI(params1);
  632. codeData.value = result.data;
  633. console.log(codeData.value, "codeData");
  634. // 根据意图识别结果判断
  635. if (result.code == 200) {
  636. chatStore.messages.push({
  637. class: "ing",
  638. type: "ing",
  639. flag: flag,
  640. content: result.data.kaishi,
  641. });
  642. } else {
  643. flag = false;
  644. console.log("执行回绝话术");
  645. const AIcontent = ref(result.msg);
  646. // 修改后的消息处理逻辑
  647. const processedContent = marked(AIcontent.value);
  648. const katexRegex = /\$\$(.*?)\$\$/g;
  649. const aiContent = processedContent.replace(
  650. katexRegex,
  651. (match, formula) => {
  652. try {
  653. return katex.renderToString(formula, { throwOnError: false });
  654. } catch (error) {
  655. console.error("KaTeX 渲染错误:", error);
  656. return match;
  657. }
  658. }
  659. );
  660. console.log(aiContent, "aiContent");
  661. chatStore.messages.push({
  662. class: "ing",
  663. type: "ing",
  664. flag: flag,
  665. content: aiContent,
  666. });
  667. chatStore.isLoading = false;
  668. }
  669. } catch (e) {
  670. console.log(e, "意图识别失败");
  671. chatStore.messages.push({
  672. class: "ing",
  673. type: "ing",
  674. flag: false,
  675. content: "工作流返回出错,请稍后重试",
  676. });
  677. chatStore.isLoading = false;
  678. }
  679. if (flag) {
  680. const params2 = {
  681. content: newVal[newVal.length - 1].content,
  682. language: "cn",
  683. marketList: "usa,sg,my,hk,cn,can,vi,th,in",
  684. token: localStorage.getItem("localToken"),
  685. // language: "cn",
  686. // marketList: "hk,cn,usa,my,sg,vi,in,gb"
  687. // token: "+SsksARQgUHIbIG3rRnnbZi0+fEeMx8pywnIlrmTxo5EOPR/wjWDV7w7+ZUseiBtf9kFa/atmNx6QfSpv5w",
  688. name: codeData.value.name,
  689. code: codeData.value.code,
  690. market: codeData.value.market,
  691. };
  692. try {
  693. const env = import.meta.env.VITE_ENV;
  694. const result20 = await dataListAPI({
  695. token:
  696. // "8Csj5VVX1UbIb4C3oxrnbZi0+fEeMx8pywnIlrmTm45Cb/EllzWACLto9J9+fCFsfdgBOvKvyY94FvqlvM0",
  697. "8nkj4QBV1RPIb4CzoRTnbZi0+fEeMx8pywnIlrmTxdwROKkuwWqAWu9orpkpeXVqL98DPfeonNYpHv+mucA",
  698. market: codeData.value.market,
  699. code: codeData.value.code,
  700. language: "cn", //t.value.suoxie,
  701. brainPrivilegeState: 1,
  702. swordPrivilegeState: 1,
  703. stockForecastPrivilegeState: 1,
  704. spaceForecastPrivilegeState: 1,
  705. aibullPrivilegeState: 1,
  706. aigoldBullPrivilegeState: 1,
  707. airadarPrivilegeState: 1,
  708. // marketList: 1,
  709. // brainPrivilegeState: userStore.brainPerssion,
  710. // swordPrivilegeState: userStore.swordPerssion,
  711. // stockForecastPrivilegeState: userStore.pricePerssion,
  712. // spaceForecastPrivilegeState: userStore.timePerssion,
  713. // aibullPrivilegeState: userStore.aibullPerssion,
  714. // aigoldBullPrivilegeState: userStore.aiGnbullPerssion,
  715. // airadarPrivilegeState: userStore.airadarPerssion,
  716. marketList: userStore.aiGoldMarketList,
  717. });
  718. const HomePage = result20.data.HomePage;
  719. const AIGoldBull = result20.data.AIGoldBull;
  720. const isLiuSe = HomePage ? true : false;
  721. const isAIGoldBull =
  722. AIGoldBull &&
  723. AIGoldBull.DNC &&
  724. AIGoldBull.FCX &&
  725. AIGoldBull.JN &&
  726. AIGoldBull.KLine20 &&
  727. AIGoldBull.QSXH
  728. ? true
  729. : false;
  730. const katexRegex = /\$\$(.*?)\$\$/g;
  731. let result21;
  732. let result22;
  733. let result23;
  734. let result24;
  735. // 用于跟踪API完成状态和结果
  736. apiStatus = {
  737. one: {
  738. completed: false,
  739. result: null,
  740. error: null,
  741. isError: false,
  742. isEnd: false,
  743. },
  744. two: {
  745. completed: false,
  746. result: null,
  747. error: null,
  748. isError: false,
  749. isEnd: false,
  750. },
  751. three: {
  752. completed: false,
  753. result: null,
  754. error: null,
  755. isError: false,
  756. isEnd: false,
  757. },
  758. four: {
  759. completed: false,
  760. result: null,
  761. error: null,
  762. isError: false,
  763. isEnd: false,
  764. },
  765. };
  766. // 音频预加载状态跟踪
  767. const audioPreloadStatus = {
  768. one: { loaded: false, url: null },
  769. two: { loaded: false, url: null },
  770. three: { loaded: false, url: null },
  771. four: { loaded: false, url: null },
  772. };
  773. // 音频播放队列管理
  774. const audioQueue = ref([]);
  775. const isPlayingAudio = ref(false);
  776. // 播放音频队列
  777. // 防止重复调用的标志
  778. let isCallingPlayNext = false;
  779. // 当前播放索引
  780. let currentPlayIndex = 0;
  781. const playNextAudio = () => {
  782. console.log("=== playNextAudio 被调用 ===");
  783. console.log("当前队列状态:", {
  784. queueLength: audioQueue.value.length,
  785. queueItems: audioQueue.value.map((item) => item.name),
  786. currentPlayIndex: currentPlayIndex,
  787. isPlayingAudio: isPlayingAudio.value,
  788. isCallingPlayNext: isCallingPlayNext,
  789. audioStoreIsPlaying: audioStore.isPlaying,
  790. });
  791. if (
  792. audioQueue.value.length === 0 ||
  793. isPlayingAudio.value ||
  794. isCallingPlayNext
  795. ) {
  796. console.log(
  797. "❌ 播放条件不满足 - 队列长度:",
  798. audioQueue.value.length,
  799. "正在播放:",
  800. isPlayingAudio.value,
  801. "正在调用:",
  802. isCallingPlayNext
  803. );
  804. return;
  805. }
  806. // 检查是否已播放完所有音频(仅在队列不为空时重置)
  807. if (
  808. currentPlayIndex >= audioQueue.value.length &&
  809. audioQueue.value.length > 0
  810. ) {
  811. console.log("🔄 所有音频播放完成,重置索引从第一个开始");
  812. currentPlayIndex = 0;
  813. }
  814. isCallingPlayNext = true;
  815. isPlayingAudio.value = true;
  816. const audioInfo = audioQueue.value[currentPlayIndex];
  817. console.log(
  818. `✅ 开始播放${audioInfo.name}音频 (索引:${currentPlayIndex}),队列总长度:`,
  819. audioQueue.value.length
  820. );
  821. console.log(
  822. "完整队列内容:",
  823. audioQueue.value.map(
  824. (item, index) =>
  825. `${index === currentPlayIndex ? "▶️" : "⏸️"} ${item.name}`
  826. )
  827. );
  828. // 只有在确实需要停止时才停止之前的音频
  829. if (
  830. audioStore.nowSound &&
  831. (audioStore.nowSound.playing() ||
  832. audioStore.nowSound.state() === "loading")
  833. ) {
  834. console.log("停止之前的音频实例");
  835. audioStore.nowSound.stop();
  836. }
  837. const audio = new Howl({
  838. src: [audioInfo.url],
  839. html5: true,
  840. format: ["mp3", "acc"],
  841. rate: 1.2,
  842. onplay: () => {
  843. audioStore.isPlaying = true;
  844. audioStore.isPaused = false;
  845. isPlayingAudio.value = true; // 确保状态同步
  846. isCallingPlayNext = false; // 重置调用标志
  847. console.log(
  848. `${audioInfo.name}音频开始播放,时长:`,
  849. audio.duration()
  850. );
  851. console.log(
  852. "音频播放状态确认 - isPlayingAudio:",
  853. isPlayingAudio.value,
  854. "audioStore.isPlaying:",
  855. audioStore.isPlaying
  856. );
  857. },
  858. onpause: () => {
  859. audioStore.isPlaying = false;
  860. audioStore.isPaused = true;
  861. audioStore.playbackPosition = audio.seek() || 0;
  862. console.log(
  863. `${audioInfo.name}音频已暂停,位置:`,
  864. audioStore.playbackPosition
  865. );
  866. },
  867. onresume: () => {
  868. audioStore.isPlaying = true;
  869. audioStore.isPaused = false;
  870. console.log(`${audioInfo.name}音频继续播放`);
  871. },
  872. onend: () => {
  873. console.log(`${audioInfo.name}音频播放完成,准备播放下一个`);
  874. console.log(
  875. "播放完成时的状态 - 当前索引:",
  876. currentPlayIndex,
  877. "队列长度:",
  878. audioQueue.value.length,
  879. "isPlayingAudio:",
  880. isPlayingAudio.value
  881. );
  882. audioStore.isPlaying = false;
  883. audioStore.isPaused = false;
  884. audioStore.playbackPosition = 0;
  885. isPlayingAudio.value = false;
  886. // 移动到下一个音频索引
  887. currentPlayIndex++;
  888. // 确保只有在音频真正播放完成时才播放下一个
  889. if (currentPlayIndex < audioQueue.value.length) {
  890. console.log(
  891. `队列中还有音频,500ms后播放下一个 (索引:${currentPlayIndex}),当前队列:`,
  892. audioQueue.value.map(
  893. (item, index) =>
  894. `${index === currentPlayIndex ? "▶️" : "⏸️"} ${
  895. item.name
  896. }`
  897. )
  898. );
  899. setTimeout(() => {
  900. isCallingPlayNext = false; // 在调用前重置标志
  901. playNextAudio();
  902. }, 500);
  903. } else {
  904. console.log(
  905. "🎉 所有音频播放完成,清除音频实例,队列保持完整,下次播放将从第一个开始"
  906. );
  907. // 清除音频实例,确保重新播放时不会使用旧实例
  908. audioStore.nowSound = null;
  909. audioStore.soundInstance = null;
  910. isCallingPlayNext = false; // 重置调用标志
  911. }
  912. },
  913. onstop: () => {
  914. console.log(`${audioInfo.name}音频被停止`);
  915. audioStore.isPlaying = false;
  916. audioStore.isPaused = false;
  917. audioStore.playbackPosition = 0;
  918. // 注意:不要在onstop中设置isPlayingAudio.value = false,因为这可能是正常的音频切换
  919. },
  920. onloaderror: (id, err) => {
  921. console.error(`${audioInfo.name}音频播放失败:`, err);
  922. isPlayingAudio.value = false;
  923. isCallingPlayNext = false; // 重置调用标志
  924. // 播放下一个音频
  925. setTimeout(() => {
  926. playNextAudio();
  927. }, 100);
  928. },
  929. });
  930. // 设置当前音频URL到store
  931. audioStore.setCurrentAudioUrl(audioInfo.url);
  932. audioStore.nowSound = audio;
  933. audioStore.setAudioInstance(audio);
  934. console.log(`尝试播放${audioInfo.name}音频`);
  935. audio.play();
  936. };
  937. // 音频队列顺序管理
  938. const audioQueueOrder = {
  939. "API1-第一个": 1,
  940. "API2-第二个": 2,
  941. "API3-第三个": 3,
  942. "API4-第四个": 4,
  943. };
  944. // 添加音频到播放队列(确保顺序)
  945. const addToAudioQueue = (url, name) => {
  946. console.log(`=== 添加音频到队列 ===`);
  947. console.log("URL:", url);
  948. console.log("Name:", name);
  949. console.log("音频启用状态:", audioStore.isVoiceEnabled);
  950. if (url && audioStore.isVoiceEnabled) {
  951. const audioItem = {
  952. url,
  953. name,
  954. order: audioQueueOrder[name] || 999,
  955. };
  956. audioQueue.value.push(audioItem);
  957. // 按顺序排序队列
  958. audioQueue.value.sort((a, b) => a.order - b.order);
  959. console.log(
  960. `音频${name}已添加到播放队列,顺序:${audioItem.order}`
  961. );
  962. console.log(
  963. "当前队列顺序:",
  964. audioQueue.value.map((item) => `${item.name}(${item.order})`)
  965. );
  966. console.log("当前播放状态详情:");
  967. console.log(" - isPlayingAudio:", isPlayingAudio.value);
  968. console.log(" - audioStore.isPlaying:", audioStore.isPlaying);
  969. console.log(" - audioStore.nowSound:", audioStore.nowSound);
  970. console.log(" - isCallingPlayNext:", isCallingPlayNext);
  971. console.log(" - 队列长度:", audioQueue.value.length);
  972. // 只有在确实没有音频在播放且这是第一个音频时才开始播放
  973. if (
  974. !isPlayingAudio.value &&
  975. !audioStore.isPlaying &&
  976. audioQueue.value.length === 1
  977. ) {
  978. console.log(
  979. "✅ 条件满足:没有音频在播放且这是第一个音频,立即开始播放"
  980. );
  981. playNextAudio();
  982. } else {
  983. console.log("⏳ 等待条件:", {
  984. isPlayingAudio: isPlayingAudio.value,
  985. audioStoreIsPlaying: audioStore.isPlaying,
  986. queueLength: audioQueue.value.length,
  987. reason:
  988. audioQueue.value.length > 1
  989. ? "队列中已有其他音频"
  990. : "有音频正在播放",
  991. });
  992. }
  993. } else {
  994. console.log("❌ 跳过添加音频:", {
  995. hasUrl: !!url,
  996. voiceEnabled: audioStore.isVoiceEnabled,
  997. });
  998. }
  999. console.log(`=== 添加音频完成 ===`);
  1000. };
  1001. // 重写audioStore的togglePlayPause方法以支持队列播放控制
  1002. const originalTogglePlayPause = audioStore.togglePlayPause;
  1003. audioStore.togglePlayPause = () => {
  1004. console.log("主页音频控制按钮被点击");
  1005. console.log(
  1006. "当前音频状态 - isPlaying:",
  1007. audioStore.isPlaying,
  1008. "isPaused:",
  1009. audioStore.isPaused
  1010. );
  1011. console.log("当前音频实例:", audioStore.soundInstance);
  1012. console.log(
  1013. "队列播放状态 - isPlayingAudio:",
  1014. isPlayingAudio.value,
  1015. "队列长度:",
  1016. audioQueue.value.length
  1017. );
  1018. console.log(
  1019. "当前播放索引:",
  1020. currentPlayIndex,
  1021. "是否所有音频播放完成:",
  1022. currentPlayIndex >= audioQueue.value.length
  1023. );
  1024. // 检查是否所有音频都播放完成,如果是则重新开始
  1025. if (
  1026. audioStore.soundInstance &&
  1027. currentPlayIndex < audioQueue.value.length &&
  1028. isPlayingAudio.value
  1029. ) {
  1030. if (audioStore.isPlaying) {
  1031. // 暂停当前音频
  1032. console.log("暂停当前音频");
  1033. audioStore.soundInstance.pause();
  1034. } else if (
  1035. audioStore.isPaused &&
  1036. audioStore.playbackPosition > 0
  1037. ) {
  1038. // 从暂停位置继续播放
  1039. console.log(
  1040. "从暂停位置继续播放音频,位置:",
  1041. audioStore.playbackPosition
  1042. );
  1043. audioStore.soundInstance.seek(audioStore.playbackPosition);
  1044. audioStore.soundInstance.play();
  1045. } else {
  1046. // 重新开始播放
  1047. console.log("重新开始播放音频");
  1048. audioStore.soundInstance.play();
  1049. }
  1050. } else {
  1051. console.log("没有音频实例,检查是否需要重新播放队列");
  1052. console.log("重新播放条件检查:", {
  1053. isPlayingAudio: isPlayingAudio.value,
  1054. queueLength: audioQueue.value.length,
  1055. currentPlayIndex: currentPlayIndex,
  1056. condition1: audioQueue.value.length === 0,
  1057. condition2: currentPlayIndex >= audioQueue.value.length,
  1058. finalCondition:
  1059. !isPlayingAudio.value &&
  1060. (audioQueue.value.length === 0 ||
  1061. currentPlayIndex >= audioQueue.value.length),
  1062. });
  1063. // 没有音频实例时,检查是否所有音频都播放完成
  1064. if (
  1065. !isPlayingAudio.value &&
  1066. (audioQueue.value.length === 0 ||
  1067. currentPlayIndex >= audioQueue.value.length)
  1068. ) {
  1069. console.log("所有音频播放完成,重新构建队列从第一个开始播放");
  1070. // 重新构建音频队列,按顺序添加所有音频(不自动播放)
  1071. const audioItems = [];
  1072. if (audioPreloadStatus.one.url) {
  1073. audioItems.push({
  1074. url: audioPreloadStatus.one.url,
  1075. name: "API1-第一个",
  1076. order: 1,
  1077. });
  1078. }
  1079. if (audioPreloadStatus.two.url) {
  1080. audioItems.push({
  1081. url: audioPreloadStatus.two.url,
  1082. name: "API2-第二个",
  1083. order: 2,
  1084. });
  1085. }
  1086. if (audioPreloadStatus.three.url) {
  1087. audioItems.push({
  1088. url: audioPreloadStatus.three.url,
  1089. name: "API3-第三个",
  1090. order: 3,
  1091. });
  1092. }
  1093. if (audioPreloadStatus.four.url) {
  1094. audioItems.push({
  1095. url: audioPreloadStatus.four.url,
  1096. name: "API4-第四个",
  1097. order: 4,
  1098. });
  1099. }
  1100. // 按顺序排序并添加到队列
  1101. audioItems.sort((a, b) => a.order - b.order);
  1102. audioQueue.value = audioItems;
  1103. console.log(
  1104. "队列重建完成,队列内容:",
  1105. audioQueue.value.map((item) => item.name)
  1106. );
  1107. console.log("开始从第一个音频播放");
  1108. // 重置播放状态并开始播放第一个音频
  1109. if (audioQueue.value.length > 0) {
  1110. // 完全重置所有播放相关状态
  1111. isPlayingAudio.value = false;
  1112. isCallingPlayNext = false;
  1113. currentPlayIndex = 0; // 重置播放索引到第一个音频
  1114. audioStore.isPlaying = false;
  1115. audioStore.isPaused = false;
  1116. audioStore.playbackPosition = 0;
  1117. audioStore.nowSound = null;
  1118. audioStore.soundInstance = null;
  1119. console.log("🔄 状态完全重置完成,准备从第一个音频开始播放");
  1120. console.log("✅ 完全重置播放状态,准备播放第一个音频");
  1121. console.log("重置后状态检查:", {
  1122. isPlayingAudio: isPlayingAudio.value,
  1123. isCallingPlayNext: isCallingPlayNext,
  1124. currentPlayIndex: currentPlayIndex,
  1125. audioStoreIsPlaying: audioStore.isPlaying,
  1126. queueLength: audioQueue.value.length,
  1127. });
  1128. setTimeout(() => {
  1129. console.log("🚀 延迟后开始播放第一个音频");
  1130. console.log("播放前最终状态检查:", {
  1131. currentPlayIndex: currentPlayIndex,
  1132. queueLength: audioQueue.value.length,
  1133. queueItems: audioQueue.value.map(
  1134. (item, index) => `${index}: ${item.name}`
  1135. ),
  1136. isPlayingAudio: isPlayingAudio.value,
  1137. isCallingPlayNext: isCallingPlayNext,
  1138. audioStoreIsPlaying: audioStore.isPlaying,
  1139. audioStoreInstance: !!audioStore.soundInstance,
  1140. });
  1141. console.log(
  1142. "🎯 即将调用 playNextAudio,期望播放:",
  1143. audioQueue.value[currentPlayIndex]?.name || "无音频"
  1144. );
  1145. playNextAudio();
  1146. }, 200);
  1147. }
  1148. } else if (!isPlayingAudio.value && audioQueue.value.length > 0) {
  1149. console.log("队列中还有音频,继续播放");
  1150. playNextAudio();
  1151. } else {
  1152. console.log(
  1153. "无法播放 - isPlayingAudio:",
  1154. isPlayingAudio.value,
  1155. "队列长度:",
  1156. audioQueue.value.length
  1157. );
  1158. }
  1159. }
  1160. };
  1161. // 预加载音频函数
  1162. const preloadAudio = (url, apiKey) => {
  1163. if (!url || !audioStore.isVoiceEnabled) {
  1164. audioPreloadStatus[apiKey].loaded = true;
  1165. return Promise.resolve();
  1166. }
  1167. // 立即设置URL,确保即使预加载失败也能使用
  1168. audioPreloadStatus[apiKey].url = url;
  1169. console.log(`设置音频${apiKey}的URL:`, url);
  1170. return new Promise((resolve) => {
  1171. const audio = new Howl({
  1172. src: [url],
  1173. html5: true,
  1174. format: ["mp3", "acc"],
  1175. rate: 1.2,
  1176. preload: true,
  1177. onload: () => {
  1178. console.log(`音频${apiKey}预加载完成:`, url);
  1179. audioPreloadStatus[apiKey].loaded = true;
  1180. resolve();
  1181. },
  1182. onloaderror: (id, err) => {
  1183. console.error(`音频${apiKey}预加载失败:`, err);
  1184. audioPreloadStatus[apiKey].loaded = true; // 标记为已处理,避免阻塞
  1185. // URL已经在上面设置了,即使预加载失败也保留URL
  1186. resolve();
  1187. },
  1188. });
  1189. });
  1190. };
  1191. // 检查第一个接口是否可以开始输出(文本和音频都准备好)
  1192. const canStartFirstOutput = () => {
  1193. return apiStatus.one.completed && audioPreloadStatus.one.loaded;
  1194. };
  1195. // 检查并按顺序执行代码的函数
  1196. const checkAndExecuteInOrder = () => {
  1197. // 检查OneAPI - 只有当文本和音频都准备好时才开始输出
  1198. if (canStartFirstOutput() && !apiStatus.one.executed) {
  1199. if (apiStatus.one.result) {
  1200. apiStatus.one.executed = true;
  1201. console.log(
  1202. "执行OneAPI代码(文本和音频同步开始):",
  1203. apiStatus.one.result
  1204. );
  1205. // 将第一个音频添加到播放队列(确保顺序:API1)
  1206. if (audioPreloadStatus.one.url) {
  1207. addToAudioQueue(audioPreloadStatus.one.url, "API1-第一个");
  1208. console.log(
  1209. "音频队列:添加API1音频,当前队列长度:",
  1210. audioQueue.value.length
  1211. );
  1212. }
  1213. // 在这里添加OneAPI成功后需要执行的代码
  1214. // 删除正在为您生成信息
  1215. chatStore.messages.pop();
  1216. // 添加报告头和时间
  1217. addTypingTask(
  1218. {
  1219. sender: "ai",
  1220. class: "title1",
  1221. type: "title1",
  1222. content: codeData.value.name + "全景作战报告",
  1223. date: result21.data.date,
  1224. },
  1225. "",
  1226. 50
  1227. );
  1228. // chatStore.messages.push({
  1229. // sender: "ai",
  1230. // class: "title1",
  1231. // type: "title1",
  1232. // content: codeData.value.name + "全景作战报告",
  1233. // date: moment().format("MM/DD/YYYY"),
  1234. // });
  1235. // 添加股票信息框
  1236. const pc1 = marked(
  1237. result21.data.name +
  1238. "\n" +
  1239. result21.data.price +
  1240. "\n" +
  1241. result21.data.date
  1242. );
  1243. const ac1 = pc1.replace(katexRegex, (match, formula) => {
  1244. try {
  1245. return katex.renderToString(formula, {
  1246. throwOnError: false,
  1247. });
  1248. } catch (error) {
  1249. console.error("KaTeX 渲染错误:", error);
  1250. return match;
  1251. }
  1252. });
  1253. // 先推送初始消息
  1254. const aiMessage1 = reactive({
  1255. sender: "ai",
  1256. class: "content1",
  1257. type: "content1",
  1258. content: "",
  1259. isTyping: true,
  1260. });
  1261. // chatStore.messages.push(aiMessage1);
  1262. // let index1 = 0;
  1263. // const typingInterval1 = setInterval(() => {
  1264. // if (index1 < ac1.length) {
  1265. // aiMessage1.content += ac1.charAt(index1);
  1266. // index1++;
  1267. // } else {
  1268. // clearInterval(typingInterval1);
  1269. // aiMessage1.isTyping = false;
  1270. // }
  1271. // }, 50); // 调整速度为50ms/字符
  1272. addTypingTask(aiMessage1, ["", ac1], 130);
  1273. // chatStore.messages.push({
  1274. // sender: "ai",
  1275. // class: "content1",
  1276. // type: "content1",
  1277. // content: ac1,
  1278. // });
  1279. // 添加六色罗盘
  1280. if (HomePage) {
  1281. const LiuSeData = JSON.parse(JSON.stringify(toRaw(HomePage)));
  1282. const sz = fnGetData(LiuSeData);
  1283. if (sz) {
  1284. hasValidData.value = true;
  1285. console.log("hasValidData设置为:", hasValidData.value);
  1286. }
  1287. // 先推送K线图消息
  1288. const klineMessageId1 = `kline-${Date.now()}`;
  1289. console.log("生成K线消息ID:", klineMessageId1);
  1290. addTypingTask(
  1291. {
  1292. sender: "ai",
  1293. class: "content1",
  1294. type: "content1",
  1295. kline: true,
  1296. chartData: sz,
  1297. messageId: klineMessageId1,
  1298. hasValidData: true,
  1299. klineType: 1,
  1300. },
  1301. "",
  1302. 50
  1303. );
  1304. // chatStore.messages.push({
  1305. // sender: "ai",
  1306. // class: "content1",
  1307. // type: "content1",
  1308. // kline: true,
  1309. // chartData: sz,
  1310. // messageId: klineMessageId1,
  1311. // hasValidData: true,
  1312. // klineType: 1,
  1313. // });
  1314. // console.log("六色罗盘消息已添加到聊天列表");
  1315. // // 在渲染完成后初始化图表
  1316. // nextTick(() => {
  1317. // console.log("nextTick开始 - 准备渲染图表");
  1318. // console.log("消息列表:", chatStore.messages);
  1319. // // 寻找最新添加的K线消息索引
  1320. // let klineIndex = -1;
  1321. // for (let i = 0; i < chatStore.messages.length; i++) {
  1322. // if (chatStore.messages[i].messageId === klineMessageId1) {
  1323. // klineIndex = i;
  1324. // break;
  1325. // }
  1326. // }
  1327. // console.log("找到的K线消息索引:", klineIndex);
  1328. // if (klineIndex !== -1) {
  1329. // const containerId = `kline-container-${klineIndex}`;
  1330. // console.log("图表容器ID:", containerId);
  1331. // // 确保DOM已经渲染完成
  1332. // setTimeout(() => {
  1333. // console.log("延时执行,确保DOM已渲染");
  1334. // KlineCanvsEcharts(containerId);
  1335. // }, 100); // 短暂延时确保DOM已渲染
  1336. // } else {
  1337. // console.warn("未找到K线消息");
  1338. // }
  1339. // });
  1340. }
  1341. // 度牛尺K线图
  1342. if (
  1343. AIGoldBull &&
  1344. AIGoldBull.DNC &&
  1345. AIGoldBull.FCX &&
  1346. AIGoldBull.JN &&
  1347. AIGoldBull.KLine20 &&
  1348. AIGoldBull.QSXH
  1349. ) {
  1350. const AIGoldBullData = JSON.parse(
  1351. JSON.stringify(toRaw(AIGoldBull))
  1352. );
  1353. const HomePageData = JSON.parse(
  1354. JSON.stringify(toRaw(HomePage))
  1355. );
  1356. console.log("处理 K 线数据 - 开始");
  1357. console.log("AIGoldBullData", AIGoldBullData);
  1358. console.log("HomePageData", HomePageData);
  1359. const Kline20 = {
  1360. name: HomePageData.StockInformation.Name,
  1361. Kline: AIGoldBullData,
  1362. };
  1363. // 打印K线数据结构
  1364. console.log("K线数据结构:", Kline20);
  1365. console.log("K线数据名称:", Kline20.name);
  1366. console.log("K线数据:", Kline20.Kline ? Kline20.Kline : null);
  1367. // 设置数据有效标志
  1368. hasValidData.value = true;
  1369. console.log("hasValidData设置为:", hasValidData.value);
  1370. // chatStore.messages.pop();
  1371. // 先推送K线图消息
  1372. const klineMessageId2 = `kline-${Date.now() + 1}`;
  1373. console.log("生成K线消息ID:", klineMessageId2);
  1374. // chatStore.messages.push({
  1375. // sender: "ai",
  1376. // class: "content2",
  1377. // type: "content2",
  1378. // kline: true,
  1379. // chartData: Kline20,
  1380. // messageId: klineMessageId2,
  1381. // hasValidData: true, // 添加hasValidData标志
  1382. // klineType: 2,
  1383. // });
  1384. addTypingTask(
  1385. {
  1386. sender: "ai",
  1387. class: "content2",
  1388. type: "content2",
  1389. kline: true,
  1390. chartData: Kline20,
  1391. messageId: klineMessageId2,
  1392. hasValidData: true, // 添加hasValidData标志
  1393. klineType: 2,
  1394. error: apiStatus.two.error ? "2" : "",
  1395. isEnd: "1",
  1396. },
  1397. "",
  1398. 50
  1399. );
  1400. // console.log("K线消息已添加到聊天列表");
  1401. // // 在渲染完成后初始化图表
  1402. // nextTick(() => {
  1403. // console.log("nextTick开始 - 准备渲染图表");
  1404. // console.log("消息列表:", chatStore.messages);
  1405. // // 寻找最新添加的K线消息索引
  1406. // let klineIndex = -1;
  1407. // for (let i = 0; i < chatStore.messages.length; i++) {
  1408. // if (chatStore.messages[i].messageId === klineMessageId2) {
  1409. // klineIndex = i;
  1410. // break;
  1411. // }
  1412. // }
  1413. // console.log("找到的K线消息索引:", klineIndex);
  1414. // if (klineIndex !== -1) {
  1415. // const containerId = `kline-container-${klineIndex}`;
  1416. // console.log("图表容器ID:", containerId);
  1417. // // 确保DOM已经渲染完成
  1418. // setTimeout(() => {
  1419. // console.log("延时执行,确保DOM已渲染");
  1420. // KlineCanvsEcharts(containerId);
  1421. // }, 100); // 短暂延时确保DOM已渲染
  1422. // } else {
  1423. // console.warn("未找到K线消息");
  1424. // }
  1425. // });
  1426. }
  1427. } else {
  1428. chatStore.messages.push({
  1429. class: "ing",
  1430. type: "ing",
  1431. flag: false,
  1432. content: "工作流返回出错,请稍后重试",
  1433. });
  1434. chatStore.isLoading = false;
  1435. }
  1436. }
  1437. // 检查TwoAPI(需要OneAPI已执行)
  1438. if (
  1439. apiStatus.one.executed &&
  1440. apiStatus.two.completed &&
  1441. !apiStatus.two.executed
  1442. ) {
  1443. if (apiStatus.two.result) {
  1444. apiStatus.two.executed = true;
  1445. console.log("执行TwoAPI代码:", apiStatus.two.result);
  1446. // 将第二个音频添加到播放队列(确保顺序:API2)
  1447. if (audioPreloadStatus.two.url) {
  1448. addToAudioQueue(audioPreloadStatus.two.url, "API2-第二个");
  1449. console.log(
  1450. "音频队列:添加API2音频,当前队列长度:",
  1451. audioQueue.value.length
  1452. );
  1453. }
  1454. // 在这里添加TwoAPI成功后需要执行的代码
  1455. // 添加标题2
  1456. addTypingTask(
  1457. {
  1458. sender: "ai",
  1459. class: "title2",
  1460. type: "title2",
  1461. content: "",
  1462. },
  1463. "",
  1464. 50
  1465. );
  1466. // chatStore.messages.push({
  1467. // sender: "ai",
  1468. // class: "title2",
  1469. // type: "title2",
  1470. // content: "",
  1471. // });
  1472. // 添加内容框1
  1473. const pc2 = marked(result22.data.hxjzpg);
  1474. console.log(pc2, "pc2");
  1475. const ac2 = pc2.replace(katexRegex, (match, formula) => {
  1476. try {
  1477. return katex.renderToString(formula, {
  1478. throwOnError: false,
  1479. });
  1480. } catch (error) {
  1481. console.error("KaTeX 渲染错误:", error);
  1482. return match;
  1483. }
  1484. });
  1485. // 先推送初始消息
  1486. const aiMessage2 = reactive({
  1487. sender: "ai",
  1488. class: "content3",
  1489. type: "content3",
  1490. content: "",
  1491. isTyping: true,
  1492. error: apiStatus.three.error ? "3" : "",
  1493. isEnd: "2",
  1494. });
  1495. // chatStore.messages.push(aiMessage2);
  1496. // let index2 = 0;
  1497. // const typingInterval2 = setInterval(() => {
  1498. // if (index2 < ac2.length) {
  1499. // aiMessage2.content += ac2.charAt(index2);
  1500. // index2++;
  1501. // } else {
  1502. // clearInterval(typingInterval2);
  1503. // aiMessage2.isTyping = false;
  1504. // }
  1505. // }, 50); // 调整速度为50ms/字符
  1506. addTypingTask(aiMessage2, ["", ac2], 130);
  1507. // chatStore.messages.push({
  1508. // sender: "ai",
  1509. // class: "content3",
  1510. // type: "content3",
  1511. // content: ac2,
  1512. // });
  1513. } else {
  1514. console.log("1111111111111111111");
  1515. if (
  1516. apiStatus.one.isEnd &&
  1517. apiStatus.two.error &&
  1518. !apiStatus.two.isError
  1519. ) {
  1520. apiStatus.two.isError = true;
  1521. chatStore.messages.push({
  1522. class: "ing",
  1523. type: "ing",
  1524. flag: false,
  1525. content: "工作流返回出错,请稍后重试",
  1526. });
  1527. chatStore.isLoading = false;
  1528. }
  1529. }
  1530. }
  1531. // 检查ThreeAPI(需要TwoAPI已执行)
  1532. if (
  1533. apiStatus.two.executed &&
  1534. apiStatus.three.completed &&
  1535. !apiStatus.three.executed
  1536. ) {
  1537. if (apiStatus.three.result) {
  1538. apiStatus.three.executed = true;
  1539. console.log("执行ThreeAPI代码:", apiStatus.three.result);
  1540. // 将第三个音频添加到播放队列(确保顺序:API3)
  1541. if (audioPreloadStatus.three.url) {
  1542. addToAudioQueue(audioPreloadStatus.three.url, "API3-第三个");
  1543. console.log(
  1544. "音频队列:添加API3音频,当前队列长度:",
  1545. audioQueue.value.length
  1546. );
  1547. }
  1548. // 在这里添加ThreeAPI成功后需要执行的代码
  1549. // 添加标题3-2
  1550. addTypingTask(
  1551. {
  1552. sender: "ai",
  1553. class: "title3",
  1554. type: "title3",
  1555. content: title2,
  1556. },
  1557. "",
  1558. 50
  1559. );
  1560. // chatStore.messages.push({
  1561. // sender: "ai",
  1562. // class: "title3",
  1563. // type: "title3",
  1564. // content: title2,
  1565. // });
  1566. // 添加内容框2
  1567. // const pc3 = marked(result23.data.zhuli1+'\n'+result23.data.zhuli2+'\n'+result23.data.zhuli3);
  1568. // const ac3 = pc3.replace(
  1569. // katexRegex,
  1570. // (match, formula) => {
  1571. // try {
  1572. // return katex.renderToString(formula, { throwOnError: false });
  1573. // } catch (error) {
  1574. // console.error("KaTeX 渲染错误:", error);
  1575. // return match;
  1576. // }
  1577. // }
  1578. // );
  1579. const ac31 = `<p style="margin:0;color:#FFD700;font-weight:bold;display:flex;justify-content:center;font-size:22px">【主力行为】</p><p>`;
  1580. const ac32 = `${result23.data.zhuli1}</p><p>${result23.data.zhuli2}</p><p>${result23.data.zhuli3}</p>`;
  1581. const ac3 = `<p style="margin:0;color:#FFD700;font-weight:bold;display:flex;justify-content:center;font-size:22px">【主力行为】</p><p>${result23.data.zhuli1}</p><p>${result23.data.zhuli2}</p><p>${result23.data.zhuli3}</p>`;
  1582. // 先推送初始消息
  1583. const aiMessage3 = reactive({
  1584. sender: "ai",
  1585. class: "content3",
  1586. type: "content3",
  1587. content: "",
  1588. isTyping: true,
  1589. });
  1590. // chatStore.messages.push(aiMessage3);
  1591. // let index3 = 0;
  1592. // const typingInterval3 = setInterval(() => {
  1593. // if (index3 < ac3.length) {
  1594. // aiMessage3.content += ac3.charAt(index3);
  1595. // index3++;
  1596. // } else {
  1597. // clearInterval(typingInterval3);
  1598. // aiMessage3.isTyping = false;
  1599. // }
  1600. // }, 50); // 调整速度为50ms/字符
  1601. addTypingTask(aiMessage3, [ac31, ac32], 200);
  1602. // chatStore.messages.push({
  1603. // sender: "ai",
  1604. // class: "content3",
  1605. // type: "content3",
  1606. // content: ac3,
  1607. // });
  1608. // 添加标题3-3
  1609. addTypingTask(
  1610. {
  1611. sender: "ai",
  1612. class: "title3",
  1613. type: "title3",
  1614. content: title3,
  1615. },
  1616. "",
  1617. 50
  1618. );
  1619. // chatStore.messages.push({
  1620. // sender: "ai",
  1621. // class: "title3",
  1622. // type: "title3",
  1623. // content: title3,
  1624. // });
  1625. // 添加内容框3
  1626. const arr = result23.data.kongjian.split(",");
  1627. const kongjian = `<p style="margin:0;color:#FFD700;font-weight:bold;display:flex;justify-content:center;font-size:22px">【空间维度】</p><p style="display:flex;justify-content:center;">${arr[0]},${arr[1]}</p><p style="display:flex;justify-content:center;">${arr[2]},${arr[3]}</p>`;
  1628. const shijian = `<p style="margin:0;color:#FFD700;font-weight:bold;display:flex;justify-content:center;font-size:22px">【时间维度】</p><p style="display:flex;justify-content:center;">${result23.data.shijian}</p>`;
  1629. const nengliang = `<p style="margin:0;color:#FFD700;font-weight:bold;display:flex;justify-content:center;font-size:22px">【能量维度】</p><p>${result23.data.nengliang}</p>`;
  1630. const ac4 = kongjian + shijian + nengliang;
  1631. const ac41 = `<p style="margin:0;color:#FFD700;font-weight:bold;display:flex;justify-content:center;font-size:22px">【空间维度】</p><p style="display:flex;justify-content:center;">`;
  1632. const ac42 = `${arr[0]},${arr[1]}`;
  1633. const ac43 = `</p><p style="display:flex;justify-content:center;">`;
  1634. const ac44 = `${arr[2]},${arr[3]}</p>`;
  1635. const ac45 = `<p style="margin:0;color:#FFD700;font-weight:bold;display:flex;justify-content:center;font-size:22px">【时间维度】</p><p style="display:flex;justify-content:center;">`;
  1636. const ac46 = `${result23.data.shijian}</p>`;
  1637. const ac47 = `<p style="margin:0;color:#FADC0C;display:flex;justify-content:center;font-size:22px">【能量维度】</p><p style="display:flex;justify-content:center;">`;
  1638. const ac48 = `${result23.data.nengliang}</p>`;
  1639. // const pc4 = marked(
  1640. // kongjian +
  1641. // "\n" +
  1642. // result23.data.shijian +
  1643. // "\n" +
  1644. // result23.data.nengliang
  1645. // );
  1646. // const ac4 = pc4.replace(katexRegex, (match, formula) => {
  1647. // try {
  1648. // return katex.renderToString(formula, { throwOnError: false });
  1649. // } catch (error) {
  1650. // console.error("KaTeX 渲染错误:", error);
  1651. // return match;
  1652. // }
  1653. // });
  1654. // 先推送初始消息
  1655. const aiMessage4 = reactive({
  1656. sender: "ai",
  1657. class: "content3",
  1658. type: "content3",
  1659. content: "",
  1660. isTyping: true,
  1661. error: apiStatus.four.error ? "4" : "",
  1662. isEnd: "3",
  1663. });
  1664. // chatStore.messages.push(aiMessage4);
  1665. // let index4 = 0;
  1666. // const typingInterval4 = setInterval(() => {
  1667. // if (index4 < ac4.length) {
  1668. // aiMessage4.content += ac4.charAt(index4);
  1669. // index4++;
  1670. // } else {
  1671. // clearInterval(typingInterval4);
  1672. // aiMessage4.isTyping = false;
  1673. // }
  1674. // }, 50); // 调整速度为50ms/字符
  1675. addTypingTask(
  1676. aiMessage4,
  1677. [ac41, ac42, ac43, ac44, ac45, ac46, ac47, ac48],
  1678. 200
  1679. );
  1680. // chatStore.messages.push({
  1681. // sender: "ai",
  1682. // class: "content3",
  1683. // type: "content3",
  1684. // content: ac4,
  1685. // });
  1686. } else {
  1687. if (
  1688. apiStatus.two.isEnd &&
  1689. apiStatus.three.error &&
  1690. !apiStatus.three.isError
  1691. ) {
  1692. apiStatus.three.isError = true;
  1693. chatStore.messages.push({
  1694. class: "ing",
  1695. type: "ing",
  1696. flag: false,
  1697. content: "工作流返回出错,请稍后重试1111",
  1698. });
  1699. chatStore.isLoading = false;
  1700. }
  1701. }
  1702. }
  1703. // 检查FourAPI(需要ThreeAPI已执行)
  1704. if (
  1705. apiStatus.three.executed &&
  1706. apiStatus.four.completed &&
  1707. !apiStatus.four.executed
  1708. ) {
  1709. if (apiStatus.four.result) {
  1710. apiStatus.four.executed = true;
  1711. console.log("执行FourAPI代码:", apiStatus.four.result);
  1712. // 将第四个音频添加到播放队列(确保顺序:API4)
  1713. if (audioPreloadStatus.four.url) {
  1714. addToAudioQueue(audioPreloadStatus.four.url, "API4-第四个");
  1715. console.log(
  1716. "音频队列:添加API4音频,当前队列长度:",
  1717. audioQueue.value.length
  1718. );
  1719. }
  1720. // 在这里添加FourAPI成功后需要执行的代码
  1721. // 添加标题3-4
  1722. addTypingTask(
  1723. {
  1724. sender: "ai",
  1725. class: "title3",
  1726. type: "title3",
  1727. content: title4,
  1728. },
  1729. "",
  1730. 50
  1731. );
  1732. // chatStore.messages.push({
  1733. // sender: "ai",
  1734. // class: "title3",
  1735. // type: "title3",
  1736. // content: title4,
  1737. // });
  1738. // 添加内容框4
  1739. const cftj = `<p style="margin:0;color:#FFD700;font-weight:bold;display:flex;justify-content:center;font-size:22px">【触发条件】</p><p>${result24.data.cftl}</p>`;
  1740. const gfzl = `<p style="margin:0;color:#FFD700;font-weight:bold;display:flex;justify-content:center;font-size:22px">【攻防指令】</p><p>${result24.data.gfzl}</p>`;
  1741. const ac5 = cftj + gfzl;
  1742. const ac51 = `<p style="margin:0;color:#FFD700;font-weight:bold;display:flex;justify-content:center;font-size:22px">【触发条件】</p><p>`;
  1743. const ac52 = `${result24.data.cftl}</p>`;
  1744. const ac53 = `<p style="margin:0;color:#FFD700;font-weight:bold;display:flex;justify-content:center;font-size:22px">【攻防指令】</p><p>`;
  1745. const ac54 = `${result24.data.gfzl}</p>`;
  1746. // const pc5 = marked(result24.data.cftl + "/n" + result24.data.gfzl);
  1747. // const ac5 = pc5.replace(katexRegex, (match, formula) => {
  1748. // try {
  1749. // return katex.renderToString(formula, { throwOnError: false });
  1750. // } catch (error) {
  1751. // console.error("KaTeX 渲染错误:", error);
  1752. // return match;
  1753. // }
  1754. // });
  1755. // 先推送初始消息
  1756. const aiMessage5 = reactive({
  1757. sender: "ai",
  1758. class: "content3",
  1759. type: "content3",
  1760. content: "",
  1761. isTyping: true,
  1762. });
  1763. // chatStore.messages.push(aiMessage5);
  1764. // let index5 = 0;
  1765. // const typingInterval5 = setInterval(() => {
  1766. // if (index5 < ac5.length) {
  1767. // aiMessage5.content += ac5.charAt(index5);
  1768. // index5++;
  1769. // } else {
  1770. // clearInterval(typingInterval5);
  1771. // aiMessage5.isTyping = false;
  1772. // }
  1773. // }, 50); // 调整速度为50ms/字符
  1774. addTypingTask(aiMessage5, [ac51, ac52, ac53, ac54], 240);
  1775. // chatStore.messages.push({
  1776. // sender: "ai",
  1777. // class: "content3",
  1778. // type: "content3",
  1779. // content: ac5,
  1780. // });
  1781. const ac6 = "该内容由AI生成,请注意甄别";
  1782. // 先推送初始消息
  1783. const aiMessage6 = reactive({
  1784. sender: "ai",
  1785. class: "mianze",
  1786. type: "mianze",
  1787. content: "",
  1788. isTyping: true,
  1789. end: true,
  1790. });
  1791. // chatStore.messages.push(aiMessage6);
  1792. // let index6 = 0;
  1793. // const typingInterval6 = setInterval(() => {
  1794. // if (index6 < ac6.length) {
  1795. // aiMessage6.content += ac6.charAt(index6);
  1796. // index6++;
  1797. // } else {
  1798. // clearInterval(typingInterval6);
  1799. // aiMessage6.isTyping = false;
  1800. // }
  1801. // }, 50); // 调整速度为50ms/字符
  1802. addTypingTask(aiMessage6, ["", ac6], 210);
  1803. // chatStore.isLoading = false;
  1804. // chatStore.messages.push({
  1805. // sender: "ai",
  1806. // class: "mianze",
  1807. // type: "mianze",
  1808. // content: "内容由AI生成,请注意甄别",
  1809. // });
  1810. } else {
  1811. if (
  1812. apiStatus.three.isEnd &&
  1813. apiStatus.four.error &&
  1814. !apiStatus.four.isError
  1815. ) {
  1816. apiStatus.four.isError = true;
  1817. chatStore.messages.push({
  1818. class: "ing",
  1819. type: "ing",
  1820. flag: false,
  1821. content: "工作流返回出错,请稍后重试",
  1822. });
  1823. chatStore.isLoading = false;
  1824. }
  1825. }
  1826. }
  1827. // 检查是否所有API都已完成并执行
  1828. if (
  1829. apiStatus.one.completed &&
  1830. apiStatus.two.completed &&
  1831. apiStatus.three.completed &&
  1832. apiStatus.four.completed &&
  1833. apiStatus.four.executed
  1834. ) {
  1835. console.log("所有API已完成,开始收集预加载的音频URL");
  1836. // 收集所有预加载的音频URL
  1837. const audioUrls = [];
  1838. console.log("预加载音频状态检查:");
  1839. console.log("audioPreloadStatus:", audioPreloadStatus);
  1840. if (audioPreloadStatus.one.url) {
  1841. console.log(
  1842. "添加预加载音频URL one:",
  1843. audioPreloadStatus.one.url
  1844. );
  1845. audioUrls.push(audioPreloadStatus.one.url);
  1846. }
  1847. if (audioPreloadStatus.two.url) {
  1848. console.log(
  1849. "添加预加载音频URL two:",
  1850. audioPreloadStatus.two.url
  1851. );
  1852. audioUrls.push(audioPreloadStatus.two.url);
  1853. }
  1854. if (audioPreloadStatus.three.url) {
  1855. console.log(
  1856. "添加预加载音频URL three:",
  1857. audioPreloadStatus.three.url
  1858. );
  1859. audioUrls.push(audioPreloadStatus.three.url);
  1860. }
  1861. if (audioPreloadStatus.four.url) {
  1862. console.log(
  1863. "添加预加载音频URL four:",
  1864. audioPreloadStatus.four.url
  1865. );
  1866. audioUrls.push(audioPreloadStatus.four.url);
  1867. }
  1868. console.log("收集到的预加载音频URLs:", audioUrls);
  1869. console.log("语音是否启用:", audioStore.isVoiceEnabled);
  1870. // 音频播放逻辑已移至各个接口的执行代码中
  1871. console.log("所有接口执行完成,音频已在各接口中单独播放");
  1872. }
  1873. };
  1874. const handleOneAPI = async () => {
  1875. try {
  1876. result21 = await dbqbSecondOneAPI(params2);
  1877. console.log("OneAPI成功返回:", result21);
  1878. apiStatus.one.completed = true;
  1879. apiStatus.one.result = result21;
  1880. // 预加载第一个接口的音频
  1881. if (result21?.data?.url) {
  1882. await preloadAudio(result21.data.url.trim(), "one");
  1883. } else {
  1884. audioPreloadStatus.one.loaded = true;
  1885. }
  1886. // 检查是否可以执行
  1887. checkAndExecuteInOrder();
  1888. } catch (error) {
  1889. console.error("OneAPI失败:", error);
  1890. apiStatus.one.completed = true;
  1891. apiStatus.one.error = error;
  1892. audioPreloadStatus.one.loaded = true; // 失败时也标记为已处理
  1893. // 即使失败也要检查后续执行
  1894. checkAndExecuteInOrder();
  1895. }
  1896. };
  1897. const handleTwoAPI = async () => {
  1898. try {
  1899. result22 = await dbqbSecondTwoAPI(params2);
  1900. console.log("TwoAPI成功返回:", result22);
  1901. apiStatus.two.completed = true;
  1902. apiStatus.two.result = result22;
  1903. // 预加载第二个接口的音频
  1904. if (result22?.data?.url) {
  1905. await preloadAudio(result22.data.url.trim(), "two");
  1906. } else {
  1907. audioPreloadStatus.two.loaded = true;
  1908. }
  1909. // 检查是否可以执行
  1910. checkAndExecuteInOrder();
  1911. } catch (error) {
  1912. console.error("TwoAPI失败:", error);
  1913. apiStatus.two.completed = true;
  1914. apiStatus.two.error = error;
  1915. audioPreloadStatus.two.loaded = true;
  1916. checkAndExecuteInOrder();
  1917. }
  1918. };
  1919. const handleThreeAPI = async () => {
  1920. try {
  1921. result23 = await dbqbSecondThreeAPI(params2);
  1922. // result23 = await dbqbSecondThreeAPI();
  1923. console.log("ThreeAPI成功返回:", result23);
  1924. apiStatus.three.completed = true;
  1925. apiStatus.three.result = result23;
  1926. // 预加载第三个接口的音频
  1927. if (result23?.data?.url) {
  1928. await preloadAudio(result23.data.url.trim(), "three");
  1929. } else {
  1930. audioPreloadStatus.three.loaded = true;
  1931. }
  1932. // 检查是否可以执行
  1933. checkAndExecuteInOrder();
  1934. } catch (error) {
  1935. console.error("ThreeAPI失败:", error);
  1936. apiStatus.three.completed = true;
  1937. apiStatus.three.error = error;
  1938. audioPreloadStatus.three.loaded = true;
  1939. checkAndExecuteInOrder();
  1940. }
  1941. };
  1942. const handleFourAPI = async () => {
  1943. try {
  1944. result24 = await dbqbSecondFourAPI(params2);
  1945. console.log("FourAPI成功返回:", result24);
  1946. apiStatus.four.completed = true;
  1947. apiStatus.four.result = result24;
  1948. // 预加载第四个接口的音频
  1949. if (result24?.data?.url) {
  1950. await preloadAudio(result24.data.url.trim(), "four");
  1951. } else {
  1952. audioPreloadStatus.four.loaded = true;
  1953. }
  1954. // 检查是否可以执行
  1955. checkAndExecuteInOrder();
  1956. } catch (error) {
  1957. console.error("FourAPI失败:", error);
  1958. apiStatus.four.completed = true;
  1959. apiStatus.four.error = error;
  1960. audioPreloadStatus.four.loaded = true;
  1961. checkAndExecuteInOrder();
  1962. }
  1963. };
  1964. if (isLiuSe && isAIGoldBull) {
  1965. handleOneAPI();
  1966. handleTwoAPI();
  1967. handleThreeAPI();
  1968. handleFourAPI();
  1969. } else {
  1970. chatStore.messages.pop();
  1971. chatStore.messages.push({
  1972. class: "ing",
  1973. type: "ing",
  1974. flag: false,
  1975. content: "数据缺失,请稍后重试",
  1976. });
  1977. chatStore.isLoading = false;
  1978. }
  1979. // 同时发起所有API调用
  1980. // const promises = [
  1981. // dbqbSecondOneAPI(params2),
  1982. // dbqbSecondTwoAPI(params2),
  1983. // dbqbSecondThreeAPI(params2),
  1984. // dbqbSecondFourAPI(params2),
  1985. // ];
  1986. // const results = await Promise.allSettled(promises);
  1987. // let result21;
  1988. // let result22;
  1989. // let result23;
  1990. // let result24;
  1991. // // 检查每个API的结果并执行相应代码
  1992. // console
  1993. // if (results[0].status === "fulfilled") {
  1994. // result21 = results[0].value;
  1995. // // oneAPI成功返回时执行的代码
  1996. // console.log("oneAPI成功:", result21);
  1997. // // 在这里添加你的业务逻辑
  1998. // }
  1999. // if (results[1].status === "fulfilled") {
  2000. // result22 = results[1].value;
  2001. // // twoAPI成功返回时执行的代码
  2002. // console.log("twoAPI成功:", result22);
  2003. // // 在这里添加你的业务逻辑
  2004. // }
  2005. // if (results[2].status === "fulfilled") {
  2006. // result23 = results[2].value;
  2007. // // threeAPI成功返回时执行的代码
  2008. // console.log("threeAPI成功:", result23);
  2009. // }
  2010. // if (results[3].status === "fulfilled") {
  2011. // result24 = results[3].value;
  2012. // // fourAPI成功返回时执行的代码
  2013. // console.log("fourAPI成功:", result24);
  2014. // }
  2015. // const result21 = await dbqbSecondOneAPI(params2);
  2016. // const result22 = await dbqbSecondTwoAPI(params2);
  2017. // const result23 = await dbqbSecondThreeAPI(params2);
  2018. // const result24 = await dbqbSecondFourAPI(params2);
  2019. // 音频收集逻辑已移至checkAndExecuteInOrder函数内部
  2020. // // 修改后的消息处理逻辑
  2021. // const processedContent = marked(AIcontent.value);
  2022. // const katexRegex = /\$\$(.*?)\$\$/g;
  2023. // const plainTextContent = htmlToText(processedContent);
  2024. // // 获取音频数据
  2025. // const TTSResult = (
  2026. // await TTSAPI({
  2027. // language: "cn",
  2028. // content: plainTextContent,
  2029. // })
  2030. // ).json();
  2031. // const tts = ref();
  2032. // await TTSResult.then((res) => {
  2033. // tts.value = JSON.parse(res.data);
  2034. // });
  2035. // const ttsUrl = ref();
  2036. // if (tts.value.tts_cn !== null) {
  2037. // audioStore.ttsUrl = tts.value.tts_cn.url;
  2038. // ttsUrl.value = tts.value.tts_cn.url;
  2039. // audioStore.isNewInstance = true;
  2040. // } else if (tts.value.tts_en !== null) {
  2041. // audioStore.ttsUrl = tts.value.tts_en.url;
  2042. // ttsUrl.value = tts.value.tts_en.url;
  2043. // audioStore.isNewInstance = true;
  2044. // }
  2045. // if (ttsUrl.value) {
  2046. // nextTick(() => {
  2047. // if (audioStore.isVoiceEnabled) {
  2048. // console.log("ttsUrl.value", ttsUrl.value);
  2049. // // 播放音频
  2050. // playAudio(ttsUrl.value);
  2051. // }
  2052. // });
  2053. // }
  2054. // // chatStore.messages.pop();
  2055. // // 先推送初始消息
  2056. // const aiMessage = reactive({
  2057. // sender: "ai",
  2058. // content: "",
  2059. // isTyping: true,
  2060. // });
  2061. // chatStore.messages.push(aiMessage);
  2062. // let index = 0;
  2063. // const typingInterval = setInterval(() => {
  2064. // if (index < processedContent.length) {
  2065. // aiMessage.content += processedContent.charAt(index);
  2066. // index++;
  2067. // } else {
  2068. // clearInterval(typingInterval);
  2069. // aiMessage.isTyping = false;
  2070. // // 延迟处理KaTeX确保DOM已更新
  2071. // nextTick(() => {
  2072. // aiMessage.content = aiMessage.content.replace(
  2073. // katexRegex,
  2074. // (match, formula) => {
  2075. // try {
  2076. // return katex.renderToString(formula, {
  2077. // throwOnError: false,
  2078. // });
  2079. // } catch (error) {
  2080. // console.error("KaTeX 渲染错误:", error);
  2081. // return match;
  2082. // }
  2083. // }
  2084. // );
  2085. // chatStore.setLoading(false);
  2086. // });
  2087. // }
  2088. // }, 50); // 调整速度为50ms/字符
  2089. // // } else {
  2090. // // chatStore.messages.pop();
  2091. // // chatStore.messages.push({
  2092. // // sender: "ai",
  2093. // // content: status.msg
  2094. // // });
  2095. // // chatStore.setLoading(false);
  2096. // // }
  2097. // }
  2098. } catch (e) {
  2099. console.error("请求失败:", e);
  2100. hasValidData.value = false; // 请求失败时设置数据无效
  2101. // chatStore.messages.pop();
  2102. // chatStore.messages.push({
  2103. // sender: "ai",
  2104. // content: "AI思考失败,请稍后再试... ",
  2105. // });
  2106. // chatStore.setLoading(false);
  2107. } finally {
  2108. // chatStore.setLoading(false);
  2109. await chatStore.getUserCount();
  2110. }
  2111. }
  2112. }
  2113. },
  2114. { deep: true }
  2115. );
  2116. function KlineCanvsEcharts(containerId) {
  2117. function vwToPx(vw) {
  2118. console.log((window.innerWidth * vw) / 100, "vwToPx");
  2119. return (window.innerWidth * vw) / 100;
  2120. }
  2121. console.log("KLine渲染: 开始处理数据, 容器ID:", containerId);
  2122. // 从 chatStore 中获取数据
  2123. const messages = chatStore.messages;
  2124. console.log("KLine渲染: 获取到的消息:", messages);
  2125. let klineMessageIndex = -1;
  2126. let klineData = null;
  2127. // 查找最近的 K线 消息
  2128. // for (let i = messages.length - 1; i >= 0; i--) {
  2129. // console.log('KLine渲染: 检查消息:', messages[i]);
  2130. // if (messages[i].type === 'kline' && messages[i].chartData) {
  2131. // klineMessageIndex = i;
  2132. // klineData = messages[i].chartData;
  2133. // console.log('KLine渲染: 找到K线消息索引:', klineMessageIndex);
  2134. // console.log('KLine渲染: 找到K线数据:', klineData);
  2135. // break;
  2136. // }
  2137. // }
  2138. klineMessageIndex = containerId.split("-")[2];
  2139. console.log("KLine渲染: 找到K线消息索引:", klineMessageIndex);
  2140. if (
  2141. messages[klineMessageIndex].kline &&
  2142. messages[klineMessageIndex].chartData
  2143. ) {
  2144. klineData = messages[klineMessageIndex].chartData;
  2145. }
  2146. var KlineOption = {};
  2147. // 检测设备类型
  2148. const isMobile = window.innerWidth < 768;
  2149. const isTablet = window.innerWidth >= 768 && window.innerWidth < 1024;
  2150. console.log(
  2151. "KLine渲染: 设备类型",
  2152. isMobile ? "移动设备" : isTablet ? "平板设备" : "桌面设备"
  2153. );
  2154. if (messages[klineMessageIndex].klineType == 1) {
  2155. if (!klineData) {
  2156. console.warn("六色罗盘渲染: 数据无效 - 在chatStore中找不到有效的K线数据");
  2157. return;
  2158. }
  2159. // 获取容器元素
  2160. const container = document.getElementById(containerId);
  2161. if (!container) {
  2162. console.error("六色罗盘渲染: 找不到容器元素:", containerId);
  2163. return;
  2164. }
  2165. // 创建图表实例
  2166. console.log("六色罗盘渲染: 创建图表实例");
  2167. try {
  2168. // 如果已有实例,先销毁
  2169. if (chartInstancesMap[containerId]) {
  2170. console.log("六色罗盘渲染: 销毁已有图表实例");
  2171. chartInstancesMap[containerId].dispose();
  2172. delete chartInstancesMap[containerId];
  2173. }
  2174. // 使用普通变量存储实例
  2175. chartInstancesMap[containerId] = echarts.init(container);
  2176. console.log("六色罗盘渲染: 图表实例创建成功");
  2177. } catch (error) {
  2178. console.error("六色罗盘渲染: 图表实例创建失败:", error);
  2179. return;
  2180. }
  2181. const name = ref("六色罗盘");
  2182. const size = ref(16);
  2183. // PC版字体大小
  2184. if (window.innerWidth > 768) {
  2185. size.value = 25;
  2186. }
  2187. KlineOption = {
  2188. tooltip: {
  2189. show: !1,
  2190. },
  2191. series: [
  2192. {
  2193. name: "\u4eea\u8868\u76d8",
  2194. type: "gauge",
  2195. center: ["50%", "50%"],
  2196. radius: "90%",
  2197. startAngle: 140,
  2198. endAngle: -140,
  2199. min: 0,
  2200. max: 6,
  2201. precision: 0,
  2202. splitNumber: 30, // 分成30份
  2203. axisLine: {
  2204. show: !0,
  2205. lineStyle: {
  2206. color: [
  2207. [0.17, "#FC4407"],
  2208. [0.33, "#FDC404"],
  2209. [0.5, "#2D8FFD"],
  2210. [0.67, "#87CCE7"],
  2211. [0.83, "#C1F478"],
  2212. [1, "#8FEB8D"],
  2213. ],
  2214. width: 20,
  2215. },
  2216. },
  2217. axisTick: {
  2218. show: !0,
  2219. splitNumber: 9,
  2220. length: 8,
  2221. lineStyle: {
  2222. color: "#eee",
  2223. width: 1,
  2224. type: "solid",
  2225. },
  2226. },
  2227. axisLabel: {
  2228. show: true,
  2229. formatter: function (v) {},
  2230. textStyle: {
  2231. color: "auto",
  2232. },
  2233. },
  2234. // 中途切割
  2235. splitLine: {
  2236. show: !0,
  2237. length: 20,
  2238. lineStyle: {
  2239. color: "#eee",
  2240. width: 2,
  2241. type: "solid",
  2242. },
  2243. },
  2244. pointer: {
  2245. length: "80%",
  2246. width: 8,
  2247. color: "auto",
  2248. },
  2249. title: {
  2250. show: !0,
  2251. offsetCenter: ["-65%", -10],
  2252. textStyle: {
  2253. color: "#333",
  2254. fontSize: 15,
  2255. },
  2256. },
  2257. detail: {
  2258. show: !0,
  2259. backgroundColor: "rgba(0,0,0,0)",
  2260. borderWidth: 0,
  2261. borderColor: "#ccc",
  2262. width: 100,
  2263. height: 40,
  2264. offsetCenter: ["-90%", 0], // name位置
  2265. formatter: function () {
  2266. return name.value;
  2267. },
  2268. textStyle: {
  2269. color: "auto",
  2270. fontSize: size.value, // 字体尺寸
  2271. },
  2272. },
  2273. data: [{ value: klineData }],
  2274. },
  2275. ],
  2276. };
  2277. } else if (messages[klineMessageIndex].klineType == 2) {
  2278. if (!klineData || !klineData.Kline) {
  2279. console.warn("KLine渲染: 数据无效 - 在chatStore中找不到有效的K线数据");
  2280. return;
  2281. }
  2282. // 获取容器元素
  2283. const container = document.getElementById(containerId);
  2284. if (!container) {
  2285. console.error("KLine渲染: 找不到容器元素:", containerId);
  2286. return;
  2287. }
  2288. // 创建图表实例
  2289. console.log("KLine渲染: 创建图表实例");
  2290. try {
  2291. // 如果已有实例,先销毁
  2292. if (chartInstancesMap[containerId]) {
  2293. console.log("KLine渲染: 销毁已有图表实例");
  2294. chartInstancesMap[containerId].dispose();
  2295. delete chartInstancesMap[containerId];
  2296. }
  2297. // 使用普通变量存储实例
  2298. chartInstancesMap[containerId] = echarts.init(container);
  2299. console.log("KLine渲染: 图表实例创建成功");
  2300. } catch (error) {
  2301. console.error("KLine渲染: 图表实例创建失败:", error);
  2302. return;
  2303. }
  2304. const data = klineData.Kline;
  2305. console.log("KLine渲染: Kline数据", data);
  2306. // 切割数据方法
  2307. const splitData = (a) => {
  2308. console.log("KLine渲染: 开始数据切割");
  2309. const categoryData = [];
  2310. let values = [];
  2311. for (let i = 0; i < a.length; i++) {
  2312. categoryData.push(a[i][0]);
  2313. values.push([a[i][1], a[i][2], a[i][3], a[i][4]]);
  2314. }
  2315. console.log("KLine渲染: 日期数据点数量", categoryData.length);
  2316. console.log("KLine渲染: 值数据点数量", values.length);
  2317. return { categoryData, values };
  2318. };
  2319. // 给配置项
  2320. console.log("KLine渲染: 开始配置图表选项");
  2321. const arr1 = [];
  2322. const arr2 = [];
  2323. const arr3 = [];
  2324. const arr4 = [];
  2325. const changeColorKline = (QSXH, KLine20) => {
  2326. if (QSXH) {
  2327. QSXH.map((item) => {
  2328. KLine20.map((kline_item) => {
  2329. if (item[1] == 1 && item[0] == kline_item[0]) {
  2330. arr1.push(kline_item);
  2331. arr2.push([
  2332. kline_item[0],
  2333. null,
  2334. null,
  2335. null,
  2336. null,
  2337. null,
  2338. null,
  2339. null,
  2340. ]);
  2341. arr3.push([
  2342. kline_item[0],
  2343. null,
  2344. null,
  2345. null,
  2346. null,
  2347. null,
  2348. null,
  2349. null,
  2350. ]);
  2351. arr4.push([
  2352. kline_item[0],
  2353. null,
  2354. null,
  2355. null,
  2356. null,
  2357. null,
  2358. null,
  2359. null,
  2360. ]);
  2361. }
  2362. if (item[1] == 2 && item[0] == kline_item[0]) {
  2363. arr2.push(kline_item);
  2364. arr1.push([
  2365. kline_item[0],
  2366. null,
  2367. null,
  2368. null,
  2369. null,
  2370. null,
  2371. null,
  2372. null,
  2373. ]);
  2374. arr3.push([
  2375. kline_item[0],
  2376. null,
  2377. null,
  2378. null,
  2379. null,
  2380. null,
  2381. null,
  2382. null,
  2383. ]);
  2384. arr4.push([
  2385. kline_item[0],
  2386. null,
  2387. null,
  2388. null,
  2389. null,
  2390. null,
  2391. null,
  2392. null,
  2393. ]);
  2394. }
  2395. if (item[1] == 3 && item[0] == kline_item[0]) {
  2396. arr3.push(kline_item);
  2397. arr2.push([
  2398. kline_item[0],
  2399. null,
  2400. null,
  2401. null,
  2402. null,
  2403. null,
  2404. null,
  2405. null,
  2406. ]);
  2407. arr1.push([
  2408. kline_item[0],
  2409. null,
  2410. null,
  2411. null,
  2412. null,
  2413. null,
  2414. null,
  2415. null,
  2416. ]);
  2417. arr4.push([
  2418. kline_item[0],
  2419. null,
  2420. null,
  2421. null,
  2422. null,
  2423. null,
  2424. null,
  2425. null,
  2426. ]);
  2427. }
  2428. if (item[1] == 4 && item[0] == kline_item[0]) {
  2429. arr4.push(kline_item);
  2430. arr2.push([
  2431. kline_item[0],
  2432. null,
  2433. null,
  2434. null,
  2435. null,
  2436. null,
  2437. null,
  2438. null,
  2439. ]);
  2440. arr3.push([
  2441. kline_item[0],
  2442. null,
  2443. null,
  2444. null,
  2445. null,
  2446. null,
  2447. null,
  2448. null,
  2449. ]);
  2450. arr1.push([
  2451. kline_item[0],
  2452. null,
  2453. null,
  2454. null,
  2455. null,
  2456. null,
  2457. null,
  2458. null,
  2459. ]);
  2460. }
  2461. });
  2462. });
  2463. }
  2464. };
  2465. console.log(arr1, arr2, arr3, arr4);
  2466. changeColorKline(data.QSXH, data.KLine20);
  2467. var dealData = splitData(data.KLine20);
  2468. var dealData1 = splitData(arr1);
  2469. var dealData2 = splitData(arr2);
  2470. var dealData3 = splitData(arr3);
  2471. var dealData4 = splitData(arr4);
  2472. var dealGnBullData = data.JN;
  2473. function processMAData(data) {
  2474. let processedData = [];
  2475. data.forEach((item, idx) => {
  2476. processedData.push({
  2477. date: item[0],
  2478. value: item[1],
  2479. type: item[2],
  2480. });
  2481. });
  2482. // 当某一种type只存在一天,设置另一种type透明
  2483. let singleTypeRed = [{ min: 0, max: 0, color: "#000" }];
  2484. let singleTypeYellow = [{ min: 0, max: 0, color: "#000" }];
  2485. let singleTypeGreen = [{ min: 0, max: 0, color: "#000" }];
  2486. for (let i = 1; i < processedData.length; i++) {
  2487. if (processedData[i].type !== processedData[i - 1].type) {
  2488. if (
  2489. i == processedData.length - 1 ||
  2490. (processedData[i].type !== processedData[i + 1].type &&
  2491. processedData[i - 1].type === processedData[i + 1].type)
  2492. ) {
  2493. if (processedData[i - 1].type === 0) {
  2494. singleTypeGreen.push({
  2495. min: i - 1,
  2496. max: i,
  2497. color: "rgba(0,0,0,0)",
  2498. });
  2499. } else if (processedData[i - 1].type === 1) {
  2500. singleTypeRed.push({
  2501. min: i - 1,
  2502. max: i,
  2503. color: "rgba(0,0,0,0)",
  2504. });
  2505. } else if (processedData[i - 1].type === 2) {
  2506. singleTypeYellow.push({
  2507. min: i - 1,
  2508. max: i,
  2509. color: "rgba(0,0,0,0)",
  2510. });
  2511. }
  2512. }
  2513. }
  2514. if (processedData[i].type !== processedData[i - 1].type) {
  2515. if (processedData[i].type == 0) {
  2516. processedData[i - 1].isTransitionGreen = 1;
  2517. } else if (processedData[i].type == 1) {
  2518. processedData[i - 1].isTransitionRed = 1;
  2519. } else if (processedData[i].type == 2) {
  2520. processedData[i - 1].isTransitionYellow = 1;
  2521. }
  2522. // // 创建过渡点,使用前一个点的值
  2523. // processedData[i - 1].isTransition = true
  2524. }
  2525. }
  2526. let greenData = [];
  2527. let redData = [];
  2528. let yellowData = [];
  2529. processedData.forEach((item, idx) => {
  2530. const point = [item.date, item.value];
  2531. if (item.type === 0) {
  2532. greenData.push(point);
  2533. redData.push([item.date, "-"]);
  2534. yellowData.push([item.date, "-"]);
  2535. // if (item.isTransition) {
  2536. // redData[redData.length - 1] = [processedData[idx].date, processedData[idx].value]
  2537. // yellowData[yellowData.length - 1] = [processedData[idx].date, processedData[idx].value]
  2538. // }
  2539. if (item.isTransitionGreen) {
  2540. greenData[greenData.length - 1] = [
  2541. processedData[idx].date,
  2542. processedData[idx].value,
  2543. ];
  2544. } else if (item.isTransitionRed) {
  2545. redData[redData.length - 1] = [
  2546. processedData[idx].date,
  2547. processedData[idx].value,
  2548. ];
  2549. } else if (item.isTransitionYellow) {
  2550. yellowData[yellowData.length - 1] = [
  2551. processedData[idx].date,
  2552. processedData[idx].value,
  2553. ];
  2554. }
  2555. } else if (item.type === 1) {
  2556. redData.push(point);
  2557. greenData.push([item.date, "-"]);
  2558. yellowData.push([item.date, "-"]);
  2559. // if (item.isTransition) {
  2560. // greenData[greenData.length - 1] = [processedData[idx].date, processedData[idx].value]
  2561. // yellowData[yellowData.length - 1] = [processedData[idx].date, processedData[idx].value]
  2562. // }
  2563. if (item.isTransitionGreen) {
  2564. greenData[greenData.length - 1] = [
  2565. processedData[idx].date,
  2566. processedData[idx].value,
  2567. ];
  2568. } else if (item.isTransitionRed) {
  2569. redData[redData.length - 1] = [
  2570. processedData[idx].date,
  2571. processedData[idx].value,
  2572. ];
  2573. } else if (item.isTransitionYellow) {
  2574. yellowData[yellowData.length - 1] = [
  2575. processedData[idx].date,
  2576. processedData[idx].value,
  2577. ];
  2578. }
  2579. } else if (item.type === 2) {
  2580. redData.push([item.date, "-"]);
  2581. greenData.push([item.date, "-"]);
  2582. yellowData.push(point);
  2583. // if (item.isTransition) {
  2584. // greenData[greenData.length - 1] = [processedData[idx].date, processedData[idx].value]
  2585. // redData[redData.length - 1] = [processedData[idx].date, processedData[idx].value]
  2586. // }
  2587. if (item.isTransitionGreen) {
  2588. greenData[greenData.length - 1] = [
  2589. processedData[idx].date,
  2590. processedData[idx].value,
  2591. ];
  2592. } else if (item.isTransitionRed) {
  2593. redData[redData.length - 1] = [
  2594. processedData[idx].date,
  2595. processedData[idx].value,
  2596. ];
  2597. } else if (item.isTransitionYellow) {
  2598. yellowData[yellowData.length - 1] = [
  2599. processedData[idx].date,
  2600. processedData[idx].value,
  2601. ];
  2602. }
  2603. }
  2604. });
  2605. return {
  2606. greenData: greenData,
  2607. redData: redData,
  2608. yellowData: yellowData,
  2609. singleTypeGreen: singleTypeGreen,
  2610. singleTypeRed: singleTypeRed,
  2611. singleTypeYellow: singleTypeYellow,
  2612. };
  2613. }
  2614. const maData = processMAData(data.FCX);
  2615. const maDuchiData = processMAData(data.DNC);
  2616. if (data.FCX[0][1] == "-1") {
  2617. maData.greenData = [];
  2618. maData.redData = [];
  2619. maData.yellowData = [];
  2620. }
  2621. const processBarData = (data) => {
  2622. const barData = [];
  2623. const markPointData = [];
  2624. data.forEach((item) => {
  2625. let color;
  2626. switch (item[4]) {
  2627. case 1:
  2628. color = "#13E113";
  2629. break;
  2630. case 2:
  2631. color = "#FF0E00";
  2632. break;
  2633. case 3:
  2634. color = "#0000FE";
  2635. break;
  2636. case 4:
  2637. color = "#1397FF";
  2638. break;
  2639. }
  2640. barData.push({
  2641. value: item[5],
  2642. itemStyle: {
  2643. normal: {
  2644. color: color,
  2645. },
  2646. },
  2647. });
  2648. if (item[1] === 1) {
  2649. markPointData.push({
  2650. coord: [item[0], item[5]],
  2651. symbol:
  2652. "image://https://d31zlh4on95l9h.cloudfront.net/images/5iujb101000d5si3v3hr7w2vg0h43z1u.png",
  2653. symbolSize: [30, 30],
  2654. label: {
  2655. normal: {
  2656. color: "rgba(0, 0, 0, 0)",
  2657. },
  2658. },
  2659. });
  2660. }
  2661. if (item[2] === 1) {
  2662. markPointData.push({
  2663. coord: [item[0], item[5] / 2],
  2664. symbol:
  2665. "image://https://d31zlh4on95l9h.cloudfront.net/images/5iujaz01000d5si016bxdf6vh0377d2h.png",
  2666. symbolSize: [30, 30],
  2667. label: {
  2668. normal: {
  2669. color: "rgba(0, 0, 0, 0)",
  2670. },
  2671. },
  2672. });
  2673. }
  2674. if (item[3] === 1) {
  2675. markPointData.push({
  2676. coord: [item[0], 0],
  2677. symbol:
  2678. "image://https://d31zlh4on95l9h.cloudfront.net/images/5iujb001000d5shzls0tmd4vs0e5tdrw.png",
  2679. symbolSize: [30, 30],
  2680. label: {
  2681. normal: {
  2682. color: "rgba(0, 0, 0, 0)",
  2683. },
  2684. },
  2685. });
  2686. }
  2687. });
  2688. return { barData, markPointData };
  2689. };
  2690. const { barData, markPointData } = processBarData(dealGnBullData);
  2691. KlineOption = {
  2692. legend: [
  2693. {
  2694. textStyle: {
  2695. color: "black",
  2696. fontSize: window.innerWidth > 768 ? 15 : vwToPx(1.8),
  2697. },
  2698. width: "100%",
  2699. top: window.innerWidth > 768 ? "0%" : "-1%",
  2700. left: "center",
  2701. itemGap: window.innerWidth > 768 ? 20 : 10,
  2702. itemWidth: 10,
  2703. itemHeight: 10,
  2704. data: [
  2705. {
  2706. name: "进攻K线",
  2707. itemStyle: {
  2708. color: "rgb(255,0,0)",
  2709. },
  2710. },
  2711. {
  2712. name: "防守K线",
  2713. itemStyle: {
  2714. color: "red",
  2715. },
  2716. },
  2717. {
  2718. name: "推进K线",
  2719. itemStyle: {
  2720. color: "orange",
  2721. },
  2722. },
  2723. {
  2724. name: "撤退K线",
  2725. itemStyle: {
  2726. color: "rgb(84,252,252)",
  2727. },
  2728. },
  2729. ],
  2730. },
  2731. {
  2732. textStyle: {
  2733. color: "black",
  2734. fontSize: window.innerWidth > 768 ? 15 : vwToPx(1.8),
  2735. },
  2736. orient: "horizontal",
  2737. top: window.innerWidth > 768 ? "3%" : "2%",
  2738. width: "100%",
  2739. left: "center",
  2740. itemGap: 15,
  2741. data: [
  2742. {
  2743. name: "{green|━}{red|━} " + "牵牛绳",
  2744. icon: "none",
  2745. textStyle: {
  2746. rich: {
  2747. green: {
  2748. color: "green",
  2749. fontSize: window.innerWidth > 768 ? 20 : 10,
  2750. },
  2751. red: {
  2752. color: "red",
  2753. fontSize: window.innerWidth > 768 ? 20 : 10,
  2754. },
  2755. },
  2756. },
  2757. },
  2758. {
  2759. name: "龙线",
  2760. },
  2761. {
  2762. name: "虫线",
  2763. },
  2764. ],
  2765. },
  2766. {
  2767. textStyle: {
  2768. color: "black",
  2769. fontSize: window.innerWidth > 768 ? 15 : vwToPx(1.8),
  2770. },
  2771. orient: "horizontal",
  2772. top: window.innerWidth > 768 ? "68%" : "64%",
  2773. width: "100%",
  2774. left: "center",
  2775. itemGap: 15,
  2776. data: [
  2777. {
  2778. name: "{green|━}{red|━} " + "度牛尺",
  2779. icon: "none",
  2780. textStyle: {
  2781. rich: {
  2782. green: {
  2783. color: "green",
  2784. fontSize: window.innerWidth > 768 ? 20 : 10,
  2785. },
  2786. red: {
  2787. color: "red",
  2788. fontSize: window.innerWidth > 768 ? 20 : 10,
  2789. },
  2790. },
  2791. },
  2792. },
  2793. ],
  2794. },
  2795. ],
  2796. tooltip: {
  2797. formatter: function (a, b, d) {
  2798. if (a[0].seriesIndex == 0) {
  2799. const KlineTag = ref([]);
  2800. const AIBullTag = ref([]);
  2801. KlineTag.value = a.find((item) => item.data[1])?.data || [];
  2802. AIBullTag.value =
  2803. a.slice(4).find((item) => item.data[1] !== "-")?.data || [];
  2804. // console.log(AIBullTag.value)
  2805. return (
  2806. a[0].name +
  2807. "<br/>" +
  2808. "开盘价" +
  2809. ":" +
  2810. KlineTag.value[1] +
  2811. "<br/>" +
  2812. "收盘价" +
  2813. ":" +
  2814. KlineTag.value[2] +
  2815. "<br/>" +
  2816. "最低价" +
  2817. ":" +
  2818. KlineTag.value[3] +
  2819. "<br/>" +
  2820. "最高价" +
  2821. ":" +
  2822. KlineTag.value[4] +
  2823. "<br/>" +
  2824. "牵牛绳" +
  2825. ":" +
  2826. AIBullTag.value[1]
  2827. );
  2828. }
  2829. if (a[0].seriesIndex == 4) {
  2830. let formattedVolume;
  2831. if (a[0].data.value >= 10000) {
  2832. formattedVolume = (a[0].data.value / 10000).toFixed(2) + "w";
  2833. } else {
  2834. formattedVolume = a[0].data.value;
  2835. }
  2836. return a[0].name + "<br/>" + "成交量" + ":" + formattedVolume;
  2837. }
  2838. if ([10, 11, 12].includes(a[0].seriesIndex)) {
  2839. const duchiData = a.find(
  2840. (item) => item.data && item.data[1] !== "-"
  2841. );
  2842. return duchiData
  2843. ? a[0].axisValue + "<br/>" + "度牛尺" + ":" + duchiData.data[1]
  2844. : null;
  2845. }
  2846. },
  2847. trigger: "axis",
  2848. axisPointer: {
  2849. type: "cross",
  2850. },
  2851. backgroundColor: "rgba(119, 120, 125, 0.6)",
  2852. borderWidth: 1,
  2853. borderColor: "#77787D",
  2854. padding: 10,
  2855. textStyle: {
  2856. color: "#fff",
  2857. },
  2858. },
  2859. axisPointer: {
  2860. link: [
  2861. {
  2862. xAxisIndex: "all",
  2863. },
  2864. ],
  2865. label: {
  2866. backgroundColor: "#77787D",
  2867. },
  2868. },
  2869. toolbox: {
  2870. show: false,
  2871. },
  2872. grid: [
  2873. {
  2874. left:
  2875. window.innerWidth > 1024
  2876. ? "70vw"
  2877. : window.innerWidth > 768
  2878. ? "65vw"
  2879. : "55vw",
  2880. right:
  2881. window.innerWidth > 1024
  2882. ? "40vw"
  2883. : window.innerWidth > 768
  2884. ? "30vw"
  2885. : "40vw",
  2886. top: window.innerWidth > 768 ? "8%" : "5%",
  2887. height: window.innerWidth > 768 ? "34%" : "34%",
  2888. containLabel: false,
  2889. },
  2890. {
  2891. left:
  2892. window.innerWidth > 1024
  2893. ? "70vw"
  2894. : window.innerWidth > 768
  2895. ? "65vw"
  2896. : "55vw",
  2897. right:
  2898. window.innerWidth > 1024
  2899. ? "40vw"
  2900. : window.innerWidth > 768
  2901. ? "30vw"
  2902. : "40vw",
  2903. top: window.innerWidth > 768 ? "45%" : "42%",
  2904. height: window.innerWidth > 768 ? "22%" : "22%",
  2905. containLabel: false,
  2906. },
  2907. {
  2908. left:
  2909. window.innerWidth > 1024
  2910. ? "70vw"
  2911. : window.innerWidth > 768
  2912. ? "65vw"
  2913. : "55vw",
  2914. right:
  2915. window.innerWidth > 1024
  2916. ? "40vw"
  2917. : window.innerWidth > 768
  2918. ? "30vw"
  2919. : "40vw",
  2920. top: window.innerWidth > 768 ? "73%" : "70%",
  2921. height: window.innerWidth > 768 ? "20%" : "22%",
  2922. containLabel: false,
  2923. },
  2924. ],
  2925. xAxis: [
  2926. {
  2927. type: "category",
  2928. data: dealData.categoryData,
  2929. boundaryGap: true,
  2930. axisLine: { onZero: false },
  2931. splitLine: { show: false },
  2932. min: "dataMin",
  2933. max: "dataMax",
  2934. axisPointer: {
  2935. z: 100,
  2936. },
  2937. axisLine: {
  2938. lineStyle: {
  2939. color: "black",
  2940. },
  2941. }, //
  2942. axisLabel: { show: false },
  2943. axisTick: { show: false },
  2944. },
  2945. {
  2946. type: "category",
  2947. gridIndex: 1,
  2948. data: dealData.categoryData,
  2949. boundaryGap: true,
  2950. axisLine: { lineStyle: { color: "black" } },
  2951. axisLabel: {
  2952. show: false,
  2953. interval: "auto",
  2954. },
  2955. },
  2956. {
  2957. type: "category",
  2958. gridIndex: 2,
  2959. data: dealData.categoryData,
  2960. boundaryGap: true,
  2961. axisLine: { lineStyle: { color: "black" } },
  2962. axisLabel: {
  2963. show: true,
  2964. interval: "auto",
  2965. },
  2966. },
  2967. ],
  2968. yAxis: [
  2969. {
  2970. scale: true,
  2971. gridIndex: 0,
  2972. position: "left",
  2973. axisLabel: {
  2974. inside: false,
  2975. align: "right",
  2976. fontSize: window.innerWidth > 768 ? 15 : 10,
  2977. },
  2978. axisLine: {
  2979. show: true,
  2980. lineStyle: {
  2981. fontSize: "",
  2982. color: "black",
  2983. },
  2984. },
  2985. axisTick: { show: false },
  2986. splitLine: { show: false },
  2987. },
  2988. {
  2989. scale: true,
  2990. gridIndex: 1,
  2991. splitNumber: 4,
  2992. min: 0,
  2993. minInterval: 1,
  2994. axisLabel: {
  2995. show: true,
  2996. fontSize: window.innerWidth > 768 ? 15 : 10,
  2997. margin: 8,
  2998. formatter: (value) => {
  2999. if (value >= 1000000000) {
  3000. return (value / 1000000000).toFixed(1) + "B";
  3001. } else if (value >= 1000000) {
  3002. return (value / 1000000).toFixed(1) + "M";
  3003. } else if (value >= 10000) {
  3004. return (value / 10000).toFixed(1) + "W";
  3005. }
  3006. return value.toFixed(0);
  3007. },
  3008. },
  3009. axisLine: { show: true, lineStyle: { color: "black" } },
  3010. axisTick: { show: false },
  3011. splitLine: { show: true, lineStyle: { type: "dashed" } },
  3012. boundaryGap: ["20%", "20%"],
  3013. },
  3014. {
  3015. type: "value",
  3016. gridIndex: 2,
  3017. min: 0,
  3018. max: 100,
  3019. axisLabel: {
  3020. show: true,
  3021. fontSize: window.innerWidth > 768 ? 15 : 10,
  3022. formatter: function (value) {
  3023. var customValues = [0, 20, 50, 80, 100];
  3024. return customValues.indexOf(value) > -1 ? value : "";
  3025. },
  3026. },
  3027. axisLine: {
  3028. show: true,
  3029. lineStyle: {
  3030. color: "black",
  3031. },
  3032. },
  3033. axisTick: {
  3034. show: false,
  3035. },
  3036. splitNumber: 10,
  3037. splitLine: {
  3038. show: true,
  3039. lineStyle: {
  3040. type: "dashed",
  3041. color: "#fff",
  3042. width: 1,
  3043. },
  3044. interval: function (index, value) {
  3045. return [20, 50, 80, 100].indexOf(value) > -1;
  3046. },
  3047. },
  3048. },
  3049. ],
  3050. dataZoom: [
  3051. {
  3052. type: "inside",
  3053. xAxisIndex: [0, 1, 2],
  3054. start: 55,
  3055. end: 100,
  3056. },
  3057. {
  3058. show: true,
  3059. xAxisIndex: [0, 1, 2],
  3060. type: "slider",
  3061. top: window.innerWidth > 768 ? "95%" : "96%",
  3062. // left: window.innerWidth > 768 ? "10%" : "8%",
  3063. // right: window.innerWidth > 768 ? "4%" : "8%",
  3064. start: 98,
  3065. end: 100,
  3066. },
  3067. ],
  3068. visualMap: [
  3069. {
  3070. type: "piecewise",
  3071. show: false,
  3072. pieces: maData.singleTypeGreen,
  3073. outOfRange: {
  3074. color: "green",
  3075. },
  3076. dimension: 0,
  3077. seriesIndex: 7,
  3078. },
  3079. {
  3080. type: "piecewise",
  3081. show: false,
  3082. pieces: maData.singleTypeRed,
  3083. outOfRange: {
  3084. color: "red",
  3085. },
  3086. dimension: 0,
  3087. seriesIndex: 8,
  3088. },
  3089. {
  3090. type: "piecewise",
  3091. show: false,
  3092. pieces: maData.singleTypeYellow,
  3093. outOfRange: {
  3094. color: "yellow",
  3095. },
  3096. dimension: 0,
  3097. seriesIndex: 9,
  3098. },
  3099. ],
  3100. series: [
  3101. {
  3102. name: "进攻K线",
  3103. type: "candlestick",
  3104. barWidth: "50%",
  3105. data: dealData1.values,
  3106. xAxisIndex: 0,
  3107. yAxisIndex: 0,
  3108. itemStyle: {
  3109. normal: {
  3110. color: "rgb(255,0,0)",
  3111. color0: "rgb(255,0,0)",
  3112. borderColor: "rgb(255,0,0)",
  3113. borderColor0: "rgb(255,0,0)",
  3114. },
  3115. },
  3116. gridIndex: 0,
  3117. },
  3118. //
  3119. {
  3120. name: "推进K线",
  3121. type: "candlestick",
  3122. barWidth: "50%",
  3123. data: dealData2.values,
  3124. xAxisIndex: 0,
  3125. yAxisIndex: 0,
  3126. itemStyle: {
  3127. normal: {
  3128. color: "rgb(0,0,252)",
  3129. color0: "rgb(0,0,252)",
  3130. borderColor: "rgb(0,0,252)",
  3131. borderColor0: "rgb(0,0,252)",
  3132. },
  3133. },
  3134. gridIndex: 0,
  3135. },
  3136. {
  3137. name: "防守K线",
  3138. type: "candlestick",
  3139. barWidth: "50%",
  3140. data: dealData3.values,
  3141. xAxisIndex: 0,
  3142. yAxisIndex: 0,
  3143. itemStyle: {
  3144. normal: {
  3145. color: "orange",
  3146. color0: "orange",
  3147. borderColor: "orange",
  3148. borderColor0: "orange",
  3149. },
  3150. },
  3151. gridIndex: 0,
  3152. },
  3153. {
  3154. name: "撤退K线",
  3155. type: "candlestick",
  3156. barWidth: "50%",
  3157. data: dealData4.values,
  3158. xAxisIndex: 0,
  3159. yAxisIndex: 0,
  3160. itemStyle: {
  3161. normal: {
  3162. color: "rgb(84,252,252)",
  3163. color0: "rgb(84,252,252)",
  3164. borderColor: "rgb(84,252,252)",
  3165. borderColor0: "rgb(84,252,252)",
  3166. },
  3167. },
  3168. gridIndex: 0,
  3169. },
  3170. {
  3171. name: "成交量",
  3172. type: "bar",
  3173. barWidth: "70%",
  3174. xAxisIndex: 1,
  3175. yAxisIndex: 1,
  3176. data: barData,
  3177. markPoint: {
  3178. data: markPointData,
  3179. label: {
  3180. show: false,
  3181. },
  3182. },
  3183. },
  3184. {
  3185. name: "{green|━}{red|━} " + "牵牛绳",
  3186. type: "line",
  3187. data: [],
  3188. smooth: true,
  3189. symbol: "none",
  3190. xAxisIndex: 0,
  3191. yAxisIndex: 0,
  3192. showSymbol: false,
  3193. lineStyle: {
  3194. opacity: 0,
  3195. },
  3196. itemStyle: {
  3197. normal: {
  3198. color: "green",
  3199. },
  3200. },
  3201. gridIndex: 0,
  3202. },
  3203. {
  3204. name: "{green|━}{red|━} " + "度牛尺",
  3205. type: "line",
  3206. data: [],
  3207. smooth: true,
  3208. symbol: "none",
  3209. xAxisIndex: 0,
  3210. yAxisIndex: 0,
  3211. showSymbol: false,
  3212. lineStyle: {
  3213. opacity: 0,
  3214. },
  3215. itemStyle: {
  3216. normal: {
  3217. color: "green",
  3218. },
  3219. },
  3220. gridIndex: 0,
  3221. },
  3222. {
  3223. name: "虫线",
  3224. type: "line",
  3225. data: maData.greenData,
  3226. smooth: true,
  3227. symbol: "none",
  3228. xAxisIndex: 0,
  3229. yAxisIndex: 0,
  3230. itemStyle: {
  3231. normal: {
  3232. color: "green",
  3233. lineStyle: {
  3234. width: 2,
  3235. type: "solid",
  3236. },
  3237. },
  3238. },
  3239. gridIndex: 0,
  3240. },
  3241. {
  3242. name: "龙线",
  3243. type: "line",
  3244. data: maData.redData,
  3245. smooth: true,
  3246. symbol: "none",
  3247. xAxisIndex: 0,
  3248. yAxisIndex: 0,
  3249. itemStyle: {
  3250. normal: {
  3251. color: "red",
  3252. lineStyle: {
  3253. width: 2,
  3254. type: "solid",
  3255. },
  3256. },
  3257. },
  3258. gridIndex: 0,
  3259. },
  3260. {
  3261. name: "黄色",
  3262. type: "line",
  3263. data: maData.yellowData,
  3264. smooth: true,
  3265. symbol: "none",
  3266. xAxisIndex: 0,
  3267. yAxisIndex: 0,
  3268. itemStyle: {
  3269. normal: {
  3270. color: "yellow",
  3271. lineStyle: {
  3272. width: 2,
  3273. type: "solid",
  3274. },
  3275. },
  3276. },
  3277. gridIndex: 0,
  3278. },
  3279. {
  3280. name: "背景区域",
  3281. type: "line",
  3282. data: [],
  3283. xAxisIndex: 2,
  3284. yAxisIndex: 2,
  3285. markArea: {
  3286. silent: true,
  3287. itemStyle: {
  3288. normal: {
  3289. opacity: 1,
  3290. },
  3291. },
  3292. label: {
  3293. normal: {
  3294. show: true,
  3295. position: "insideRight",
  3296. fontSize: window.innerWidth > 768 ? 16 : 12,
  3297. fontWeight: "bold",
  3298. color: "#13E113",
  3299. distance: 10,
  3300. },
  3301. },
  3302. data: [
  3303. [
  3304. {
  3305. yAxis: 0,
  3306. itemStyle: {
  3307. normal: {
  3308. color: "#CFFFCF",
  3309. },
  3310. },
  3311. label: {
  3312. normal: {
  3313. formatter: "度牛区",
  3314. },
  3315. },
  3316. },
  3317. {
  3318. yAxis: 20,
  3319. },
  3320. ],
  3321. [
  3322. {
  3323. yAxis: 20,
  3324. itemStyle: {
  3325. normal: {
  3326. color: "#A6FFFF",
  3327. },
  3328. },
  3329. },
  3330. {
  3331. yAxis: 40,
  3332. },
  3333. ],
  3334. [
  3335. {
  3336. yAxis: 40,
  3337. itemStyle: {
  3338. normal: {
  3339. color: "#FFF686",
  3340. },
  3341. },
  3342. },
  3343. {
  3344. yAxis: 60,
  3345. },
  3346. ],
  3347. [
  3348. {
  3349. yAxis: 60,
  3350. itemStyle: {
  3351. normal: { color: "#FFD2B3" },
  3352. },
  3353. },
  3354. {
  3355. yAxis: 80,
  3356. },
  3357. ],
  3358. [
  3359. {
  3360. yAxis: 80,
  3361. itemStyle: {
  3362. normal: { color: "#FFB8B8" },
  3363. },
  3364. label: {
  3365. normal: {
  3366. formatter: "度牛区",
  3367. color: "#FF0000",
  3368. position: "insideLeft",
  3369. distance: 10,
  3370. },
  3371. },
  3372. },
  3373. {
  3374. yAxis: 100,
  3375. },
  3376. ],
  3377. ],
  3378. },
  3379. },
  3380. {
  3381. name: "度牛尺",
  3382. type: "line",
  3383. data: maDuchiData.greenData,
  3384. symbol: "none",
  3385. xAxisIndex: 2,
  3386. yAxisIndex: 2,
  3387. itemStyle: {
  3388. normal: {
  3389. color: "green",
  3390. lineStyle: {
  3391. width: 2,
  3392. type: "solid",
  3393. },
  3394. },
  3395. },
  3396. gridIndex: 2,
  3397. markPoint: {
  3398. symbol: "rect",
  3399. symbolSize: (value, params) => {
  3400. const width = window.innerWidth;
  3401. const baseHeight = 22;
  3402. // if (width <= 375) {
  3403. // return [2, 16];
  3404. // } else if (width <= 768) {
  3405. // return [2, 22];
  3406. // }
  3407. return [2, baseHeight];
  3408. },
  3409. itemStyle: {
  3410. normal: {
  3411. label: {
  3412. show: false,
  3413. },
  3414. },
  3415. },
  3416. data: [
  3417. ...maDuchiData.greenData
  3418. .map((item) => {
  3419. if (item[1] === 0) {
  3420. return {
  3421. coord: [item[0], 20],
  3422. symbolOffset: [0, 10],
  3423. itemStyle: {
  3424. color: "#00ff00",
  3425. },
  3426. };
  3427. }
  3428. })
  3429. .filter(Boolean),
  3430. ],
  3431. },
  3432. },
  3433. {
  3434. type: "line",
  3435. data: maDuchiData.redData,
  3436. // smooth: true,
  3437. symbol: "none",
  3438. xAxisIndex: 2,
  3439. yAxisIndex: 2,
  3440. itemStyle: {
  3441. normal: {
  3442. color: "red",
  3443. lineStyle: {
  3444. width: 2,
  3445. type: "solid",
  3446. },
  3447. },
  3448. },
  3449. gridIndex: 2,
  3450. markPoint: {
  3451. symbol: "rect",
  3452. symbolSize: (value, params) => {
  3453. const width = window.innerWidth;
  3454. const baseHeight = 22;
  3455. // if (width <= 375) {
  3456. // return [2, 16];
  3457. // } else if (width <= 768) {
  3458. // return [2, 24];
  3459. // }
  3460. return [2, baseHeight];
  3461. },
  3462. itemStyle: {
  3463. normal: {
  3464. label: {
  3465. show: false,
  3466. },
  3467. },
  3468. },
  3469. data: [
  3470. ...maDuchiData.redData
  3471. .map((item) => {
  3472. if (item[1] === 100) {
  3473. return {
  3474. coord: [item[0], 80],
  3475. symbolOffset: [0, -10],
  3476. itemStyle: {
  3477. color: "#ff0000",
  3478. },
  3479. };
  3480. }
  3481. })
  3482. .filter(Boolean),
  3483. ],
  3484. },
  3485. },
  3486. {
  3487. name: "辅助线",
  3488. type: "line",
  3489. data: [],
  3490. xAxisIndex: 2,
  3491. yAxisIndex: 2,
  3492. markLine: {
  3493. silent: true,
  3494. symbol: "none",
  3495. lineStyle: {
  3496. color: "#000000",
  3497. width: 3,
  3498. type: "solid",
  3499. },
  3500. data: [{ yAxis: 20 }],
  3501. },
  3502. },
  3503. {
  3504. name: "辅助线",
  3505. type: "line",
  3506. data: [],
  3507. xAxisIndex: 2,
  3508. yAxisIndex: 2,
  3509. markLine: {
  3510. silent: true,
  3511. symbol: "none",
  3512. lineStyle: {
  3513. color: "#000000",
  3514. width: 3,
  3515. type: "solid",
  3516. },
  3517. data: [{ yAxis: 50 }],
  3518. },
  3519. },
  3520. {
  3521. name: "辅助线",
  3522. type: "line",
  3523. data: [],
  3524. xAxisIndex: 2,
  3525. yAxisIndex: 2,
  3526. markLine: {
  3527. silent: true,
  3528. symbol: "none",
  3529. lineStyle: {
  3530. color: "#000000",
  3531. width: 3,
  3532. type: "solid",
  3533. },
  3534. data: [{ yAxis: 80 }],
  3535. },
  3536. },
  3537. {
  3538. name: "辅助线",
  3539. type: "line",
  3540. data: [],
  3541. xAxisIndex: 2,
  3542. yAxisIndex: 2,
  3543. markLine: {
  3544. silent: true,
  3545. symbol: "none",
  3546. lineStyle: {
  3547. color: "#000000",
  3548. width: 3,
  3549. type: "solid",
  3550. },
  3551. data: [{ yAxis: 100 }],
  3552. },
  3553. },
  3554. ],
  3555. };
  3556. }
  3557. console.log("KLine渲染: 图表配置完成");
  3558. try {
  3559. // 应用配置
  3560. console.log("KLine渲染: 开始设置图表选项");
  3561. chartInstancesMap[containerId].setOption(KlineOption);
  3562. console.log("KLine渲染: 图表选项设置成功");
  3563. // 窗口大小变化时重新渲染图表
  3564. const resizeFunc = _.throttle(
  3565. function () {
  3566. console.log("窗口大小改变,调整图表大小");
  3567. if (
  3568. chartInstancesMap[containerId] &&
  3569. !chartInstancesMap[containerId].isDisposed()
  3570. ) {
  3571. // 如果设备类型发生变化,重新渲染
  3572. const newIsMobile = window.innerWidth < 768;
  3573. const newIsTablet =
  3574. window.innerWidth >= 768 && window.innerWidth < 1024;
  3575. if (newIsMobile !== isMobile || newIsTablet !== isTablet) {
  3576. console.log("设备类型变化,重新渲染图表");
  3577. KlineCanvsEcharts(containerId);
  3578. return;
  3579. }
  3580. chartInstancesMap[containerId].resize();
  3581. }
  3582. },
  3583. 1000,
  3584. { trailing: false }
  3585. );
  3586. // 给resize事件绑定一个特定的函数名,便于后续移除
  3587. window[`resize_${containerId}`] = resizeFunc;
  3588. // 绑定resize事件
  3589. window.removeEventListener("resize", window[`resize_${containerId}`]);
  3590. window.addEventListener("resize", window[`resize_${containerId}`]);
  3591. console.log("KLine渲染: 图表渲染完成");
  3592. } catch (error) {
  3593. console.error("KLine渲染: 图表渲染出错", error);
  3594. }
  3595. }
  3596. watch(
  3597. () => audioStore.isVoiceEnabled,
  3598. (newVal) => {
  3599. // 添加状态锁定逻辑
  3600. if (newVal === audioStore.lastVoiceState) return;
  3601. audioStore.lastVoiceState = newVal;
  3602. if (newVal) {
  3603. console.log("开启语音播放");
  3604. // 添加重试机制
  3605. const tryPlay = () => {
  3606. if (!audioStore.ttsUrl) return; // 新增空值判断
  3607. if (audioStore.soundInstance?.playing()) return;
  3608. playAudio(audioStore.ttsUrl);
  3609. setTimeout(() => {
  3610. if (!audioStore.soundInstance?.playing()) {
  3611. Howler.unload();
  3612. }
  3613. }, 1000);
  3614. };
  3615. tryPlay();
  3616. } else {
  3617. console.log("关闭语音播放");
  3618. pauseAudio();
  3619. // 强制停止并释放资源
  3620. // Howler.stop();
  3621. // Howler.unload();
  3622. // if (audioStore.soundInstance) {
  3623. // audioStore.soundInstance.off(); // 移除所有事件监听
  3624. // audioStore.soundInstance = null;
  3625. // }
  3626. }
  3627. },
  3628. { immediate: true }
  3629. );
  3630. watch(
  3631. () => dataStore.activeTabIndex,
  3632. (newVal) => {
  3633. setTimeout(() => {
  3634. console.log("activeTabIndex变化:", newVal);
  3635. // 当标签页切换回来时,重新渲染所有图表
  3636. if (newVal === 0) {
  3637. console.log("切换到AI聊天页,重新渲染图表");
  3638. // 延迟执行以确保DOM已渲染
  3639. renderAllKlineCharts();
  3640. }
  3641. }, 1000);
  3642. },
  3643. { immediate: true } // 添加immediate属性,确保初始化时执行一次
  3644. );
  3645. // 添加渲染所有K线图的方法
  3646. function renderAllKlineCharts() {
  3647. console.log("重新渲染所有K线图");
  3648. // 查找所有K线消息
  3649. const messages = chatStore.messages;
  3650. for (let i = 0; i < messages.length; i++) {
  3651. if (messages[i].kline && messages[i].chartData) {
  3652. const containerId = `kline-container-${i}`;
  3653. console.log(`尝试渲染K线图: ${containerId}`);
  3654. // 确保DOM已经渲染
  3655. const container = document.getElementById(containerId);
  3656. if (container) {
  3657. // 渲染图表
  3658. KlineCanvsEcharts(containerId);
  3659. } else {
  3660. console.warn(`找不到容器: ${containerId}`);
  3661. }
  3662. }
  3663. }
  3664. }
  3665. // 初始化随机GIF
  3666. onMounted(() => {
  3667. // 初始化marked组件
  3668. marked.setOptions({
  3669. breaks: true, // 支持换行符转换为 <br>
  3670. gfm: true, // 启用 GitHub Flavored Markdown
  3671. sanitize: false, // 不清理 HTML(谨慎使用)
  3672. smartLists: true, // 智能列表
  3673. smartypants: true, // 智能标点符号
  3674. xhtml: false, // 不使用 XHTML 输出
  3675. renderer: renderer,
  3676. });
  3677. renderAllKlineCharts();
  3678. console.log("组件挂载完成");
  3679. // 添加页面可见性变化监听器
  3680. document.addEventListener("visibilitychange", handleVisibilityChange);
  3681. // 添加DOM变化监听器
  3682. const observer = new MutationObserver((mutations) => {
  3683. mutations.forEach((mutation) => {
  3684. if (mutation.type === "childList" && mutation.addedNodes.length) {
  3685. // 检查是否添加了图表容器
  3686. const containers = document.querySelectorAll(
  3687. '[id^="kline-container-"]'
  3688. );
  3689. if (containers.length) {
  3690. // console.log("DOM变化监听到K线容器:", Array.from(containers).map(el => el.id));
  3691. }
  3692. }
  3693. });
  3694. });
  3695. // 开始监听DOM变化
  3696. observer.observe(document.body, { childList: true, subtree: true });
  3697. });
  3698. // 页面可见性变化处理
  3699. let wasPlayingBeforeHidden = false;
  3700. const handleVisibilityChange = () => {
  3701. if (document.hidden) {
  3702. // 页面被隐藏时,如果音频正在播放,则暂停并记录状态
  3703. if (audioStore.isPlaying) {
  3704. wasPlayingBeforeHidden = true;
  3705. audioStore.pause();
  3706. console.log("页面切换离开,音频已暂停");
  3707. } else {
  3708. wasPlayingBeforeHidden = false;
  3709. }
  3710. } else {
  3711. // 页面重新可见时,如果之前在播放,则恢复播放
  3712. if (wasPlayingBeforeHidden && !audioStore.isPlaying) {
  3713. audioStore.play();
  3714. console.log("页面切换回来,音频已恢复播放");
  3715. wasPlayingBeforeHidden = false;
  3716. }
  3717. }
  3718. };
  3719. // 组件卸载时清理所有图表实例和事件监听器
  3720. onUnmounted(() => {
  3721. // 移除页面可见性变化监听器
  3722. document.removeEventListener("visibilitychange", handleVisibilityChange);
  3723. // 停止音频播放
  3724. if (audioStore.isPlaying) {
  3725. audioStore.stop();
  3726. console.log("组件卸载,音频已停止");
  3727. }
  3728. // 清理所有图表实例
  3729. Object.keys(chartInstancesMap).forEach((key) => {
  3730. if (chartInstancesMap[key]) {
  3731. // 移除resize事件监听
  3732. if (window[`resize_${key}`]) {
  3733. window.removeEventListener("resize", window[`resize_${key}`]);
  3734. delete window[`resize_${key}`];
  3735. }
  3736. // 销毁图表实例
  3737. chartInstancesMap[key].dispose();
  3738. delete chartInstancesMap[key];
  3739. }
  3740. });
  3741. });
  3742. </script>
  3743. <template>
  3744. <div class="chat-container">
  3745. <!-- GIF区域 -->
  3746. <div class="gif-area">
  3747. <img :src="bgc1" alt="夺宝奇兵大模型logo" class="bgc" />
  3748. <img :src="logo1" alt="夺宝奇兵大模型logo" class="logo1" />
  3749. <img :src="logo2" alt="夺宝奇兵大模型logo" class="logo2" />
  3750. </div>
  3751. <div
  3752. v-for="(msg, index) in chatMsg"
  3753. :key="index"
  3754. :class="{
  3755. 'message-bubble': true,
  3756. [msg.sender]: msg.sender,
  3757. [msg.class]: msg.class,
  3758. }"
  3759. >
  3760. <div v-if="msg.type === 'kline'" class="kline-container">
  3761. <div :id="'kline-container-' + index" class="chart-mount-point">
  3762. <div v-if="!msg.hasValidData" class="no-data-message">
  3763. <p>暂无K线数据</p>
  3764. </div>
  3765. </div>
  3766. </div>
  3767. <div v-else-if="msg.type == 'ing'">
  3768. <div v-if="msg.flag">
  3769. <span>{{ msg.content }}</span>
  3770. <span class="loading-dots">
  3771. <span class="dot">.</span>
  3772. <span class="dot">.</span>
  3773. <span class="dot">.</span>
  3774. <span class="dot">.</span>
  3775. <span class="dot">.</span>
  3776. <span class="dot">.</span>
  3777. </span>
  3778. </div>
  3779. <div v-else v-html="msg.content"></div>
  3780. </div>
  3781. <div v-else-if="msg.type == 'title1'" style="display: flex; width: 100%">
  3782. <div class="mainTitle">
  3783. {{ msg.content }}
  3784. </div>
  3785. <div class="date">
  3786. {{ msg.date }}
  3787. </div>
  3788. </div>
  3789. <div v-else-if="msg.type == 'title2'" class="title2">
  3790. <img class="title1Img" :src="title1" alt="出错了" />
  3791. </div>
  3792. <div v-else-if="msg.type == 'title3'" class="title3">
  3793. <img class="title2Img" :src="msg.content" alt="出错了" />
  3794. </div>
  3795. <div v-else-if="msg.type == 'content1'" class="content1">
  3796. <div v-if="msg.kline" class="kline-container content1chart">
  3797. <div :id="'kline-container-' + index" class="chart-mount-point">
  3798. <div v-if="!msg.hasValidData" class="no-data-message">
  3799. <p>暂无数据</p>
  3800. </div>
  3801. </div>
  3802. </div>
  3803. <div v-else class="content1Text">
  3804. <div v-html="msg.content" class="text1"></div>
  3805. </div>
  3806. </div>
  3807. <div v-else-if="msg.type == 'content2'" class="content2">
  3808. <div class="kline-container content2chart">
  3809. <div :id="'kline-container-' + index" class="chart-mount-point">
  3810. <div v-if="!msg.hasValidData" class="no-data-message">
  3811. <p>暂无数据</p>
  3812. </div>
  3813. </div>
  3814. </div>
  3815. </div>
  3816. <div v-else-if="msg.type == 'content3'" class="content3">
  3817. <div class="content3Text">
  3818. <div v-html="msg.content" class="text3"></div>
  3819. </div>
  3820. </div>
  3821. <div v-else-if="msg.type == 'mianze'" class="mianze">
  3822. <div v-html="msg.content"></div>
  3823. </div>
  3824. <div v-else v-html="msg.content"></div>
  3825. </div>
  3826. </div>
  3827. </template>
  3828. <style scoped>
  3829. p {
  3830. font-size: 20px;
  3831. }
  3832. .bgc {
  3833. position: absolute;
  3834. z-index: -1;
  3835. max-width: 530px;
  3836. min-width: 340px;
  3837. width: 40%;
  3838. height: auto;
  3839. /* right: 30px; */
  3840. /* top: -30px; */
  3841. }
  3842. .logo1 {
  3843. max-width: 350px;
  3844. min-width: 200px;
  3845. width: 25%;
  3846. }
  3847. .logo2 {
  3848. margin-top: 20px;
  3849. max-width: 350px;
  3850. min-width: 200px;
  3851. width: 30%;
  3852. /* position: relative; */
  3853. }
  3854. .chat-container {
  3855. display: flex;
  3856. flex-direction: column;
  3857. overflow: hidden;
  3858. }
  3859. .gif-area {
  3860. padding: 70px 0px;
  3861. position: relative;
  3862. /* height: 30vh; */
  3863. display: flex;
  3864. flex-direction: column;
  3865. justify-content: center;
  3866. align-items: center;
  3867. flex-shrink: 0;
  3868. /* 防止GIF区域被压缩 */
  3869. }
  3870. .gif-area img {
  3871. /* width: 30%; */
  3872. /* 改为百分比单位 */
  3873. /* min-width: 200px; */
  3874. /* 最小尺寸 */
  3875. /* max-width: 400px; */
  3876. /* 最大尺寸 */
  3877. /* height: auto; */
  3878. /* left: 50%; */
  3879. /* transition: all 0.3s; */
  3880. /* 添加过渡效果 */
  3881. }
  3882. .message-area {
  3883. margin-top: 2%;
  3884. flex: 1;
  3885. /* 消息区域占据剩余空间 */
  3886. overflow-y: auto;
  3887. padding: 20px;
  3888. display: flex;
  3889. flex-direction: column;
  3890. gap: 15px;
  3891. }
  3892. .marquee-container {
  3893. /* position: absolute; */
  3894. bottom: 0;
  3895. width: 100%;
  3896. /* ga */
  3897. }
  3898. .marquee-row {
  3899. white-space: nowrap;
  3900. overflow: visible;
  3901. padding: 8px 0;
  3902. width: 100%;
  3903. }
  3904. .marquee-item {
  3905. display: inline-block;
  3906. margin: 0 15px;
  3907. padding: 8px 20px;
  3908. background: rgba(255, 255, 255, 0.9);
  3909. /* 白色背景 */
  3910. border-radius: 10px;
  3911. /* 圆角矩形 */
  3912. color: #333;
  3913. /* 文字颜色改为深色 */
  3914. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  3915. /* 添加阴影 */
  3916. transition: all 0.3s;
  3917. transition: color 0.3s;
  3918. }
  3919. .top {
  3920. animation: marquee 25s linear infinite;
  3921. /* 默认动画是运行状态 */
  3922. animation-play-state: running;
  3923. }
  3924. .bottom {
  3925. animation: marquee 15s linear infinite reverse;
  3926. /* 默认动画是运行状态 */
  3927. animation-play-state: running;
  3928. }
  3929. /* 添加PC端专用速度 */
  3930. @media (min-width: 768px) {
  3931. .top {
  3932. animation-duration: 35s;
  3933. /* PC端改为35秒 */
  3934. }
  3935. .bottom {
  3936. animation-duration: 35s;
  3937. /* PC端改为35秒 */
  3938. }
  3939. }
  3940. @keyframes marquee {
  3941. 0% {
  3942. transform: translateX(100%);
  3943. }
  3944. 100% {
  3945. transform: translateX(-250%);
  3946. }
  3947. }
  3948. .loading-dots {
  3949. display: inline-block;
  3950. }
  3951. .dot {
  3952. opacity: 0.4;
  3953. animation: loading 1.4s infinite;
  3954. }
  3955. .dot:nth-child(1) {
  3956. animation-delay: 0s;
  3957. }
  3958. .dot:nth-child(2) {
  3959. animation-delay: 0.2s;
  3960. }
  3961. .dot:nth-child(3) {
  3962. animation-delay: 0.4s;
  3963. }
  3964. .dot:nth-child(4) {
  3965. animation-delay: 0.6s;
  3966. }
  3967. .dot:nth-child(5) {
  3968. animation-delay: 0.8s;
  3969. }
  3970. .dot:nth-child(6) {
  3971. animation-delay: 1s;
  3972. }
  3973. @keyframes loading {
  3974. 0%,
  3975. 60%,
  3976. 100% {
  3977. opacity: 0.4;
  3978. }
  3979. 30% {
  3980. opacity: 1;
  3981. }
  3982. }
  3983. .message-bubble {
  3984. max-width: 80%;
  3985. margin: 10px 0px;
  3986. padding: 15px 20px;
  3987. position: relative;
  3988. }
  3989. .message-bubble.user {
  3990. color: #6d22f8;
  3991. background: white;
  3992. font-weight: bold;
  3993. margin-left: auto;
  3994. border-radius: 10px;
  3995. margin-right: 20px;
  3996. /* border-bottom-right-radius: 5px; */
  3997. }
  3998. .message-bubble.ai {
  3999. background: #2b378d;
  4000. color: #ffffff;
  4001. margin: 0 auto;
  4002. /* border-bottom-left-radius: 5px; */
  4003. }
  4004. .message-bubble.ing {
  4005. background: #ffffff;
  4006. color: #000000;
  4007. font-weight: bold;
  4008. border-radius: 10px;
  4009. margin-left: 20px;
  4010. margin-right: auto;
  4011. /* border-bottom-left-radius: 5px; */
  4012. }
  4013. .message-bubble.ai.title1 {
  4014. width: 100%;
  4015. display: flex;
  4016. border-radius: 10px 10px 0px 0px;
  4017. /* border-bottom-left-radius: 5px; */
  4018. }
  4019. .mainTitle {
  4020. font-size: 16px;
  4021. font-weight: bold;
  4022. background-image: url("@/assets/img/AiEmotion/bk01.png");
  4023. background-repeat: no-repeat;
  4024. background-size: 100% 100%;
  4025. min-width: 200px;
  4026. width: 20vw;
  4027. height: 50px;
  4028. padding: 5px 0px 0px 0px;
  4029. display: flex;
  4030. justify-content: center;
  4031. align-items: center;
  4032. }
  4033. .date {
  4034. font-size: 1.5rem;
  4035. font-weight: bold;
  4036. margin-left: auto;
  4037. /* width: 100px; */
  4038. display: flex;
  4039. justify-content: center;
  4040. align-items: center;
  4041. }
  4042. .message-bubble.ai.title2 {
  4043. width: 100%;
  4044. display: flex;
  4045. justify-content: center;
  4046. align-items: center;
  4047. }
  4048. .title1Img {
  4049. max-width: 500px;
  4050. width: 80vw;
  4051. }
  4052. .message-bubble.ai.title3 {
  4053. width: 100%;
  4054. display: flex;
  4055. justify-content: center;
  4056. align-items: center;
  4057. }
  4058. .title2Img {
  4059. max-width: 500px;
  4060. width: 90vw;
  4061. }
  4062. .message-bubble.ai.content1 {
  4063. width: 100%;
  4064. display: flex;
  4065. justify-content: center;
  4066. align-items: center;
  4067. }
  4068. .content1chart {
  4069. background-image: url("@/assets/img/AIchat/罗盘边框.png");
  4070. background-repeat: no-repeat;
  4071. background-size: 100% 100%;
  4072. width: 50vw;
  4073. min-width: 350px;
  4074. display: flex;
  4075. justify-content: center;
  4076. align-items: center;
  4077. }
  4078. .content1Text {
  4079. background-image: url("@/assets/img/AIchat/框.png");
  4080. background-repeat: no-repeat;
  4081. background-size: 100% 100%;
  4082. width: 50vw;
  4083. min-width: 350px;
  4084. /* height: 20vw; */
  4085. /* max-height: 400px; */
  4086. padding: 5% 0;
  4087. }
  4088. .text1 {
  4089. font-weight: bold;
  4090. /* margin-left: 6%; */
  4091. /* margin-bottom: 10px; */
  4092. margin: 0px 6% 10px 6%;
  4093. font-size: 20px;
  4094. }
  4095. .message-bubble.ai.content2 {
  4096. width: 100%;
  4097. display: flex;
  4098. justify-content: center;
  4099. align-items: center;
  4100. }
  4101. .content2chart {
  4102. background-image: url("@/assets/img/AIchat/PCbackPic.png");
  4103. background-repeat: no-repeat;
  4104. background-size: 100% 100%;
  4105. width: 50vw;
  4106. min-width: 350px;
  4107. display: flex;
  4108. justify-content: center;
  4109. align-items: center;
  4110. height: calc(500px + 10vw) !important;
  4111. }
  4112. .message-bubble.ai.content3 {
  4113. width: 100%;
  4114. display: flex;
  4115. justify-content: center;
  4116. align-items: center;
  4117. }
  4118. .content3Text {
  4119. background-image: url("@/assets/img/AIchat/边框.png");
  4120. background-repeat: no-repeat;
  4121. background-size: 100% 100%;
  4122. width: 50vw;
  4123. min-width: 350px;
  4124. /* height: 20vw; */
  4125. /* max-height: 400px; */
  4126. padding: 5% 0px;
  4127. }
  4128. .text3 {
  4129. /* font-weight: bold; */
  4130. /* margin-left: 6%; */
  4131. /* margin-bottom: 10px; */
  4132. margin: 0px 6% 10px 6%;
  4133. font-size: 20px;
  4134. }
  4135. .message-bubble.ai.mianze {
  4136. width: 100%;
  4137. text-align: center;
  4138. font-weight: bold;
  4139. font-size: 24px;
  4140. border-radius: 0px 0px 10px 10px;
  4141. }
  4142. .kline-container {
  4143. margin-top: 10px;
  4144. /* 最小高度 */
  4145. min-height: 320px;
  4146. /* 视口高度单位 */
  4147. height: 40vh;
  4148. width: 50vw;
  4149. }
  4150. @media (max-width: 768px) {
  4151. .kline-container {
  4152. min-width: 75vw;
  4153. }
  4154. .content1Text {
  4155. width: 77vw;
  4156. min-width: 0px;
  4157. /* height: 20vw; */
  4158. /* min-height: 150px; */
  4159. }
  4160. .date {
  4161. font-size: 14px;
  4162. }
  4163. .text1 {
  4164. font-size: 20px;
  4165. }
  4166. .content2chart {
  4167. background-image: url("@/assets/img/AIchat/new-app-bgc.png") !important;
  4168. height: 100vw;
  4169. }
  4170. .content3Text {
  4171. width: 77vw;
  4172. min-width: 0px;
  4173. /* height: 20vw; */
  4174. /* min-height: 150px; */
  4175. }
  4176. .text3 {
  4177. font-size: 20px;
  4178. }
  4179. .message-bubble.ai.mianze {
  4180. font-size: 18px;
  4181. }
  4182. }
  4183. .kline-container .chart-mount-point {
  4184. display: flex;
  4185. justify-content: center;
  4186. align-items: center;
  4187. height: 80%;
  4188. width: 90%;
  4189. }
  4190. </style>