CSAPP/src/types/electron.d.ts

63 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { ApiResponse, MenuItem, TagResolutionConfig } from '../EIAC_Desktop_Api';
export interface ElectronAPI {
/**
* 获取菜单缓存
* @returns 菜单缓存
*/
getMenuCacheAsync: () => Promise<ApiResponse<MenuItem[]>>;
/**
* 获取配置缓存
* @returns 配置缓存
*/
getConfigCacheAsync: () => Promise<ApiResponse<TagResolutionConfig[]>>;
/**
* 在新标签页打开URL
* @param callback 回调函数参数为webContentId和url。其中webContentId是请求打开URL的webview的id。
*/
onOpenTab: (callback: (webContentId: number, url: string) => void) => void;
/**
* 获取当前屏幕的缩放比例和分辨率
* @returns 缩放比例和分辨率
*/
getPrimaryDisplay: () => Promise<Electron.Display>;
/**
* 检查URL是否可用
* @param url 要检查的URL
* @returns 是否可用
*/
checkUrlAvailable: (url: string) => Promise<{ ok: boolean; status: number; message?: string }>;
/**
* 设置webview的cookie
* @param url 要设置cookie的URL
* @param cookie cookie字符串
*/
setWebviewCookie: (url: string, cookie: string) => Promise<boolean>;
/**
* 按键将值设置到sessionStorage
* @param key 键
* @param value 值
*/
setSessionStorage: (key: string, value: string) => void;
/**
* 从sessionStorage中获取指定键的值
* @param key 键
* @returns 值
*/
getSessionStorage: (key: string) => string | null;
/**
* 从sessionStorage中删除指定键的值
* @param key 键
*/
removeSessionStorage: (key: string) => void;
/**
* 清空sessionStorage
*/
clearSessionStorage: () => void;
}
declare global {
interface Window {
electronAPI: ElectronAPI;
}
}