suerprisePlus
2024-06-25 c93d4b3af5739f786cfdf20b16b28ec60403f709
src/views/chartView/index.vue
@@ -1,12 +1,7 @@
<template>
  <div class="chartBox">
    <div class="ChartBox">
      <JwChat-index
        :taleList="list"
        @enter="bindEnter"
        v-model="inputMsg"
        :toolConfig="tool"
      >
      <JwChat-index :taleList="list" @enter="bindEnter" v-model="inputMsg" :toolConfig="tool">
      </JwChat-index>
    </div>
  </div>
@@ -17,8 +12,11 @@
import msgData from "../../assets/js/msg/msgData";
import store from "../../store";
import bus from "./../../assets/js/bus.js";
import { getAIMessage } from "../../api/api.js";
import { getAIMessage, getV1Fastgpt } from "../../api/api.js";
import mapInfo from "../../assets/js/map/mapInfo.js";
import axios from "axios";
import layerJson from "../../assets/js/map/mapJsonLayer.js";
import { factors } from "@turf/turf";
export default {
  name: "jwChat",
@@ -70,35 +68,150 @@
    }
    // this.setLoading();
    setTimeout(() => {
      // this.setMsgStart("您好");
      this.setMsgStart("您好");
    }, config.loadTime);
    bus.$on("mapInfo", (res) => {
      if (res) {
        this.setMapInfo(res);
        // this.setMapInfo(res);
      }
    });
    bus.$on("setInsertMarkDown", (res) => {
      if (res) {
        this.setMarkDownInfo(res);
      }
    });
    bus.$on("setRagMoreListAll", res => {
      if (res) {
        this.setRagMoreList(res);
      }
    });
    // axios.get("http://192.168.11.89:12315/Markdown.md").then((response) => {
    //     if (response.status == 200) {
    //       console.log(response);
    //       this.setMarkDownInfo(response.data);
    //     }
    //   });
  },
  methods: {
    bindEnter() {
      const msg = this.inputMsg;
      if (!msg) return;
      this.getMsg("role", msg);
      this.setLoading();
      setTimeout(() => {
        this.setMsgStart(msg);
      }, 200);
    },
    async setMsgStart(res) {
      const data = await getAIMessage(res);
      const message = data.order;
      if (data.order.args && data.order.args.place) {
        message = data.order.args.place;
      if (res.indexOf("军事目标") > -1 || res.indexOf("民宅") > -1 || res.indexOf("经济目标") > -1 || res.indexOf("海军陆战队") > -1 || res.indexOf("堤丰") > -1) {
        this.$store.state.setScreenFlag = true;
        this.list.splice(-1, 1);
        this.loading = false;
        layerJson.setQyeryData(res);
      }
      this.getMsg("ai", message);
      if (data.order.name) {
        mapInfo.init(data.order.name);
      // else if(res.indexOf("苏比克湾") > -1){
      //   this.$store.state.setScreenFlag = true;
      //   this.list.splice(-1, 1);
      //   this.loading = false;
      //   this.$nextTick(() => {
      //         setTimeout(() => {
      //           mapInfo.setEntityQueryInput();
      //         }, 1000);
      //       });
      // }
      else if (res == "三维实景") {
        layerJson.setTitleSetRest();
        this.setV1Fastgpt(res)
      } else {
        const data = await getAIMessage(res);
        if (data.code == 200) {
          if (data.content) {
            this.getMsg("ai", data.content);
          } else {
            this.getMsg("ai", "");
          }
          if (data.name) {
            this.$store.state.setScreenFlag = true;
            this.$nextTick(() => {
              setTimeout(() => {
                mapInfo.init(data.name);
              }, 1000);
            });
          }
        }
      }
    },
    setRagMoreList(res) {
      const obj = this.$store.state.ragList
      const val_data = obj.filter(item => {
        if (item.quest === res) {
          return item;
        }
      });
      if (val_data.length <= 0) return
      this.$store.state.ragList = obj;
      const val_obj = val_data[0]
      const key = val_obj.index;
      const val = val_obj.val;
      this.list[key].list[0].more = false;
      var flag = 1;
      var intValTime = setInterval(() => {
        if (flag >= val.length) {
          const obj = JSON.parse(JSON.stringify(this.list))
          this.list = obj
          for (var i in obj) {
            if (obj[i].quest === res) {
              obj.splice(i, 1)
            }
          }
          clearInterval(intValTime)
          return
        }
        const valitem = val[flag];
        const roleMsg = msgData.getRagData(valitem, false, "");
        this.list[key].list.push(roleMsg[0])
        flag++
      }, 1000);
    },
    setRagInterval(flag, index, res) {
      if (flag < res.length) {
        const obj = res[flag]
        this.list[index].list.push(roleMsg[0])
        setTimeout(() => {
          flag++;
          this.setRagInterval(flag, index, res)
        }, 1000);
      } else {
        return
      }
    },
    async setV1Fastgpt(res) {
      const data = await getV1Fastgpt(res);
      const length = this.list.length - 1;
      const obj = data[0].quoteList
      this.$store.state.ragList.push({
        quest: res,
        index: length,
        val: obj
      })
      var roleMsg = msgData.getRagData(obj[0], true, res);
      this.list[length].list = roleMsg
      this.loading = false;
    },
    setMarkDownInfo(res) {
      var roleMsg = msgData.getRole("markDown", res);
      this.list.push(roleMsg.msg);
      //
    },
    setMapInfo(res) {
      var msg = "";
@@ -110,10 +223,14 @@
    },
    getMsg(type, msg) {
      var roleMsg = msgData.getRole(type, msg);
      if (this.loading) {
        this.loading = false;
        const length = this.list.length - 1;
        this.list[length].text = roleMsg.msg.text;
        this.list[this.list.length - 1].list = roleMsg.msg.list;
      } else {
        this.list.push(roleMsg.msg);
      }
@@ -210,6 +327,7 @@
  line-height: 30px;
  border-bottom: 1px solid #c1c1c1;
}
@keyframes siz {
  from {
    width: 0;