zhangxiao
2024-08-26 53fd55bdf6544ae9c2697e460766ce2d53044dbe
src/views/sessionManager/components/chatMenu.vue
@@ -4,35 +4,50 @@
      <div class="myAgent___djnd_ myAgentAnim myAgentlight___yK7Gk">
        <div data-testid="msh-sidebar-main" class="myAgentHome___PG6IZ"></div>
        <div class="myAgentLine___Isl6E"></div>
        <div class="myAgentTool___Y1_mC" data-testid="msh-sidebar-new" @click="()=>{
          EventBus.emit('newChat')
        }">
        <div
          class="myAgentTool___Y1_mC"
          data-testid="msh-sidebar-new"
          @click="
            () => {
              EventBus.emit('newChat');
            }
          "
        >
          <div class="myAgentToolIcon___gaAKI myAgentToolIconNew___DBZrW">
            <img
            src="@/assets/images/talk.png"
            style="width: 24px"
            alt="">
            <img src="@/assets/images/talk.png" style="width: 24px" alt="" />
          </div>
        </div>
        <div data-testid="msh-sidebar-history" class="myAgentTool___Y1_mC"  @click="()=>{
          EventBus.emit('history')
        }">
        <div
          data-testid="msh-sidebar-history"
          class="myAgentTool___Y1_mC"
          @click="
            () => {
              EventBus.emit('history');
            }
          "
        >
          <div class="myAgentToolIcon___gaAKI myAgentToolIconHistory___GTLWk" >
            <img
              src="@/assets/images/historybg.png"
              style="width: 24px"
            alt="">
              alt=""
            />
          </div>
        </div>
        <div data-testid="msh-sidebar-square" class="myAgentTool___Y1_mC myAgentToolSquare___dbLm1" @click="()=>{
          EventBus.emit('smartAi')
        }">
          <div class="myAgentToolIcon___gaAKI myAgentToolIconSquare___Rj1o_"><img
            src="@/assets/images/agent.png"
            style="width: 24px"
            alt=""></div>
        <div
          data-testid="msh-sidebar-square"
          class="myAgentTool___Y1_mC myAgentToolSquare___dbLm1"
          @click="
            () => {
              EventBus.emit('smartAi');
            }
          "
        >
          <div class="myAgentToolIcon___gaAKI myAgentToolIconSquare___Rj1o_"
            ><img src="@/assets/images/agent.png" style="width: 24px" alt=""
          /></div>
        </div>
        <div class="myAgentLine___Isl6E" style="margin-top: 4px;"></div>
        <div class="myAgentLine___Isl6E" style="margin-top: 4px"></div>
        <div id="myAgentBox">
<!--          <div class="myAgentBox___zrCit">-->
<!--            <div class="myAgentBoxImg___Mgu9e">-->
@@ -89,11 +104,18 @@
                  <img
                    :src="item.icon ? httpUrl + item.icon:imgSrc"
                    alt=""
                    style="border-radius: 50%; width: 100%; height: 100%;">
                    style="border-radius: 50%; width: 100%; height: 100%"
                  />
                </div>
                <span class="myAgentBoxImgLayoutTip___xHV4m">{{item.name}}</span>
                <span class="myAgentBoxImgLayoutTip___xHV4m">{{
                  item.name
                }}</span>
              </div>
              <div data-testid="msh-sidebar-bot-delete" class="myAgentBoxImgDelete___qXZuq"  @click.stop="deleteSession(item)">
              <div
                data-testid="msh-sidebar-bot-delete"
                class="myAgentBoxImgDelete___qXZuq"
                @click.stop="deleteSession(item)"
              >
                <div class="myAgentBoxImgDeleteInner____Hawc"  >从侧边栏移除</div>
              </div>
            </div>
@@ -108,39 +130,50 @@
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 {
  addSessionApi,
  chatApi,
  getDialogListApi,
  getSessionDetailsApi,
  deleteSessionApi,
  sessionListApi
} from "@/api/session";
import { Message } from "@arco-design/web-vue";
    sessionListApi,
  } from '@/api/session';
  import { Message } from '@arco-design/web-vue';
const httpUrl = localStorage.getItem('httpUrl');
import EventBus from '@/utils/EventBus';
const emit = defineEmits(["querySessionDetail","changeAgentType","createSession"]);
import { appUsageSessionListApi, deleteAppUsage } from "@/api/Agent";
import { getAgentSessionDetailsApi } from "@/api/agentSession";
const activeSessionId = ref("");
const fieldNames = { value: "id", label: "name" };
  const emit = defineEmits([
    'querySessionDetail',
    'changeAgentType',
    'createSession',
  ]);
  import { appUsageSessionListApi, deleteAppUsage } from '@/api/Agent';
  import { getAgentSessionDetailsApi } from '@/api/agentSession';
  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 sessionList = ref([]); //用户操作会话列表
import img1 from '@/assets/images/talkbg.png'
import logo from "@/assets/images/model.png";
  import img1 from '@/assets/images/talkbg.png';
  import logo from '@/assets/images/model.png';
const imgSrc = ref(logo);
// 查询历史用户习惯会话列表
const querySessionList = async (id) => {
@@ -149,7 +182,7 @@
    sessionList.value = data.map((item) => {
      return {
        ...item,
      }
        };
    });
    // sessionList.value.splice(0, 5);
    console.log(sessionList.value,'用户习惯会话列表');
@@ -157,7 +190,6 @@
    // Message.warning("查询失败");
  }
};
// 新增会话
const createNewSession = async (session) => {
@@ -177,24 +209,17 @@
        id: session.app_id,
        dsl: data.dsl,
        title: session.name,
      }
      EventBus.emit("createAgent",sessionObj);
        };
        EventBus.emit('createAgent', sessionObj);
      emit('changeAgentType','2');
    }
  }
}
  };
//根据会话id删除会话
const deleteSession = async (session) => {
  const { code } = await deleteAppUsage({
    app_id:session.app_id
      app_id: session.app_id,
  });
  if (code === 200) {
    // Message.success('删除成功');
@@ -214,29 +239,21 @@
  }
};
onBeforeMount(()=>{
  querySessionList('');
})
onMounted(() => {
  EventBus.on("queryAppUsageList", (data) => {
    querySessionList('');
  })
})
onBeforeUnmount(() => {
  EventBus.off("queryAppUsageList");
});
  onMounted(() => {
    EventBus.on('queryAppUsageList', (data) => {
      querySessionList('');
    });
  });
  onBeforeUnmount(() => {
    EventBus.off('queryAppUsageList');
  });
</script>
<style scoped lang="less">
  @import "@/views/sessionManager/style/layout.css";
  @import '@/views/sessionManager/style/layout.css';
  .layoutNavMoveCenter {
    display: flex;
    justify-content: center;
@@ -249,8 +266,4 @@
    //max-height: 220px;
    //overflow: hidden;
  }
</style>