/** 常用工具方法 */ /** * 数字前置补零 * @param value 值 * @param length 位数 */ export declare function digit(value: number | string, length?: number): string; /** * 时间格式化 * @param time 时间 * @param format 格式 */ export declare function toDateString(time?: number | string | Date, format?: string): string; /** * 时间语义化 * @param time 时间 * @param onlyDate 超过 30 天是否仅返回日期 */ export declare function timeAgo(time: number | string | Date, onlyDate?: boolean): string; /** * parentId 形式数据转 children 形式参数 */ export interface ToTreeDataOption { /** * 数据 */ data?: T[] | null; /** * id 字段名称 */ idField?: string | null; /** * parentId 字段名称 */ parentIdField?: string | null; /** * 生成的 children 字段名称 */ childrenField?: string | null; /** * 最顶级的 parentId 值 */ parentId?: number | string | Array | null; /** * 是否添加包含所有父级 id 的字段 */ addParentIds?: boolean | null; /** * 包含所有父级 id 字段的名称 */ parentIdsField?: string | null; /** * 所有父级的 id */ parentIds?: Array | null; } /** * parentId 形式数据转 children 形式 * @param option ToTreeDataOption */ export declare function toTreeData(option: ToTreeDataOption): T[]; /** * 遍历 children 形式数据 * @param data 需要遍历的数据 * @param callback 回调 * @param childrenField children 字段名 */ export declare function eachTreeData(data?: T[], callback?: (value: T, index: number, parent?: T) => void | boolean, childrenField?: string, parent?: T): void; /** * 处理树形数据 * @param data 需要处理的数据 * @param formatter 处理器 * @param childrenField children 字段名 */ export declare function formatTreeData(data: T[] | undefined | null, formatter: (value: T, index?: number, parent?: U) => U | void | undefined, childrenField?: string, resultChildrenField?: string, parent?: U): U[]; /** * 生成随机字符串 * @param length 长度 * @param radix 基数 */ export declare function uuid(length?: number, radix?: number): string; /** * 生成 m 到 n 的随机数 * @param m 最小值, 包含 * @param n 最大值, 不包含 */ export declare function random(m: number, n: number): number; /** * 数字千分位 * @param num 数字 */ export declare function formatNumber(num?: number | null): string; /** * html 转义 * @param html */ export declare function escape(html?: string | null): string; /** * html 转纯文本 * @param html */ export declare function htmlToText(html?: string | null): string; /** * 深度克隆对象 * @param obj 源对象 * @return 克隆后的对象 */ export declare function deepClone(obj: any): any; /** * 赋值不改变字段原字段 * @param target 目标对象 * @param source 源对象 * @param excludes 排除的字段 */ export declare function assignObject(target: T, source: Record, excludes?: string[]): T; /** * 判断是否是外链 * @param url 地址 */ export declare function isExternalLink(url?: string | null): boolean; /** * 经纬度坐标 */ export interface Point { lng: number; lat: number; } /** * 百度地图坐标转高德地图坐标 * @param point 坐标 */ export declare function bd09ToGcj02(point: Point): Point; /** * 高德地图坐标转百度地图坐标 * @param point 坐标 */ export declare function gcj02ToBd09(point: Point): Point; /** * 播放音频 * @param url 音频地址 */ export declare function play(url: string): HTMLAudioElement; /** * 获取设备信息返回结果 */ export interface DeviceResult { [key: string]: string | boolean | undefined | null; os?: string | null; ie?: string | false; weixin?: string | false; android?: boolean; ios?: boolean; mobile?: boolean; } /** * 获取设备信息 * @param key 自定义的 agent */ export declare function device(key?: string): DeviceResult; /** * 倒计时回调类型 */ type CountdownCallback = (time: number[], serverTime: number | string | Date | undefined, timer: number) => void; /** * 倒计时 * @param endTime 结束时间 * @param serverTime 服务端当前时间 * @param callback 回调 */ export declare function countdown(endTime: number | string | Date, serverTime?: number | string | Date | CountdownCallback, callback?: CountdownCallback): number; /** * 浏览器全屏切换 * @param el dom * @param fullscreen 是否全屏 */ export declare function toggleFullscreen(el?: HTMLElement, fullscreen?: boolean): boolean; /** * 获取当前是否是全屏状态 */ export declare function isFullscreen(): boolean; /** * 获取屏幕宽度 */ export declare function screenWidth(): number; /** * 获取屏幕高度 */ export declare function screenHeight(): number; /** * 获取内容区域宽度 */ export declare function contentWidth(): number; /** * 获取内容区域高度 */ export declare function contentHeight(): number; /** * 导出 excel * @param XLSX XLSX 对象 * @param sheet 数组或 sheet 对象 * @param sheetName 文件名称 * @param type 文件格式 */ export declare function exportSheet(XLSX: any, sheet: any, sheetName?: string, type?: string): void; /** * 排列组合二维数组 * @param arrays 二维数组 * @param separator 分隔符 */ export declare function combineArrays(arrays: string[], separator?: string): string[]; export {};