gzjs-utils
Version:
smart js utils
124 lines (123 loc) • 2.62 kB
TypeScript
import { Utils } from "./Utils";
import { WebRTCIP } from "./WebRTCIP";
import { Bytes } from "./Bytes";
import { Base64 } from "./Base64";
import { MD5 } from "./MD5";
import { AES } from "./AES";
import _Hmac_ from "./Hmac";
import _SHA_ from "./SHA";
import EnumBuilder from "./EnumBuilder";
import { Env } from "./Env";
import { TreeUtils } from "./TreeUtils";
import { DateUtils } from "./DateUtils";
export type KeyInfo = {
/**
* 请求过期时长,单位/秒
*/
req: number;
/**
* 申请日期, yyyy-MM-dd HH:mm:ss
*/
begin: string;
/**
* 到期时间,yyyy-MM-dd HH:mm:ss
*/
end: string;
/**
* 是否可用
*/
enabled: boolean;
/**
* 相对有效 日期 的可用时长,如果 enabled=false,则表示 已过期的时长
*/
diff: number;
/**
* 扩展数据
*/
data?: string;
};
/**
* 枚举项
*/
export interface EnumItem {
/**
* 枚举项名称
*/
label: string;
/**
* 枚举项描述
*/
desc?: string;
/**
* 枚举项编码,默认枚举值
*/
value: string | number;
/**
* 扩展值
*/
values?: (string | number)[];
/**
* 比较是否相等,
* @param val
*/
eq?: (val: any | string) => boolean;
/**
* 文字颜色值
*/
color?: string;
/**
* 背景颜色
*/
bgColor?: string;
}
export type KeyTool = {
version: string;
/**
* 读取授权码信息
* @param key
*/
readKey(key: string): KeyInfo;
/**
* 创建授权码
* @param seconds 授权码授权时长,单位/秒
* @param ext_data 扩展数据
*/
createKey(seconds?: number, ext_data?: any): string;
};
/**
* 分页参数
*/
export type PageParam = {
pageNo?: number | 1;
pageSize?: number | 10;
};
/**
* 分页结果对象
*/
export type PageResult<T = any> = {
list: T[];
total: number;
};
type TreeUtilBase = Pick<TreeUtils, 'buildTree' | 'eachTree' | 'findTreeItem' | 'treeToArray'>;
export type JsUtils = Utils & TreeUtilBase & WebRTCIP & {
Bytes: Bytes;
Base64: Base64;
Utils: Utils;
DateUtils: DateUtils;
TreeUtils: TreeUtils;
MD5: MD5;
AES: AES;
Hmac: typeof _Hmac_;
SHA: typeof _SHA_;
EnumBuilder: typeof EnumBuilder;
readonly KeyTool: KeyTool;
getEnvironments(): Env;
readonly version: string;
/**
* 关闭工具日志警告
* @param flag
*/
disable_warning?: (flag?: boolean) => void;
};
declare const _JsUtils_: JsUtils;
export default _JsUtils_;