38 lines
1.3 KiB
Vue
38 lines
1.3 KiB
Vue
<template>
|
|
<Teleport to="body">
|
|
<div v-if="float.visible" class="chat-citation-float" :class="{ 'chat-citation-float--kb': float.type === 'kb' }"
|
|
:style="{ top: `${float.top}px`, left: `${float.left}px` }"
|
|
@mouseenter="onEnter?.()" @mouseleave="onLeave?.()">
|
|
<template v-if="float.type === 'web'">
|
|
<div class="chat-citation-float__title">{{ float.title || float.url }}</div>
|
|
<a v-if="float.url" class="chat-citation-float__link" :href="float.url" target="_blank"
|
|
rel="noopener noreferrer">{{ float.url }}</a>
|
|
</template>
|
|
<template v-else>
|
|
<div class="chat-citation-float__title">{{ float.title }}</div>
|
|
<div v-if="float.loading" class="chat-citation-float__muted">{{ loadingText }}</div>
|
|
<div v-else-if="float.error" class="chat-citation-float__error">{{ float.error }}</div>
|
|
<div v-else class="chat-citation-float__body">{{ float.content }}</div>
|
|
</template>
|
|
</div>
|
|
</Teleport>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { useI18n } from 'vue-i18n'
|
|
import type { CitationFloatState } from '@/composables/useChatCitationPopover'
|
|
|
|
defineProps<{
|
|
float: CitationFloatState
|
|
onEnter?: () => void
|
|
onLeave?: () => void
|
|
}>()
|
|
|
|
const { t } = useI18n()
|
|
const loadingText = t('common.loading')
|
|
</script>
|
|
|
|
<style lang="less">
|
|
@import './css/chat-citations.less';
|
|
</style>
|