feat: 新增脚本录制功能
This commit is contained in:
46
global.d.ts
vendored
46
global.d.ts
vendored
@@ -1,4 +1,5 @@
|
||||
import { IPC_EVENTS } from '@lib/constants'
|
||||
import type { AutomationScript, ScriptSaveInput, ScriptExecutionResult } from '@lib/script-types'
|
||||
|
||||
declare global {
|
||||
// 定义每个通道的参数和返回值类型
|
||||
@@ -53,6 +54,40 @@ declare global {
|
||||
params: []
|
||||
return: Promise<ThemeMode>
|
||||
}
|
||||
|
||||
// 脚本管理
|
||||
[IPC_EVENTS.SCRIPT_LIST]: {
|
||||
params: []
|
||||
return: Promise<AutomationScript[]>
|
||||
}
|
||||
[IPC_EVENTS.SCRIPT_GET]: {
|
||||
params: [id: string]
|
||||
return: Promise<AutomationScript | null>
|
||||
}
|
||||
[IPC_EVENTS.SCRIPT_SAVE]: {
|
||||
params: [input: ScriptSaveInput]
|
||||
return: Promise<AutomationScript>
|
||||
}
|
||||
[IPC_EVENTS.SCRIPT_DELETE]: {
|
||||
params: [id: string]
|
||||
return: Promise<boolean>
|
||||
}
|
||||
[IPC_EVENTS.SCRIPT_TOGGLE]: {
|
||||
params: [id: string, enabled: boolean]
|
||||
return: Promise<boolean>
|
||||
}
|
||||
[IPC_EVENTS.SCRIPT_RUN]: {
|
||||
params: [id: string]
|
||||
return: Promise<ScriptExecutionResult>
|
||||
}
|
||||
[IPC_EVENTS.SCRIPT_RECORD_START]: {
|
||||
params: [url?: string]
|
||||
return: Promise<{ success: boolean; code?: string; error?: string }>
|
||||
}
|
||||
[IPC_EVENTS.SCRIPT_RECORD_STOP]: {
|
||||
params: []
|
||||
return: Promise<{ success: boolean; code?: string; error?: string }>
|
||||
}
|
||||
}
|
||||
|
||||
type TabId = string
|
||||
@@ -97,6 +132,17 @@ declare global {
|
||||
executeScript: (options: any) => Promise<{success: boolean, error?: string}>,
|
||||
// 打开渠道
|
||||
openChannel: (channels: any) => Promise<{success: boolean, error?: string}>,
|
||||
// 脚本管理
|
||||
scriptApi: {
|
||||
list: () => Promise<AutomationScript[]>,
|
||||
get: (id: string) => Promise<AutomationScript | null>,
|
||||
save: (input: ScriptSaveInput) => Promise<AutomationScript>,
|
||||
delete: (id: string) => Promise<boolean>,
|
||||
toggle: (id: string, enabled: boolean) => Promise<boolean>,
|
||||
run: (id: string) => Promise<ScriptExecutionResult>,
|
||||
startRecording: (url?: string) => Promise<{ success: boolean; code?: string; error?: string }>,
|
||||
stopRecording: () => Promise<{ success: boolean; code?: string; error?: string }>,
|
||||
},
|
||||
}
|
||||
|
||||
interface Window {
|
||||
|
||||
Reference in New Issue
Block a user