refactor: chat embed
This commit is contained in:
parent
146d4e2624
commit
ad19518108
@ -14,7 +14,8 @@
|
|||||||
<template #reference>
|
<template #reference>
|
||||||
<div class="list-item flex align-center border border-r-6 p-8-12 cursor" style="width: 39%"
|
<div class="list-item flex align-center border border-r-6 p-8-12 cursor" style="width: 39%"
|
||||||
@click.stop="emit('clickNodes', item)" @mousedown.stop="emit('onmousedown', item)">
|
@click.stop="emit('clickNodes', item)" @mousedown.stop="emit('onmousedown', item)">
|
||||||
<el-avatar v-if="isAppIcon(item?.icon)" shape="square" :size="32" style="background: none">
|
<LogoIcon v-if="item.resource_type === 'application'" height="32px" />
|
||||||
|
<el-avatar v-else-if="isAppIcon(item?.icon)" shape="square" :size="32" style="background: none">
|
||||||
<img :src="resetUrl(item?.icon)" alt="" />
|
<img :src="resetUrl(item?.icon)" alt="" />
|
||||||
</el-avatar>
|
</el-avatar>
|
||||||
<el-avatar v-else class="avatar-green" shape="square" :size="32">
|
<el-avatar v-else class="avatar-green" shape="square" :size="32">
|
||||||
@ -27,7 +28,8 @@
|
|||||||
<template #default>
|
<template #default>
|
||||||
<div class="flex-between mb-8">
|
<div class="flex-between mb-8">
|
||||||
<div class="flex align-center">
|
<div class="flex align-center">
|
||||||
<el-avatar v-if="isAppIcon(item?.icon)" shape="square" :size="32" style="background: none">
|
<LogoIcon v-if="item.resource_type === 'application'" height="32px" />
|
||||||
|
<el-avatar v-else-if="isAppIcon(item?.icon)" shape="square" :size="32" style="background: none">
|
||||||
<img :src="resetUrl(item?.icon)" alt="" />
|
<img :src="resetUrl(item?.icon)" alt="" />
|
||||||
</el-avatar>
|
</el-avatar>
|
||||||
<el-avatar v-else class="avatar-green" shape="square" :size="32">
|
<el-avatar v-else class="avatar-green" shape="square" :size="32">
|
||||||
|
|||||||
@ -11,7 +11,17 @@
|
|||||||
>
|
>
|
||||||
<div class="chat-embed__header" :style="(user.isEE() || user.isPE()) && customStyle">
|
<div class="chat-embed__header" :style="(user.isEE() || user.isPE()) && customStyle">
|
||||||
<div class="flex align-center">
|
<div class="flex align-center">
|
||||||
<div class="mr-12 ml-24 flex">
|
<!-- TODO icon更换 -->
|
||||||
|
<AppIcon
|
||||||
|
iconName="app-history-outlined"
|
||||||
|
style="font-size: 20px"
|
||||||
|
class="ml-16"
|
||||||
|
:style="{
|
||||||
|
color: applicationDetail?.custom_theme?.header_font_color,
|
||||||
|
}"
|
||||||
|
@click.prevent.stop="show = true"
|
||||||
|
/>
|
||||||
|
<div class="mr-12 ml-16 flex">
|
||||||
<el-avatar
|
<el-avatar
|
||||||
v-if="isAppIcon(applicationDetail?.icon)"
|
v-if="isAppIcon(applicationDetail?.icon)"
|
||||||
shape="square"
|
shape="square"
|
||||||
@ -50,24 +60,38 @@
|
|||||||
</AiChat>
|
</AiChat>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 历史记录弹出层 -->
|
<el-drawer
|
||||||
<div @click.prevent.stop="show = !show" class="chat-popover-button cursor color-secondary">
|
v-model="show"
|
||||||
<AppIcon
|
:with-header="false"
|
||||||
iconName="app-history-outlined"
|
class="left-drawer"
|
||||||
:style="{
|
direction="ltr"
|
||||||
color: applicationDetail?.custom_theme?.header_font_color,
|
:size="280"
|
||||||
}"
|
>
|
||||||
></AppIcon>
|
<div>
|
||||||
</div>
|
<div class="flex align-center mb-16">
|
||||||
|
<div class="flex mr-8">
|
||||||
<el-collapse-transition>
|
<el-avatar
|
||||||
<div v-show="show" class="chat-popover w-full" v-click-outside="clickoutside">
|
v-if="isAppIcon(applicationDetail?.icon)"
|
||||||
<div class="border-b p-16-24">
|
shape="square"
|
||||||
<span>{{ $t('chat.history') }}</span>
|
:size="32"
|
||||||
|
style="background: none"
|
||||||
|
>
|
||||||
|
<img :src="applicationDetail?.icon" alt="" />
|
||||||
|
</el-avatar>
|
||||||
|
<LogoIcon v-else height="32px" />
|
||||||
|
</div>
|
||||||
|
<h4>{{ applicationDetail?.name }}</h4>
|
||||||
</div>
|
</div>
|
||||||
|
<el-button class="add-button w-full primary" @click="newChat">
|
||||||
|
<AppIcon iconName="app-create-chat"></AppIcon>
|
||||||
|
<span class="ml-4">{{ $t('chat.createChat') }}</span>
|
||||||
|
</el-button>
|
||||||
|
<p class="mt-20 mb-8">{{ $t('chat.history') }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<el-scrollbar max-height="300">
|
<div class="left-height pt-0">
|
||||||
<div class="p-8">
|
<el-scrollbar>
|
||||||
|
<div>
|
||||||
<common-list
|
<common-list
|
||||||
:style="{ '--el-color-primary': applicationDetail?.custom_theme?.theme_color }"
|
:style="{ '--el-color-primary': applicationDetail?.custom_theme?.theme_color }"
|
||||||
:data="chatLogData"
|
:data="chatLogData"
|
||||||
@ -113,9 +137,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
</div>
|
</div>
|
||||||
</el-collapse-transition>
|
<div class="flex align-center user-info" @click="toUserCenter">
|
||||||
<div class="chat-popover-mask" v-show="show"></div>
|
<el-avatar :size="32">
|
||||||
|
<img src="@/assets/user-icon.svg" style="width: 54%" alt="" />
|
||||||
|
</el-avatar>
|
||||||
|
<span v-if="chatUser.chat_profile?.authentication" class="ml-8 color-text-primary">{{
|
||||||
|
chatUser.chatUserProfile?.nick_name
|
||||||
|
}}</span>
|
||||||
|
</div>
|
||||||
|
</el-drawer>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<UserCenter v-model:show="userCenterDrawerShow" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@ -126,7 +159,10 @@ import { hexToRgba } from '@/utils/theme'
|
|||||||
import { MsgError } from '@/utils/message'
|
import { MsgError } from '@/utils/message'
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
import { t } from '@/locales'
|
import { t } from '@/locales'
|
||||||
const { user, chatLog } = useStore()
|
import UserCenter from '../mobile/component/UserCenter.vue'
|
||||||
|
import chatAPI from '@/api/chat/chat'
|
||||||
|
|
||||||
|
const { user, chatLog, chatUser } = useStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
const isPopup = computed(() => {
|
const isPopup = computed(() => {
|
||||||
@ -219,13 +255,17 @@ function handleScroll(event: any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clickoutside() {
|
const newObj = {
|
||||||
show.value = false
|
id: 'new',
|
||||||
|
abstract: t('chat.createChat'),
|
||||||
}
|
}
|
||||||
|
|
||||||
function newChat() {
|
function newChat() {
|
||||||
paginationConfig.current_page = 1
|
paginationConfig.current_page = 1
|
||||||
currentRecordList.value = []
|
currentRecordList.value = []
|
||||||
|
if (!chatLogData.value.some((v) => v.id === 'new')) {
|
||||||
|
chatLogData.value.unshift(newObj)
|
||||||
|
}
|
||||||
currentChatId.value = 'new'
|
currentChatId.value = 'new'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +275,7 @@ function getChatLog(id: string) {
|
|||||||
page_size: 20,
|
page_size: 20,
|
||||||
}
|
}
|
||||||
|
|
||||||
chatLog.asyncGetChatLogClient(id, page, left_loading).then((res: any) => {
|
chatAPI.pageChat(page.current_page, page.page_size, left_loading).then((res: any) => {
|
||||||
chatLogData.value = res.data.records
|
chatLogData.value = res.data.records
|
||||||
paginationConfig.current_page = 1
|
paginationConfig.current_page = 1
|
||||||
paginationConfig.total = 0
|
paginationConfig.total = 0
|
||||||
@ -248,13 +288,12 @@ function getChatLog(id: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getChatRecord() {
|
function getChatRecord() {
|
||||||
return chatLog
|
return chatAPI
|
||||||
.asyncChatRecordLog(
|
.pageChatRecord(
|
||||||
applicationDetail.value.id,
|
|
||||||
currentChatId.value,
|
currentChatId.value,
|
||||||
paginationConfig,
|
paginationConfig.current_page,
|
||||||
|
paginationConfig.page_size,
|
||||||
loading,
|
loading,
|
||||||
false,
|
|
||||||
)
|
)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
paginationConfig.total = res.data.total
|
paginationConfig.total = res.data.total
|
||||||
@ -301,6 +340,12 @@ const init = () => {
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
init()
|
init()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const userCenterDrawerShow = ref(false)
|
||||||
|
function toUserCenter() {
|
||||||
|
if (!chatUser.chat_profile?.authentication) return
|
||||||
|
userCenterDrawerShow.value = true
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.chat-embed {
|
.chat-embed {
|
||||||
@ -324,23 +369,34 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
.new-chat-button {
|
.new-chat-button {
|
||||||
z-index: 11;
|
z-index: 11;
|
||||||
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
// 历史对话弹出层
|
// 历史对话弹出层
|
||||||
.chat-popover {
|
.left-drawer {
|
||||||
position: absolute;
|
.el-drawer__body {
|
||||||
top: var(--app-header-height);
|
padding: 16px;
|
||||||
background: #ffffff;
|
background:
|
||||||
padding-bottom: 24px;
|
linear-gradient(187.61deg, rgba(235, 241, 255, 0.5) 39.6%, rgba(231, 249, 255, 0.5) 94.3%),
|
||||||
z-index: 2009;
|
#eef1f4;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
.add-button {
|
||||||
|
border: 1px solid var(--el-color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-height {
|
||||||
|
height: calc(100vh - 212px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-info {
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
margin-top: 16px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.chat-popover-button {
|
&.chat-embed--popup {
|
||||||
z-index: 2009;
|
|
||||||
position: absolute;
|
|
||||||
top: 16px;
|
|
||||||
right: 16px;
|
|
||||||
font-size: 22px;
|
|
||||||
}
|
|
||||||
&.chat-embed--popup {
|
|
||||||
.chat-popover-button {
|
.chat-popover-button {
|
||||||
right: 85px;
|
right: 85px;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
>
|
>
|
||||||
<div class="chat-embed__header" :style="(user.isEE() || user.isPE()) && customStyle">
|
<div class="chat-embed__header" :style="(user.isEE() || user.isPE()) && customStyle">
|
||||||
<div class="flex align-center">
|
<div class="flex align-center">
|
||||||
|
<!-- TODO icon更换 -->
|
||||||
<AppIcon
|
<AppIcon
|
||||||
iconName="app-history-outlined"
|
iconName="app-history-outlined"
|
||||||
style="font-size: 20px"
|
style="font-size: 20px"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user