import { RawLocation } from "vue-router"; import EventBus from "./extend/method/bus"; import Tips from "./extend/method/tips"; import Loading from "./util/loading"; import { HttpResponseType } from "./configure/mapping/types/response"; import { AxiosInstance } from "axios"; import { List2TreeSetting } from "./extend/method/array"; import { EncryptType } from "./util/encrypt"; declare module "vue/types/vue" { interface Vue { /** * 发送请求 * @param apiName httpConfig.dir配置中,获取到的文件名 * @param methodName 查询接口需要调用api文件中的哪个方法 * @param params 需要携带的参数 */ $api(apiName: string, methodName: string, params?: Dictionary | Dictionary[]): Promise; /** * axios对象 */ $ajax: AxiosInstance; /** * 跳转页面,使用方式同 vm.$router.push/vm.$router.replace * @param location routerName/Route * @param replace boolean类型 true代表调用vm.$router.replace false代表调用vm.$router.push 默认为false */ $jump(location: RawLocation, replace?: boolean): void; /** * 改变vuex对象的值,vm.$stores.commit的封装 * @param mutationName mutation名称 * @param payload 要传递的参数 */ $changeStore(mutationName: string, payload?: any): void; /** * 获取ref实例 * @param ref ref绑定的值 */ $getRef(ref: string | undefined): any | any[]; /** * 根据传入的分割长度,来切割数组 * @param source * @param chunkLength */ $chunk(source: T[], chunkLength: number): T[][]; /** * 事件总线 */ $bus: EventBus; /** * 收集事件id,用于自动销毁事件监听 * @param busIds */ $busCollect(...busIds: string[]): void; /** * 提示 */ $tips: Tips; /** * 数据加解密 */ $encrypt: EncryptType; /** * loading */ $loading: Loading; /** * 将dom平滑滚动至某个部位 * @param target 被滚动的对象 * @param from 从什么位置开始 * @param to 到什么位置 * @param duration 需要多长时间完成 * @param completeCallback 完成后的回调函数 */ $slideTo(target: Element, from: number, to: number, duration: number, completeCallback: Function): void; /** * 日期格式化 * @param date 要被格式化的对象 string/date类型 * @param pattern 要格式化成什么样的,默认 yyyy-MM-dd hh:mm:ss */ $formatDate(date: Date | string, pattern: string): string; /** * 将数字格式化为指定位数的小数,支持是否四舍五入 * @param num 要被格式化的对象 * @param digits 保留几位小数 * @param isRound 是否四舍五入 */ $toFixed(num: string | number, digits: number, isRound: boolean): number; /** * 将数字格式化为千分位 * @param num */ $formatNumber(num: number): string; /** * 格式化金钱,将分转换为元 * @param target 要被转换的数据 * @param addComma 是否添加千分位 */ $formatMoney(target: string | number, addComma: boolean): string | number; /** * 检测类型 * @param target 要被检测的对象 * @param type 类型 可传多个 */ $typeEqual(target: any, ...type: Function[]): boolean; /** * 在数组中删除某个元素 * @param array 数组 * @param removeItem 要删除的元素 */ $removeItemInArray(array: Array, removeItem: any): void; /** * 给字符串去空白 * @param str 字符串 */ $trim(str: string): string; /** * 判断是否为空 * @param obj 要被判断的对象 * @param throwMessage 要抛出异常的内容 不为空则抛出该异常提示 */ $isEmpty(obj: any, throwMessage?: string): boolean; /** * 判断是否不为空 * @param obj 要被判断的对象 * @param throwMessage 要抛出异常的内容 不为空则抛出该异常提示 */ $isNotEmpty(obj: any, throwMessage?: string): boolean; /** * 获取指定范围内的随机数 * @param min * @param max */ $getRandomByRegion(min: number, max: number): number; /** * 将列表转换为树形结构 * @param array * @param setting */ $list2Tree(array: Array, setting: List2TreeSetting): Array; /** * 将树形列表拉平 * @param array * @param childrenField * @param removeChildren */ $tree2List(array: Array, childrenField: string, removeChildren: boolean): Array; /** * 复制内容至剪切板 * @param content 要复制的内容 */ $copy(content: string): void; /** * 生成指定长度的数组数据 * @param length 长度 * @param generateFactory 创建数据的工厂函数 */ $loopGenerate(length: number, generateFactory: () => T): Array; /** * 防抖 * @param fn * @param delay */ $debounce(fn: Function, delay: number): Function; /** * 节流 * @param fn * @param delay */ $throttle(fn: Function, delay: number): Function; } }