Commit d91b9a64 authored by nick zheng's avatar nick zheng

Merge branch 'beta' into 'master'

feat(知识库切片返回): pc端应用分享页支持显示知识库切片&&切片样式调整

See merge request !227
parents a9e7f87d 6c2b12c0
...@@ -17,6 +17,11 @@ const isExpandContent = ref(false) ...@@ -17,6 +17,11 @@ const isExpandContent = ref(false)
const ELLIPSIS_HIGHT = 100 const ELLIPSIS_HIGHT = 100
const documentIcon = (documentName: string) => {
const type = documentName.split('.')?.pop()?.toLowerCase()
return type ? `https://gsst-poe-sit.gz.bcebos.com/icon/${type}.svg` : ''
}
onMounted(() => { onMounted(() => {
nextTick(() => { nextTick(() => {
if (knowledgeContentRef.value) { if (knowledgeContentRef.value) {
...@@ -32,27 +37,35 @@ function handleClickExpand() { ...@@ -32,27 +37,35 @@ function handleClickExpand() {
<template> <template>
<div <div
class="rounded-theme border bg-white px-[15px] py-4" class="group overflow-hidden rounded-[10px] border"
:class="isExpandContent ? 'border-theme-color' : 'border-inactive-border-color'" :class="
isExpandContent
? 'border-theme-color bg-[#f1f2ff]'
: 'hover:border-theme-color border-[#ededee] bg-[#fafaff] hover:bg-[#f1f2ff]'
"
> >
<div class="flex-center text-gray-font-color font-family-medium flex-shrink-0 justify-between gap-[10px]"> <div class="flex-center h-9 flex-shrink-0 justify-between gap-[18px] overflow-hidden bg-[#e2e4ff] px-[10px]">
<div class="flex flex-1 items-center gap-[5px]"> <div class="text-font-color flex flex-1 items-center gap-[5px] overflow-hidden">
<div
class="h-[18px] w-[18px] flex-shrink-0 bg-cover bg-center bg-no-repeat"
:style="{ backgroundImage: `url(${documentIcon(contentResultItem.documentName)})` }"
/>
<n-ellipsis>
{{ contentResultItem.documentName }}
</n-ellipsis>
</div>
<div class="text-gray-font-color flex flex-1 items-center justify-end gap-[5px] overflow-hidden">
<span class="flex-shrink-0"> <span class="flex-shrink-0">
{{ t('personal_space_module.agent_module.agent_setting_module.agent_config_module.from_knowledge_base') }}: {{ t('personal_space_module.agent_module.agent_setting_module.agent_config_module.from_knowledge_base') }}:
</span> </span>
<n-ellipsis class="w-full!"> <n-ellipsis>
{{ contentResultItem.knowledgeName }} {{ contentResultItem.knowledgeName }}
</n-ellipsis> </n-ellipsis>
</div> </div>
<div class="flex flex-shrink-0 items-center gap-[5px]">
<span>{{ t('personal_space_module.agent_module.agent_setting_module.agent_config_module.score') }}:</span>
<span>{{ (Math.floor(contentResultItem.score * 100) / 100).toFixed(2) }}</span>
</div>
</div> </div>
<div class="text-font-color relative mt-3 leading-4"> <div class="text-font-color relative mt-3 px-[15px] leading-4">
<span <span
ref="knowledgeContentRef" ref="knowledgeContentRef"
class="whitespace-pre-wrap break-all leading-4" class="whitespace-pre-wrap break-all leading-4"
...@@ -63,8 +76,8 @@ function handleClickExpand() { ...@@ -63,8 +76,8 @@ function handleClickExpand() {
<div <div
v-show="isContentExceed" v-show="isContentExceed"
class="text-gray-font-color flex-center mt-4 h-[16px] w-[72px] cursor-pointer gap-[5px] bg-white pr-2 leading-4 hover:text-[rgba(153,153,153,0.8)]" class="text-gray-font-color flex-center ml-auto mt-3 h-[16px] w-[72px] cursor-pointer items-baseline gap-[5px] pr-2 leading-4 hover:text-[rgba(153,153,153,0.8)] group-hover:bg-[#f1f2ff]"
:class="isExpandContent ? 'ml-auto items-baseline' : 'flex w-full justify-end'" :class="isExpandContent ? 'bg-[#f1f2ff]' : 'bg-[#fafaff]'"
@click="handleClickExpand" @click="handleClickExpand"
> >
<span class="inline-block leading-4"> <span class="inline-block leading-4">
...@@ -76,5 +89,11 @@ function handleClickExpand() { ...@@ -76,5 +89,11 @@ function handleClickExpand() {
/> />
</div> </div>
</div> </div>
<div class="font-family-medium text-gray-font-color mb-3 flex flex-shrink-0 items-center gap-[5px] px-[15px]">
<span>{{ t('personal_space_module.agent_module.agent_setting_module.agent_config_module.score') }}:</span>
<span>{{ (Math.floor(contentResultItem.score * 100) / 100).toFixed(2) }}</span>
</div>
</div> </div>
</template> </template>
...@@ -4,6 +4,7 @@ import HitKnowledgeItem from './hit-knowledge-item.vue' ...@@ -4,6 +4,7 @@ import HitKnowledgeItem from './hit-knowledge-item.vue'
interface Props { interface Props {
knowledgeContentResult: KnowledgeContentResultItem[] knowledgeContentResult: KnowledgeContentResultItem[]
to: string | HTMLElement
} }
defineProps<Props>() defineProps<Props>()
...@@ -20,8 +21,8 @@ const isShowDrawer = defineModel<boolean>('isShowDrawer', { required: true }) ...@@ -20,8 +21,8 @@ const isShowDrawer = defineModel<boolean>('isShowDrawer', { required: true })
:show-mask="'transparent'" :show-mask="'transparent'"
:trap-focus="false" :trap-focus="false"
:block-scroll="false" :block-scroll="false"
:to="to"
class="shadow-[0_0_20px_rgba(0,4,65,0.07)]! rounded-[10px]!" class="shadow-[0_0_20px_rgba(0,4,65,0.07)]! rounded-[10px]!"
to="#agent-config-target"
> >
<n-drawer-content <n-drawer-content
:title="t('personal_space_module.agent_module.agent_setting_module.agent_config_module.back_chunk_content')" :title="t('personal_space_module.agent_module.agent_setting_module.agent_config_module.back_chunk_content')"
......
...@@ -104,6 +104,7 @@ function handleShowKnowledgeResult(knowledgeContentResult: KnowledgeContentResul ...@@ -104,6 +104,7 @@ function handleShowKnowledgeResult(knowledgeContentResult: KnowledgeContentResul
<HitKnowledge <HitKnowledge
v-model:is-show-drawer="isShowKnowledgeContent" v-model:is-show-drawer="isShowKnowledgeContent"
:knowledge-content-result="currentKnowledgeContentResult!" :knowledge-content-result="currentKnowledgeContentResult!"
:to="'#agent-config-target'"
/> />
</main> </main>
</template> </template>
......
...@@ -288,6 +288,13 @@ function handleMessageSend(lastQuestionContent?: string) { ...@@ -288,6 +288,13 @@ function handleMessageSend(lastQuestionContent?: string) {
emit('updatePageScroll') emit('updatePageScroll')
} }
// 知识库
if (data.knowledgeContentResult) {
emit('updateSpecifyMessageItem', latestAssistantMessageKey, {
knowledgeContentResult: data.knowledgeContentResult,
})
}
// 数据库 // 数据库
if (data.dbChainResult && data.dbChainResult?.[0]) { if (data.dbChainResult && data.dbChainResult?.[0]) {
emit('updateSpecifyMessageItem', latestAssistantMessageKey, { emit('updateSpecifyMessageItem', latestAssistantMessageKey, {
......
...@@ -28,6 +28,7 @@ const props = defineProps<Props>() ...@@ -28,6 +28,7 @@ const props = defineProps<Props>()
const emit = defineEmits<{ const emit = defineEmits<{
audioPlay: [] audioPlay: []
audioPause: [] audioPause: []
showKnowledgeResult: []
}>() }>()
const userStore = useUserStore() const userStore = useUserStore()
...@@ -299,7 +300,14 @@ const handleContentCopy = throttle( ...@@ -299,7 +300,14 @@ const handleContentCopy = throttle(
<!-- pc端展示操作 --> <!-- pc端展示操作 -->
<div v-show="!isMobile" class="flex w-full items-center justify-between"> <div v-show="!isMobile" class="flex w-full items-center justify-between">
<div></div> <div
v-show="isAgentMessage && messageItem.knowledgeContentResult.length"
class="flex-center rounded-theme h-8 cursor-pointer gap-[5px] px-[13px] font-['Microsoft_YaHei_UI'] text-[#0B7DFF] hover:opacity-80"
@click="emit('showKnowledgeResult')"
>
<i class="iconfont icon-knowledge" />
<span>{{ t('common_module.knowledge') }}</span>
</div>
<div <div
v-show="isAgentMessage && messageItem.textContent && !messageItem.isAnswerResponseLoading" v-show="isAgentMessage && messageItem.textContent && !messageItem.isAnswerResponseLoading"
......
<script setup lang="ts"> <script setup lang="ts">
import { computed, nextTick, provide, useTemplateRef, watch } from 'vue' import { computed, nextTick, provide, ref, useTemplateRef, watch } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useElementVisibility } from '@vueuse/core' import { useElementVisibility } from '@vueuse/core'
import MessageItem from './message-item.vue' import MessageItem from './message-item.vue'
...@@ -7,6 +7,7 @@ import ContinueQuestion from './continue-question.vue' ...@@ -7,6 +7,7 @@ import ContinueQuestion from './continue-question.vue'
import { useScroll } from '@/composables/useScroll' import { useScroll } from '@/composables/useScroll'
import { PersonalAppConfigState } from '@/store/types/personal-app-config' import { PersonalAppConfigState } from '@/store/types/personal-app-config'
import { useLayoutConfig } from '@/composables/useLayoutConfig' import { useLayoutConfig } from '@/composables/useLayoutConfig'
import HitKnowledge from '@/views/personal-space/personal-app-setting/components/agent-config/agent-preview/components/hit-knowledge.vue'
interface Props { interface Props {
messageList: Map<string, ConversationMessageItem> messageList: Map<string, ConversationMessageItem>
...@@ -40,6 +41,9 @@ provide('updateSpecifyMessageItem', { ...@@ -40,6 +41,9 @@ provide('updateSpecifyMessageItem', {
}, },
}) })
const isShowKnowledgeContent = ref(false)
const currentKnowledgeContentResult = ref<KnowledgeContentResultItem[]>([])
const isShowContinueQuestion = computed(() => { const isShowContinueQuestion = computed(() => {
return ( return (
props.continuousQuestionStatus === 'default' && props.continuousQuestionStatus === 'default' &&
...@@ -70,6 +74,11 @@ function handleScrollToBottom() { ...@@ -70,6 +74,11 @@ function handleScrollToBottom() {
isNotShowBackBottomBtn.value && scrollToBottom() isNotShowBackBottomBtn.value && scrollToBottom()
}) })
} }
function handleShowKnowledgeResult(knowledgeContentResult: KnowledgeContentResultItem[]) {
isShowKnowledgeContent.value = true
currentKnowledgeContentResult.value = knowledgeContentResult
}
</script> </script>
<template> <template>
...@@ -83,6 +92,7 @@ function handleScrollToBottom() { ...@@ -83,6 +92,7 @@ function handleScrollToBottom() {
:agent-application-config="agentApplicationConfig" :agent-application-config="agentApplicationConfig"
@audio-play="() => $emit('audioPlay', messageItem)" @audio-play="() => $emit('audioPlay', messageItem)"
@audio-pause="() => $emit('audioPause')" @audio-pause="() => $emit('audioPause')"
@show-knowledge-result="handleShowKnowledgeResult(messageItem.knowledgeContentResult)"
/> />
<p v-show="isMobile && isAnswerResponseLoading" class="ml-1 mt-[7px] text-xs text-[#84868c]"> <p v-show="isMobile && isAnswerResponseLoading" class="ml-1 mt-[7px] text-xs text-[#84868c]">
...@@ -105,6 +115,12 @@ function handleScrollToBottom() { ...@@ -105,6 +115,12 @@ function handleScrollToBottom() {
<i class="iconfont icon-huidaodibu text-sm" /> <i class="iconfont icon-huidaodibu text-sm" />
</div> </div>
</Transition> </Transition>
<HitKnowledge
v-model:is-show-drawer="isShowKnowledgeContent"
:knowledge-content-result="currentKnowledgeContentResult!"
:to="'#share-agent-web-container'"
/>
</main> </main>
</template> </template>
......
...@@ -336,7 +336,7 @@ function onSmartFormsStatusFreezeCheck(smartFormType: SmartFormTypes) { ...@@ -336,7 +336,7 @@ function onSmartFormsStatusFreezeCheck(smartFormType: SmartFormTypes) {
@to-create-application="handleCreateApplicationPage" @to-create-application="handleCreateApplicationPage"
/> />
<div class="h-[calc(100%-68px)] w-full bg-[#f2f5f9]"> <div id="share-agent-web-container" class="relative h-[calc(100%-68px)] w-full overflow-hidden bg-[#f2f5f9]">
<div class="relative mx-auto flex h-full w-[1000px] flex-col overflow-hidden"> <div class="relative mx-auto flex h-full w-[1000px] flex-col overflow-hidden">
<div v-show="isEnableVoice" class="absolute right-10 top-7 flex select-none items-center gap-2"> <div v-show="isEnableVoice" class="absolute right-10 top-7 flex select-none items-center gap-2">
<span>{{ t('common_module.voice_auto_play') }}</span> <span>{{ t('common_module.voice_auto_play') }}</span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment