You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
759 B
27 lines
759 B
// @ts-nocheck window.api 不需要检查
|
|
|
|
import { IApiClient } from "./abstract"
|
|
|
|
export class ElectronApiClient implements IApiClient {
|
|
call<T = any>(command: string, ...args: any[]): Promise<T> {
|
|
// Electron 特定实现
|
|
return window.api.call(command, ...args)
|
|
}
|
|
|
|
callSync<T = any>(command: string, ...args: any[]): Promise<T> {
|
|
// Electron 特定实现
|
|
return window.api.callSync(command, ...args)
|
|
}
|
|
|
|
on<K extends string>(channel: K, callback: (...args: any[]) => void): void {
|
|
window.api.on(channel, callback)
|
|
}
|
|
|
|
off<K extends string>(channel: K, callback: (...args: any[]) => void): void {
|
|
window.api.off(channel, callback)
|
|
}
|
|
|
|
offAll<K extends string>(channel: K): void {
|
|
window.api.offAll(channel)
|
|
}
|
|
}
|
|
|