@bizjs/biz-utils
Version:
The biz utils for web develpoment.
42 lines (41 loc) • 1.21 kB
TypeScript
import type { OpenUrlOptions, UrlQuery } from './typings/common';
/**
* 将浏览器的 querystring 转换为对象
* @param search
*/
export declare function getQuery(search?: string): Record<string, string | undefined>;
export type { OpenUrlOptions };
/**
* 打开链接
* @param url
* @param options
* @returns
*/
export declare function openUrl(url: string, options?: OpenUrlOptions): void;
export type DownloadOptions = OpenUrlOptions & {
filename?: string;
};
/**
* 文件下载(常规模式,浏览器打开下载链接)
* @param url
* @param options
* @returns
*/
export declare function download(url: string, options?: DownloadOptions): void;
export type DownloadBlobOptions = {
filename?: string;
query?: UrlQuery;
onProgress?: (total: number, loaded: number, e?: ProgressEvent) => void;
xhrOptions?: {
headers?: Record<string, string>;
withCredenticals?: boolean;
};
};
/**
* 下载文件(二进制模式,支持进度条)
* @param url
* @param options
* @returns
*/
export declare function downloadBlob(url: string, options?: DownloadBlobOptions): Promise<boolean>;
export declare function copyText(content: string): Promise<void>;