mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: Knowledge source redirection failed
This commit is contained in:
parent
afaf3d6e26
commit
51a29a997b
|
|
@ -21,11 +21,7 @@
|
|||
</div>
|
||||
<div class="ml-8" v-else>
|
||||
<a
|
||||
:href="
|
||||
item.source_url && !item.source_url.endsWith('/')
|
||||
? item.source_url + '/'
|
||||
: item.source_url
|
||||
"
|
||||
:href="getNormalizedUrl(item?.source_url)"
|
||||
target="_blank"
|
||||
class="ellipsis"
|
||||
:title="item?.document_name?.trim()"
|
||||
|
|
@ -43,7 +39,9 @@
|
|||
|
||||
<div class="border-t color-secondary flex-between mt-12" style="padding-top: 12px">
|
||||
<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>
|
||||
</div>
|
||||
<el-button
|
||||
|
|
@ -66,7 +64,7 @@ import { computed, ref } from 'vue'
|
|||
import ParagraphSourceDialog from './ParagraphSourceDialog.vue'
|
||||
import ExecutionDetailDialog from './ExecutionDetailDialog.vue'
|
||||
import { isWorkFlow } from '@/utils/application'
|
||||
import { getImgUrl } from '@/utils/utils'
|
||||
import { getImgUrl, getNormalizedUrl } from '@/utils/utils'
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
|
|
|
|||
|
|
@ -22,11 +22,7 @@
|
|||
|
||||
<template v-if="meta?.source_url">
|
||||
<a
|
||||
:href="
|
||||
meta?.source_url && !meta?.source_url.endsWith('/')
|
||||
? meta?.source_url + '/'
|
||||
: meta?.source_url
|
||||
"
|
||||
:href="getNormalizedUrl(meta?.source_url)"
|
||||
target="_blank"
|
||||
class="ellipsis-1 break-all"
|
||||
:title="data?.document_name?.trim()"
|
||||
|
|
@ -54,7 +50,7 @@
|
|||
</CardBox>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { getImgUrl } from '@/utils/utils'
|
||||
import { getImgUrl, getNormalizedUrl } from '@/utils/utils'
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
|
|
@ -94,6 +90,7 @@ const meta = computed(() => (isMetaObject.value ? props.data.meta : parsedMeta.v
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.paragraph-source-card-height {
|
||||
height: 260px;
|
||||
}
|
||||
|
|
@ -105,6 +102,7 @@ const meta = computed(() => (isMetaObject.value ? props.data.meta : parsedMeta.v
|
|||
.paragraph-source-card {
|
||||
.footer-content {
|
||||
display: block;
|
||||
|
||||
.item {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,3 +106,10 @@ export function cutFilename(filename: string, num: number) {
|
|||
const suffix = lastIndex === -1 ? '' : filename.substring(lastIndex + 1)
|
||||
return filename.substring(0, num - suffix.length - 1) + '.' + suffix
|
||||
}
|
||||
|
||||
export function getNormalizedUrl(url: string) {
|
||||
if (url && !url.endsWith('/') && !/\.[^/]+$/.test(url)) {
|
||||
return url + '/'
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue