zhangxiao
2024-08-26 53fd55bdf6544ae9c2697e460766ce2d53044dbe
src/views/sessionManager/components/smartAi.vue
@@ -1,48 +1,39 @@
<template>
  <div class="layoutAgentCenter">
              <a-scrollbar
                style="
                  height: calc(100vh - 100px);
                  overflow-y: auto;
                  overflow-x: hidden;
                "
      style="height: calc(100vh - 100px); overflow-y: auto; overflow-x: hidden"
              >
                <div class="search">
                  <!--                  查询框-->
                  <img src="@/assets/images/his.png"
                       style="width: 100%"
                       alt="">
        <img src="@/assets/images/his.png" style="width: 100%" alt="" />
                </div>
                <div class="agentMainCenter">
                  <a-row class="agentCenter">
                    <a-col :span="8" v-for="item in dialogs">
                      <div
                        class="item agentCenter-box"
                        @click="createNewSession(item)"
                      >
            <div class="item agentCenter-box" @click="createNewSession(item)">
                        <div class="text" >
                          <a-avatar>
                            <img
                              :style="{ width: '100%' }"
                              alt="dessert"
                              :src="item.avatar || imgSrc"
                    :src="item.icon || imgSrc"
                            />
                          </a-avatar>
                          <span style="margin-left: 10px;font-weight: 500;color: var(--color-text-1)">
                <span
                  style="
                    margin-left: 10px;
                    font-weight: 500;
                    color: var(--color-text-1);
                  "
                >
                            {{ item.name }}
                          </span>
                        </div>
                        <div class="time"
                        >
                        </div>
              <div class="time"> </div>
                      </div>
                    </a-col>
                    <a-col :span="8" v-for="item in agentList">
                      <div
                        class="item agentCenter-box"
                        @click="createNewSession(item)"
                      >
            <div class="item agentCenter-box" @click="createNewSession(item)">
                        <div class="text" >
                          <a-avatar>
                            <img
@@ -51,13 +42,17 @@
                              :src="item.avatar || imgSrc"
                            />
                          </a-avatar>
                          <span style="margin-left: 10px;font-weight: 500;color: var(--color-text-1)">
                <span
                  style="
                    margin-left: 10px;
                    font-weight: 500;
                    color: var(--color-text-1);
                  "
                >
                            {{ item.name }}
                          </span>
                        </div>
                        <div class="time"
                        >
                        </div>
              <div class="time"> </div>
                      </div>
                    </a-col>
                  </a-row>
@@ -69,33 +64,46 @@
import {
  IconClose,
  IconSearch,
  IconTiktokColor
} from "@arco-design/web-vue/es/icon";
import { useAppStore, useUserStore } from "@/store";
import { computed, nextTick, onMounted, watch, reactive, ref, onBeforeMount, onBeforeUnmount } from "vue";
    IconTiktokColor,
  } from '@arco-design/web-vue/es/icon';
  import { useAppStore, useUserStore } from '@/store';
  import {
    computed,
    nextTick,
    onMounted,
    watch,
    reactive,
    ref,
    onBeforeMount,
    onBeforeUnmount,
  } from 'vue';
import { Message } from "@arco-design/web-vue";
  import { Message } from '@arco-design/web-vue';
import EventBus from '@/utils/EventBus';
import moment from "moment";
  import moment from 'moment';
import {
  addSessionApi,
  chatApi,
  getDialogListApi,
  getSessionDetailsApi,
  sessionListApi
} from "@/api/session";
import { queryCanvasList } from "@/api/Agent";
const emit = defineEmits(["querySessionDetail","changeAgentType","createSession"]);
import logo from "@/assets/images/model.png";
    sessionListApi,
  } from '@/api/session';
  import { queryCanvasList } from '@/api/Agent';
  const emit = defineEmits([
    'querySessionDetail',
    'changeAgentType',
    'createSession',
  ]);
  import logo from '@/assets/images/model.png';
const sessionList = ref([]); //会话列表
const activeSessionId = ref("");
const fieldNames = { value: "id", label: "name" };
  const activeSessionId = ref('');
  const fieldNames = { value: 'id', label: 'name' };
const dialogs = ref([]);
const dialogObj = reactive({});
const agentObj = reactive({});
const agentList = ref([]);
const searchValue = ref("");
const selectValue = ref("");
  const searchValue = ref('');
  const selectValue = ref('');
const sectionList = ref({});
const imgSrc = ref(logo);
const DialogList = async () => {
@@ -106,11 +114,10 @@
      dialogs.value = data.map((item) => {
        return {
          ...item,
          type: 1 //智能体
            type: 1, //智能体
        };
      });
      // console.log(data, "dialogs");
        // console.log(dialogs, 'dialogs');
    }
  }
};
@@ -118,35 +125,30 @@
const queryCanvas = async (params = {}) => {
  try {
    const { data } = await queryCanvasList(params);
    console.log(data, "agent");
    agentList.value = data.map((item) => {
      return {
        ...item,
        name: item.title,
        type: 2 //agent
          type: 2, //agent
      };
    });
      // console.log(agentList, 'agent');
    // 合并数组
    // dialogs.value = dialogs.value.concat(agentList.value);
  } catch (err) {
    // you can report use errorHandler or other
  } finally {
  }
};
// 查询会话列表
const querySessionList = async (id) => {
  const { code, data } = await sessionListApi(id);
  if (code === 200) {
    sessionList.value = data;
  } else {
    Message.warning("查询失败");
      Message.warning('查询失败');
  }
};
// 生成智能体新建会话
@@ -159,30 +161,25 @@
    emit('changeAgentType','1');
  } else {
    // 生成agent新的对话
    EventBus.emit("createAgent",session);
      EventBus.emit('createAgent', session);
    emit('changeAgentType','2');
  }
}
  };
onBeforeMount(()=>{
  DialogList();
  queryCanvas();
})
  });
onMounted(() => {
  EventBus.on("smartAi", () => {
    EventBus.on('smartAi', () => {
    emit('changeAgentType','4');
    DialogList();
    queryCanvas();
  });
})
onBeforeUnmount(() => {
  EventBus.off("smartAi");
});
  onBeforeUnmount(() => {
    EventBus.off('smartAi');
  });
</script>
<style scoped lang="less">
  .layoutAgentCenter{
@@ -238,16 +235,10 @@
          color: var(--color-text-2);
          //border: 1px solid var(--color-neutral-3);
          background: var(--color-bg-3);
          box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16), 0 3px 6px 0 rgba(0, 0, 0, 0.12), 0 5px 12px 4px rgba(0, 0, 0, 0.09);
          box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16),
            0 3px 6px 0 rgba(0, 0, 0, 0.12), 0 5px 12px 4px rgba(0, 0, 0, 0.09);
        }
      }
    }
  }
</style>