mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 10:12:51 +00:00
feat: 对话,图片404 闪屏问题
This commit is contained in:
parent
a7704c3a8a
commit
1ecce3bc84
|
|
@ -63,7 +63,7 @@
|
|||
</div>
|
||||
|
||||
<el-card v-else shadow="always" class="dialog-card">
|
||||
<MdPreview ref="editorRef" editorId="preview-only" :modelValue="item.answer_text" />
|
||||
<MdRenderer :source="item.answer_text"></MdRenderer>
|
||||
</el-card>
|
||||
<div class="flex-between mt-8" v-if="log">
|
||||
<LogOperationButton :data="item" :applicationId="appId" />
|
||||
|
|
@ -136,7 +136,7 @@ import { ChatManagement, type chatType } from '@/api/type/application'
|
|||
import { randomId } from '@/utils/utils'
|
||||
import useStore from '@/stores'
|
||||
import { MdPreview } from 'md-editor-v3'
|
||||
|
||||
import MdRenderer from '@/components/markdown-renderer/MdRenderer.vue'
|
||||
defineOptions({ name: 'AiChat' })
|
||||
const route = useRoute()
|
||||
const {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
<template>
|
||||
<MdPreview
|
||||
ref="editorRef"
|
||||
editorId="preview-only"
|
||||
:modelValue="item"
|
||||
v-for="item in md_view_list"
|
||||
/>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { MdPreview } from 'md-editor-v3'
|
||||
|
||||
const props = withDefaults(defineProps<{ source?: string; inner_suffix?: boolean }>(), {
|
||||
source: ''
|
||||
})
|
||||
|
||||
const md_view_list = computed(() => {
|
||||
const temp_source = props.source
|
||||
const temp_md_img_list = temp_source.match(/(!\[.*?\]\(img\/.*?\){.*?})|(!\[.*?\]\(img\/.*?\))/g)
|
||||
const md_img_list = temp_md_img_list ? temp_md_img_list.filter((i) => i) : []
|
||||
const split_img_value = temp_source
|
||||
.split(/(!\[.*?\]\(img\/.*?\){.*?})|(!\[.*?\]\(img\/.*?\))/g)
|
||||
.filter((item) => item !== undefined)
|
||||
.filter((item) => !md_img_list?.includes(item))
|
||||
const result = Array.from(
|
||||
{ length: md_img_list.length + split_img_value.length },
|
||||
(v, i) => i
|
||||
).map((index) => {
|
||||
if (index % 2 == 0) {
|
||||
return split_img_value[Math.floor(index / 2)]
|
||||
} else {
|
||||
return md_img_list[Math.floor(index / 2)]
|
||||
}
|
||||
})
|
||||
return result
|
||||
})
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
Loading…
Reference in New Issue