142 lines
3.9 KiB
TypeScript
142 lines
3.9 KiB
TypeScript
import { IPC_EVENTS } from '@common/constants'
|
|
|
|
declare global {
|
|
// 定义每个通道的参数和返回值类型
|
|
interface IPCTypings {
|
|
// 同步通信
|
|
[IPC_EVENTS.APP_MINIMIZE]: {
|
|
params: [window:number]
|
|
return: {success: boolean, error?: string}
|
|
}
|
|
[IPC_EVENTS.APP_MAXIMIZE]: {
|
|
params: [window:number]
|
|
return: {success: boolean, error?: string}
|
|
}
|
|
[IPC_EVENTS.GET_WINDOW_ID]: {
|
|
params: []
|
|
return: number
|
|
}
|
|
|
|
// 异步通信
|
|
[IPC_EVENTS.FILE_READ]: {
|
|
params: [filePath: string]
|
|
return: Promise<{success: boolean, data?: string, error?: string}>
|
|
}
|
|
[IPC_EVENTS.FILE_WRITE]: {
|
|
params: [filePath: string, content: string]
|
|
return: Promise<{success: boolean, error?: string}>
|
|
}
|
|
|
|
// 事件通信
|
|
[IPC_EVENTS.TIME_UPDATE]: {
|
|
params: [time: string]
|
|
return: void
|
|
}
|
|
[IPC_EVENTS.CUSTOM_EVENT]: {
|
|
params: [message: string]
|
|
return: void
|
|
}
|
|
}
|
|
|
|
// 定义IPC API 接口
|
|
interface WindowApi {
|
|
invoke<T extends keyof IPCTypings>(channel: T, ...args: IPCTypings[T]['params']): IPCTypings[T]['return'],
|
|
invokeAsync<T extends keyof IPCTypings>(channel: T, ...args: IPCTypings[T]['params']): IPCTypings[T]['return'],
|
|
on<T extends keyof IPCTypings>(channel: T, callback: (...args: IPCTypings[T]['params']) => void): () => void
|
|
send<T extends keyof IPCTypings>(channel: T, ...args: IPCTypings[T]['params']): void,
|
|
getCurrentWindowId(): number,
|
|
versions: NodeJS.ProcessVersions,
|
|
external: {
|
|
open: (url: string) => void
|
|
},
|
|
minimizeWindow: () => void,
|
|
maximizeWindow: () => void,
|
|
closeWindow: () => void,
|
|
onWindowMaximized: (callback: (isMaximized: boolean) => void) => void,
|
|
isWindowMaximized: () => Promise<boolean>,
|
|
viewIsReady: () => void
|
|
app: {
|
|
setFrameless: (route?: string) => void
|
|
},
|
|
tabs: {
|
|
create: (url?: string) => void,
|
|
list: () => void,
|
|
navigate: (tabId: string, url: string) => void,
|
|
reload: (tabId: string) => void,
|
|
back: (tabId: string) => void,
|
|
forward: (tabId: string) => void,
|
|
switch: (tabId: string) => void,
|
|
close: (tabId: string) => void,
|
|
on: (event: 'tab-updated' | 'tab-created' | 'tab-closed' | 'tab-switched', handler: (payload: any) => void) => void
|
|
},
|
|
readFile: (filePath: string) => Promise<{success: boolean, data?: string, error?: string}>,
|
|
logger: {
|
|
debug: (message: string, ...meta?: any[]) => void;
|
|
info: (message: string, ...meta?: any[]) => void;
|
|
warn: (message: string, ...meta?: any[]) => void;
|
|
error: (message: string, ...meta?: any[]) => void;
|
|
},
|
|
}
|
|
|
|
declare interface Window {
|
|
api: WindowApi;
|
|
}
|
|
|
|
type ThemeMode = 'dark' | 'light' | 'system';
|
|
|
|
// 弹窗类型定义
|
|
interface CreateDialogProps {
|
|
winId?: string;
|
|
title?: string;
|
|
content: string;
|
|
confirmText?: string;
|
|
cancelText?: string;
|
|
isModal?: boolean;
|
|
onConfirm?: () => void;
|
|
onCancel?: () => void;
|
|
}
|
|
|
|
interface CreateDialogueProps {
|
|
messages: DialogueMessageProps[];
|
|
providerName: string;
|
|
selectedModel: string;
|
|
messageId: number;
|
|
conversationId: number;
|
|
}
|
|
|
|
interface UniversalChunk {
|
|
isEnd: boolean;
|
|
result: string;
|
|
}
|
|
|
|
interface DialogueBackStream {
|
|
messageId: number;
|
|
data: UniversalChunk & { isError?: boolean };
|
|
}
|
|
|
|
interface DialogueMessageProps {
|
|
role: DialogueMessageRole;
|
|
content: string;
|
|
}
|
|
}
|
|
|
|
declare module "@store/*";
|
|
declare module "@modules/*";
|
|
declare module "@utils/*";
|
|
declare module "@assets/images/*";
|
|
declare module "@constant/*";
|
|
declare module "@remixicon/vue";
|
|
declare module "vue-router";
|
|
declare module '@iconify/vue' {
|
|
import { DefineComponent } from 'vue'
|
|
export const Icon: DefineComponent<{
|
|
icon: string
|
|
width?: string | number
|
|
height?: string | number
|
|
color?: string
|
|
flip?: string
|
|
rotate?: number
|
|
}>
|
|
}
|
|
|