feat: 新增 Provider 抽象系统支持插件提供翻译和 OCR 能力#560
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new 'Provider' abstraction to ZTools, allowing translation and OCR capabilities to be provided by plugins and managed centrally. It includes a new 'Providers' settings page, a ProviderManager to aggregate built-in and plugin providers, and exposed APIs for other plugins to consume these services. Feedback on the changes suggests correcting a documentation typo regarding translation.image, adding error logging to a silent catch block in the settings UI, and replacing an any type with a concrete type in the TypeScript definitions for better type safety.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| | `translation` | 文本翻译 | `{ text, from?, to? }` | `{ text, detectedFrom? }` | | ||
| | `ocr` | 图片文字识别 | `{ image, lang? }` | `{ text, blocks?, confidence? }` | | ||
|
|
||
| - `translation.image` / `ocr.image` 可为:本地路径 / `data:` URI / `http(s)` URL(具体支持取决于实现)。 |
There was a problem hiding this comment.
| } catch { | ||
| providerTypes.value = [] | ||
| } |
| setParams: ( | ||
| providerId: string, | ||
| params: Record<string, unknown> | ||
| ) => Promise<{ success: boolean; data?: any; error?: string }> |
There was a problem hiding this comment.
为了增强类型安全和代码可读性,建议为 setParams 方法返回的 data 提供一个具体的类型,而不是使用 any。可以参考 getSettings 等方法的返回类型,保持一致性。
| ) => Promise<{ success: boolean; data?: any; error?: string }> | |
| ) => Promise<{ success: boolean; data?: { enabled: Partial<Record<'translation' | 'ocr', string[]>>; defaultId: Partial<Record<'translation' | 'ocr', string>>; params: Record<string, Record<string, unknown>>; }; error?: string }> |
|
部分功能还不够稳定,再等我看看迭代一下 |
变更概要: