diff --git a/src/components/assistant/util.ts b/src/components/assistant/util.ts index 2c1ab63a..fa9afd0f 100644 --- a/src/components/assistant/util.ts +++ b/src/components/assistant/util.ts @@ -397,7 +397,9 @@ export async function generateImage(options: { const response = await fetch('/bizyair/model/images', { method: 'POST', headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + Authorization: Cookies.get('bizy_token') || '', + ...(options as any)?.headers }, body: JSON.stringify({ prompt: prompt, diff --git a/src/components/community/detail/Index.vue b/src/components/community/detail/Index.vue index 50a6cbb3..2ff5fc84 100644 --- a/src/components/community/detail/Index.vue +++ b/src/components/community/detail/Index.vue @@ -58,6 +58,14 @@ const showAllTags = ref(false) + // 添加视频检测函数 + const isVideoUrl = (url: string) => { + if (!url) return false + const videoExtensions = ['.mp4', '.webm', '.ogg', '.mov', '.avi', '.mkv'] + const lowercaseUrl = url.toLowerCase() + return videoExtensions.some(ext => lowercaseUrl.includes(ext)) + } + const fetchModelDetail = async () => { try { const res = await model_detail({ @@ -821,15 +829,30 @@ class="flex flex-col gap-4 items-start justify-start relative min-w-[620px] w-[65%] overflow-hidden" >
- - - +
+
+ +
+
- import { Model } from '@/types/model' + // import { Model } from '@/types/model' import vDefaultPic from '@/components/modules/vDefaultPic.vue' import vTooltips from '@/components/modules/v-tooltip.vue' import { sliceString, formatNumber } from '@/utils/tool' @@ -18,24 +18,16 @@ const showDialog = ref(false) const imgSrc = ref('') const tagsStore = useDictStore() - const props = defineProps({ - model: { - type: Object as () => Model | null, - default: null - }, - loading: { - type: Boolean, - default: false - }, - imageLoaded: { - type: Boolean, - default: false - } - }) + const props = defineProps<{ + model?: any + imageLoaded?: boolean + loading?: boolean + }>() const emit = defineEmits(['action', 'image-load', 'image-error']) - // 计算工作流或节点的提示文本 + const isHovering = ref(false) + const actionTooltipText = computed(() => { return props.model?.type === 'Workflow' ? t('community.modelCard.tooltips.loadWorkflow') @@ -94,6 +86,41 @@ imgSrc.value = url.includes('?') ? `${url}&t=${timestamp}` : `${url}?t=${timestamp}` } }) + + const isVideo = computed(() => { + if (!imgSrc.value) return false + const videoExtensions = ['.mp4', '.webm', '.ogg', '.mov', '.avi', '.mkv'] + const url = imgSrc.value.toLowerCase() + return videoExtensions.some(ext => url.includes(ext)) + }) + + const getVideoThumbnail = (videoUrl: string) => { + if (videoUrl.includes('x-oss-process=video/snapshot')) { + return videoUrl + } + const separator = videoUrl.includes('?') ? '&' : '?' + return `${videoUrl}${separator}x-oss-process=video/snapshot,t_0000,f_jpg,w_300,h_600` + } + + const currentMediaSrc = computed(() => { + if (!imgSrc.value) return '' + if (isVideo.value) { + return isHovering.value ? imgSrc.value : getVideoThumbnail(imgSrc.value) + } + return imgSrc.value + }) + + const handleMouseEnter = () => { + if (isVideo.value) { + isHovering.value = true + } + } + + const handleMouseLeave = () => { + if (isVideo.value) { + isHovering.value = false + } + }