fix: Knowledge source redirection failed

This commit is contained in:
wxg0103 2025-02-27 15:16:34 +08:00
parent afaf3d6e26
commit 51a29a997b
3 changed files with 16 additions and 13 deletions

View File

@ -21,11 +21,7 @@
</div> </div>
<div class="ml-8" v-else> <div class="ml-8" v-else>
<a <a
:href=" :href="getNormalizedUrl(item?.source_url)"
item.source_url && !item.source_url.endsWith('/')
? item.source_url + '/'
: item.source_url
"
target="_blank" target="_blank"
class="ellipsis" class="ellipsis"
:title="item?.document_name?.trim()" :title="item?.document_name?.trim()"
@ -43,7 +39,9 @@
<div class="border-t color-secondary flex-between mt-12" style="padding-top: 12px"> <div class="border-t color-secondary flex-between mt-12" style="padding-top: 12px">
<div> <div>
<span class="mr-8"> {{ $t('chat.KnowledgeSource.consume') }}: {{ data?.message_tokens + data?.answer_tokens }} </span> <span class="mr-8">
{{ $t('chat.KnowledgeSource.consume') }}: {{ data?.message_tokens + data?.answer_tokens }}
</span>
<span> {{ $t('chat.KnowledgeSource.consumeTime') }}: {{ data?.run_time?.toFixed(2) }} s</span> <span> {{ $t('chat.KnowledgeSource.consumeTime') }}: {{ data?.run_time?.toFixed(2) }} s</span>
</div> </div>
<el-button <el-button
@ -66,7 +64,7 @@ import { computed, ref } from 'vue'
import ParagraphSourceDialog from './ParagraphSourceDialog.vue' import ParagraphSourceDialog from './ParagraphSourceDialog.vue'
import ExecutionDetailDialog from './ExecutionDetailDialog.vue' import ExecutionDetailDialog from './ExecutionDetailDialog.vue'
import { isWorkFlow } from '@/utils/application' import { isWorkFlow } from '@/utils/application'
import { getImgUrl } from '@/utils/utils' import { getImgUrl, getNormalizedUrl } from '@/utils/utils'
const props = defineProps({ const props = defineProps({
data: { data: {
type: Object, type: Object,

View File

@ -22,11 +22,7 @@
<template v-if="meta?.source_url"> <template v-if="meta?.source_url">
<a <a
:href=" :href="getNormalizedUrl(meta?.source_url)"
meta?.source_url && !meta?.source_url.endsWith('/')
? meta?.source_url + '/'
: meta?.source_url
"
target="_blank" target="_blank"
class="ellipsis-1 break-all" class="ellipsis-1 break-all"
:title="data?.document_name?.trim()" :title="data?.document_name?.trim()"
@ -54,7 +50,7 @@
</CardBox> </CardBox>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { getImgUrl } from '@/utils/utils' import { getImgUrl, getNormalizedUrl } from '@/utils/utils'
import { computed } from 'vue' import { computed } from 'vue'
const props = defineProps({ const props = defineProps({
@ -94,6 +90,7 @@ const meta = computed(() => (isMetaObject.value ? props.data.meta : parsedMeta.v
} }
} }
} }
.paragraph-source-card-height { .paragraph-source-card-height {
height: 260px; height: 260px;
} }
@ -105,6 +102,7 @@ const meta = computed(() => (isMetaObject.value ? props.data.meta : parsedMeta.v
.paragraph-source-card { .paragraph-source-card {
.footer-content { .footer-content {
display: block; display: block;
.item { .item {
max-width: 100%; max-width: 100%;
} }

View File

@ -106,3 +106,10 @@ export function cutFilename(filename: string, num: number) {
const suffix = lastIndex === -1 ? '' : filename.substring(lastIndex + 1) const suffix = lastIndex === -1 ? '' : filename.substring(lastIndex + 1)
return filename.substring(0, num - suffix.length - 1) + '.' + suffix return filename.substring(0, num - suffix.length - 1) + '.' + suffix
} }
export function getNormalizedUrl(url: string) {
if (url && !url.endsWith('/') && !/\.[^/]+$/.test(url)) {
return url + '/'
}
return url
}