@moluoxixi/ajax-package 0.0.11
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.
- package/README.md +1016 -0
- package/es/SystemErrorDialog.d.ts +125 -0
- package/es/_types/api.d.ts +26 -0
- package/es/_types/emits.d.ts +6 -0
- package/es/_types/index.d.ts +4 -0
- package/es/_types/props.d.ts +13 -0
- package/es/_utils/index.d.ts +3 -0
- package/es/_utils/messageWrapper.d.ts +35 -0
- package/es/_utils/notificationWrapper.d.ts +8 -0
- package/es/_utils/systemErrorInfo.d.ts +6 -0
- package/es/class.d.ts +29 -0
- package/es/index.d.ts +4 -0
- package/es/index.mjs +12912 -0
- package/es/netseriver.d.ts +12 -0
- package/package.json +33 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
2
|
+
title: {
|
|
3
|
+
type: StringConstructor;
|
|
4
|
+
default: string;
|
|
5
|
+
};
|
|
6
|
+
width: {
|
|
7
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
8
|
+
default: number;
|
|
9
|
+
};
|
|
10
|
+
userName: {
|
|
11
|
+
type: StringConstructor;
|
|
12
|
+
default: undefined;
|
|
13
|
+
};
|
|
14
|
+
userId: {
|
|
15
|
+
type: StringConstructor;
|
|
16
|
+
default: undefined;
|
|
17
|
+
};
|
|
18
|
+
deptName: {
|
|
19
|
+
type: StringConstructor;
|
|
20
|
+
default: undefined;
|
|
21
|
+
};
|
|
22
|
+
deptId: {
|
|
23
|
+
type: StringConstructor;
|
|
24
|
+
default: undefined;
|
|
25
|
+
};
|
|
26
|
+
clientIp: {
|
|
27
|
+
type: StringConstructor;
|
|
28
|
+
default: undefined;
|
|
29
|
+
};
|
|
30
|
+
requestUrl: {
|
|
31
|
+
type: StringConstructor;
|
|
32
|
+
default: undefined;
|
|
33
|
+
};
|
|
34
|
+
traceId: {
|
|
35
|
+
type: StringConstructor;
|
|
36
|
+
default: undefined;
|
|
37
|
+
};
|
|
38
|
+
errorMessage: {
|
|
39
|
+
type: StringConstructor;
|
|
40
|
+
default: undefined;
|
|
41
|
+
};
|
|
42
|
+
errorCode: {
|
|
43
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
44
|
+
default: undefined;
|
|
45
|
+
};
|
|
46
|
+
modelValue: {
|
|
47
|
+
type: BooleanConstructor;
|
|
48
|
+
default: boolean;
|
|
49
|
+
};
|
|
50
|
+
}>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
53
|
+
'update:modelValue': (val: boolean) => true;
|
|
54
|
+
close: () => true;
|
|
55
|
+
confirm: (data: any) => true;
|
|
56
|
+
report: () => true;
|
|
57
|
+
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
58
|
+
title: {
|
|
59
|
+
type: StringConstructor;
|
|
60
|
+
default: string;
|
|
61
|
+
};
|
|
62
|
+
width: {
|
|
63
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
64
|
+
default: number;
|
|
65
|
+
};
|
|
66
|
+
userName: {
|
|
67
|
+
type: StringConstructor;
|
|
68
|
+
default: undefined;
|
|
69
|
+
};
|
|
70
|
+
userId: {
|
|
71
|
+
type: StringConstructor;
|
|
72
|
+
default: undefined;
|
|
73
|
+
};
|
|
74
|
+
deptName: {
|
|
75
|
+
type: StringConstructor;
|
|
76
|
+
default: undefined;
|
|
77
|
+
};
|
|
78
|
+
deptId: {
|
|
79
|
+
type: StringConstructor;
|
|
80
|
+
default: undefined;
|
|
81
|
+
};
|
|
82
|
+
clientIp: {
|
|
83
|
+
type: StringConstructor;
|
|
84
|
+
default: undefined;
|
|
85
|
+
};
|
|
86
|
+
requestUrl: {
|
|
87
|
+
type: StringConstructor;
|
|
88
|
+
default: undefined;
|
|
89
|
+
};
|
|
90
|
+
traceId: {
|
|
91
|
+
type: StringConstructor;
|
|
92
|
+
default: undefined;
|
|
93
|
+
};
|
|
94
|
+
errorMessage: {
|
|
95
|
+
type: StringConstructor;
|
|
96
|
+
default: undefined;
|
|
97
|
+
};
|
|
98
|
+
errorCode: {
|
|
99
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
100
|
+
default: undefined;
|
|
101
|
+
};
|
|
102
|
+
modelValue: {
|
|
103
|
+
type: BooleanConstructor;
|
|
104
|
+
default: boolean;
|
|
105
|
+
};
|
|
106
|
+
}>> & Readonly<{
|
|
107
|
+
"onUpdate:modelValue"?: ((val: boolean) => any) | undefined;
|
|
108
|
+
onClose?: (() => any) | undefined;
|
|
109
|
+
onConfirm?: ((data: any) => any) | undefined;
|
|
110
|
+
onReport?: (() => any) | undefined;
|
|
111
|
+
}>, {
|
|
112
|
+
title: string;
|
|
113
|
+
width: string | number;
|
|
114
|
+
userName: string;
|
|
115
|
+
userId: string;
|
|
116
|
+
deptName: string;
|
|
117
|
+
deptId: string;
|
|
118
|
+
clientIp: string;
|
|
119
|
+
requestUrl: string;
|
|
120
|
+
traceId: string;
|
|
121
|
+
errorMessage: string;
|
|
122
|
+
errorCode: string | number;
|
|
123
|
+
modelValue: boolean;
|
|
124
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
125
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { default as BaseApi } from '../class.ts';
|
|
3
|
+
export interface BaseApiConfig {
|
|
4
|
+
baseURL?: string;
|
|
5
|
+
timeout?: number;
|
|
6
|
+
responseFields?: {
|
|
7
|
+
code?: string;
|
|
8
|
+
message?: string;
|
|
9
|
+
data?: string;
|
|
10
|
+
errors?: string;
|
|
11
|
+
tips?: string;
|
|
12
|
+
};
|
|
13
|
+
onTimeout?: () => void;
|
|
14
|
+
getToken?: () => string | null;
|
|
15
|
+
onLoginRequired?: () => void;
|
|
16
|
+
enableSystemErrorDialog?: boolean;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
export interface vueAxiosPluginOptionsType {
|
|
20
|
+
default?: BaseApiConfig;
|
|
21
|
+
globalMixin?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export type vueHttpServiceType = BaseApi;
|
|
24
|
+
export interface vueAxiosPluginType {
|
|
25
|
+
install: (app: App, options?: vueAxiosPluginOptionsType) => void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface SystemErrorDialogPropsType {
|
|
2
|
+
title?: string;
|
|
3
|
+
width?: number | string;
|
|
4
|
+
userName?: string;
|
|
5
|
+
userId?: string;
|
|
6
|
+
deptName?: string;
|
|
7
|
+
deptId?: string;
|
|
8
|
+
clientIp?: string;
|
|
9
|
+
requestUrl?: string;
|
|
10
|
+
traceId?: string;
|
|
11
|
+
errorMessage?: string;
|
|
12
|
+
errorCode?: number | string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare function createMessageWrapper(): (import('element-plus').MessageFn & {
|
|
2
|
+
primary: import('element-plus').MessageTypedFn;
|
|
3
|
+
success: import('element-plus').MessageTypedFn;
|
|
4
|
+
warning: import('element-plus').MessageTypedFn;
|
|
5
|
+
info: import('element-plus').MessageTypedFn;
|
|
6
|
+
error: import('element-plus').MessageTypedFn;
|
|
7
|
+
} & import('vue').ObjectPlugin<any[]> & {
|
|
8
|
+
_context: import('vue').AppContext | null;
|
|
9
|
+
}) | (import('element-plus').MessageFn & {
|
|
10
|
+
primary: import('element-plus').MessageTypedFn;
|
|
11
|
+
success: import('element-plus').MessageTypedFn;
|
|
12
|
+
warning: import('element-plus').MessageTypedFn;
|
|
13
|
+
info: import('element-plus').MessageTypedFn;
|
|
14
|
+
error: import('element-plus').MessageTypedFn;
|
|
15
|
+
} & ((app: import('vue').App, ...options: any[]) => any) & Partial<import('vue').ObjectPlugin<any[]>> & {
|
|
16
|
+
_context: import('vue').AppContext | null;
|
|
17
|
+
}) | {
|
|
18
|
+
success: (options: string | {
|
|
19
|
+
message?: string;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}) => void;
|
|
22
|
+
error: (options: string | {
|
|
23
|
+
message?: string;
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}) => void;
|
|
26
|
+
warning: (options: string | {
|
|
27
|
+
message?: string;
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
}) => void;
|
|
30
|
+
info: (options: string | {
|
|
31
|
+
message?: string;
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
}) => void;
|
|
34
|
+
};
|
|
35
|
+
export type MessageInstance = ReturnType<typeof createMessageWrapper>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function createNotificationWrapper(): ((import('element-plus').Notify & import('vue').Plugin) & {
|
|
2
|
+
_context: import('vue').AppContext | null;
|
|
3
|
+
}) | ((options: string | {
|
|
4
|
+
message?: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
type?: "success" | "error" | "warning" | "info";
|
|
7
|
+
}) => void);
|
|
8
|
+
export type NotificationInstance = ReturnType<typeof createNotificationWrapper>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { SystemErrorDialogPropsType } from '../_types/index.ts';
|
|
3
|
+
export declare function normalizePayload(payload: any): Record<string, any>;
|
|
4
|
+
export declare function resolveTraceId(headers: AxiosResponse['headers'] | undefined): string;
|
|
5
|
+
export declare function getUserInfoFromLocalStorage(): Record<string, any>;
|
|
6
|
+
export declare function extractSystemErrorInfo(response: AxiosResponse, code: number, message: string): Omit<SystemErrorDialogPropsType, 'title' | 'width'>;
|
package/es/class.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AxiosError, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig, default as axios } from 'axios';
|
|
2
|
+
import { BaseApiConfig } from './_types/index';
|
|
3
|
+
import { MessageInstance, NotificationInstance } from './_utils/index';
|
|
4
|
+
export default class BaseApi {
|
|
5
|
+
protected baseURL: string;
|
|
6
|
+
protected timeout: number;
|
|
7
|
+
protected responseFields: Required<BaseApiConfig['responseFields']>;
|
|
8
|
+
protected onTimeout: () => void;
|
|
9
|
+
protected getToken?: () => string | null;
|
|
10
|
+
protected onLoginRequired?: () => void;
|
|
11
|
+
protected enableSystemErrorDialog: boolean;
|
|
12
|
+
instance: ReturnType<typeof axios.create>;
|
|
13
|
+
protected messageInstance: MessageInstance;
|
|
14
|
+
protected notificationInstance: NotificationInstance;
|
|
15
|
+
constructor(config: BaseApiConfig);
|
|
16
|
+
processRequestConfig(config: InternalAxiosRequestConfig): InternalAxiosRequestConfig<any>;
|
|
17
|
+
processResponseConfig(response: AxiosResponse): AxiosResponse['data'];
|
|
18
|
+
processResponseError(error: AxiosError): Promise<AxiosError>;
|
|
19
|
+
private setupInterceptors;
|
|
20
|
+
protected request<R>(config: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
21
|
+
get<R>(url: string, params?: Record<string, any>, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
22
|
+
post<R>(url: string, data?: Record<string, any>, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
23
|
+
delete<R>(url: string, params?: Record<string, any>, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
24
|
+
put<R>(url: string, data?: Record<string, any>, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
25
|
+
all<R>(requests: Array<AxiosRequestConfig | Promise<AxiosResponse<R>>>): Promise<AxiosResponse['data'][]>;
|
|
26
|
+
uploadFile<R>(url: string, file: File | Blob, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
27
|
+
private showSystemExceptionDialog;
|
|
28
|
+
private reportError;
|
|
29
|
+
}
|
package/es/index.d.ts
ADDED