UNPKG

yg-tools

Version:

some convenient APIs and Methods for Youngon

103 lines (102 loc) 2.63 kB
import GlobalConfig from '../config/config'; import { User } from '../models'; import { LDKey } from './LDK'; export { LDKey }; export default class YGUtils<CustomLDK extends typeof LDKey = typeof LDKey> { config: GlobalConfig; LDK: CustomLDK; constructor(config: GlobalConfig, customLDK?: CustomLDK); static createYGUtils<CustomLDK extends typeof LDKey = typeof LDKey>(config: GlobalConfig, customLDK?: CustomLDK): YGUtils<CustomLDK>; /** * 本地数据存储 * */ LocalData: { /** * 获取本地存储的数据 * */ getItem: (key: string) => any; /** * 将 data 存储在本地缓存中指定的 key 中,会覆盖掉原来该 key 对应的内容 * */ setItem: (key: string, data: any) => any; /** * 从本地缓存中同步移除指定 key * */ removeItem: (key: string) => any; /** * 同步清理本地数据缓存 * */ clear: () => any; }; /** * 本地数据是否过期 */ isDataTimeOut: (timeout?: number | undefined) => boolean; /** * iYoungon 小程序签到详情页面地址 */ signDetailPagePath: string; /** * 判断不为空 */ notEmpty: (arrs: { key: string; value: string | number; }[]) => boolean; /** * 跳转到小程序首页 */ gotoIndex: () => void; /** * 用户类型标志转换为名称 */ utype2Name: (utype: number) => string; /** * 职位标志转换为名称 */ position2Name: (position: number) => string; /** * 性别标志转换为名称 */ sex2Name: (sex: number) => string; /** * 性别 Map */ sexMap: { text: string; value: number; }[]; /** * 部门 Array */ departmentArray: string[]; /** * 用户信息标志转换为名称 */ handelUserInfo: (user: User) => User; /** * 部门颜色 */ transDepartMentColor: (department: string) => string; /** * 对象转 Query 字符串 并过滤空值 */ toQuery: (data: Record<string, string | number | boolean>) => string; /** * 检测月、日、时、分、秒是否补零 */ checkTime: (i: number | string) => string | number; /** * 获取当前时间 */ getNowTime: () => { cn: string; en: string; ymd: string; hms: string; }; /** * 函数防抖 */ debounce(func: Function, wait: number, immediate?: boolean): () => void; }