/** 常用工具方法 */ /** * toTree 方法参数 */ export interface ToTreeOption { /** 数据 */ 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 ToTreeOption */ export declare function toTree(option: ToTreeOption): T[]; /** * 遍历树形形式数据 * @param data 需要遍历的数据 * @param callback 回调 * @param childrenField children 字段名 */ export declare function eachTree(data?: T[], callback?: (item: T, index: number, parent?: T) => void | boolean, childrenField?: string, parent?: T): void; /** * 格式化树形数据 * @param data 需要格式化的数据 * @param formatter 格式器 * @param childrenField children 字段名 * @param resultChildrenField 格式化后的 children 字段名 */ export declare function mapTree(data: T[] | undefined | null, formatter: (item: T, index?: number, parent?: U) => U | void | undefined, childrenField?: string, resultChildrenField?: string, parent?: U): U[]; /** * 查找树形数据 * @param data 数据 * @param predicate 查找条件 * @param childrenField children 字段名 */ export declare function findTree(data: T[] | undefined, predicate: (value: T, index: number) => unknown, childrenField?: string): T | undefined; /** * 生成随机字符串 * @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; /** * 赋值不改变原字段 * @param target 目标对象 * @param source 源对象 * @param excludes 排除的字段 */ export declare function assignObject(target: T, source: Record, excludes?: string[]): T; /** * 全屏 * @param el HTMLElement */ export declare function requestFullscreen(el?: HTMLElement): void; /** * 退出全屏 */ export declare function exitFullscreen(): void; /** * 检查是否全屏 */ export declare function checkFullscreen(): 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 isExternalLink(url?: string | null): boolean; /** * 获取节点样式 * @param el 节点 */ export declare function getCurrentStyle(el: Element): CSSStyleDeclaration; /** * 防抖函数 * @param func 函数 * @param wait 等待时间 */ export declare function debounce any>(func: T, wait: number): (this: any) => void; /** * 节流函数 * @param func 函数 * @param wait 等待时间 */ export declare function throttle any>(func: T, wait: number): (this: any) => void; /** * 忽略对象属性 * @param obj 来源对象 * @param fields 忽略的属性 */ export declare function omit(obj: T | null | undefined, fields: Array): Omit; /** * 摘选对象属性 * @param obj 来源对象 * @param fields 摘选的属性 */ export declare function pick(obj: T, fields: Array): Pick; /** * 判断元素内容是否溢出省略 * @param el 元素节点 */ export declare function contentIsEllipsis(el: HTMLElement, direction?: 'horizontal' | 'vertical'): boolean;