@moluoxixi/ajax-package 0.0.15 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,40 @@
1
+ export default service;
2
+ /**
3
+ * 创建 axios 实例
4
+ * @type {NewApi}
5
+ */
6
+ declare const service: NewApi;
7
+ /**
8
+ * 自定义 API 类,继承自 BaseApi
9
+ * 实现了原有的 axios 封装功能
10
+ */
11
+ export class NewApi {
12
+ constructor(config?: {});
13
+ /**
14
+ * 处理请求配置
15
+ * 在请求发送之前进行一些处理
16
+ * 对应旧代码的请求拦截器逻辑
17
+ */
18
+ processRequestConfig(config: any): any;
19
+ /**
20
+ * 处理 HTTP 状态码
21
+ */
22
+ handleHttpStatus(response: any): void;
23
+ /**
24
+ * 处理业务错误(重写父类方法,不抛出错误,只显示消息)
25
+ */
26
+ handleBusinessError(code: any, message: any): void;
27
+ /**
28
+ * 处理成功响应(完全重写,符合旧代码逻辑)
29
+ */
30
+ handleSuccessResponse(response: any): any;
31
+ /**
32
+ * 处理超时错误(重写父类方法)
33
+ */
34
+ handleTimeoutError(error: any): void;
35
+ /**
36
+ * 处理网络错误(重写父类方法)
37
+ */
38
+ handleNetworkError(error: any): void;
39
+ }
40
+ export function showErrorNotification(title: any, errors: any): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moluoxixi/ajax-package",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "AjaxPackage 组件",
5
5
  "sideEffects": [
6
6
  "*.css",
@@ -1,9 +0,0 @@
1
- import { AxiosResponse, InternalAxiosRequestConfig } from 'axios';
2
- import { BaseApi, BaseApiConfig } from '@moluoxixi/ajax-package';
3
- export default class BaseRequestApi extends BaseApi {
4
- constructor(config?: Partial<BaseApiConfig>);
5
- processRequestConfig(config: InternalAxiosRequestConfig): InternalAxiosRequestConfig;
6
- protected handleSuccessResponse(response: AxiosResponse): AxiosResponse['data'];
7
- protected handleHttpStatus(response: AxiosResponse): void;
8
- protected handleBusinessError(code: any, message: any): void;
9
- }
@@ -1,21 +0,0 @@
1
- import { AxiosError, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
2
- import { default as BaseRequestApi } from './BaseRequestApi.ts';
3
- export default class DownloadApi extends BaseRequestApi {
4
- private downloadingFiles;
5
- constructor();
6
- processRequestConfig(config: InternalAxiosRequestConfig): InternalAxiosRequestConfig;
7
- processResponseError(error: AxiosError): Promise<AxiosError>;
8
- protected handleSuccessResponse(response: AxiosResponse): AxiosResponse['data'];
9
- downloadFileFromUrl(url: string, filename?: string, params?: Record<string, any>, data?: Record<string, any>, method?: 'get' | 'post', config?: AxiosRequestConfig): Promise<boolean>;
10
- private getFilenameFromUrl;
11
- downloadMultipleFiles(files: Array<{
12
- url: string;
13
- filename?: string;
14
- params?: Record<string, any>;
15
- data?: Record<string, any>;
16
- method?: 'get' | 'post';
17
- }>, onProgress?: (progress: number, currentFile: string) => void): Promise<{
18
- success: number;
19
- total: number;
20
- }>;
21
- }
@@ -1,4 +0,0 @@
1
- import { BaseApi, BaseApiConfig } from '@moluoxixi/ajax-package';
2
- export default class RoleApi extends BaseApi {
3
- constructor(config?: Partial<BaseApiConfig>);
4
- }
@@ -1,4 +0,0 @@
1
- import { BaseApi, BaseApiConfig } from '@moluoxixi/ajax-package';
2
- export default class UserApi extends BaseApi {
3
- constructor(config?: Partial<BaseApiConfig>);
4
- }
@@ -1,9 +0,0 @@
1
- import { default as DownloadApi } from './DownloadApi.ts';
2
- import { default as BaseRequestApi } from './BaseRequestApi.ts';
3
- import { default as UserApi } from './UserApi.ts';
4
- import { default as RoleApi } from './RoleApi.ts';
5
- export declare const downloadRequest: DownloadApi;
6
- export declare const userRequest: any;
7
- export declare const baseRequest: any;
8
- export declare const roleRequest: any;
9
- export { DownloadApi, BaseRequestApi, UserApi, RoleApi, };