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.

3262 lines
91 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
2 months ago
2 months ago
4 months ago
3 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
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months 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 AIgif1 from "@/assets/img/AIchat/AIgif1.gif";
  28. import AIgif2 from "@/assets/img/AIchat/AIgif2.gif";
  29. import AIgif3 from "@/assets/img/AIchat/AIgif3.gif";
  30. import AIgif4 from "@/assets/img/AIchat/AIgif4.gif";
  31. import AIgif5 from "@/assets/img/AIchat/AIgif5.gif";
  32. import AIgif6 from "@/assets/img/AIchat/AIgif6.gif";
  33. import AIgif7 from "@/assets/img/AIchat/AIgif7.gif";
  34. import title1 from "@/assets/img/AIchat/核心价值评估标题.png";
  35. import title2 from "@/assets/img/AIchat/主力作战.png";
  36. import title3 from "@/assets/img/AIchat/攻防三维.png";
  37. import title4 from "@/assets/img/AIchat/综合作战.png";
  38. const gifList = [AIgif1, AIgif2, AIgif3, AIgif4, AIgif5, AIgif6, AIgif7];
  39. const chatStore = useChatStore();
  40. const audioStore = useAudioStore();
  41. const dataStore = useDataStore();
  42. // 随机GIF
  43. const currentGif = ref("");
  44. const renderer = new marked.Renderer();
  45. // 重写 del 方法,让删除线不生效
  46. renderer.del = function (text) {
  47. // 处理各种数据类型
  48. console.log("text", text);
  49. return "~" + text.tokens[0].raw + "<br>" + text.tokens[2].raw + "~";
  50. };
  51. // 定义自定义事件
  52. const emit = defineEmits(["updateMessage", "sendMessage"]);
  53. // 音频播放方法
  54. const playAudio = (url) => {
  55. // 添加空值校验
  56. if (!url) {
  57. console.warn("音频URL为空,跳过播放");
  58. audioStore.isPlaying = false;
  59. return;
  60. }
  61. const handlePlay = () => {
  62. // if (audioStore.soundInstance) {
  63. // Howler.unload(); // 添加清理旧实例
  64. // // audioStore.soundInstance.stop()
  65. // }
  66. if (audioStore.isNewInstance) {
  67. const newSound = new Howl({
  68. src: [url],
  69. html5: true, // 强制HTML5 Audio解决iOS兼容问题
  70. format: ["mp3", "acc"],
  71. rate: 1.2, // 调整播放速度
  72. onplay: () => {
  73. audioStore.isPlaying = true; // 改为更新store状态
  74. newSound.volume(1); // 添加音量设置
  75. },
  76. onend: () => (audioStore.isPlaying = false),
  77. onstop: () => (audioStore.isPlaying = false),
  78. onloaderror: (id, err) => {
  79. console.error("音频加载失败:", err);
  80. ElMessage.error("音频播放失败,请检查网络连接");
  81. },
  82. });
  83. if (audioStore.nowSound) {
  84. audioStore.nowSound.stop();
  85. }
  86. audioStore.nowSound = newSound;
  87. audioStore.isNewInstance = false;
  88. console.log("新音频");
  89. } else {
  90. console.log("已经有音频");
  91. }
  92. const newSound = audioStore.nowSound;
  93. // 添加立即播放逻辑
  94. newSound.play();
  95. audioStore.setAudioInstance(newSound);
  96. Howler._howls.push(newSound); // 强制注册到全局管理
  97. // // 处理浏览器自动播放策略
  98. // if (Howler.autoUnlock) {
  99. // Howler.autoUnlock();
  100. // }
  101. };
  102. // if (/iPhone|iPad|iPod/.test(navigator.userAgent)) {
  103. // document.addEventListener('touchstart', handlePlay, { once: true });
  104. // ElMessage.info('请轻触屏幕以启用音频播放');
  105. // } else {
  106. // handlePlay();
  107. // }
  108. handlePlay();
  109. // Howler.volume(1.0) // 添加全局音量设置
  110. };
  111. // 新增暂停方法
  112. const pauseAudio = () => {
  113. if (audioStore.soundInstance) {
  114. // 添加移动端特殊处理
  115. // if (/iPhone|iPad|iPod/.test(navigator.userAgent)) {
  116. // Howler.pause(); // iOS需要强制停止音频上下文
  117. // } else {
  118. // audioStore.soundInstance.pause();
  119. // }
  120. audioStore.soundInstance.pause();
  121. audioStore.isPlaying = false;
  122. // // 添加状态同步
  123. // nextTick(() => {
  124. // Howler.unload();
  125. // audioStore.soundInstance = null;
  126. // });
  127. }
  128. };
  129. // 音频轮流播放方法
  130. const playAudioSequence = (audioUrls) => {
  131. if (!audioUrls || audioUrls.length === 0) {
  132. console.warn("音频URL列表为空,跳过播放");
  133. return;
  134. }
  135. let currentIndex = 0;
  136. const playNext = () => {
  137. if (currentIndex >= audioUrls.length) {
  138. console.log("所有音频播放完成");
  139. return;
  140. }
  141. const currentUrl = audioUrls[currentIndex];
  142. console.log(`正在播放第${currentIndex + 1}个音频:`, currentUrl);
  143. // 停止当前播放的音频
  144. if (audioStore.nowSound) {
  145. audioStore.nowSound.stop();
  146. }
  147. const sound = new Howl({
  148. src: [currentUrl],
  149. html5: true,
  150. format: ["mp3", "acc"],
  151. rate: 1.2,
  152. onplay: () => {
  153. audioStore.isPlaying = true;
  154. console.log(`开始播放音频 ${currentIndex + 1}`);
  155. },
  156. onend: () => {
  157. audioStore.isPlaying = false;
  158. console.log(`音频 ${currentIndex + 1} 播放完成`);
  159. currentIndex++;
  160. // 播放下一个音频
  161. setTimeout(() => {
  162. playNext();
  163. }, 500); // 间隔500ms播放下一个
  164. },
  165. onstop: () => {
  166. audioStore.isPlaying = false;
  167. },
  168. onloaderror: (id, err) => {
  169. console.error(`音频 ${currentIndex + 1} 加载失败:`, err);
  170. currentIndex++;
  171. // 跳过失败的音频,播放下一个
  172. setTimeout(() => {
  173. playNext();
  174. }, 100);
  175. }
  176. });
  177. audioStore.nowSound = sound;
  178. audioStore.setAudioInstance(sound);
  179. sound.play();
  180. };
  181. // 开始播放第一个音频
  182. playNext();
  183. };
  184. // 获取消息
  185. const chatMsg = computed(() => chatStore.messages);
  186. const props = defineProps({
  187. messages: Array,
  188. chartData: {
  189. type: Object,
  190. default: null,
  191. },
  192. index: {
  193. type: Number,
  194. required: true,
  195. },
  196. });
  197. // 打字机效果
  198. const typewriterContent = ref("");
  199. const isTyping = ref(false);
  200. const typeWriter = (text, callback) => {
  201. let index = 0;
  202. isTyping.value = true;
  203. typewriterContent.value = "";
  204. const typingInterval = setInterval(() => {
  205. if (index < text.length) {
  206. typewriterContent.value += text.charAt(index);
  207. index++;
  208. // 自动滚动到底部
  209. nextTick(() => {
  210. const container = document.querySelector(".message-area");
  211. if (container) container.scrollTop = container.scrollHeight;
  212. });
  213. } else {
  214. clearInterval(typingInterval);
  215. isTyping.value = false;
  216. if (callback) callback();
  217. }
  218. }, 50); // 调整速度(毫秒)
  219. };
  220. const fnGetData = (data) => {
  221. const YaLiZhiChengLuoPan = data.YaLiZhiChengLuoPan;
  222. let sz = ref(5.5); // 进行判断
  223. const yl = YaLiZhiChengLuoPan.Yali; // 压力位
  224. const zc = YaLiZhiChengLuoPan.ZhiCheng; // 支撑位
  225. console.log("yl", yl, "zc", zc);
  226. if (yl == "较大" && zc == "较弱") {
  227. sz.value = 0.5; // 极高风险
  228. } else if (yl == "一般" && zc == "较弱") {
  229. sz.value = 1.5; // 弱撑中压区
  230. } else if (yl == "较弱" && zc == "较弱") {
  231. sz.value = 2.5; // 弱撑弱压区
  232. } else if (yl == "较大" && zc == "较大") {
  233. sz.value = 3.5; // 强撑强压区
  234. } else if (yl == "一般" && zc == "较大") {
  235. sz.value = 4.5; // 强撑中压
  236. } else if (yl == "较弱" && zc == "较大") {
  237. sz.value = 5.5; // 强撑弱压区
  238. } else if (yl == "较大" && zc == "一般") {
  239. sz.value = 0.2;
  240. } else if (yl == "一般" && zc == "一般") {
  241. sz.value = 3;
  242. } else if (yl == "较弱" && zc == "一般") {
  243. sz.value = 5.8;
  244. }
  245. return sz.value;
  246. };
  247. const typingQueue = ref([]);
  248. const isTypingInProgress = ref(false);
  249. // 创建打字机效果的Promise函数
  250. const createTypingEffect = (message, content, speed) => {
  251. return new Promise((resolve) => {
  252. chatStore.messages.push(message);
  253. if (content != "") {
  254. let index = 0;
  255. message.content = "";
  256. message.isTyping = true;
  257. const typingInterval = setInterval(() => {
  258. if (index < content.length) {
  259. message.content += content.charAt(index);
  260. index++;
  261. } else {
  262. clearInterval(typingInterval);
  263. message.isTyping = false;
  264. // 处理KaTeX渲染(如果需要)
  265. nextTick(() => {
  266. if (message.content.includes("$$")) {
  267. message.content = message.content.replace(
  268. katexRegex,
  269. (match, formula) => {
  270. try {
  271. return katex.renderToString(formula, {
  272. throwOnError: false,
  273. });
  274. } catch (error) {
  275. console.error("KaTeX 渲染错误:", error);
  276. return match;
  277. }
  278. }
  279. );
  280. }
  281. resolve(); // 完成后resolve
  282. });
  283. }
  284. }, speed);
  285. } else {
  286. if (message.kline) {
  287. if (message.klineType == 1) {
  288. console.log("六色罗盘消息已添加到聊天列表");
  289. // 在渲染完成后初始化图表
  290. nextTick(() => {
  291. console.log("nextTick开始 - 准备渲染图表");
  292. console.log("消息列表:", chatStore.messages);
  293. // 寻找最新添加的K线消息索引
  294. let klineIndex = -1;
  295. for (let i = 0; i < chatStore.messages.length; i++) {
  296. if (chatStore.messages[i].messageId === message.messageId) {
  297. klineIndex = i;
  298. break;
  299. }
  300. }
  301. console.log("找到的K线消息索引:", klineIndex);
  302. if (klineIndex !== -1) {
  303. const containerId = `kline-container-${klineIndex}`;
  304. console.log("图表容器ID:", containerId);
  305. // 确保DOM已经渲染完成
  306. setTimeout(() => {
  307. console.log("延时执行,确保DOM已渲染");
  308. KlineCanvsEcharts(containerId);
  309. }, 100); // 短暂延时确保DOM已渲染
  310. } else {
  311. console.warn("未找到K线消息");
  312. }
  313. });
  314. } else {
  315. console.log("K线消息已添加到聊天列表");
  316. // 在渲染完成后初始化图表
  317. nextTick(() => {
  318. console.log("nextTick开始 - 准备渲染图表");
  319. console.log("消息列表:", chatStore.messages);
  320. // 寻找最新添加的K线消息索引
  321. let klineIndex = -1;
  322. for (let i = 0; i < chatStore.messages.length; i++) {
  323. if (chatStore.messages[i].messageId === message.messageId) {
  324. klineIndex = i;
  325. break;
  326. }
  327. }
  328. console.log("找到的K线消息索引:", klineIndex);
  329. if (klineIndex !== -1) {
  330. const containerId = `kline-container-${klineIndex}`;
  331. console.log("图表容器ID:", containerId);
  332. // 确保DOM已经渲染完成
  333. setTimeout(() => {
  334. console.log("延时执行,确保DOM已渲染");
  335. KlineCanvsEcharts(containerId);
  336. }, 100); // 短暂延时确保DOM已渲染
  337. } else {
  338. console.warn("未找到K线消息");
  339. }
  340. });
  341. }
  342. // 延时1秒后resolve
  343. setTimeout(() => {
  344. resolve();
  345. }, 1000);
  346. } else {
  347. // 延时1秒后resolve
  348. setTimeout(() => {
  349. resolve();
  350. }, 1000);
  351. }
  352. }
  353. });
  354. };
  355. // 队列处理函数
  356. const processTypingQueue = async () => {
  357. if (isTypingInProgress.value || typingQueue.value.length === 0) {
  358. return;
  359. }
  360. isTypingInProgress.value = true;
  361. while (typingQueue.value.length > 0) {
  362. const task = typingQueue.value.shift();
  363. await createTypingEffect(task.message, task.content, task.speed);
  364. }
  365. isTypingInProgress.value = false;
  366. };
  367. // 添加打字机任务到队列
  368. const addTypingTask = (message, content, speed = 50) => {
  369. typingQueue.value.push({ message, content, speed });
  370. processTypingQueue();
  371. };
  372. const hasValidData = ref(false);
  373. // 创建一个非响应式的对象来存储图表实例
  374. const chartInstancesMap = {};
  375. // 存储上一次的消息的length
  376. const previousMessagesLength = ref(0);
  377. watch(
  378. () => props.messages,
  379. async (newVal, oldVal) => {
  380. // console.log(newVal, 'newVal')
  381. // console.log(oldVal, 'oldVal')
  382. // console.log(previousMessagesLength.value, 'previousMessagesLength')
  383. // console.log(newVal.length, 'newVal.length')
  384. // // 添加空值判断
  385. if (!newVal?.length || newVal === previousMessagesLength.value) return;
  386. previousMessagesLength.value = newVal.length;
  387. if (newVal.length > 0) {
  388. console.log("消息列表已更新,最新消息:", newVal[newVal.length - 1]);
  389. chatStore.messages.push(newVal[newVal.length - 1]);
  390. console.log("消息列表已更新,最新消息:", chatMsg[chatMsg.length - 1]);
  391. console.log("token", localStorage.getItem("localToken"));
  392. // 获取权限
  393. const userStore = useUserStore();
  394. const params1 = {
  395. content: newVal[newVal.length - 1].content,
  396. language: "cn",
  397. marketList: "usa,sg,my,hk,cn,can,vi,th,in",
  398. token: localStorage.getItem("localToken"),
  399. // language: "cn",
  400. // marketList: "hk,cn,usa,my,sg,vi,in,gb"
  401. // token: "+SsksARQgUHIbIG3rRnnbZi0+fEeMx8pywnIlrmTxo5EOPR/wjWDV7w7+ZUseiBtf9kFa/atmNx6QfSpv5w",
  402. };
  403. // 标志
  404. let flag = true;
  405. const codeData = ref();
  406. // 第一阶段,意图识别
  407. try {
  408. // 调用工作流获取回复
  409. const result = await dbqbFirstAPI(params1);
  410. codeData.value = result.data;
  411. console.log(codeData.value, "codeData");
  412. // 根据意图识别结果判断
  413. if (result.code == 200) {
  414. chatStore.messages.push({
  415. class: "ing",
  416. type: "ing",
  417. flag: flag,
  418. content: result.data.kaishi,
  419. });
  420. } else {
  421. flag = false;
  422. console.log("执行回绝话术");
  423. const AIcontent = ref(result.msg);
  424. // 修改后的消息处理逻辑
  425. const processedContent = marked(AIcontent.value);
  426. const katexRegex = /\$\$(.*?)\$\$/g;
  427. const aiContent = processedContent.replace(
  428. katexRegex,
  429. (match, formula) => {
  430. try {
  431. return katex.renderToString(formula, { throwOnError: false });
  432. } catch (error) {
  433. console.error("KaTeX 渲染错误:", error);
  434. return match;
  435. }
  436. }
  437. );
  438. console.log(aiContent, "aiContent");
  439. chatStore.messages.push({
  440. class: "ing",
  441. type: "ing",
  442. flag: flag,
  443. content: aiContent,
  444. });
  445. chatStore.setLoading(false);
  446. }
  447. } catch (e) {
  448. console.log(e, "意图识别失败");
  449. }
  450. if (flag) {
  451. const params2 = {
  452. content: newVal[newVal.length - 1].content,
  453. language: "cn",
  454. marketList: "usa,sg,my,hk,cn,can,vi,th,in",
  455. token: localStorage.getItem("localToken"),
  456. // language: "cn",
  457. // marketList: "hk,cn,usa,my,sg,vi,in,gb"
  458. // token: "+SsksARQgUHIbIG3rRnnbZi0+fEeMx8pywnIlrmTxo5EOPR/wjWDV7w7+ZUseiBtf9kFa/atmNx6QfSpv5w",
  459. name: codeData.value.name,
  460. code: codeData.value.code,
  461. market: codeData.value.market,
  462. };
  463. try {
  464. const result20 = await dataListAPI({
  465. token: localStorage.getItem("localToken"),
  466. market: codeData.value.market,
  467. code: codeData.value.code,
  468. language: "cn", //t.value.suoxie,
  469. // brainPrivilegeState: 1,
  470. // swordPrivilegeState: 1,
  471. // stockForecastPrivilegeState: 1,
  472. // spaceForecastPrivilegeState: 1,
  473. // aibullPrivilegeState: 1,
  474. // aigoldBullPrivilegeState: 1,
  475. // airadarPrivilegeState: 1,
  476. // marketList: 1,
  477. brainPrivilegeState: userStore.brainPerssion,
  478. swordPrivilegeState: userStore.swordPerssion,
  479. stockForecastPrivilegeState: userStore.pricePerssion,
  480. spaceForecastPrivilegeState: userStore.timePerssion,
  481. aibullPrivilegeState: userStore.aibullPerssion,
  482. aigoldBullPrivilegeState: userStore.aiGnbullPerssion,
  483. airadarPrivilegeState: userStore.airadarPerssion,
  484. marketList: userStore.aiGoldMarketList,
  485. });
  486. const HomePage = result20.data.HomePage;
  487. const AIGoldBull = result20.data.AIGoldBull;
  488. const result21 = await dbqbSecondOneAPI(params2);
  489. const result22 = await dbqbSecondTwoAPI(params2);
  490. const result23 = await dbqbSecondThreeAPI(params2);
  491. const result24 = await dbqbSecondFourAPI(params2);
  492. // 收集所有音频URL
  493. const audioUrls = [];
  494. if (result21.data.url) audioUrls.push(result21.data.url.trim());
  495. if (result22.data.url) audioUrls.push(result22.data.url.trim());
  496. if (result23.data.url) audioUrls.push(result23.data.url.trim());
  497. if (result24.data.url) audioUrls.push(result24.data.url.trim());
  498. // 开始轮流播放音频
  499. if (audioUrls.length > 0 && audioStore.isVoiceEnabled) {
  500. playAudioSequence(audioUrls);
  501. }
  502. const katexRegex = /\$\$(.*?)\$\$/g;
  503. // 删除正在为您生成信息
  504. chatStore.messages.pop();
  505. // 添加报告头和时间
  506. addTypingTask(
  507. {
  508. sender: "ai",
  509. class: "title1",
  510. type: "title1",
  511. content: codeData.value.name + "全景作战报告",
  512. date: moment().format("MM/DD/YYYY"),
  513. },
  514. "",
  515. 50
  516. );
  517. // chatStore.messages.push({
  518. // sender: "ai",
  519. // class: "title1",
  520. // type: "title1",
  521. // content: codeData.value.name + "全景作战报告",
  522. // date: moment().format("MM/DD/YYYY"),
  523. // });
  524. // 添加股票信息框
  525. const pc1 = marked(
  526. result21.data.name +
  527. "\n" +
  528. result21.data.price +
  529. "\n" +
  530. result21.data.date
  531. );
  532. const ac1 = pc1.replace(katexRegex, (match, formula) => {
  533. try {
  534. return katex.renderToString(formula, { throwOnError: false });
  535. } catch (error) {
  536. console.error("KaTeX 渲染错误:", error);
  537. return match;
  538. }
  539. });
  540. // 先推送初始消息
  541. const aiMessage1 = reactive({
  542. sender: "ai",
  543. class: "content1",
  544. type: "content1",
  545. content: "",
  546. isTyping: true,
  547. });
  548. // chatStore.messages.push(aiMessage1);
  549. // let index1 = 0;
  550. // const typingInterval1 = setInterval(() => {
  551. // if (index1 < ac1.length) {
  552. // aiMessage1.content += ac1.charAt(index1);
  553. // index1++;
  554. // } else {
  555. // clearInterval(typingInterval1);
  556. // aiMessage1.isTyping = false;
  557. // }
  558. // }, 50); // 调整速度为50ms/字符
  559. addTypingTask(aiMessage1, ac1, 50);
  560. // chatStore.messages.push({
  561. // sender: "ai",
  562. // class: "content1",
  563. // type: "content1",
  564. // content: ac1,
  565. // });
  566. // 添加六色罗盘
  567. const LiuSeData = JSON.parse(JSON.stringify(toRaw(HomePage)));
  568. const sz = fnGetData(LiuSeData);
  569. if (sz) {
  570. hasValidData.value = true;
  571. console.log("hasValidData设置为:", hasValidData.value);
  572. }
  573. // 先推送K线图消息
  574. const klineMessageId1 = `kline-${Date.now()}`;
  575. console.log("生成K线消息ID:", klineMessageId1);
  576. addTypingTask(
  577. {
  578. sender: "ai",
  579. class: "content1",
  580. type: "content1",
  581. kline: true,
  582. chartData: sz,
  583. messageId: klineMessageId1,
  584. hasValidData: true,
  585. klineType: 1,
  586. },
  587. "",
  588. 50
  589. );
  590. // chatStore.messages.push({
  591. // sender: "ai",
  592. // class: "content1",
  593. // type: "content1",
  594. // kline: true,
  595. // chartData: sz,
  596. // messageId: klineMessageId1,
  597. // hasValidData: true,
  598. // klineType: 1,
  599. // });
  600. // console.log("六色罗盘消息已添加到聊天列表");
  601. // // 在渲染完成后初始化图表
  602. // nextTick(() => {
  603. // console.log("nextTick开始 - 准备渲染图表");
  604. // console.log("消息列表:", chatStore.messages);
  605. // // 寻找最新添加的K线消息索引
  606. // let klineIndex = -1;
  607. // for (let i = 0; i < chatStore.messages.length; i++) {
  608. // if (chatStore.messages[i].messageId === klineMessageId1) {
  609. // klineIndex = i;
  610. // break;
  611. // }
  612. // }
  613. // console.log("找到的K线消息索引:", klineIndex);
  614. // if (klineIndex !== -1) {
  615. // const containerId = `kline-container-${klineIndex}`;
  616. // console.log("图表容器ID:", containerId);
  617. // // 确保DOM已经渲染完成
  618. // setTimeout(() => {
  619. // console.log("延时执行,确保DOM已渲染");
  620. // KlineCanvsEcharts(containerId);
  621. // }, 100); // 短暂延时确保DOM已渲染
  622. // } else {
  623. // console.warn("未找到K线消息");
  624. // }
  625. // });
  626. // 度牛尺K线图
  627. const AIGoldBullData = JSON.parse(JSON.stringify(toRaw(AIGoldBull)));
  628. const HomePageData = JSON.parse(JSON.stringify(toRaw(HomePage)));
  629. console.log("处理 K 线数据 - 开始");
  630. console.log("AIGoldBullData", AIGoldBullData);
  631. console.log("HomePageData", HomePageData);
  632. const Kline20 = {
  633. name: HomePageData.StockInformation.Name,
  634. Kline: AIGoldBullData,
  635. };
  636. // 打印K线数据结构
  637. console.log("K线数据结构:", Kline20);
  638. console.log("K线数据名称:", Kline20.name);
  639. console.log("K线数据:", Kline20.Kline ? Kline20.Kline : null);
  640. // 设置数据有效标志
  641. hasValidData.value = true;
  642. console.log("hasValidData设置为:", hasValidData.value);
  643. // chatStore.messages.pop();
  644. // 先推送K线图消息
  645. const klineMessageId2 = `kline-${Date.now() + 1}`;
  646. console.log("生成K线消息ID:", klineMessageId2);
  647. // chatStore.messages.push({
  648. // sender: "ai",
  649. // class: "content2",
  650. // type: "content2",
  651. // kline: true,
  652. // chartData: Kline20,
  653. // messageId: klineMessageId2,
  654. // hasValidData: true, // 添加hasValidData标志
  655. // klineType: 2,
  656. // });
  657. addTypingTask(
  658. {
  659. sender: "ai",
  660. class: "content2",
  661. type: "content2",
  662. kline: true,
  663. chartData: Kline20,
  664. messageId: klineMessageId2,
  665. hasValidData: true, // 添加hasValidData标志
  666. klineType: 2,
  667. },
  668. "",
  669. 50
  670. );
  671. // console.log("K线消息已添加到聊天列表");
  672. // // 在渲染完成后初始化图表
  673. // nextTick(() => {
  674. // console.log("nextTick开始 - 准备渲染图表");
  675. // console.log("消息列表:", chatStore.messages);
  676. // // 寻找最新添加的K线消息索引
  677. // let klineIndex = -1;
  678. // for (let i = 0; i < chatStore.messages.length; i++) {
  679. // if (chatStore.messages[i].messageId === klineMessageId2) {
  680. // klineIndex = i;
  681. // break;
  682. // }
  683. // }
  684. // console.log("找到的K线消息索引:", klineIndex);
  685. // if (klineIndex !== -1) {
  686. // const containerId = `kline-container-${klineIndex}`;
  687. // console.log("图表容器ID:", containerId);
  688. // // 确保DOM已经渲染完成
  689. // setTimeout(() => {
  690. // console.log("延时执行,确保DOM已渲染");
  691. // KlineCanvsEcharts(containerId);
  692. // }, 100); // 短暂延时确保DOM已渲染
  693. // } else {
  694. // console.warn("未找到K线消息");
  695. // }
  696. // });
  697. // 添加标题2
  698. addTypingTask(
  699. {
  700. sender: "ai",
  701. class: "title2",
  702. type: "title2",
  703. content: "",
  704. },
  705. "",
  706. 50
  707. );
  708. // chatStore.messages.push({
  709. // sender: "ai",
  710. // class: "title2",
  711. // type: "title2",
  712. // content: "",
  713. // });
  714. // 添加内容框1
  715. const pc2 = marked(result22.data.hxjzpg);
  716. console.log(pc2, "pc2");
  717. const ac2 = pc2.replace(katexRegex, (match, formula) => {
  718. try {
  719. return katex.renderToString(formula, { throwOnError: false });
  720. } catch (error) {
  721. console.error("KaTeX 渲染错误:", error);
  722. return match;
  723. }
  724. });
  725. // 先推送初始消息
  726. const aiMessage2 = reactive({
  727. sender: "ai",
  728. class: "content3",
  729. type: "content3",
  730. content: "",
  731. isTyping: true,
  732. });
  733. // chatStore.messages.push(aiMessage2);
  734. // let index2 = 0;
  735. // const typingInterval2 = setInterval(() => {
  736. // if (index2 < ac2.length) {
  737. // aiMessage2.content += ac2.charAt(index2);
  738. // index2++;
  739. // } else {
  740. // clearInterval(typingInterval2);
  741. // aiMessage2.isTyping = false;
  742. // }
  743. // }, 50); // 调整速度为50ms/字符
  744. addTypingTask(aiMessage2, ac2, 50);
  745. // chatStore.messages.push({
  746. // sender: "ai",
  747. // class: "content3",
  748. // type: "content3",
  749. // content: ac2,
  750. // });
  751. // 添加标题3-2
  752. addTypingTask(
  753. {
  754. sender: "ai",
  755. class: "title3",
  756. type: "title3",
  757. content: title2,
  758. },
  759. "",
  760. 50
  761. );
  762. // chatStore.messages.push({
  763. // sender: "ai",
  764. // class: "title3",
  765. // type: "title3",
  766. // content: title2,
  767. // });
  768. // 添加内容框2
  769. // const pc3 = marked(result23.data.zhuli1+'\n'+result23.data.zhuli2+'\n'+result23.data.zhuli3);
  770. // const ac3 = pc3.replace(
  771. // katexRegex,
  772. // (match, formula) => {
  773. // try {
  774. // return katex.renderToString(formula, { throwOnError: false });
  775. // } catch (error) {
  776. // console.error("KaTeX 渲染错误:", error);
  777. // return match;
  778. // }
  779. // }
  780. // );
  781. const ac3 = `<p style="margin:0;color:#FADC0C;display:flex;justify-content:center;font-size:28px">【主力行为】</p><p>${result23.data.zhuli1}</p><p>${result23.data.zhuli2}</p><p>${result23.data.zhuli3}</p>`;
  782. // 先推送初始消息
  783. const aiMessage3 = reactive({
  784. sender: "ai",
  785. class: "content3",
  786. type: "content3",
  787. content: "",
  788. isTyping: true,
  789. });
  790. // chatStore.messages.push(aiMessage3);
  791. // let index3 = 0;
  792. // const typingInterval3 = setInterval(() => {
  793. // if (index3 < ac3.length) {
  794. // aiMessage3.content += ac3.charAt(index3);
  795. // index3++;
  796. // } else {
  797. // clearInterval(typingInterval3);
  798. // aiMessage3.isTyping = false;
  799. // }
  800. // }, 50); // 调整速度为50ms/字符
  801. addTypingTask(aiMessage3, ac3, 50);
  802. // chatStore.messages.push({
  803. // sender: "ai",
  804. // class: "content3",
  805. // type: "content3",
  806. // content: ac3,
  807. // });
  808. // 添加标题3-3
  809. addTypingTask(
  810. {
  811. sender: "ai",
  812. class: "title3",
  813. type: "title3",
  814. content: title3,
  815. },
  816. "",
  817. 50
  818. );
  819. // chatStore.messages.push({
  820. // sender: "ai",
  821. // class: "title3",
  822. // type: "title3",
  823. // content: title3,
  824. // });
  825. // 添加内容框3
  826. const arr = result23.data.kongjian.split(",");
  827. const kongjian = `<p style="margin:0;color:#FADC0C;display:flex;justify-content:center;font-size:28px">【空间维度】</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>`;
  828. const shijian = `<p style="margin:0;color:#FADC0C;display:flex;justify-content:center;font-size:28px">【时间维度】</p><p style="display:flex;justify-content:center;">${result23.data.shijian}</p>`;
  829. const nengliang = `<p style="margin:0;color:#FADC0C;display:flex;justify-content:center;font-size:28px">【能量维度】</p><p>${result23.data.nengliang}</p>`;
  830. const ac4 = kongjian + shijian + nengliang;
  831. // const pc4 = marked(
  832. // kongjian +
  833. // "\n" +
  834. // result23.data.shijian +
  835. // "\n" +
  836. // result23.data.nengliang
  837. // );
  838. // const ac4 = pc4.replace(katexRegex, (match, formula) => {
  839. // try {
  840. // return katex.renderToString(formula, { throwOnError: false });
  841. // } catch (error) {
  842. // console.error("KaTeX 渲染错误:", error);
  843. // return match;
  844. // }
  845. // });
  846. // 先推送初始消息
  847. const aiMessage4 = reactive({
  848. sender: "ai",
  849. class: "content3",
  850. type: "content3",
  851. content: "",
  852. isTyping: true,
  853. });
  854. // chatStore.messages.push(aiMessage4);
  855. // let index4 = 0;
  856. // const typingInterval4 = setInterval(() => {
  857. // if (index4 < ac4.length) {
  858. // aiMessage4.content += ac4.charAt(index4);
  859. // index4++;
  860. // } else {
  861. // clearInterval(typingInterval4);
  862. // aiMessage4.isTyping = false;
  863. // }
  864. // }, 50); // 调整速度为50ms/字符
  865. addTypingTask(aiMessage4, ac4, 50);
  866. // chatStore.messages.push({
  867. // sender: "ai",
  868. // class: "content3",
  869. // type: "content3",
  870. // content: ac4,
  871. // });
  872. // 添加标题3-4
  873. addTypingTask(
  874. {
  875. sender: "ai",
  876. class: "title3",
  877. type: "title3",
  878. content: title4,
  879. },
  880. "",
  881. 50
  882. );
  883. chatStore.messages.push({
  884. sender: "ai",
  885. class: "title3",
  886. type: "title3",
  887. content: title4,
  888. });
  889. // 添加内容框4
  890. const cftj = `<p style="margin:0;color:#FADC0C;display:flex;justify-content:center;font-size:28px">【触发条件】</p><p>${result24.data.cftl}</p>`;
  891. const gfzl = `<p style="margin:0;color:#FADC0C;display:flex;justify-content:center;font-size:28px">【攻防指令】</p><p>${result24.data.gfzl}</p>`;
  892. const ac5 = cftj + gfzl;
  893. // const pc5 = marked(result24.data.cftl + "/n" + result24.data.gfzl);
  894. // const ac5 = pc5.replace(katexRegex, (match, formula) => {
  895. // try {
  896. // return katex.renderToString(formula, { throwOnError: false });
  897. // } catch (error) {
  898. // console.error("KaTeX 渲染错误:", error);
  899. // return match;
  900. // }
  901. // });
  902. // 先推送初始消息
  903. const aiMessage5 = reactive({
  904. sender: "ai",
  905. class: "content3",
  906. type: "content3",
  907. content: "",
  908. isTyping: true,
  909. });
  910. // chatStore.messages.push(aiMessage5);
  911. // let index5 = 0;
  912. // const typingInterval5 = setInterval(() => {
  913. // if (index5 < ac5.length) {
  914. // aiMessage5.content += ac5.charAt(index5);
  915. // index5++;
  916. // } else {
  917. // clearInterval(typingInterval5);
  918. // aiMessage5.isTyping = false;
  919. // }
  920. // }, 50); // 调整速度为50ms/字符
  921. addTypingTask(aiMessage5, ac5, 50);
  922. // chatStore.messages.push({
  923. // sender: "ai",
  924. // class: "content3",
  925. // type: "content3",
  926. // content: ac5,
  927. // });
  928. const ac6 = "内容由AI生成,请注意甄别";
  929. // 先推送初始消息
  930. const aiMessage6 = reactive({
  931. sender: "ai",
  932. class: "mianze",
  933. type: "mianze",
  934. content: "",
  935. isTyping: true,
  936. });
  937. // chatStore.messages.push(aiMessage6);
  938. // let index6 = 0;
  939. // const typingInterval6 = setInterval(() => {
  940. // if (index6 < ac6.length) {
  941. // aiMessage6.content += ac6.charAt(index6);
  942. // index6++;
  943. // } else {
  944. // clearInterval(typingInterval6);
  945. // aiMessage6.isTyping = false;
  946. // }
  947. // }, 50); // 调整速度为50ms/字符
  948. addTypingTask(aiMessage6, ac6, 100);
  949. // chatStore.messages.push({
  950. // sender: "ai",
  951. // class: "mianze",
  952. // type: "mianze",
  953. // content: "内容由AI生成,请注意甄别",
  954. // });
  955. // // 修改后的消息处理逻辑
  956. // const processedContent = marked(AIcontent.value);
  957. // const katexRegex = /\$\$(.*?)\$\$/g;
  958. // const plainTextContent = htmlToText(processedContent);
  959. // // 获取音频数据
  960. // const TTSResult = (
  961. // await TTSAPI({
  962. // language: "cn",
  963. // content: plainTextContent,
  964. // })
  965. // ).json();
  966. // const tts = ref();
  967. // await TTSResult.then((res) => {
  968. // tts.value = JSON.parse(res.data);
  969. // });
  970. // const ttsUrl = ref();
  971. // if (tts.value.tts_cn !== null) {
  972. // audioStore.ttsUrl = tts.value.tts_cn.url;
  973. // ttsUrl.value = tts.value.tts_cn.url;
  974. // audioStore.isNewInstance = true;
  975. // } else if (tts.value.tts_en !== null) {
  976. // audioStore.ttsUrl = tts.value.tts_en.url;
  977. // ttsUrl.value = tts.value.tts_en.url;
  978. // audioStore.isNewInstance = true;
  979. // }
  980. // if (ttsUrl.value) {
  981. // nextTick(() => {
  982. // if (audioStore.isVoiceEnabled) {
  983. // console.log("ttsUrl.value", ttsUrl.value);
  984. // // 播放音频
  985. // playAudio(ttsUrl.value);
  986. // }
  987. // });
  988. // }
  989. // // chatStore.messages.pop();
  990. // // 先推送初始消息
  991. // const aiMessage = reactive({
  992. // sender: "ai",
  993. // content: "",
  994. // isTyping: true,
  995. // });
  996. // chatStore.messages.push(aiMessage);
  997. // let index = 0;
  998. // const typingInterval = setInterval(() => {
  999. // if (index < processedContent.length) {
  1000. // aiMessage.content += processedContent.charAt(index);
  1001. // index++;
  1002. // } else {
  1003. // clearInterval(typingInterval);
  1004. // aiMessage.isTyping = false;
  1005. // // 延迟处理KaTeX确保DOM已更新
  1006. // nextTick(() => {
  1007. // aiMessage.content = aiMessage.content.replace(
  1008. // katexRegex,
  1009. // (match, formula) => {
  1010. // try {
  1011. // return katex.renderToString(formula, {
  1012. // throwOnError: false,
  1013. // });
  1014. // } catch (error) {
  1015. // console.error("KaTeX 渲染错误:", error);
  1016. // return match;
  1017. // }
  1018. // }
  1019. // );
  1020. // chatStore.setLoading(false);
  1021. // });
  1022. // }
  1023. // }, 50); // 调整速度为50ms/字符
  1024. // // } else {
  1025. // // chatStore.messages.pop();
  1026. // // chatStore.messages.push({
  1027. // // sender: "ai",
  1028. // // content: status.msg
  1029. // // });
  1030. // // chatStore.setLoading(false);
  1031. // // }
  1032. // }
  1033. } catch (e) {
  1034. console.error("请求失败:", e);
  1035. hasValidData.value = false; // 请求失败时设置数据无效
  1036. // chatStore.messages.pop();
  1037. // chatStore.messages.push({
  1038. // sender: "ai",
  1039. // content: "AI思考失败,请稍后再试... ",
  1040. // });
  1041. // chatStore.setLoading(false);
  1042. } finally {
  1043. chatStore.setLoading(false);
  1044. await chatStore.getUserCount();
  1045. }
  1046. }
  1047. }
  1048. },
  1049. { deep: true }
  1050. );
  1051. function KlineCanvsEcharts(containerId) {
  1052. function vwToPx(vw) {
  1053. console.log((window.innerWidth * vw) / 100, "vwToPx");
  1054. return (window.innerWidth * vw) / 100;
  1055. }
  1056. console.log("KLine渲染: 开始处理数据, 容器ID:", containerId);
  1057. // 从 chatStore 中获取数据
  1058. const messages = chatStore.messages;
  1059. console.log("KLine渲染: 获取到的消息:", messages);
  1060. let klineMessageIndex = -1;
  1061. let klineData = null;
  1062. // 查找最近的 K线 消息
  1063. // for (let i = messages.length - 1; i >= 0; i--) {
  1064. // console.log('KLine渲染: 检查消息:', messages[i]);
  1065. // if (messages[i].type === 'kline' && messages[i].chartData) {
  1066. // klineMessageIndex = i;
  1067. // klineData = messages[i].chartData;
  1068. // console.log('KLine渲染: 找到K线消息索引:', klineMessageIndex);
  1069. // console.log('KLine渲染: 找到K线数据:', klineData);
  1070. // break;
  1071. // }
  1072. // }
  1073. klineMessageIndex = containerId.split("-")[2];
  1074. console.log("KLine渲染: 找到K线消息索引:", klineMessageIndex);
  1075. if (
  1076. messages[klineMessageIndex].kline &&
  1077. messages[klineMessageIndex].chartData
  1078. ) {
  1079. klineData = messages[klineMessageIndex].chartData;
  1080. }
  1081. var KlineOption = {};
  1082. // 检测设备类型
  1083. const isMobile = window.innerWidth < 768;
  1084. const isTablet = window.innerWidth >= 768 && window.innerWidth < 1024;
  1085. console.log(
  1086. "KLine渲染: 设备类型",
  1087. isMobile ? "移动设备" : isTablet ? "平板设备" : "桌面设备"
  1088. );
  1089. if (messages[klineMessageIndex].klineType == 1) {
  1090. if (!klineData) {
  1091. console.warn("六色罗盘渲染: 数据无效 - 在chatStore中找不到有效的K线数据");
  1092. return;
  1093. }
  1094. // 获取容器元素
  1095. const container = document.getElementById(containerId);
  1096. if (!container) {
  1097. console.error("六色罗盘渲染: 找不到容器元素:", containerId);
  1098. return;
  1099. }
  1100. // 创建图表实例
  1101. console.log("六色罗盘渲染: 创建图表实例");
  1102. try {
  1103. // 如果已有实例,先销毁
  1104. if (chartInstancesMap[containerId]) {
  1105. console.log("六色罗盘渲染: 销毁已有图表实例");
  1106. chartInstancesMap[containerId].dispose();
  1107. delete chartInstancesMap[containerId];
  1108. }
  1109. // 使用普通变量存储实例
  1110. chartInstancesMap[containerId] = echarts.init(container);
  1111. console.log("六色罗盘渲染: 图表实例创建成功");
  1112. } catch (error) {
  1113. console.error("六色罗盘渲染: 图表实例创建失败:", error);
  1114. return;
  1115. }
  1116. const name = ref("六色罗盘");
  1117. const size = ref(16);
  1118. // PC版字体大小
  1119. if (window.innerWidth > 768) {
  1120. size.value = 25;
  1121. }
  1122. KlineOption = {
  1123. tooltip: {
  1124. show: !1,
  1125. },
  1126. series: [
  1127. {
  1128. name: "\u4eea\u8868\u76d8",
  1129. type: "gauge",
  1130. center: ["50%", "50%"],
  1131. radius: "90%",
  1132. startAngle: 140,
  1133. endAngle: -140,
  1134. min: 0,
  1135. max: 6,
  1136. precision: 0,
  1137. splitNumber: 30, // 分成30份
  1138. axisLine: {
  1139. show: !0,
  1140. lineStyle: {
  1141. color: [
  1142. [0.17, "#FC4407"],
  1143. [0.33, "#FDC404"],
  1144. [0.5, "#2D8FFD"],
  1145. [0.67, "#87CCE7"],
  1146. [0.83, "#C1F478"],
  1147. [1, "#8FEB8D"],
  1148. ],
  1149. width: 20,
  1150. },
  1151. },
  1152. axisTick: {
  1153. show: !0,
  1154. splitNumber: 9,
  1155. length: 8,
  1156. lineStyle: {
  1157. color: "#eee",
  1158. width: 1,
  1159. type: "solid",
  1160. },
  1161. },
  1162. axisLabel: {
  1163. show: true,
  1164. formatter: function (v) {},
  1165. textStyle: {
  1166. color: "auto",
  1167. },
  1168. },
  1169. // 中途切割
  1170. splitLine: {
  1171. show: !0,
  1172. length: 20,
  1173. lineStyle: {
  1174. color: "#eee",
  1175. width: 2,
  1176. type: "solid",
  1177. },
  1178. },
  1179. pointer: {
  1180. length: "80%",
  1181. width: 8,
  1182. color: "auto",
  1183. },
  1184. title: {
  1185. show: !0,
  1186. offsetCenter: ["-65%", -10],
  1187. textStyle: {
  1188. color: "#333",
  1189. fontSize: 15,
  1190. },
  1191. },
  1192. detail: {
  1193. show: !0,
  1194. backgroundColor: "rgba(0,0,0,0)",
  1195. borderWidth: 0,
  1196. borderColor: "#ccc",
  1197. width: 100,
  1198. height: 40,
  1199. offsetCenter: ["-90%", 0], // name位置
  1200. formatter: function () {
  1201. return name.value;
  1202. },
  1203. textStyle: {
  1204. color: "auto",
  1205. fontSize: size.value, // 字体尺寸
  1206. },
  1207. },
  1208. data: [{ value: klineData }],
  1209. },
  1210. ],
  1211. };
  1212. } else if (messages[klineMessageIndex].klineType == 2) {
  1213. if (!klineData || !klineData.Kline) {
  1214. console.warn("KLine渲染: 数据无效 - 在chatStore中找不到有效的K线数据");
  1215. return;
  1216. }
  1217. // 获取容器元素
  1218. const container = document.getElementById(containerId);
  1219. if (!container) {
  1220. console.error("KLine渲染: 找不到容器元素:", containerId);
  1221. return;
  1222. }
  1223. // 创建图表实例
  1224. console.log("KLine渲染: 创建图表实例");
  1225. try {
  1226. // 如果已有实例,先销毁
  1227. if (chartInstancesMap[containerId]) {
  1228. console.log("KLine渲染: 销毁已有图表实例");
  1229. chartInstancesMap[containerId].dispose();
  1230. delete chartInstancesMap[containerId];
  1231. }
  1232. // 使用普通变量存储实例
  1233. chartInstancesMap[containerId] = echarts.init(container);
  1234. console.log("KLine渲染: 图表实例创建成功");
  1235. } catch (error) {
  1236. console.error("KLine渲染: 图表实例创建失败:", error);
  1237. return;
  1238. }
  1239. const data = klineData.Kline;
  1240. console.log("KLine渲染: Kline数据", data);
  1241. // 切割数据方法
  1242. const splitData = (a) => {
  1243. console.log("KLine渲染: 开始数据切割");
  1244. const categoryData = [];
  1245. let values = [];
  1246. for (let i = 0; i < a.length; i++) {
  1247. categoryData.push(a[i][0]);
  1248. values.push([a[i][1], a[i][2], a[i][3], a[i][4]]);
  1249. }
  1250. console.log("KLine渲染: 日期数据点数量", categoryData.length);
  1251. console.log("KLine渲染: 值数据点数量", values.length);
  1252. return { categoryData, values };
  1253. };
  1254. // 给配置项
  1255. console.log("KLine渲染: 开始配置图表选项");
  1256. const arr1 = [];
  1257. const arr2 = [];
  1258. const arr3 = [];
  1259. const arr4 = [];
  1260. const changeColorKline = (QSXH, KLine20) => {
  1261. if (QSXH) {
  1262. QSXH.map((item) => {
  1263. KLine20.map((kline_item) => {
  1264. if (item[1] == 1 && item[0] == kline_item[0]) {
  1265. arr1.push(kline_item);
  1266. arr2.push([
  1267. kline_item[0],
  1268. null,
  1269. null,
  1270. null,
  1271. null,
  1272. null,
  1273. null,
  1274. null,
  1275. ]);
  1276. arr3.push([
  1277. kline_item[0],
  1278. null,
  1279. null,
  1280. null,
  1281. null,
  1282. null,
  1283. null,
  1284. null,
  1285. ]);
  1286. arr4.push([
  1287. kline_item[0],
  1288. null,
  1289. null,
  1290. null,
  1291. null,
  1292. null,
  1293. null,
  1294. null,
  1295. ]);
  1296. }
  1297. if (item[1] == 2 && item[0] == kline_item[0]) {
  1298. arr2.push(kline_item);
  1299. arr1.push([
  1300. kline_item[0],
  1301. null,
  1302. null,
  1303. null,
  1304. null,
  1305. null,
  1306. null,
  1307. null,
  1308. ]);
  1309. arr3.push([
  1310. kline_item[0],
  1311. null,
  1312. null,
  1313. null,
  1314. null,
  1315. null,
  1316. null,
  1317. null,
  1318. ]);
  1319. arr4.push([
  1320. kline_item[0],
  1321. null,
  1322. null,
  1323. null,
  1324. null,
  1325. null,
  1326. null,
  1327. null,
  1328. ]);
  1329. }
  1330. if (item[1] == 3 && item[0] == kline_item[0]) {
  1331. arr3.push(kline_item);
  1332. arr2.push([
  1333. kline_item[0],
  1334. null,
  1335. null,
  1336. null,
  1337. null,
  1338. null,
  1339. null,
  1340. null,
  1341. ]);
  1342. arr1.push([
  1343. kline_item[0],
  1344. null,
  1345. null,
  1346. null,
  1347. null,
  1348. null,
  1349. null,
  1350. null,
  1351. ]);
  1352. arr4.push([
  1353. kline_item[0],
  1354. null,
  1355. null,
  1356. null,
  1357. null,
  1358. null,
  1359. null,
  1360. null,
  1361. ]);
  1362. }
  1363. if (item[1] == 4 && item[0] == kline_item[0]) {
  1364. arr4.push(kline_item);
  1365. arr2.push([
  1366. kline_item[0],
  1367. null,
  1368. null,
  1369. null,
  1370. null,
  1371. null,
  1372. null,
  1373. null,
  1374. ]);
  1375. arr3.push([
  1376. kline_item[0],
  1377. null,
  1378. null,
  1379. null,
  1380. null,
  1381. null,
  1382. null,
  1383. null,
  1384. ]);
  1385. arr1.push([
  1386. kline_item[0],
  1387. null,
  1388. null,
  1389. null,
  1390. null,
  1391. null,
  1392. null,
  1393. null,
  1394. ]);
  1395. }
  1396. });
  1397. });
  1398. }
  1399. };
  1400. console.log(arr1, arr2, arr3, arr4);
  1401. changeColorKline(data.QSXH, data.KLine20);
  1402. var dealData = splitData(data.KLine20);
  1403. var dealData1 = splitData(arr1);
  1404. var dealData2 = splitData(arr2);
  1405. var dealData3 = splitData(arr3);
  1406. var dealData4 = splitData(arr4);
  1407. var dealGnBullData = data.JN;
  1408. function processMAData(data) {
  1409. let processedData = [];
  1410. data.forEach((item, idx) => {
  1411. processedData.push({
  1412. date: item[0],
  1413. value: item[1],
  1414. type: item[2],
  1415. });
  1416. });
  1417. // 当某一种type只存在一天,设置另一种type透明
  1418. let singleTypeRed = [{ min: 0, max: 0, color: "#000" }];
  1419. let singleTypeYellow = [{ min: 0, max: 0, color: "#000" }];
  1420. let singleTypeGreen = [{ min: 0, max: 0, color: "#000" }];
  1421. for (let i = 1; i < processedData.length; i++) {
  1422. if (processedData[i].type !== processedData[i - 1].type) {
  1423. if (
  1424. i == processedData.length - 1 ||
  1425. (processedData[i].type !== processedData[i + 1].type &&
  1426. processedData[i - 1].type === processedData[i + 1].type)
  1427. ) {
  1428. if (processedData[i - 1].type === 0) {
  1429. singleTypeGreen.push({
  1430. min: i - 1,
  1431. max: i,
  1432. color: "rgba(0,0,0,0)",
  1433. });
  1434. } else if (processedData[i - 1].type === 1) {
  1435. singleTypeRed.push({
  1436. min: i - 1,
  1437. max: i,
  1438. color: "rgba(0,0,0,0)",
  1439. });
  1440. } else if (processedData[i - 1].type === 2) {
  1441. singleTypeYellow.push({
  1442. min: i - 1,
  1443. max: i,
  1444. color: "rgba(0,0,0,0)",
  1445. });
  1446. }
  1447. }
  1448. }
  1449. if (processedData[i].type !== processedData[i - 1].type) {
  1450. if (processedData[i].type == 0) {
  1451. processedData[i - 1].isTransitionGreen = 1;
  1452. } else if (processedData[i].type == 1) {
  1453. processedData[i - 1].isTransitionRed = 1;
  1454. } else if (processedData[i].type == 2) {
  1455. processedData[i - 1].isTransitionYellow = 1;
  1456. }
  1457. // // 创建过渡点,使用前一个点的值
  1458. // processedData[i - 1].isTransition = true
  1459. }
  1460. }
  1461. let greenData = [];
  1462. let redData = [];
  1463. let yellowData = [];
  1464. processedData.forEach((item, idx) => {
  1465. const point = [item.date, item.value];
  1466. if (item.type === 0) {
  1467. greenData.push(point);
  1468. redData.push([item.date, "-"]);
  1469. yellowData.push([item.date, "-"]);
  1470. // if (item.isTransition) {
  1471. // redData[redData.length - 1] = [processedData[idx].date, processedData[idx].value]
  1472. // yellowData[yellowData.length - 1] = [processedData[idx].date, processedData[idx].value]
  1473. // }
  1474. if (item.isTransitionGreen) {
  1475. greenData[greenData.length - 1] = [
  1476. processedData[idx].date,
  1477. processedData[idx].value,
  1478. ];
  1479. } else if (item.isTransitionRed) {
  1480. redData[redData.length - 1] = [
  1481. processedData[idx].date,
  1482. processedData[idx].value,
  1483. ];
  1484. } else if (item.isTransitionYellow) {
  1485. yellowData[yellowData.length - 1] = [
  1486. processedData[idx].date,
  1487. processedData[idx].value,
  1488. ];
  1489. }
  1490. } else if (item.type === 1) {
  1491. redData.push(point);
  1492. greenData.push([item.date, "-"]);
  1493. yellowData.push([item.date, "-"]);
  1494. // if (item.isTransition) {
  1495. // greenData[greenData.length - 1] = [processedData[idx].date, processedData[idx].value]
  1496. // yellowData[yellowData.length - 1] = [processedData[idx].date, processedData[idx].value]
  1497. // }
  1498. if (item.isTransitionGreen) {
  1499. greenData[greenData.length - 1] = [
  1500. processedData[idx].date,
  1501. processedData[idx].value,
  1502. ];
  1503. } else if (item.isTransitionRed) {
  1504. redData[redData.length - 1] = [
  1505. processedData[idx].date,
  1506. processedData[idx].value,
  1507. ];
  1508. } else if (item.isTransitionYellow) {
  1509. yellowData[yellowData.length - 1] = [
  1510. processedData[idx].date,
  1511. processedData[idx].value,
  1512. ];
  1513. }
  1514. } else if (item.type === 2) {
  1515. redData.push([item.date, "-"]);
  1516. greenData.push([item.date, "-"]);
  1517. yellowData.push(point);
  1518. // if (item.isTransition) {
  1519. // greenData[greenData.length - 1] = [processedData[idx].date, processedData[idx].value]
  1520. // redData[redData.length - 1] = [processedData[idx].date, processedData[idx].value]
  1521. // }
  1522. if (item.isTransitionGreen) {
  1523. greenData[greenData.length - 1] = [
  1524. processedData[idx].date,
  1525. processedData[idx].value,
  1526. ];
  1527. } else if (item.isTransitionRed) {
  1528. redData[redData.length - 1] = [
  1529. processedData[idx].date,
  1530. processedData[idx].value,
  1531. ];
  1532. } else if (item.isTransitionYellow) {
  1533. yellowData[yellowData.length - 1] = [
  1534. processedData[idx].date,
  1535. processedData[idx].value,
  1536. ];
  1537. }
  1538. }
  1539. });
  1540. return {
  1541. greenData: greenData,
  1542. redData: redData,
  1543. yellowData: yellowData,
  1544. singleTypeGreen: singleTypeGreen,
  1545. singleTypeRed: singleTypeRed,
  1546. singleTypeYellow: singleTypeYellow,
  1547. };
  1548. }
  1549. const maData = processMAData(data.FCX);
  1550. const maDuchiData = processMAData(data.DNC);
  1551. if (data.FCX[0][1] == "-1") {
  1552. maData.greenData = [];
  1553. maData.redData = [];
  1554. maData.yellowData = [];
  1555. }
  1556. const processBarData = (data) => {
  1557. const barData = [];
  1558. const markPointData = [];
  1559. data.forEach((item) => {
  1560. let color;
  1561. switch (item[4]) {
  1562. case 1:
  1563. color = "#13E113";
  1564. break;
  1565. case 2:
  1566. color = "#FF0E00";
  1567. break;
  1568. case 3:
  1569. color = "#0000FE";
  1570. break;
  1571. case 4:
  1572. color = "#1397FF";
  1573. break;
  1574. }
  1575. barData.push({
  1576. value: item[5],
  1577. itemStyle: {
  1578. normal: {
  1579. color: color,
  1580. },
  1581. },
  1582. });
  1583. if (item[1] === 1) {
  1584. markPointData.push({
  1585. coord: [item[0], item[5]],
  1586. symbol:
  1587. "image://https://d31zlh4on95l9h.cloudfront.net/images/5iujb101000d5si3v3hr7w2vg0h43z1u.png",
  1588. symbolSize: [30, 30],
  1589. label: {
  1590. normal: {
  1591. color: "rgba(0, 0, 0, 0)",
  1592. },
  1593. },
  1594. });
  1595. }
  1596. if (item[2] === 1) {
  1597. markPointData.push({
  1598. coord: [item[0], item[5] / 2],
  1599. symbol:
  1600. "image://https://d31zlh4on95l9h.cloudfront.net/images/5iujaz01000d5si016bxdf6vh0377d2h.png",
  1601. symbolSize: [30, 30],
  1602. label: {
  1603. normal: {
  1604. color: "rgba(0, 0, 0, 0)",
  1605. },
  1606. },
  1607. });
  1608. }
  1609. if (item[3] === 1) {
  1610. markPointData.push({
  1611. coord: [item[0], 0],
  1612. symbol:
  1613. "image://https://d31zlh4on95l9h.cloudfront.net/images/5iujb001000d5shzls0tmd4vs0e5tdrw.png",
  1614. symbolSize: [30, 30],
  1615. label: {
  1616. normal: {
  1617. color: "rgba(0, 0, 0, 0)",
  1618. },
  1619. },
  1620. });
  1621. }
  1622. });
  1623. return { barData, markPointData };
  1624. };
  1625. const { barData, markPointData } = processBarData(dealGnBullData);
  1626. KlineOption = {
  1627. legend: [
  1628. {
  1629. textStyle: {
  1630. color: "black",
  1631. fontSize: window.innerWidth > 768 ? 15 : vwToPx(1.8),
  1632. },
  1633. width: "100%",
  1634. top: window.innerWidth > 768 ? "0%" : "-1%",
  1635. left: "center",
  1636. itemGap: window.innerWidth > 768 ? 20 : 10,
  1637. itemWidth: 10,
  1638. itemHeight: 10,
  1639. data: [
  1640. {
  1641. name: "进攻K线",
  1642. itemStyle: {
  1643. color: "rgb(255,0,0)",
  1644. },
  1645. },
  1646. {
  1647. name: "防守K线",
  1648. itemStyle: {
  1649. color: "red",
  1650. },
  1651. },
  1652. {
  1653. name: "推进K线",
  1654. itemStyle: {
  1655. color: "orange",
  1656. },
  1657. },
  1658. {
  1659. name: "撤退K线",
  1660. itemStyle: {
  1661. color: "rgb(84,252,252)",
  1662. },
  1663. },
  1664. ],
  1665. },
  1666. {
  1667. textStyle: {
  1668. color: "black",
  1669. fontSize: window.innerWidth > 768 ? 15 : vwToPx(1.8),
  1670. },
  1671. orient: "horizontal",
  1672. top: window.innerWidth > 768 ? "3%" : "2%",
  1673. width: "100%",
  1674. left: "center",
  1675. itemGap: 15,
  1676. data: [
  1677. {
  1678. name: "{green|━}{red|━} " + "牵牛绳",
  1679. icon: "none",
  1680. textStyle: {
  1681. rich: {
  1682. green: {
  1683. color: "green",
  1684. fontSize: window.innerWidth > 768 ? 20 : 10,
  1685. },
  1686. red: {
  1687. color: "red",
  1688. fontSize: window.innerWidth > 768 ? 20 : 10,
  1689. },
  1690. },
  1691. },
  1692. },
  1693. {
  1694. name: "龙线",
  1695. },
  1696. {
  1697. name: "虫线",
  1698. },
  1699. ],
  1700. },
  1701. {
  1702. textStyle: {
  1703. color: "black",
  1704. fontSize: window.innerWidth > 768 ? 15 : vwToPx(1.8),
  1705. },
  1706. orient: "horizontal",
  1707. top: window.innerWidth > 768 ? "72%" : "64%",
  1708. width: "100%",
  1709. left: "center",
  1710. itemGap: 15,
  1711. data: [
  1712. {
  1713. name: "{green|━}{red|━} " + "度牛尺",
  1714. icon: "none",
  1715. textStyle: {
  1716. rich: {
  1717. green: {
  1718. color: "green",
  1719. fontSize: window.innerWidth > 768 ? 20 : 10,
  1720. },
  1721. red: {
  1722. color: "red",
  1723. fontSize: window.innerWidth > 768 ? 20 : 10,
  1724. },
  1725. },
  1726. },
  1727. },
  1728. ],
  1729. },
  1730. ],
  1731. tooltip: {
  1732. formatter: function (a, b, d) {
  1733. if (a[0].seriesIndex == 0) {
  1734. const KlineTag = ref([]);
  1735. const AIBullTag = ref([]);
  1736. KlineTag.value = a.find((item) => item.data[1])?.data || [];
  1737. AIBullTag.value =
  1738. a.slice(4).find((item) => item.data[1] !== "-")?.data || [];
  1739. // console.log(AIBullTag.value)
  1740. return (
  1741. a[0].name +
  1742. "<br/>" +
  1743. "开盘价" +
  1744. ":" +
  1745. KlineTag.value[1] +
  1746. "<br/>" +
  1747. "收盘价" +
  1748. ":" +
  1749. KlineTag.value[2] +
  1750. "<br/>" +
  1751. "最低价" +
  1752. ":" +
  1753. KlineTag.value[3] +
  1754. "<br/>" +
  1755. "最高价" +
  1756. ":" +
  1757. KlineTag.value[4] +
  1758. "<br/>" +
  1759. "牵牛绳" +
  1760. ":" +
  1761. AIBullTag.value[1]
  1762. );
  1763. }
  1764. if (a[0].seriesIndex == 4) {
  1765. let formattedVolume;
  1766. if (a[0].data.value >= 10000) {
  1767. formattedVolume = (a[0].data.value / 10000).toFixed(2) + "w";
  1768. } else {
  1769. formattedVolume = a[0].data.value;
  1770. }
  1771. return a[0].name + "<br/>" + "成交量" + ":" + formattedVolume;
  1772. }
  1773. if ([10, 11, 12].includes(a[0].seriesIndex)) {
  1774. const duchiData = a.find(
  1775. (item) => item.data && item.data[1] !== "-"
  1776. );
  1777. return duchiData
  1778. ? a[0].axisValue + "<br/>" + "度牛尺" + ":" + duchiData.data[1]
  1779. : null;
  1780. }
  1781. },
  1782. trigger: "axis",
  1783. axisPointer: {
  1784. type: "cross",
  1785. },
  1786. backgroundColor: "rgba(119, 120, 125, 0.6)",
  1787. borderWidth: 1,
  1788. borderColor: "#77787D",
  1789. padding: 10,
  1790. textStyle: {
  1791. color: "#fff",
  1792. },
  1793. },
  1794. axisPointer: {
  1795. link: [
  1796. {
  1797. xAxisIndex: "all",
  1798. },
  1799. ],
  1800. label: {
  1801. backgroundColor: "#77787D",
  1802. },
  1803. },
  1804. toolbox: {
  1805. show: false,
  1806. },
  1807. grid: [
  1808. {
  1809. // left: window.innerWidth > 768 ? '8%' : '15%',
  1810. // right: window.innerWidth > 768 ? '4%' : '2.5%',
  1811. top: window.innerWidth > 768 ? "10%" : "5%",
  1812. height: window.innerWidth > 768 ? "36%" : "34%",
  1813. containLabel: false,
  1814. },
  1815. {
  1816. // left: window.innerWidth > 768 ? '8%' : '15%',
  1817. // right: window.innerWidth > 768 ? '4%' : '2.5%',
  1818. top: window.innerWidth > 768 ? "50%" : "42%",
  1819. height: window.innerWidth > 768 ? "20%" : "22%",
  1820. containLabel: false,
  1821. },
  1822. {
  1823. // left: window.innerWidth > 768 ? '8%' : '15%',
  1824. // right: window.innerWidth > 768 ? '4%' : '2.5%',
  1825. top: window.innerWidth > 768 ? "78%" : "70%",
  1826. height: window.innerWidth > 768 ? "20%" : "22%",
  1827. containLabel: false,
  1828. },
  1829. ],
  1830. xAxis: [
  1831. {
  1832. type: "category",
  1833. data: dealData.categoryData,
  1834. boundaryGap: true,
  1835. axisLine: { onZero: false },
  1836. splitLine: { show: false },
  1837. min: "dataMin",
  1838. max: "dataMax",
  1839. axisPointer: {
  1840. z: 100,
  1841. },
  1842. axisLine: {
  1843. lineStyle: {
  1844. color: "black",
  1845. },
  1846. }, //
  1847. axisLabel: { show: false },
  1848. axisTick: { show: false },
  1849. },
  1850. {
  1851. type: "category",
  1852. gridIndex: 1,
  1853. data: dealData.categoryData,
  1854. boundaryGap: true,
  1855. axisLine: { lineStyle: { color: "black" } },
  1856. axisLabel: {
  1857. show: false,
  1858. interval: "auto",
  1859. },
  1860. },
  1861. {
  1862. type: "category",
  1863. gridIndex: 2,
  1864. data: dealData.categoryData,
  1865. boundaryGap: true,
  1866. axisLine: { lineStyle: { color: "black" } },
  1867. axisLabel: {
  1868. show: true,
  1869. interval: "auto",
  1870. },
  1871. },
  1872. ],
  1873. yAxis: [
  1874. {
  1875. scale: true,
  1876. gridIndex: 0,
  1877. position: "left",
  1878. axisLabel: {
  1879. inside: false,
  1880. align: "right",
  1881. fontSize: window.innerWidth > 768 ? 15 : 10,
  1882. },
  1883. axisLine: {
  1884. show: true,
  1885. lineStyle: {
  1886. fontSize: "",
  1887. color: "black",
  1888. },
  1889. },
  1890. axisTick: { show: false },
  1891. splitLine: { show: false },
  1892. },
  1893. {
  1894. scale: true,
  1895. gridIndex: 1,
  1896. splitNumber: 4,
  1897. min: 0,
  1898. minInterval: 1,
  1899. axisLabel: {
  1900. show: true,
  1901. fontSize: window.innerWidth > 768 ? 15 : 10,
  1902. margin: 8,
  1903. formatter: (value) => {
  1904. if (value >= 1000000000) {
  1905. return (value / 1000000000).toFixed(1) + "B";
  1906. } else if (value >= 1000000) {
  1907. return (value / 1000000).toFixed(1) + "M";
  1908. } else if (value >= 10000) {
  1909. return (value / 10000).toFixed(1) + "W";
  1910. }
  1911. return value.toFixed(0);
  1912. },
  1913. },
  1914. axisLine: { show: true, lineStyle: { color: "black" } },
  1915. axisTick: { show: false },
  1916. splitLine: { show: true, lineStyle: { type: "dashed" } },
  1917. boundaryGap: ["20%", "20%"],
  1918. },
  1919. {
  1920. type: "value",
  1921. gridIndex: 2,
  1922. min: 0,
  1923. max: 100,
  1924. axisLabel: {
  1925. show: true,
  1926. fontSize: window.innerWidth > 768 ? 15 : 10,
  1927. formatter: function (value) {
  1928. var customValues = [0, 20, 50, 80, 100];
  1929. return customValues.indexOf(value) > -1 ? value : "";
  1930. },
  1931. },
  1932. axisLine: {
  1933. show: true,
  1934. lineStyle: {
  1935. color: "black",
  1936. },
  1937. },
  1938. axisTick: {
  1939. show: false,
  1940. },
  1941. splitNumber: 10,
  1942. splitLine: {
  1943. show: true,
  1944. lineStyle: {
  1945. type: "dashed",
  1946. color: "#fff",
  1947. width: 1,
  1948. },
  1949. interval: function (index, value) {
  1950. return [20, 50, 80, 100].indexOf(value) > -1;
  1951. },
  1952. },
  1953. },
  1954. ],
  1955. dataZoom: [
  1956. {
  1957. type: "inside",
  1958. xAxisIndex: [0, 1, 2],
  1959. start: 55,
  1960. end: 100,
  1961. },
  1962. {
  1963. show: true,
  1964. xAxisIndex: [0, 1, 2],
  1965. type: "slider",
  1966. top: window.innerWidth > 768 ? "95%" : "96%",
  1967. left: window.innerWidth > 768 ? "10%" : "8%",
  1968. start: 98,
  1969. end: 100,
  1970. },
  1971. ],
  1972. visualMap: [
  1973. {
  1974. type: "piecewise",
  1975. show: false,
  1976. pieces: maData.singleTypeGreen,
  1977. outOfRange: {
  1978. color: "green",
  1979. },
  1980. dimension: 0,
  1981. seriesIndex: 7,
  1982. },
  1983. {
  1984. type: "piecewise",
  1985. show: false,
  1986. pieces: maData.singleTypeRed,
  1987. outOfRange: {
  1988. color: "red",
  1989. },
  1990. dimension: 0,
  1991. seriesIndex: 8,
  1992. },
  1993. {
  1994. type: "piecewise",
  1995. show: false,
  1996. pieces: maData.singleTypeYellow,
  1997. outOfRange: {
  1998. color: "yellow",
  1999. },
  2000. dimension: 0,
  2001. seriesIndex: 9,
  2002. },
  2003. ],
  2004. series: [
  2005. {
  2006. name: "进攻K线",
  2007. type: "candlestick",
  2008. barWidth: "50%",
  2009. data: dealData1.values,
  2010. xAxisIndex: 0,
  2011. yAxisIndex: 0,
  2012. itemStyle: {
  2013. normal: {
  2014. color: "rgb(255,0,0)",
  2015. color0: "rgb(255,0,0)",
  2016. borderColor: "rgb(255,0,0)",
  2017. borderColor0: "rgb(255,0,0)",
  2018. },
  2019. },
  2020. gridIndex: 0,
  2021. },
  2022. //
  2023. {
  2024. name: "推进K线",
  2025. type: "candlestick",
  2026. barWidth: "50%",
  2027. data: dealData2.values,
  2028. xAxisIndex: 0,
  2029. yAxisIndex: 0,
  2030. itemStyle: {
  2031. normal: {
  2032. color: "rgb(0,0,252)",
  2033. color0: "rgb(0,0,252)",
  2034. borderColor: "rgb(0,0,252)",
  2035. borderColor0: "rgb(0,0,252)",
  2036. },
  2037. },
  2038. gridIndex: 0,
  2039. },
  2040. {
  2041. name: "防守K线",
  2042. type: "candlestick",
  2043. barWidth: "50%",
  2044. data: dealData3.values,
  2045. xAxisIndex: 0,
  2046. yAxisIndex: 0,
  2047. itemStyle: {
  2048. normal: {
  2049. color: "orange",
  2050. color0: "orange",
  2051. borderColor: "orange",
  2052. borderColor0: "orange",
  2053. },
  2054. },
  2055. gridIndex: 0,
  2056. },
  2057. {
  2058. name: "撤退K线",
  2059. type: "candlestick",
  2060. barWidth: "50%",
  2061. data: dealData4.values,
  2062. xAxisIndex: 0,
  2063. yAxisIndex: 0,
  2064. itemStyle: {
  2065. normal: {
  2066. color: "rgb(84,252,252)",
  2067. color0: "rgb(84,252,252)",
  2068. borderColor: "rgb(84,252,252)",
  2069. borderColor0: "rgb(84,252,252)",
  2070. },
  2071. },
  2072. gridIndex: 0,
  2073. },
  2074. {
  2075. name: "成交量",
  2076. type: "bar",
  2077. barWidth: "70%",
  2078. xAxisIndex: 1,
  2079. yAxisIndex: 1,
  2080. data: barData,
  2081. markPoint: {
  2082. data: markPointData,
  2083. label: {
  2084. show: false,
  2085. },
  2086. },
  2087. },
  2088. {
  2089. name: "{green|━}{red|━} " + "牵牛绳",
  2090. type: "line",
  2091. data: [],
  2092. smooth: true,
  2093. symbol: "none",
  2094. xAxisIndex: 0,
  2095. yAxisIndex: 0,
  2096. showSymbol: false,
  2097. lineStyle: {
  2098. opacity: 0,
  2099. },
  2100. itemStyle: {
  2101. normal: {
  2102. color: "green",
  2103. },
  2104. },
  2105. gridIndex: 0,
  2106. },
  2107. {
  2108. name: "{green|━}{red|━} " + "度牛尺",
  2109. type: "line",
  2110. data: [],
  2111. smooth: true,
  2112. symbol: "none",
  2113. xAxisIndex: 0,
  2114. yAxisIndex: 0,
  2115. showSymbol: false,
  2116. lineStyle: {
  2117. opacity: 0,
  2118. },
  2119. itemStyle: {
  2120. normal: {
  2121. color: "green",
  2122. },
  2123. },
  2124. gridIndex: 0,
  2125. },
  2126. {
  2127. name: "虫线",
  2128. type: "line",
  2129. data: maData.greenData,
  2130. smooth: true,
  2131. symbol: "none",
  2132. xAxisIndex: 0,
  2133. yAxisIndex: 0,
  2134. itemStyle: {
  2135. normal: {
  2136. color: "green",
  2137. lineStyle: {
  2138. width: 2,
  2139. type: "solid",
  2140. },
  2141. },
  2142. },
  2143. gridIndex: 0,
  2144. },
  2145. {
  2146. name: "龙线",
  2147. type: "line",
  2148. data: maData.redData,
  2149. smooth: true,
  2150. symbol: "none",
  2151. xAxisIndex: 0,
  2152. yAxisIndex: 0,
  2153. itemStyle: {
  2154. normal: {
  2155. color: "red",
  2156. lineStyle: {
  2157. width: 2,
  2158. type: "solid",
  2159. },
  2160. },
  2161. },
  2162. gridIndex: 0,
  2163. },
  2164. {
  2165. name: "黄色",
  2166. type: "line",
  2167. data: maData.yellowData,
  2168. smooth: true,
  2169. symbol: "none",
  2170. xAxisIndex: 0,
  2171. yAxisIndex: 0,
  2172. itemStyle: {
  2173. normal: {
  2174. color: "yellow",
  2175. lineStyle: {
  2176. width: 2,
  2177. type: "solid",
  2178. },
  2179. },
  2180. },
  2181. gridIndex: 0,
  2182. },
  2183. {
  2184. name: "背景区域",
  2185. type: "line",
  2186. data: [],
  2187. xAxisIndex: 2,
  2188. yAxisIndex: 2,
  2189. markArea: {
  2190. silent: true,
  2191. itemStyle: {
  2192. normal: {
  2193. opacity: 1,
  2194. },
  2195. },
  2196. label: {
  2197. normal: {
  2198. show: true,
  2199. position: "insideRight",
  2200. fontSize: window.innerWidth > 768 ? 16 : 12,
  2201. fontWeight: "bold",
  2202. color: "#13E113",
  2203. distance: 10,
  2204. },
  2205. },
  2206. data: [
  2207. [
  2208. {
  2209. yAxis: 0,
  2210. itemStyle: {
  2211. normal: {
  2212. color: "#CFFFCF",
  2213. },
  2214. },
  2215. label: {
  2216. normal: {
  2217. formatter: "度牛区",
  2218. },
  2219. },
  2220. },
  2221. {
  2222. yAxis: 20,
  2223. },
  2224. ],
  2225. [
  2226. {
  2227. yAxis: 20,
  2228. itemStyle: {
  2229. normal: {
  2230. color: "#A6FFFF",
  2231. },
  2232. },
  2233. },
  2234. {
  2235. yAxis: 40,
  2236. },
  2237. ],
  2238. [
  2239. {
  2240. yAxis: 40,
  2241. itemStyle: {
  2242. normal: {
  2243. color: "#FFF686",
  2244. },
  2245. },
  2246. },
  2247. {
  2248. yAxis: 60,
  2249. },
  2250. ],
  2251. [
  2252. {
  2253. yAxis: 60,
  2254. itemStyle: {
  2255. normal: { color: "#FFD2B3" },
  2256. },
  2257. },
  2258. {
  2259. yAxis: 80,
  2260. },
  2261. ],
  2262. [
  2263. {
  2264. yAxis: 80,
  2265. itemStyle: {
  2266. normal: { color: "#FFB8B8" },
  2267. },
  2268. label: {
  2269. normal: {
  2270. formatter: "度牛区",
  2271. color: "#FF0000",
  2272. position: "insideLeft",
  2273. distance: 10,
  2274. },
  2275. },
  2276. },
  2277. {
  2278. yAxis: 100,
  2279. },
  2280. ],
  2281. ],
  2282. },
  2283. },
  2284. {
  2285. name: "度牛尺",
  2286. type: "line",
  2287. data: maDuchiData.greenData,
  2288. symbol: "none",
  2289. xAxisIndex: 2,
  2290. yAxisIndex: 2,
  2291. itemStyle: {
  2292. normal: {
  2293. color: "green",
  2294. lineStyle: {
  2295. width: 2,
  2296. type: "solid",
  2297. },
  2298. },
  2299. },
  2300. gridIndex: 2,
  2301. markPoint: {
  2302. symbol: "rect",
  2303. symbolSize: (value, params) => {
  2304. const width = window.innerWidth;
  2305. const baseHeight = 36;
  2306. if (width <= 375) {
  2307. return [2, 16];
  2308. } else if (width <= 768) {
  2309. return [2, 24];
  2310. }
  2311. return [2, baseHeight];
  2312. },
  2313. itemStyle: {
  2314. normal: {
  2315. label: {
  2316. show: false,
  2317. },
  2318. },
  2319. },
  2320. data: [
  2321. ...maDuchiData.greenData
  2322. .map((item) => {
  2323. if (item[1] === 0) {
  2324. return {
  2325. coord: [item[0], 20],
  2326. symbolOffset: window.innerWidth > 768 ? [0, 20] : [0, 12],
  2327. itemStyle: {
  2328. color: "#00ff00",
  2329. },
  2330. };
  2331. }
  2332. })
  2333. .filter(Boolean),
  2334. ],
  2335. },
  2336. },
  2337. {
  2338. type: "line",
  2339. data: maDuchiData.redData,
  2340. // smooth: true,
  2341. symbol: "none",
  2342. xAxisIndex: 2,
  2343. yAxisIndex: 2,
  2344. itemStyle: {
  2345. normal: {
  2346. color: "red",
  2347. lineStyle: {
  2348. width: 2,
  2349. type: "solid",
  2350. },
  2351. },
  2352. },
  2353. gridIndex: 2,
  2354. markPoint: {
  2355. symbol: "rect",
  2356. symbolSize: (value, params) => {
  2357. const width = window.innerWidth;
  2358. const baseHeight = 36;
  2359. if (width <= 375) {
  2360. return [2, 16];
  2361. } else if (width <= 768) {
  2362. return [2, 24];
  2363. }
  2364. return [2, baseHeight];
  2365. },
  2366. itemStyle: {
  2367. normal: {
  2368. label: {
  2369. show: false,
  2370. },
  2371. },
  2372. },
  2373. data: [
  2374. ...maDuchiData.redData
  2375. .map((item) => {
  2376. if (item[1] === 100) {
  2377. return {
  2378. coord: [item[0], 80],
  2379. symbolOffset:
  2380. window.innerWidth > 768 ? [0, -20] : [0, -12],
  2381. itemStyle: {
  2382. color: "#ff0000",
  2383. },
  2384. };
  2385. }
  2386. })
  2387. .filter(Boolean),
  2388. ],
  2389. },
  2390. },
  2391. {
  2392. name: "辅助线",
  2393. type: "line",
  2394. data: [],
  2395. xAxisIndex: 2,
  2396. yAxisIndex: 2,
  2397. markLine: {
  2398. silent: true,
  2399. symbol: "none",
  2400. lineStyle: {
  2401. color: "#000000",
  2402. width: 3,
  2403. type: "solid",
  2404. },
  2405. data: [{ yAxis: 20 }],
  2406. },
  2407. },
  2408. {
  2409. name: "辅助线",
  2410. type: "line",
  2411. data: [],
  2412. xAxisIndex: 2,
  2413. yAxisIndex: 2,
  2414. markLine: {
  2415. silent: true,
  2416. symbol: "none",
  2417. lineStyle: {
  2418. color: "#000000",
  2419. width: 3,
  2420. type: "solid",
  2421. },
  2422. data: [{ yAxis: 50 }],
  2423. },
  2424. },
  2425. {
  2426. name: "辅助线",
  2427. type: "line",
  2428. data: [],
  2429. xAxisIndex: 2,
  2430. yAxisIndex: 2,
  2431. markLine: {
  2432. silent: true,
  2433. symbol: "none",
  2434. lineStyle: {
  2435. color: "#000000",
  2436. width: 3,
  2437. type: "solid",
  2438. },
  2439. data: [{ yAxis: 80 }],
  2440. },
  2441. },
  2442. {
  2443. name: "辅助线",
  2444. type: "line",
  2445. data: [],
  2446. xAxisIndex: 2,
  2447. yAxisIndex: 2,
  2448. markLine: {
  2449. silent: true,
  2450. symbol: "none",
  2451. lineStyle: {
  2452. color: "#000000",
  2453. width: 3,
  2454. type: "solid",
  2455. },
  2456. data: [{ yAxis: 100 }],
  2457. },
  2458. },
  2459. ],
  2460. };
  2461. }
  2462. console.log("KLine渲染: 图表配置完成");
  2463. try {
  2464. // 应用配置
  2465. console.log("KLine渲染: 开始设置图表选项");
  2466. chartInstancesMap[containerId].setOption(KlineOption);
  2467. console.log("KLine渲染: 图表选项设置成功");
  2468. // 窗口大小变化时重新渲染图表
  2469. const resizeFunc = _.throttle(
  2470. function () {
  2471. console.log("窗口大小改变,调整图表大小");
  2472. if (
  2473. chartInstancesMap[containerId] &&
  2474. !chartInstancesMap[containerId].isDisposed()
  2475. ) {
  2476. // 如果设备类型发生变化,重新渲染
  2477. const newIsMobile = window.innerWidth < 768;
  2478. const newIsTablet =
  2479. window.innerWidth >= 768 && window.innerWidth < 1024;
  2480. if (newIsMobile !== isMobile || newIsTablet !== isTablet) {
  2481. console.log("设备类型变化,重新渲染图表");
  2482. KlineCanvsEcharts(containerId);
  2483. return;
  2484. }
  2485. chartInstancesMap[containerId].resize();
  2486. }
  2487. },
  2488. 1000,
  2489. { trailing: false }
  2490. );
  2491. // 给resize事件绑定一个特定的函数名,便于后续移除
  2492. window[`resize_${containerId}`] = resizeFunc;
  2493. // 绑定resize事件
  2494. window.removeEventListener("resize", window[`resize_${containerId}`]);
  2495. window.addEventListener("resize", window[`resize_${containerId}`]);
  2496. console.log("KLine渲染: 图表渲染完成");
  2497. } catch (error) {
  2498. console.error("KLine渲染: 图表渲染出错", error);
  2499. }
  2500. }
  2501. watch(
  2502. () => audioStore.isVoiceEnabled,
  2503. (newVal) => {
  2504. // 添加状态锁定逻辑
  2505. if (newVal === audioStore.lastVoiceState) return;
  2506. audioStore.lastVoiceState = newVal;
  2507. if (newVal) {
  2508. console.log("开启语音播放");
  2509. // 添加重试机制
  2510. const tryPlay = () => {
  2511. if (!audioStore.ttsUrl) return; // 新增空值判断
  2512. if (audioStore.soundInstance?.playing()) return;
  2513. playAudio(audioStore.ttsUrl);
  2514. setTimeout(() => {
  2515. if (!audioStore.soundInstance?.playing()) {
  2516. Howler.unload();
  2517. }
  2518. }, 1000);
  2519. };
  2520. tryPlay();
  2521. } else {
  2522. console.log("关闭语音播放");
  2523. pauseAudio();
  2524. // 强制停止并释放资源
  2525. // Howler.stop();
  2526. // Howler.unload();
  2527. // if (audioStore.soundInstance) {
  2528. // audioStore.soundInstance.off(); // 移除所有事件监听
  2529. // audioStore.soundInstance = null;
  2530. // }
  2531. }
  2532. },
  2533. { immediate: true }
  2534. );
  2535. watch(
  2536. () => dataStore.activeTabIndex,
  2537. (newVal) => {
  2538. setTimeout(() => {
  2539. console.log("activeTabIndex变化:", newVal);
  2540. // 当标签页切换回来时,重新渲染所有图表
  2541. if (newVal === 0) {
  2542. console.log("切换到AI聊天页,重新渲染图表");
  2543. // 延迟执行以确保DOM已渲染
  2544. renderAllKlineCharts();
  2545. }
  2546. }, 300);
  2547. },
  2548. { immediate: true } // 添加immediate属性,确保初始化时执行一次
  2549. );
  2550. // 添加渲染所有K线图的方法
  2551. function renderAllKlineCharts() {
  2552. console.log("重新渲染所有K线图");
  2553. // 查找所有K线消息
  2554. const messages = chatStore.messages;
  2555. for (let i = 0; i < messages.length; i++) {
  2556. if (messages[i].kline && messages[i].chartData) {
  2557. const containerId = `kline-container-${i}`;
  2558. console.log(`尝试渲染K线图: ${containerId}`);
  2559. // 确保DOM已经渲染
  2560. const container = document.getElementById(containerId);
  2561. if (container) {
  2562. // 渲染图表
  2563. KlineCanvsEcharts(containerId);
  2564. } else {
  2565. console.warn(`找不到容器: ${containerId}`);
  2566. }
  2567. }
  2568. }
  2569. }
  2570. // 初始化随机GIF
  2571. onMounted(() => {
  2572. // 初始化marked组件
  2573. marked.setOptions({
  2574. breaks: true, // 支持换行符转换为 <br>
  2575. gfm: true, // 启用 GitHub Flavored Markdown
  2576. sanitize: false, // 不清理 HTML(谨慎使用)
  2577. smartLists: true, // 智能列表
  2578. smartypants: true, // 智能标点符号
  2579. xhtml: false, // 不使用 XHTML 输出
  2580. renderer: renderer,
  2581. });
  2582. const random = Math.floor(Math.random() * 6) + 1;
  2583. currentGif.value = gifList[random];
  2584. console.log("组件挂载完成");
  2585. // 添加DOM变化监听器
  2586. const observer = new MutationObserver((mutations) => {
  2587. mutations.forEach((mutation) => {
  2588. if (mutation.type === "childList" && mutation.addedNodes.length) {
  2589. // 检查是否添加了图表容器
  2590. const containers = document.querySelectorAll(
  2591. '[id^="kline-container-"]'
  2592. );
  2593. if (containers.length) {
  2594. // console.log("DOM变化监听到K线容器:", Array.from(containers).map(el => el.id));
  2595. }
  2596. }
  2597. });
  2598. });
  2599. // 开始监听DOM变化
  2600. observer.observe(document.body, { childList: true, subtree: true });
  2601. });
  2602. // 组件卸载时清理所有图表实例和事件监听器
  2603. onUnmounted(() => {
  2604. // 清理所有图表实例
  2605. Object.keys(chartInstancesMap).forEach((key) => {
  2606. if (chartInstancesMap[key]) {
  2607. // 移除resize事件监听
  2608. if (window[`resize_${key}`]) {
  2609. window.removeEventListener("resize", window[`resize_${key}`]);
  2610. delete window[`resize_${key}`];
  2611. }
  2612. // 销毁图表实例
  2613. chartInstancesMap[key].dispose();
  2614. delete chartInstancesMap[key];
  2615. }
  2616. });
  2617. });
  2618. </script>
  2619. <template>
  2620. <div class="chat-container">
  2621. <!-- GIF区域 -->
  2622. <div class="gif-area">
  2623. <img :src="currentGif" alt="AI动画" />
  2624. </div>
  2625. <div
  2626. v-for="(msg, index) in chatMsg"
  2627. :key="index"
  2628. :class="{
  2629. 'message-bubble': true,
  2630. [msg.sender]: msg.sender,
  2631. [msg.class]: msg.class,
  2632. }"
  2633. >
  2634. <div v-if="msg.type === 'kline'" class="kline-container">
  2635. <div :id="'kline-container-' + index" class="chart-mount-point">
  2636. <div v-if="!msg.hasValidData" class="no-data-message">
  2637. <p>暂无K线数据</p>
  2638. </div>
  2639. </div>
  2640. </div>
  2641. <div v-else-if="msg.type == 'ing'">
  2642. <div v-if="msg.flag">
  2643. <span>{{ msg.content }}</span>
  2644. <span class="loading-dots">
  2645. <span class="dot">.</span>
  2646. <span class="dot">.</span>
  2647. <span class="dot">.</span>
  2648. <span class="dot">.</span>
  2649. <span class="dot">.</span>
  2650. <span class="dot">.</span>
  2651. </span>
  2652. </div>
  2653. <div v-else v-html="msg.content"></div>
  2654. </div>
  2655. <div v-else-if="msg.type == 'title1'" style="display: flex; width: 100%">
  2656. <div class="mainTitle">
  2657. {{ msg.content }}
  2658. </div>
  2659. <div class="date">
  2660. {{ msg.date }}
  2661. </div>
  2662. </div>
  2663. <div v-else-if="msg.type == 'title2'" class="title2">
  2664. <img class="title1Img" :src="title1" alt="出错了" />
  2665. </div>
  2666. <div v-else-if="msg.type == 'title3'" class="title3">
  2667. <img class="title2Img" :src="msg.content" alt="出错了" />
  2668. </div>
  2669. <div v-else-if="msg.type == 'content1'" class="content1">
  2670. <div v-if="msg.kline" class="kline-container content1chart">
  2671. <div :id="'kline-container-' + index" class="chart-mount-point">
  2672. <div v-if="!msg.hasValidData" class="no-data-message">
  2673. <p>暂无数据</p>
  2674. </div>
  2675. </div>
  2676. </div>
  2677. <div v-else class="content1Text">
  2678. <div v-html="msg.content" class="text1"></div>
  2679. </div>
  2680. </div>
  2681. <div v-else-if="msg.type == 'content2'" class="content2">
  2682. <div class="kline-container content2chart">
  2683. <div :id="'kline-container-' + index" class="chart-mount-point">
  2684. <div v-if="!msg.hasValidData" class="no-data-message">
  2685. <p>暂无数据</p>
  2686. </div>
  2687. </div>
  2688. </div>
  2689. </div>
  2690. <div v-else-if="msg.type == 'content3'" class="content3">
  2691. <div class="content3Text">
  2692. <div v-html="msg.content" class="text3"></div>
  2693. </div>
  2694. </div>
  2695. <div v-else-if="msg.type == 'mianze'" class="mianze">
  2696. <div v-html="msg.content"></div>
  2697. </div>
  2698. <div v-else v-html="msg.content"></div>
  2699. </div>
  2700. </div>
  2701. </template>
  2702. <style scoped>
  2703. .chat-container {
  2704. display: flex;
  2705. flex-direction: column;
  2706. overflow: hidden;
  2707. }
  2708. .gif-area {
  2709. /* position: relative; */
  2710. /* height: 30vh; */
  2711. display: flex;
  2712. flex-direction: column;
  2713. justify-content: center;
  2714. align-items: center;
  2715. flex-shrink: 0;
  2716. /* 防止GIF区域被压缩 */
  2717. }
  2718. .gif-area img {
  2719. width: 30%;
  2720. /* 改为百分比单位 */
  2721. min-width: 200px;
  2722. /* 最小尺寸 */
  2723. max-width: 400px;
  2724. /* 最大尺寸 */
  2725. height: auto;
  2726. left: 50%;
  2727. transition: all 0.3s;
  2728. /* 添加过渡效果 */
  2729. }
  2730. .message-area {
  2731. margin-top: 2%;
  2732. flex: 1;
  2733. /* 消息区域占据剩余空间 */
  2734. overflow-y: auto;
  2735. padding: 20px;
  2736. display: flex;
  2737. flex-direction: column;
  2738. gap: 15px;
  2739. }
  2740. .marquee-container {
  2741. /* position: absolute; */
  2742. bottom: 0;
  2743. width: 100%;
  2744. /* ga */
  2745. }
  2746. .marquee-row {
  2747. white-space: nowrap;
  2748. overflow: visible;
  2749. padding: 8px 0;
  2750. width: 100%;
  2751. }
  2752. .marquee-item {
  2753. display: inline-block;
  2754. margin: 0 15px;
  2755. padding: 8px 20px;
  2756. background: rgba(255, 255, 255, 0.9);
  2757. /* 白色背景 */
  2758. border-radius: 10px;
  2759. /* 圆角矩形 */
  2760. color: #333;
  2761. /* 文字颜色改为深色 */
  2762. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  2763. /* 添加阴影 */
  2764. transition: all 0.3s;
  2765. transition: color 0.3s;
  2766. }
  2767. .top {
  2768. animation: marquee 25s linear infinite;
  2769. /* 默认动画是运行状态 */
  2770. animation-play-state: running;
  2771. }
  2772. .bottom {
  2773. animation: marquee 15s linear infinite reverse;
  2774. /* 默认动画是运行状态 */
  2775. animation-play-state: running;
  2776. }
  2777. /* 添加PC端专用速度 */
  2778. @media (min-width: 768px) {
  2779. .top {
  2780. animation-duration: 35s;
  2781. /* PC端改为35秒 */
  2782. }
  2783. .bottom {
  2784. animation-duration: 35s;
  2785. /* PC端改为35秒 */
  2786. }
  2787. }
  2788. @keyframes marquee {
  2789. 0% {
  2790. transform: translateX(100%);
  2791. }
  2792. 100% {
  2793. transform: translateX(-250%);
  2794. }
  2795. }
  2796. .loading-dots {
  2797. display: inline-block;
  2798. }
  2799. .dot {
  2800. opacity: 0.4;
  2801. animation: loading 1.4s infinite;
  2802. }
  2803. .dot:nth-child(1) {
  2804. animation-delay: 0s;
  2805. }
  2806. .dot:nth-child(2) {
  2807. animation-delay: 0.2s;
  2808. }
  2809. .dot:nth-child(3) {
  2810. animation-delay: 0.4s;
  2811. }
  2812. .dot:nth-child(4) {
  2813. animation-delay: 0.6s;
  2814. }
  2815. .dot:nth-child(5) {
  2816. animation-delay: 0.8s;
  2817. }
  2818. .dot:nth-child(6) {
  2819. animation-delay: 1s;
  2820. }
  2821. @keyframes loading {
  2822. 0%,
  2823. 60%,
  2824. 100% {
  2825. opacity: 0.4;
  2826. }
  2827. 30% {
  2828. opacity: 1;
  2829. }
  2830. }
  2831. .message-bubble {
  2832. max-width: 80%;
  2833. margin: 10px 0px;
  2834. padding: 15px 20px;
  2835. position: relative;
  2836. }
  2837. .message-bubble.user {
  2838. color: #6d22f8;
  2839. background: white;
  2840. font-weight: bold;
  2841. margin-left: auto;
  2842. border-radius: 10px;
  2843. margin-right: 20px;
  2844. /* border-bottom-right-radius: 5px; */
  2845. }
  2846. .message-bubble.ai {
  2847. background: #2b378d;
  2848. color: #ffffff;
  2849. margin: 0 auto;
  2850. /* border-bottom-left-radius: 5px; */
  2851. }
  2852. .message-bubble.ing {
  2853. background: #ffffff;
  2854. color: #000000;
  2855. font-weight: bold;
  2856. border-radius: 10px;
  2857. margin-left: 20px;
  2858. margin-right: auto;
  2859. /* border-bottom-left-radius: 5px; */
  2860. }
  2861. .message-bubble.ai.title1 {
  2862. width: 100%;
  2863. display: flex;
  2864. border-radius: 10px 10px 0px 0px;
  2865. /* border-bottom-left-radius: 5px; */
  2866. }
  2867. .mainTitle {
  2868. font-size: 16px;
  2869. font-weight: bold;
  2870. background-image: url("@/assets/img/AiEmotion/bk01.png");
  2871. background-repeat: no-repeat;
  2872. background-size: 100% 100%;
  2873. min-width: 200px;
  2874. width: 20vw;
  2875. height: 50px;
  2876. padding: 5px 0px 0px 0px;
  2877. display: flex;
  2878. justify-content: center;
  2879. align-items: center;
  2880. }
  2881. .date {
  2882. font-size: 18px;
  2883. font-weight: bold;
  2884. margin-left: auto;
  2885. /* width: 100px; */
  2886. display: flex;
  2887. justify-content: center;
  2888. align-items: center;
  2889. }
  2890. .message-bubble.ai.title2 {
  2891. width: 100%;
  2892. display: flex;
  2893. justify-content: center;
  2894. align-items: center;
  2895. }
  2896. .title1Img {
  2897. max-width: 500px;
  2898. width: 80vw;
  2899. }
  2900. .message-bubble.ai.title3 {
  2901. width: 100%;
  2902. display: flex;
  2903. justify-content: center;
  2904. align-items: center;
  2905. }
  2906. .title2Img {
  2907. max-width: 500px;
  2908. width: 90vw;
  2909. }
  2910. .message-bubble.ai.content1 {
  2911. width: 100%;
  2912. display: flex;
  2913. justify-content: center;
  2914. align-items: center;
  2915. }
  2916. .content1chart {
  2917. background-image: url("@/assets/img/AIchat/罗盘边框.png");
  2918. background-repeat: no-repeat;
  2919. background-size: 100% 100%;
  2920. width: 50vw;
  2921. min-width: 350px;
  2922. display: flex;
  2923. justify-content: center;
  2924. align-items: center;
  2925. }
  2926. .content1Text {
  2927. background-image: url("@/assets/img/AIchat/框.png");
  2928. background-repeat: no-repeat;
  2929. background-size: 100% 100%;
  2930. width: 50vw;
  2931. min-width: 350px;
  2932. /* height: 20vw; */
  2933. /* max-height: 400px; */
  2934. padding: 5% 0;
  2935. }
  2936. .text1 {
  2937. font-weight: bold;
  2938. /* margin-left: 6%; */
  2939. /* margin-bottom: 10px; */
  2940. margin: 0px 6% 10px 6%;
  2941. font-size: 30px;
  2942. }
  2943. .message-bubble.ai.content2 {
  2944. width: 100%;
  2945. display: flex;
  2946. justify-content: center;
  2947. align-items: center;
  2948. }
  2949. .content2chart {
  2950. background-image: url("@/assets/img/AIchat/PCbackPic.png");
  2951. background-repeat: no-repeat;
  2952. background-size: 100% 100%;
  2953. width: 50vw;
  2954. min-width: 350px;
  2955. display: flex;
  2956. justify-content: center;
  2957. align-items: center;
  2958. }
  2959. .message-bubble.ai.content3 {
  2960. width: 100%;
  2961. display: flex;
  2962. justify-content: center;
  2963. align-items: center;
  2964. }
  2965. .content3Text {
  2966. background-image: url("@/assets/img/AIchat/边框.png");
  2967. background-repeat: no-repeat;
  2968. background-size: 100% 100%;
  2969. width: 50vw;
  2970. min-width: 350px;
  2971. /* height: 20vw; */
  2972. /* max-height: 400px; */
  2973. padding: 5% 0px;
  2974. }
  2975. .text3 {
  2976. /* font-weight: bold; */
  2977. /* margin-left: 6%; */
  2978. /* margin-bottom: 10px; */
  2979. margin: 0px 6% 10px 6%;
  2980. font-size: 30px;
  2981. }
  2982. .message-bubble.ai.mianze {
  2983. width: 100%;
  2984. text-align: center;
  2985. font-weight: bold;
  2986. font-size: 24px;
  2987. border-radius: 0px 0px 10px 10px;
  2988. }
  2989. .kline-container {
  2990. margin-top: 10px;
  2991. /* 最小高度 */
  2992. min-height: 320px;
  2993. /* 视口高度单位 */
  2994. height: 40vh;
  2995. width: 50vw;
  2996. }
  2997. @media (max-width: 768px) {
  2998. .kline-container {
  2999. min-width: 75vw;
  3000. }
  3001. .content1Text {
  3002. width: 77vw;
  3003. min-width: 0px;
  3004. /* height: 20vw; */
  3005. /* min-height: 150px; */
  3006. }
  3007. .text1 {
  3008. font-size: 20px;
  3009. }
  3010. .content2chart {
  3011. background-image: url("@/assets/img/AIchat/new-app-bgc.png") !important;
  3012. height: 100vw;
  3013. }
  3014. .content3Text {
  3015. width: 77vw;
  3016. min-width: 0px;
  3017. /* height: 20vw; */
  3018. /* min-height: 150px; */
  3019. }
  3020. .text3 {
  3021. font-size: 20px;
  3022. }
  3023. .message-bubble.ai.mianze {
  3024. font-size: 18px;
  3025. }
  3026. }
  3027. .kline-container .chart-mount-point {
  3028. display: flex;
  3029. justify-content: center;
  3030. align-items: center;
  3031. height: 80%;
  3032. width: 90%;
  3033. }
  3034. </style>