feat: add screenshot OCR extraction

This commit is contained in:
2026-07-08 00:42:49 +08:00
parent 18a9f53062
commit 273af6a429
14 changed files with 1407 additions and 46 deletions
+4
View File
@@ -17,6 +17,10 @@ export function CopyNativeRegionImage(arg1:main.CaptureResult):Promise<void>;
export function CopyRegionImage(arg1:main.CaptureResult):Promise<void>;
export function ExtractTextNativeRegion(arg1:main.CaptureResult):Promise<void>;
export function ExtractTextRegion(arg1:main.CaptureResult):Promise<void>;
export function GetConfig():Promise<domain.AppConfig>;
export function QuitApp():Promise<void>;
+8
View File
@@ -30,6 +30,14 @@ export function CopyRegionImage(arg1) {
return window['go']['main']['App']['CopyRegionImage'](arg1);
}
export function ExtractTextNativeRegion(arg1) {
return window['go']['main']['App']['ExtractTextNativeRegion'](arg1);
}
export function ExtractTextRegion(arg1) {
return window['go']['main']['App']['ExtractTextRegion'](arg1);
}
export function GetConfig() {
return window['go']['main']['App']['GetConfig']();
}
+93 -30
View File
@@ -1,13 +1,13 @@
export namespace application {
export class Point {
x: number;
y: number;
static createFrom(source: any = {}) {
return new Point(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.x = source["x"];
@@ -25,7 +25,7 @@ export namespace application {
static createFrom(source: any = {}) {
return new Annotation(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.tool = source["tool"];
@@ -35,7 +35,7 @@ export namespace application {
this.strokeWidth = source["strokeWidth"];
this.fontSize = source["fontSize"];
}
convertValues(a: any, classs: any, asMap: boolean = false): any {
if (!a) {
return a;
@@ -58,7 +58,67 @@ export namespace application {
}
export namespace domain {
export class OCRProviderConfig {
label: string;
endpoint: string;
accessKeyId: string;
accessKeySecret: string;
region: string;
service: string;
action: string;
version: string;
timeoutSecs: number;
static createFrom(source: any = {}) {
return new OCRProviderConfig(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.label = source["label"];
this.endpoint = source["endpoint"];
this.accessKeyId = source["accessKeyId"];
this.accessKeySecret = source["accessKeySecret"];
this.region = source["region"];
this.service = source["service"];
this.action = source["action"];
this.version = source["version"];
this.timeoutSecs = source["timeoutSecs"];
}
}
export class OCRConfig {
activeProvider: string;
providers: Record<string, OCRProviderConfig>;
static createFrom(source: any = {}) {
return new OCRConfig(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.activeProvider = source["activeProvider"];
this.providers = this.convertValues(source["providers"], OCRProviderConfig, true);
}
convertValues(a: any, classs: any, asMap: boolean = false): any {
if (!a) {
return a;
}
if (a.slice && a.map) {
return (a as any[]).map(elem => this.convertValues(elem, classs));
} else if ("object" === typeof a) {
if (asMap) {
for (const key of Object.keys(a)) {
a[key] = new classs(a[key]);
}
return a;
}
return new classs(a);
}
return a;
}
}
export class LLMProviderConfig {
label: string;
baseUrl: string;
@@ -68,11 +128,11 @@ export namespace domain {
temperature: number;
timeoutSecs: number;
maxInlineBytes: number;
static createFrom(source: any = {}) {
return new LLMProviderConfig(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.label = source["label"];
@@ -89,18 +149,18 @@ export namespace domain {
activeProvider: string;
prompt: string;
providers: Record<string, LLMProviderConfig>;
static createFrom(source: any = {}) {
return new LLMConfig(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.activeProvider = source["activeProvider"];
this.prompt = source["prompt"];
this.providers = this.convertValues(source["providers"], LLMProviderConfig, true);
}
convertValues(a: any, classs: any, asMap: boolean = false): any {
if (!a) {
return a;
@@ -129,11 +189,11 @@ export namespace domain {
strictHostKey: boolean;
knownHostsPath: string;
connectTimeoutSecs: number;
static createFrom(source: any = {}) {
return new SSHConfig(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.host = source["host"];
@@ -156,11 +216,11 @@ export namespace domain {
pathPrefix: string;
publicUrlBase: string;
usePathStyle: boolean;
static createFrom(source: any = {}) {
return new S3Config(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.endpoint = source["endpoint"];
@@ -179,11 +239,12 @@ export namespace domain {
s3: S3Config;
ssh: SSHConfig;
llm: LLMConfig;
ocr: OCRConfig;
static createFrom(source: any = {}) {
return new AppConfig(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.hotkey = source["hotkey"];
@@ -191,8 +252,9 @@ export namespace domain {
this.s3 = this.convertValues(source["s3"], S3Config);
this.ssh = this.convertValues(source["ssh"], SSHConfig);
this.llm = this.convertValues(source["llm"], LLMConfig);
this.ocr = this.convertValues(source["ocr"], OCRConfig);
}
convertValues(a: any, classs: any, asMap: boolean = false): any {
if (!a) {
return a;
@@ -211,22 +273,24 @@ export namespace domain {
return a;
}
}
}
export namespace main {
export class CaptureActionResult {
completed: boolean;
path?: string;
static createFrom(source: any = {}) {
return new CaptureActionResult(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.completed = source["completed"];
@@ -238,11 +302,11 @@ export namespace main {
y: number;
w: number;
h: number;
static createFrom(source: any = {}) {
return new RegionRect(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.x = source["x"];
@@ -254,17 +318,17 @@ export namespace main {
export class CaptureResult {
rect: RegionRect;
annotations: application.Annotation[];
static createFrom(source: any = {}) {
return new CaptureResult(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.rect = this.convertValues(source["rect"], RegionRect);
this.annotations = this.convertValues(source["annotations"], application.Annotation);
}
convertValues(a: any, classs: any, asMap: boolean = false): any {
if (!a) {
return a;
@@ -285,4 +349,3 @@ export namespace main {
}
}