UNPKG

@buession/prototype

Version:

A native object extension framework for Javascript.

95 lines (94 loc) 2.04 kB
/** * Window 对象扩展 */ interface Window { /** * 浏览器信息 */ readonly browser: Browser; /** * 剪贴板对象 */ readonly clipboardData: ClipboardData; /** * 将字符串复制到剪贴板 * * @param str 字符串 */ copy(str: string): void; /** * 延时执行 * * @param func 延时执行方法 * @param wait 延时时长(单位:毫秒) * @param args 方法参数 * * @return 方法执行结果 */ delay(func: Function, wait: number, ...args: any): any; } interface Browser { /** * User-Agent */ readonly userAgent: string; /** * 浏览器名称 */ readonly name: string; /** * 浏览器版本 */ readonly version: string; /** * 是否为移动设备 */ readonly isMobile: boolean; } interface Location { search: string; /** * 获取所有的请求参数及值 * * @return 所有的请求参数及值 */ getParameters(): Record<string, any>; /** * 获取指定请求参数的值 * * @param name 参数名 * @return 指定请求参数的值 */ getParameter(name: string): any; } type ClipboardDataFormat = "text" | "url" | "file" | "html" | "image"; declare var Window: { prototype: Window; new (): Window; }; declare var Browser: { prototype: Browser; new (): Browser; }; declare var Location: { prototype: Location; new (): Location; }; interface ClipboardData { /** * 设置粘贴板数据 * * @param format 数据格式 * @param content 数据内容 */ setData(format: ClipboardDataFormat, content: string): void; } declare const isMobile: boolean; declare const isChrome: boolean; declare const isFirefox: boolean; declare const isMozilla: boolean; declare const isEdge: boolean; declare const isMSIE: boolean; declare const isOpera: boolean; declare const isSafari: boolean; declare const isNetscape: boolean;