mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-05 20:41:30 +08:00
fix: remove youtube render (#9920)
This commit is contained in:
parent
e9db53c973
commit
e3e8783eb8
@ -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",
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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()
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user