更新 Electron API 类型声明,添加身份证监听相关方法,并修改 Window 接口以确保 electronAPI 不可选

This commit is contained in:
yuchenglong
2025-11-21 09:19:57 +08:00
parent 11dcc4c21a
commit 196669c013
2 changed files with 10 additions and 14 deletions

13
src/electron.d.ts vendored
View File

@@ -1,10 +1,17 @@
// Electron API 类型声明
interface ElectronAPI {
fetchPdf: (pdfUrl: string) => Promise<{ success: boolean; data?: string; error?: string }>;
fetchPdf: (
pdfUrl: string
) => Promise<{ success: boolean; data?: string; error?: string }>;
printPdf: (pdfUrl: string) => Promise<{ success: boolean; error?: string }>;
startIdCardListen: () => Promise<any>;
stopIdCardListen: () => Promise<any>;
onIdCardData: (callback: (data: any) => void) => void;
onIdCardError: (callback: (error: any) => void) => void;
log: (level: string, message: any) => void;
removeIdCardListeners: () => void;
}
interface Window {
electronAPI?: ElectronAPI;
electronAPI: ElectronAPI;
}

11
src/vite-env.d.ts vendored
View File

@@ -1,12 +1 @@
/// <reference types="vite/client" />
interface Window {
electronAPI: {
startIdCardListen: () => Promise<any>;
stopIdCardListen: () => Promise<any>;
onIdCardData: (callback: (data: any) => void) => void;
onIdCardError: (callback: (error: any) => void) => void;
log: (level: string, message: any) => void;
removeIdCardListeners: () => void;
};
}