mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-29 23:12:38 +08:00
refactor(OCR设置): 添加错误边界处理并移除无用注释
在OCR设置组件中添加ErrorBoundary以处理潜在错误 移除OcrTesseractSettings中的TODO注释
This commit is contained in:
parent
0569d146f4
commit
6215dd378e
@ -1,4 +1,5 @@
|
||||
// import { loggerService } from '@logger'
|
||||
import { ErrorBoundary } from '@renderer/components/ErrorBoundary'
|
||||
import { isBuiltinOcrProvider, OcrProvider } from '@renderer/types'
|
||||
import { getOcrProviderLogo } from '@renderer/utils/ocr'
|
||||
import { Avatar, Divider, Flex } from 'antd'
|
||||
@ -35,7 +36,7 @@ const OcrProviderSettings = ({ provider }: Props) => {
|
||||
</Flex>
|
||||
</SettingTitle>
|
||||
<Divider style={{ width: '100%', margin: '10px 0' }} />
|
||||
{getProviderSettings()}
|
||||
<ErrorBoundary>{getProviderSettings()}</ErrorBoundary>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { PictureOutlined } from '@ant-design/icons'
|
||||
import { ErrorBoundary } from '@renderer/components/ErrorBoundary'
|
||||
import { useTheme } from '@renderer/context/ThemeProvider'
|
||||
import { useAppSelector } from '@renderer/store'
|
||||
import { OcrProvider } from '@renderer/types'
|
||||
@ -26,7 +27,7 @@ const OcrSettings: FC = () => {
|
||||
]
|
||||
|
||||
return (
|
||||
<>
|
||||
<ErrorBoundary>
|
||||
<SettingGroup theme={themeMode}>
|
||||
<SettingTitle>{t('settings.tool.ocr.title')}</SettingTitle>
|
||||
<SettingDivider />
|
||||
@ -35,7 +36,7 @@ const OcrSettings: FC = () => {
|
||||
<SettingGroup theme={themeMode}>
|
||||
<OcrProviderSettings provider={provider} />
|
||||
</SettingGroup>
|
||||
</>
|
||||
</ErrorBoundary>
|
||||
)
|
||||
}
|
||||
export default OcrSettings
|
||||
|
||||
@ -13,7 +13,6 @@ export const OcrTesseractSettings = () => {
|
||||
const { t } = useTranslation()
|
||||
const { provider } = useOcrProvider(BuiltinOcrProviderIds.tesseract)
|
||||
|
||||
// TODO: use error boundary
|
||||
if (!isOcrTesseractProvider(provider)) {
|
||||
throw new Error('Not tesseract provider.')
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user