import { HttpClient, HttpEvent, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; import { AlainThemeConfig } from '../theme.config'; export declare type _HttpHeaders = HttpHeaders | { [header: string]: string | string[]; }; export declare type HttpObserve = 'body' | 'events' | 'response'; /** * 封装HttpClient,主要解决: * + 优化HttpClient在参数上便利性 * + 统一实现 loading * + 统一处理时间格式问题 */ export declare class _HttpClient { private http; private cog; constructor(http: HttpClient, cog: AlainThemeConfig); private _loading; /** 是否正在加载中 */ readonly loading: boolean; parseParams(params: {}): HttpParams; appliedUrl(url: string, params?: {}): string; begin(): void; end(): void; /** * GET:返回一个 `string` 类型 */ get(url: string, params: any, options: { headers?: _HttpHeaders; observe?: 'body'; reportProgress?: boolean; responseType: 'text'; withCredentials?: boolean; }): Observable; /** * GET:返回一个 `HttpEvent` 类型 */ get(url: string, params: any, options: { headers?: _HttpHeaders; observe: 'events'; reportProgress?: boolean; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; withCredentials?: boolean; }): Observable>; /** * GET:返回一个 `HttpResponse` 类型 */ get(url: string, params: any, options: { headers?: _HttpHeaders; observe: 'response'; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }): Observable>; /** * GET:返回一个 `HttpResponse` 类型 */ get(url: string, params: any, options: { headers?: _HttpHeaders; observe: 'response'; reportProgress?: boolean; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; withCredentials?: boolean; }): Observable>; /** * GET:返回一个 `any` 类型 */ get(url: string, params?: any, options?: { headers?: _HttpHeaders; observe?: 'body' | 'events' | 'response'; reportProgress?: boolean; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; withCredentials?: boolean; }): Observable; /** * GET:返回一个泛类型 */ get(url: string, params?: any, options?: { headers?: _HttpHeaders; observe: 'body'; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }): Observable; /** * POST:返回一个 `string` 类型 */ post(url: string, body: any, params: any, options: { headers?: _HttpHeaders; observe?: 'body'; reportProgress?: boolean; responseType: 'text'; withCredentials?: boolean; }): Observable; /** * POST:返回一个 `HttpEvent` 类型 */ post(url: string, body: any, params: any, options: { headers?: _HttpHeaders; observe: 'events'; reportProgress?: boolean; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; withCredentials?: boolean; }): Observable>; /** * POST:返回一个 `HttpResponse` 类型 */ post(url: string, body: any, params: any, options: { headers?: _HttpHeaders; observe: 'response'; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }): Observable>; /** * POST:返回一个 `any` 类型 */ post(url: string, body?: any, params?: any, options?: { headers?: _HttpHeaders; observe?: 'body' | 'events' | 'response'; reportProgress?: boolean; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; withCredentials?: boolean; }): Observable; /** * POST:返回一个 `JSON` 类型 */ post(url: string, body?: any, params?: any, options?: { headers?: _HttpHeaders; observe: 'response'; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }): Observable; /** * DELETE:返回一个 `string` 类型 */ delete(url: string, params: any, options: { headers?: _HttpHeaders; observe?: 'body'; reportProgress?: boolean; responseType: 'text'; withCredentials?: boolean; }): Observable; /** * DELETE:返回一个 `JSON` 类型 */ delete(url: string, params: any, options: { headers?: _HttpHeaders; observe: 'response'; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }): Observable>; /** * DELETE:返回一个 `any` 类型 */ delete(url: string, params?: any, options?: { headers?: _HttpHeaders; observe?: 'body' | 'events' | 'response'; reportProgress?: boolean; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; withCredentials?: boolean; }): Observable; /** * DELETE:返回一个泛类型 */ delete(url: string, params?: any, options?: { headers?: _HttpHeaders; observe?: 'body' | 'events' | 'response'; reportProgress?: boolean; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; withCredentials?: boolean; }): Observable; /** * `jsonp` 请求 * * @param url URL地址 * @param params 请求参数 * @param callbackParam CALLBACK值,默认:JSONP_CALLBACK */ jsonp(url: string, params?: any, callbackParam?: string): Observable; /** * PATCH:返回一个 `string` 类型 */ patch(url: string, body: any, params: any, options: { headers?: _HttpHeaders; observe?: 'body'; reportProgress?: boolean; responseType: 'text'; withCredentials?: boolean; }): Observable; /** * PATCH:返回一个 `HttpResponse` 类型 */ patch(url: string, body: any, params: any, options: { headers?: _HttpHeaders; observe: 'response'; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }): Observable>; /** * PATCH:返回一个 `any` 类型 */ patch(url: string, body?: any, params?: any, options?: { headers?: _HttpHeaders; observe?: 'body' | 'events' | 'response'; reportProgress?: boolean; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; withCredentials?: boolean; }): Observable; /** * PATCH:返回一个 `JSON` 类型 */ patch(url: string, body?: any, params?: any, options?: { headers?: _HttpHeaders; observe: 'response'; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }): Observable; /** * PUT:返回一个 `string` 类型 */ put(url: string, body: any, params: any, options: { headers?: _HttpHeaders; observe?: 'body'; reportProgress?: boolean; responseType: 'text'; withCredentials?: boolean; }): Observable; /** * PUT:返回一个 `HttpResponse` 类型 */ put(url: string, body: any, params: any, options: { headers?: _HttpHeaders; observe: 'response'; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }): Observable>; /** * PUT:返回一个 `any` 类型 */ put(url: string, body?: any, params?: any, options?: { headers?: _HttpHeaders; observe?: 'body' | 'events' | 'response'; reportProgress?: boolean; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; withCredentials?: boolean; }): Observable; /** * PUT:返回一个 `JSON` 类型 */ put(url: string, body?: any, params?: any, options?: { headers?: _HttpHeaders; observe: 'response'; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }): Observable; /** 返回一个 `arraybuffer` 类型 */ request(method: string, url: string, options: { body?: any; headers?: _HttpHeaders; params?: any; observe?: 'body'; reportProgress?: boolean; responseType: 'arraybuffer'; withCredentials?: boolean; }): Observable; request(method: string, url: string, options: { body?: any; headers?: _HttpHeaders; params?: any; observe?: 'body'; reportProgress?: boolean; responseType: 'blob'; withCredentials?: boolean; }): Observable; request(method: string, url: string, options: { body?: any; headers?: _HttpHeaders; params?: any; observe?: 'body'; reportProgress?: boolean; responseType: 'text'; withCredentials?: boolean; }): Observable; request(method: string, url: string, options: { body?: any; headers?: _HttpHeaders; params?: any; observe: 'events'; reportProgress?: boolean; responseType: 'arraybuffer'; withCredentials?: boolean; }): Observable>; request(method: string, url: string, options: { body?: any; headers?: _HttpHeaders; params?: any; observe: 'events'; reportProgress?: boolean; responseType: 'blob'; withCredentials?: boolean; }): Observable>; request(method: string, url: string, options: { body?: any; headers?: _HttpHeaders; params?: any; observe: 'events'; reportProgress?: boolean; responseType: 'text'; withCredentials?: boolean; }): Observable>; request(method: string, url: string, options: { body?: any; headers?: _HttpHeaders; params?: any; reportProgress?: boolean; observe: 'events'; responseType?: 'json'; withCredentials?: boolean; }): Observable>; request(method: string, url: string, options: { body?: any; headers?: _HttpHeaders; params?: any; reportProgress?: boolean; observe: 'events'; responseType?: 'json'; withCredentials?: boolean; }): Observable>; request(method: string, url: string, options: { body?: any; headers?: _HttpHeaders; params?: any; observe: 'response'; reportProgress?: boolean; responseType: 'arraybuffer'; withCredentials?: boolean; }): Observable>; request(method: string, url: string, options: { body?: any; headers?: _HttpHeaders; params?: any; observe: 'response'; reportProgress?: boolean; responseType: 'blob'; withCredentials?: boolean; }): Observable>; request(method: string, url: string, options: { body?: any; headers?: _HttpHeaders; params?: any; observe: 'response'; reportProgress?: boolean; responseType: 'text'; withCredentials?: boolean; }): Observable>; request(method: string, url: string, options: { body?: any; headers?: _HttpHeaders; params?: any; reportProgress?: boolean; observe: 'response'; responseType?: 'json'; withCredentials?: boolean; }): Observable>; request(method: string, url: string, options: { body?: any; headers?: _HttpHeaders; params?: any; reportProgress?: boolean; observe: 'response'; responseType?: 'json'; withCredentials?: boolean; }): Observable>; request(method: string, url: string, options?: { body?: any; headers?: _HttpHeaders; params?: any; observe?: 'body'; responseType?: 'json'; reportProgress?: boolean; withCredentials?: boolean; }): Observable; request(method: string, url: string, options?: { body?: any; headers?: _HttpHeaders; params?: any; observe?: 'body'; responseType?: 'json'; reportProgress?: boolean; withCredentials?: boolean; }): Observable; request(method: string, url: string, options?: { body?: any; headers?: _HttpHeaders; params?: any; observe?: HttpObserve; reportProgress?: boolean; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; withCredentials?: boolean; }): Observable; }