fix: remove youtube render (#9920)

This commit is contained in:
Chen Tao 2025-09-05 11:15:26 +08:00 committed by GitHub
parent e9db53c973
commit e3e8783eb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 1 additions and 77 deletions

View File

@ -286,7 +286,6 @@
"react-router-dom": "6",
"react-spinners": "^0.14.1",
"react-transition-group": "^4.4.5",
"react-youtube": "^10.1.0",
"redux": "^5.0.1",
"redux-persist": "^6.0.0",
"reflect-metadata": "0.2.2",

View File

@ -153,8 +153,7 @@ export async function addWebLoader(
case 'youtube':
loaderInstance = YoutubeLoader.createFromUrl(url, {
addVideoInfo: true,
transcriptFormat: 'srt',
language: 'zh'
transcriptFormat: 'srt'
})
splitterType = 'srt'
break

View File

@ -3,7 +3,6 @@ import { VideoMessageBlock } from '@renderer/types/newMessage'
import { FC, useRef } from 'react'
import { useTranslation } from 'react-i18next'
import ReactPlayer from 'react-player'
import YouTube, { YouTubeProps } from 'react-youtube'
import styled from 'styled-components'
const logger = loggerService.withContext('MessageVideo')
@ -21,30 +20,6 @@ const MessageVideo: FC<Props> = ({ block }) => {
return null
}
/**
* YouTube
*/
const renderYoutube = () => {
if (!block.url) {
logger.warn('YouTube video was requested but block.url is missing.')
return <div>{t('message.video.error.youtube_url_missing')}</div>
}
const onPlayerReady: YouTubeProps['onReady'] = (event) => {
event.target.pauseVideo()
}
const opts: YouTubeProps['opts'] = {
height: '100%',
width: '100%',
playerVars: {
start: Math.floor(block.metadata?.startTime ?? 0)
}
}
return <YouTube style={{ height: '100%', width: '100%' }} videoId={block.url} opts={opts} onReady={onPlayerReady} />
}
/**
*
*/
@ -79,9 +54,6 @@ const MessageVideo: FC<Props> = ({ block }) => {
const renderVideo = () => {
switch (block.metadata?.type) {
case 'youtube':
return renderYoutube()
case 'video':
return renderLocalVideo()

View File

@ -2,7 +2,6 @@ import { FileMetadata, KnowledgeSearchResult } from '@renderer/types'
import { Typography } from 'antd'
import React, { FC, useRef } from 'react'
import ReactPlayer from 'react-player'
import YouTube, { YouTubeProps } from 'react-youtube'
import styled from 'styled-components'
const { Paragraph } = Typography
@ -28,37 +27,6 @@ const VideoItem: FC<Props> = ({ item, searchKeyword }) => {
const { highlightText } = useHighlightText()
/**
* YouTube
*/
const renderYoutube = () => {
if (!item.metadata.source) {
logger.warn('YouTube video was requested but block.url is missing.')
return <ErrorContainer>{t('knowledge.error.video.youtube_url_missing')}</ErrorContainer>
}
const onPlayerReady: YouTubeProps['onReady'] = (event) => {
event.target.pauseVideo()
}
const opts: YouTubeProps['opts'] = {
height: '100%',
width: '100%',
playerVars: {
start: Math.floor(item.metadata?.startTime ?? 0)
}
}
return (
<YouTube
style={{ height: '100%', width: '100%' }}
videoId={item.metadata.source}
opts={opts}
onReady={onPlayerReady}
/>
)
}
/**
*
*/
@ -93,9 +61,6 @@ const VideoItem: FC<Props> = ({ item, searchKeyword }) => {
const renderVideo = () => {
switch (item.metadata?.type) {
case 'youtube':
return renderYoutube()
case 'video':
return renderLocalVideo()

View File

@ -313,17 +313,6 @@ export function processKnowledgeReferences(
}
switch (metadata.type) {
case 'youtube': {
onChunkReceived({
type: ChunkType.VIDEO_SEARCHED,
video: {
type: 'url',
content: metadata.source
},
metadata
})
break
}
case 'video': {
onChunkReceived({
type: ChunkType.VIDEO_SEARCHED,