suerprisePlus
2024-06-25 c93d4b3af5739f786cfdf20b16b28ec60403f709
src/views/chartView/index.vue
@@ -15,6 +15,8 @@
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,12 +72,17 @@
    }, 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) => {
@@ -88,20 +95,41 @@
  methods: {
    bindEnter() {
      const msg = this.inputMsg;
      if (!msg) return;
      this.getMsg("role", msg);
      this.setLoading();
      setTimeout(() => {
        this.setMsgStart(msg);
      }, 200);
    },
    async setMsgStart(res) {
      if (res == "三维实景") {
      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);
      }
      // 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.status == 200) {
        if (data.code == 200) {
          if (data.content) {
            this.getMsg("ai", data.content);
          } else {
@@ -118,36 +146,69 @@
        }
      }
    },
    async setV1Fastgpt(res) {
      const data = await getV1Fastgpt(res);
      const obj = data.split(/[\n]/)
      const list_a = [];
      obj.filter(item => {
        if (item.indexOf("data: ") > -1) {
          if (item.indexOf('nodeId') > -1) {
          } else  if(item.indexOf("content")>-1){
            const a = JSON.parse(item.split('data: '))
            console.log(a);
            // if (a.choices[0].content) {
            //   console.log(a.choices[0].content);
            // }
    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
      })
      // console.log(list_a)
      // const a = val_data[0].split('data: ');
      // const b = JSON.parse(a[1]);
      // console.log(b)
      // const c = b[1].historyPreview.length - 1;
      // const d = b[1].historyPreview[c].value
      // this.getMsg("ai", d);
      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);
      // 
@@ -162,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);
      }