mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-05 04:19:02 +08:00
fix(ocr): move ProviderSettings component outside main component
Extract ProviderSettings component to fix react-hooks error
This commit is contained in:
parent
c08a570c27
commit
f4a6dd91cf
@ -26,23 +26,6 @@ const OcrProviderSettings = ({ provider }: Props) => {
|
||||
return null
|
||||
}
|
||||
|
||||
const ProviderSettings = () => {
|
||||
if (isBuiltinOcrProvider(provider)) {
|
||||
switch (provider.id) {
|
||||
case 'tesseract':
|
||||
return <OcrTesseractSettings />
|
||||
case 'system':
|
||||
return <OcrSystemSettings />
|
||||
case 'paddleocr':
|
||||
return <OcrPpocrSettings />
|
||||
default:
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
throw new Error('Not supported OCR provider')
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<SettingGroup theme={themeMode}>
|
||||
<SettingTitle>
|
||||
@ -53,7 +36,7 @@ const OcrProviderSettings = ({ provider }: Props) => {
|
||||
</SettingTitle>
|
||||
<Divider style={{ width: '100%', margin: '10px 0' }} />
|
||||
<ErrorBoundary>
|
||||
<ProviderSettings />
|
||||
<ProviderSettings provider={provider} />
|
||||
</ErrorBoundary>
|
||||
</SettingGroup>
|
||||
)
|
||||
@ -64,4 +47,21 @@ const ProviderName = styled.span`
|
||||
font-weight: 500;
|
||||
`
|
||||
|
||||
const ProviderSettings = ({ provider }: { provider: OcrProvider }) => {
|
||||
if (isBuiltinOcrProvider(provider)) {
|
||||
switch (provider.id) {
|
||||
case 'tesseract':
|
||||
return <OcrTesseractSettings />
|
||||
case 'system':
|
||||
return <OcrSystemSettings />
|
||||
case 'paddleocr':
|
||||
return <OcrPpocrSettings />
|
||||
default:
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
throw new Error('Not supported OCR provider')
|
||||
}
|
||||
}
|
||||
|
||||
export default OcrProviderSettings
|
||||
|
||||
Loading…
Reference in New Issue
Block a user