fix(ocr): move ProviderSettings component outside main component

Extract ProviderSettings component to fix react-hooks error
This commit is contained in:
icarus 2025-10-14 16:16:46 +08:00
parent c08a570c27
commit f4a6dd91cf

View File

@ -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