@vue-start/pro 0.1.0
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/CHANGELOG.md +19 -0
- package/README.md +11 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.es.js +728 -0
- package/dist/index.js +748 -0
- package/package.json +28 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# 0.1.0 (2022-08-12)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **element-pro:** curd schema form ([175f9e7](https://github.com/zxeryu/vue-start/commit/175f9e70482009afd118573be6e716535f584043))
|
|
11
|
+
- **pro:** curd request props ([daf2fca](https://github.com/zxeryu/vue-start/commit/daf2fca7876c2a9f4c155400edb3fdd99fa9f825))
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- **pro:** pro 组件抽象层重构 ([0ba27c5](https://github.com/zxeryu/vue-start/commit/0ba27c591c7a6eebce2c1986908e295194a6f326))
|
|
16
|
+
|
|
17
|
+
### Performance Improvements
|
|
18
|
+
|
|
19
|
+
- **pro:** requests to operates ([9b69165](https://github.com/zxeryu/vue-start/commit/9b6916582a4c15a7012c3267126b00c065b32d23))
|
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as axios from 'axios';
|
|
2
|
+
import { AxiosRequestConfig, AxiosResponse, AxiosInstance, AxiosInterceptorManager } from 'axios';
|
|
3
|
+
import { Observable, Subject, BehaviorSubject } from 'rxjs';
|
|
4
|
+
import * as vue from 'vue';
|
|
5
|
+
import { App } from 'vue';
|
|
6
|
+
|
|
7
|
+
declare type ReqType = {
|
|
8
|
+
body?: Record<string, any>;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* 两种模式
|
|
13
|
+
* requestFromReq :开发时候创建的
|
|
14
|
+
* requestConfig: 通过配置添加
|
|
15
|
+
*/
|
|
16
|
+
interface IRequestActor<TReq = any, TRes = any, TErr = any> {
|
|
17
|
+
name: string;
|
|
18
|
+
requestFromReq?: (req: TReq) => AxiosRequestConfig;
|
|
19
|
+
requestConfig?: AxiosRequestConfig;
|
|
20
|
+
label?: string;
|
|
21
|
+
req?: TReq;
|
|
22
|
+
res?: AxiosResponse<TRes>;
|
|
23
|
+
err?: TErr;
|
|
24
|
+
stage?: "DONE" | "FAILED" | "CANCEL";
|
|
25
|
+
id?: string;
|
|
26
|
+
extra?: Record<string, any>;
|
|
27
|
+
}
|
|
28
|
+
declare const isPreRequestActor: (actor: IRequestActor) => boolean;
|
|
29
|
+
declare const isCancelRequestActor: (actor: IRequestActor) => boolean;
|
|
30
|
+
declare const isFailedRequestActor: (actor: IRequestActor) => boolean;
|
|
31
|
+
declare const isDoneRequestActor: (actor: IRequestActor) => boolean;
|
|
32
|
+
declare const createRequestActor: <TReq extends ReqType, TRes>(name: string, requestFromReq: ((req: TReq) => AxiosRequestConfig) | undefined, extra?: Pick<IRequestActor<TReq, TRes, any>, "label"> | undefined) => IRequestActor<TReq, TRes, any>;
|
|
33
|
+
declare const cancelActorIfExists: (actor: any) => void;
|
|
34
|
+
declare const isCancelActor: (actor: any) => any;
|
|
35
|
+
declare const createRequestFactory: (client: AxiosInstance) => (actor: IRequestActor) => {
|
|
36
|
+
(): Observable<AxiosResponse<any>>;
|
|
37
|
+
clear(): void;
|
|
38
|
+
config: AxiosRequestConfig;
|
|
39
|
+
};
|
|
40
|
+
declare const createRequestObservable: (actor$: Observable<IRequestActor>, client: AxiosInstance) => Observable<IRequestActor<any, any, any>>;
|
|
41
|
+
|
|
42
|
+
declare type DispatchRequestType = (actor: IRequestActor, params?: IRequestActor["req"], extra?: IRequestActor["extra"]) => IRequestActor;
|
|
43
|
+
declare type RequestProvideType = {
|
|
44
|
+
client: AxiosInstance;
|
|
45
|
+
requestSubject$: Subject<IRequestActor>;
|
|
46
|
+
dispatchRequest: DispatchRequestType;
|
|
47
|
+
};
|
|
48
|
+
declare const useRequestProvide: () => RequestProvideType;
|
|
49
|
+
declare type TRequestInterceptor = (request: AxiosInterceptorManager<AxiosRequestConfig>, response: AxiosInterceptorManager<AxiosResponse>) => void;
|
|
50
|
+
declare const ContentTypeInterceptor: TRequestInterceptor;
|
|
51
|
+
declare const createRequest: (options: AxiosRequestConfig, interceptors: TRequestInterceptor[]) => (app: App) => void;
|
|
52
|
+
|
|
53
|
+
declare const isContentTypeMultipartFormData: (headers: any) => any;
|
|
54
|
+
declare const isContentTypeFormURLEncoded: (headers: any) => any;
|
|
55
|
+
declare const isContentTypeJSON: (headers: any) => any;
|
|
56
|
+
declare const paramsSerializer: (params: any) => string;
|
|
57
|
+
declare const transformRequest: (data: any, headers: any) => any;
|
|
58
|
+
declare const transformResponse: (data: unknown, headers: {
|
|
59
|
+
[k: string]: any;
|
|
60
|
+
}) => any;
|
|
61
|
+
declare const getRequestConfig: (actor: IRequestActor) => axios.AxiosRequestConfig;
|
|
62
|
+
declare const toUrl: (actor: IRequestActor, baseUrl?: string) => string;
|
|
63
|
+
declare const generateId: () => string;
|
|
64
|
+
|
|
65
|
+
interface IUseRequestOptions<TReq, TRes, TErr> {
|
|
66
|
+
defaultLoading?: boolean;
|
|
67
|
+
onSuccess?: (actor: IRequestActor<TReq, TRes, TErr>) => void;
|
|
68
|
+
onFail?: (actor: IRequestActor<TReq, TRes, TErr>) => void;
|
|
69
|
+
onFinish?: () => void;
|
|
70
|
+
}
|
|
71
|
+
declare const useRequest: <TReq, TRes, TErr>(requestActor: IRequestActor<TReq, TRes, TErr>, options?: IUseRequestOptions<TReq, TRes, TErr> | undefined) => readonly [(params: TReq | undefined, options?: Pick<IUseRequestOptions<TReq, TRes, TErr>, "onSuccess" | "onFail"> | undefined) => void, BehaviorSubject<boolean>];
|
|
72
|
+
/**
|
|
73
|
+
* 直接发起请求
|
|
74
|
+
*/
|
|
75
|
+
declare const useDirectRequest: <TRequestActor extends IRequestActor<any, any, any>>(requestActor: TRequestActor, params: TRequestActor["req"] | (() => TRequestActor["req"]), deps: any | any[]) => (BehaviorSubject<boolean> | vue.UnwrapNestedRefs<TRequestActor["res"]> | ((nextParams?: TRequestActor["req"] | undefined) => void))[];
|
|
76
|
+
|
|
77
|
+
export { ContentTypeInterceptor, DispatchRequestType, IRequestActor, IUseRequestOptions, ReqType, RequestProvideType, TRequestInterceptor, cancelActorIfExists, createRequest, createRequestActor, createRequestFactory, createRequestObservable, generateId, getRequestConfig, isCancelActor, isCancelRequestActor, isContentTypeFormURLEncoded, isContentTypeJSON, isContentTypeMultipartFormData, isDoneRequestActor, isFailedRequestActor, isPreRequestActor, paramsSerializer, toUrl, transformRequest, transformResponse, useDirectRequest, useRequest, useRequestProvide };
|