2023-11-29 09:34:45 +00:00
|
|
|
<template>
|
2023-12-01 11:17:58 +00:00
|
|
|
<div class="chat" v-loading="loading">
|
2023-11-29 09:34:45 +00:00
|
|
|
<div class="chat__header">
|
2024-05-14 09:56:40 +00:00
|
|
|
<h4 class="ml-24">{{ applicationDetail?.name }}</h4>
|
2023-11-30 10:50:42 +00:00
|
|
|
</div>
|
2024-05-14 09:56:40 +00:00
|
|
|
<div class="flex">
|
|
|
|
|
<div class="chat__left">
|
|
|
|
|
<div class="p-24 pb-0">
|
|
|
|
|
<el-button class="add-button w-full primary">
|
|
|
|
|
<el-icon><Plus /></el-icon><span class="ml-4">新建对话</span>
|
|
|
|
|
</el-button>
|
|
|
|
|
<p class="mt-20 mb-8">历史记录</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="chat-list-height pt-0">
|
|
|
|
|
<el-scrollbar>
|
|
|
|
|
<div class="p-8 pt-0">
|
|
|
|
|
<common-list
|
|
|
|
|
:data="chatLogeData"
|
|
|
|
|
class="mt-8"
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
@click="clickMemberHandle"
|
|
|
|
|
>
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<auto-tooltip :content="row.abstract">
|
|
|
|
|
{{ row.abstract }}
|
|
|
|
|
</auto-tooltip>
|
|
|
|
|
</template>
|
|
|
|
|
</common-list>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="gradient-divider lighter mt-8"><span>仅显示最近 20 条对话</span></div>
|
|
|
|
|
</el-scrollbar>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="chat__right w-full">
|
|
|
|
|
<AiChat
|
|
|
|
|
v-model:data="applicationDetail"
|
|
|
|
|
:available="applicationAvailable"
|
|
|
|
|
:appId="applicationDetail?.id"
|
|
|
|
|
></AiChat>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="chat__footer"></div>
|
2023-11-29 09:34:45 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
2023-11-30 10:50:42 +00:00
|
|
|
import { reactive, ref, watch, onMounted } from 'vue'
|
|
|
|
|
import { useRouter, useRoute } from 'vue-router'
|
|
|
|
|
import applicationApi from '@/api/application'
|
|
|
|
|
import useStore from '@/stores'
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const {
|
|
|
|
|
params: { accessToken }
|
|
|
|
|
} = route as any
|
|
|
|
|
|
2024-05-14 09:56:40 +00:00
|
|
|
const { application, user, log } = useStore()
|
2023-11-30 10:50:42 +00:00
|
|
|
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
const applicationDetail = ref<any>({})
|
2024-03-05 04:18:07 +00:00
|
|
|
const applicationAvailable = ref<boolean>(true)
|
2024-05-14 09:56:40 +00:00
|
|
|
const chatLogeData = ref<any[]>([])
|
2023-11-30 10:50:42 +00:00
|
|
|
|
|
|
|
|
function getAccessToken(token: string) {
|
2024-03-05 04:18:07 +00:00
|
|
|
application
|
|
|
|
|
.asyncAppAuthentication(token, loading)
|
|
|
|
|
.then((res) => {
|
|
|
|
|
getProfile()
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
applicationAvailable.value = false
|
|
|
|
|
})
|
2023-11-30 10:50:42 +00:00
|
|
|
}
|
|
|
|
|
function getProfile() {
|
2024-03-05 04:18:07 +00:00
|
|
|
applicationApi
|
|
|
|
|
.getProfile(loading)
|
|
|
|
|
.then((res) => {
|
|
|
|
|
applicationDetail.value = res.data
|
2024-05-14 09:56:40 +00:00
|
|
|
getChatLog(applicationDetail.value.id)
|
2024-03-05 04:18:07 +00:00
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
applicationAvailable.value = false
|
|
|
|
|
})
|
2023-11-30 10:50:42 +00:00
|
|
|
}
|
2024-05-14 09:56:40 +00:00
|
|
|
|
|
|
|
|
function getChatLog(id: string) {
|
|
|
|
|
const page = {
|
|
|
|
|
current_page: 1,
|
|
|
|
|
page_size: 20
|
|
|
|
|
}
|
|
|
|
|
const param = {
|
|
|
|
|
history_day: 183
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.asyncGetChatLog(id, page, param, loading).then((res: any) => {
|
|
|
|
|
chatLogeData.value = res.data.records
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-30 10:50:42 +00:00
|
|
|
onMounted(() => {
|
|
|
|
|
user.changeUserType(2)
|
|
|
|
|
getAccessToken(accessToken)
|
|
|
|
|
})
|
2023-11-29 09:34:45 +00:00
|
|
|
</script>
|
2023-12-26 08:56:14 +00:00
|
|
|
<style lang="scss">
|
2023-11-29 09:34:45 +00:00
|
|
|
.chat {
|
|
|
|
|
background-color: var(--app-layout-bg-color);
|
2023-12-26 08:56:14 +00:00
|
|
|
overflow: hidden;
|
2023-11-29 09:34:45 +00:00
|
|
|
&__header {
|
|
|
|
|
background: var(--app-header-bg-color);
|
|
|
|
|
position: fixed;
|
|
|
|
|
width: 100%;
|
|
|
|
|
left: 0;
|
|
|
|
|
top: 0;
|
|
|
|
|
z-index: 100;
|
|
|
|
|
height: var(--app-header-height);
|
|
|
|
|
line-height: var(--app-header-height);
|
|
|
|
|
box-sizing: border-box;
|
2024-04-17 07:21:23 +00:00
|
|
|
border-bottom: 1px solid var(--el-border-color);
|
2023-11-29 09:34:45 +00:00
|
|
|
}
|
2024-05-14 09:56:40 +00:00
|
|
|
&__left {
|
|
|
|
|
padding-top: calc(var(--app-header-height) - 8px);
|
|
|
|
|
|
|
|
|
|
background: #ffffff;
|
|
|
|
|
width: 280px;
|
|
|
|
|
.add-button {
|
|
|
|
|
border: 1px solid var(--el-color-primary);
|
|
|
|
|
}
|
|
|
|
|
.chat-list-height {
|
|
|
|
|
height: calc(100vh - var(--app-header-height) - 160px);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
&__right {
|
|
|
|
|
width: calc(100% - 280px);
|
2023-11-29 09:34:45 +00:00
|
|
|
padding-top: calc(var(--app-header-height) + 24px);
|
2024-05-14 09:56:40 +00:00
|
|
|
height: calc(100vh - var(--app-header-height) - 30px);
|
2023-12-26 08:56:14 +00:00
|
|
|
overflow: hidden;
|
2024-05-14 09:56:40 +00:00
|
|
|
position: relative;
|
2023-11-29 09:34:45 +00:00
|
|
|
}
|
2023-12-01 11:17:58 +00:00
|
|
|
&__footer {
|
|
|
|
|
background: #f3f7f9;
|
|
|
|
|
height: 80px;
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom: 0;
|
2024-05-14 09:56:40 +00:00
|
|
|
left: 280px;
|
|
|
|
|
width: calc(100% - 280px);
|
2023-12-01 11:17:58 +00:00
|
|
|
box-sizing: border-box;
|
2023-12-26 08:56:14 +00:00
|
|
|
border-radius: 8px !important;
|
2023-12-01 11:17:58 +00:00
|
|
|
&:before {
|
|
|
|
|
background: linear-gradient(0deg, #f3f7f9 0%, rgba(243, 247, 249, 0) 100%);
|
|
|
|
|
content: '';
|
|
|
|
|
position: absolute;
|
|
|
|
|
width: 100%;
|
|
|
|
|
top: -16px;
|
|
|
|
|
left: 0;
|
|
|
|
|
height: 16px;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-14 09:56:40 +00:00
|
|
|
.gradient-divider {
|
|
|
|
|
position: relative;
|
|
|
|
|
text-align: center;
|
|
|
|
|
color: var(--el-color-info);
|
|
|
|
|
::before {
|
|
|
|
|
content: '';
|
|
|
|
|
width: 17%;
|
|
|
|
|
height: 1px;
|
|
|
|
|
background: linear-gradient(90deg, rgba(222, 224, 227, 0) 0%, #dee0e3 100%);
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 16px;
|
|
|
|
|
top: 50%;
|
|
|
|
|
}
|
|
|
|
|
::after {
|
|
|
|
|
content: '';
|
|
|
|
|
width: 17%;
|
|
|
|
|
height: 1px;
|
|
|
|
|
background: linear-gradient(90deg, #dee0e3 0%, rgba(222, 224, 227, 0) 100%);
|
|
|
|
|
position: absolute;
|
|
|
|
|
right: 16px;
|
|
|
|
|
top: 50%;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-11-29 09:34:45 +00:00
|
|
|
.chat-width {
|
2023-12-11 10:27:31 +00:00
|
|
|
max-width: var(--app-chat-width, 860px);
|
2023-11-29 09:34:45 +00:00
|
|
|
margin: 0 auto;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|