@airpower/web 1.4.0 → 1.4.3
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/dist/http/Http.d.ts +31 -14
- package/dist/main.js +52 -33
- package/package.json +1 -1
package/dist/http/Http.d.ts
CHANGED
|
@@ -82,34 +82,51 @@ export declare class Http {
|
|
|
82
82
|
* @param contentType `content-shared`
|
|
83
83
|
*/
|
|
84
84
|
setContentType(contentType: HttpContentType): this;
|
|
85
|
+
/**
|
|
86
|
+
* ### 是否直接抛出错误
|
|
87
|
+
* @param isThrowError 是否回调错误
|
|
88
|
+
*/
|
|
89
|
+
throwError(isThrowError?: boolean): this;
|
|
90
|
+
/**
|
|
91
|
+
* ### 无返回发送请求
|
|
92
|
+
* @param postData 发送的数据模型(数组)
|
|
93
|
+
*/
|
|
94
|
+
request<REQ extends Transformer>(postData: REQ | REQ[] | undefined): Promise<void>;
|
|
85
95
|
/**
|
|
86
96
|
* ### 发送请求并获取转换后的模型
|
|
87
|
-
* @param postData
|
|
97
|
+
* @param postData 发送的数据模型(数组)
|
|
88
98
|
* @param parseClass 返回的模型
|
|
89
99
|
*/
|
|
90
|
-
|
|
100
|
+
requestModel<REQ extends Transformer, RES extends Transformer>(postData: REQ | REQ[] | undefined, parseClass: ITransformerConstructor<RES>): Promise<RES>;
|
|
91
101
|
/**
|
|
92
102
|
* ### 发送请求并获取转换后的模型数组
|
|
93
|
-
* @param postData
|
|
103
|
+
* @param postData 发送的数据模型(数组)
|
|
94
104
|
* @param parseClass 返回的模型数组
|
|
95
105
|
*/
|
|
96
|
-
|
|
106
|
+
requestModelList<REQ extends Transformer, RES extends Transformer>(postData: REQ | REQ[] | undefined, parseClass: ITransformerConstructor<RES>): Promise<RES[]>;
|
|
97
107
|
/**
|
|
98
|
-
* ###
|
|
99
|
-
* @param
|
|
108
|
+
* ### POST 发送请求并获取原始 `data`
|
|
109
|
+
* @param postData 发送的数据模型(数组)
|
|
110
|
+
* @returns 响应的原始 `data`
|
|
100
111
|
*/
|
|
101
|
-
|
|
112
|
+
requestRaw<REQ extends Transformer>(postData: REQ | REQ[] | undefined): Promise<IJson | IJson[]>;
|
|
102
113
|
/**
|
|
103
|
-
*
|
|
104
|
-
* @param
|
|
114
|
+
* 发送请求
|
|
115
|
+
* @param request 请求
|
|
116
|
+
* @param request.body 请求体
|
|
117
|
+
* @param request.params 请求参数
|
|
118
|
+
* @returns 响应的JSON
|
|
105
119
|
*/
|
|
106
|
-
request
|
|
120
|
+
send(request: {
|
|
121
|
+
body?: unknown;
|
|
122
|
+
params?: unknown;
|
|
123
|
+
}): Promise<IJson | IJson[]>;
|
|
107
124
|
/**
|
|
108
125
|
* ### 发送请求
|
|
109
126
|
*
|
|
110
|
-
* @param
|
|
111
|
-
* @
|
|
112
|
-
* @
|
|
127
|
+
* @param request 请求
|
|
128
|
+
* @param request.body 请求体
|
|
129
|
+
* @param request.params 请求参数
|
|
113
130
|
*/
|
|
114
|
-
private
|
|
131
|
+
private axiosRequest;
|
|
115
132
|
}
|
package/dist/main.js
CHANGED
|
@@ -15067,37 +15067,45 @@ class Http {
|
|
|
15067
15067
|
setContentType(contentType) {
|
|
15068
15068
|
return this.addHttpHeader(HttpHeader.CONTENT_TYPE, contentType);
|
|
15069
15069
|
}
|
|
15070
|
+
/**
|
|
15071
|
+
* ### 是否直接抛出错误
|
|
15072
|
+
* @param isThrowError 是否回调错误
|
|
15073
|
+
*/
|
|
15074
|
+
throwError(isThrowError = true) {
|
|
15075
|
+
this.isThrowError = isThrowError;
|
|
15076
|
+
return this;
|
|
15077
|
+
}
|
|
15078
|
+
/**
|
|
15079
|
+
* ### 无返回发送请求
|
|
15080
|
+
* @param postData 发送的数据模型(数组)
|
|
15081
|
+
*/
|
|
15082
|
+
async request(postData) {
|
|
15083
|
+
await this.requestRaw(postData);
|
|
15084
|
+
}
|
|
15070
15085
|
/**
|
|
15071
15086
|
* ### 发送请求并获取转换后的模型
|
|
15072
|
-
* @param postData
|
|
15087
|
+
* @param postData 发送的数据模型(数组)
|
|
15073
15088
|
* @param parseClass 返回的模型
|
|
15074
15089
|
*/
|
|
15075
|
-
async
|
|
15076
|
-
const result = await this.
|
|
15090
|
+
async requestModel(postData, parseClass) {
|
|
15091
|
+
const result = await this.requestRaw(postData);
|
|
15077
15092
|
return Transformer.parse(result, parseClass);
|
|
15078
15093
|
}
|
|
15079
15094
|
/**
|
|
15080
15095
|
* ### 发送请求并获取转换后的模型数组
|
|
15081
|
-
* @param postData
|
|
15096
|
+
* @param postData 发送的数据模型(数组)
|
|
15082
15097
|
* @param parseClass 返回的模型数组
|
|
15083
15098
|
*/
|
|
15084
|
-
async
|
|
15085
|
-
const result = await this.
|
|
15099
|
+
async requestModelList(postData, parseClass) {
|
|
15100
|
+
const result = await this.requestRaw(postData);
|
|
15086
15101
|
return result.map((item) => Transformer.parse(item, parseClass));
|
|
15087
15102
|
}
|
|
15088
15103
|
/**
|
|
15089
|
-
* ###
|
|
15090
|
-
* @param isThrowError 是否回调错误
|
|
15091
|
-
*/
|
|
15092
|
-
throwError(isThrowError = true) {
|
|
15093
|
-
this.isThrowError = isThrowError;
|
|
15094
|
-
return this;
|
|
15095
|
-
}
|
|
15096
|
-
/**
|
|
15097
|
-
* ### POST 发送模型/模型数组并
|
|
15104
|
+
* ### POST 发送请求并获取原始 `data`
|
|
15098
15105
|
* @param postData 发送的数据模型(数组)
|
|
15106
|
+
* @returns 响应的原始 `data`
|
|
15099
15107
|
*/
|
|
15100
|
-
async
|
|
15108
|
+
async requestRaw(postData) {
|
|
15101
15109
|
let body = {};
|
|
15102
15110
|
if (postData) {
|
|
15103
15111
|
if (Array.isArray(postData)) {
|
|
@@ -15106,12 +15114,23 @@ class Http {
|
|
|
15106
15114
|
body = postData.toJson();
|
|
15107
15115
|
}
|
|
15108
15116
|
}
|
|
15109
|
-
this.
|
|
15117
|
+
return this.send({
|
|
15118
|
+
body
|
|
15119
|
+
});
|
|
15120
|
+
}
|
|
15121
|
+
/**
|
|
15122
|
+
* 发送请求
|
|
15123
|
+
* @param request 请求
|
|
15124
|
+
* @param request.body 请求体
|
|
15125
|
+
* @param request.params 请求参数
|
|
15126
|
+
* @returns 响应的JSON
|
|
15127
|
+
*/
|
|
15128
|
+
async send(request) {
|
|
15110
15129
|
return new Promise((resolve, reject) => {
|
|
15111
15130
|
if (this.loadingHandler) {
|
|
15112
15131
|
this.loadingHandler(true);
|
|
15113
15132
|
}
|
|
15114
|
-
this.
|
|
15133
|
+
this.axiosRequest(request).then((response) => {
|
|
15115
15134
|
if (response.code === WebConfig.unAuthorizeCode) {
|
|
15116
15135
|
if (this.isThrowError || !this.errorHandler) {
|
|
15117
15136
|
reject(response);
|
|
@@ -15148,17 +15167,19 @@ class Http {
|
|
|
15148
15167
|
/**
|
|
15149
15168
|
* ### 发送请求
|
|
15150
15169
|
*
|
|
15151
|
-
* @param
|
|
15152
|
-
* @
|
|
15153
|
-
* @
|
|
15170
|
+
* @param request 请求
|
|
15171
|
+
* @param request.body 请求体
|
|
15172
|
+
* @param request.params 请求参数
|
|
15154
15173
|
*/
|
|
15155
|
-
async
|
|
15174
|
+
async axiosRequest(request) {
|
|
15175
|
+
const { body, params } = request;
|
|
15156
15176
|
const axiosConfig = {};
|
|
15157
15177
|
axiosConfig.url = this.url;
|
|
15158
15178
|
axiosConfig.headers = this.headers;
|
|
15159
15179
|
axiosConfig.timeout = this.timeout;
|
|
15160
15180
|
axiosConfig.method = this.method;
|
|
15161
15181
|
axiosConfig.data = body;
|
|
15182
|
+
axiosConfig.params = params;
|
|
15162
15183
|
axiosConfig.withCredentials = this.widthCookie;
|
|
15163
15184
|
const response = new HttpResponse();
|
|
15164
15185
|
try {
|
|
@@ -15217,7 +15238,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
15217
15238
|
try {
|
|
15218
15239
|
const exportModel = new ExportModel();
|
|
15219
15240
|
exportModel.fileCode = fileCode;
|
|
15220
|
-
const downloadPath = await Http.create(props.param.queryExportUrl).throwError().
|
|
15241
|
+
const downloadPath = await Http.create(props.param.queryExportUrl).throwError().requestRaw(exportModel);
|
|
15221
15242
|
isLoading.value = false;
|
|
15222
15243
|
exportFilePath.value = WebFileUtil.getStaticFileUrl(downloadPath);
|
|
15223
15244
|
} catch (e) {
|
|
@@ -15236,9 +15257,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
15236
15257
|
try {
|
|
15237
15258
|
const exportRequest = props.param.param;
|
|
15238
15259
|
exportRequest.page = void 0;
|
|
15239
|
-
const fileCode = await Http.create(props.param.createExportTaskUrl).
|
|
15240
|
-
exportRequest
|
|
15241
|
-
);
|
|
15260
|
+
const fileCode = await Http.create(props.param.createExportTaskUrl).requestRaw(exportRequest);
|
|
15242
15261
|
await startLoop(fileCode);
|
|
15243
15262
|
} catch (e) {
|
|
15244
15263
|
console.warn(e);
|
|
@@ -18537,7 +18556,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
18537
18556
|
}, () => [
|
|
18538
18557
|
item.prefixText ? (openBlock(), createElementBlock("span", _hoisted_5$1, toDisplayString(item.prefixText), 1)) : createCommentVNode("", true),
|
|
18539
18558
|
item.formatter ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
18540
|
-
createTextVNode(toDisplayString(item.formatter(
|
|
18559
|
+
createTextVNode(toDisplayString(item.formatter(getRowEntity(scope))), 1)
|
|
18541
18560
|
], 64)) : unref(getDictionary)(unref(EntityClass), item.key) ? (openBlock(), createBlock(unref(EnumColumn), {
|
|
18542
18561
|
key: 2,
|
|
18543
18562
|
column: item,
|
|
@@ -18606,7 +18625,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
18606
18625
|
disabled: button.disabled ? button.disabled(getRowEntity(scope)) : false,
|
|
18607
18626
|
type: button.dangerButton ? "danger" : button.warningButton ? "warning" : "default",
|
|
18608
18627
|
underline: "never",
|
|
18609
|
-
onClick: ($event) =>
|
|
18628
|
+
onClick: ($event) => button.click(getRowEntity(scope))
|
|
18610
18629
|
}, {
|
|
18611
18630
|
default: withCtx(() => [
|
|
18612
18631
|
createTextVNode(toDisplayString(button.label), 1)
|
|
@@ -19949,7 +19968,7 @@ class AbstractCurdService extends AbstractService {
|
|
|
19949
19968
|
* @param apiUrl `可选` 自定义请求URL
|
|
19950
19969
|
*/
|
|
19951
19970
|
async getPage(request, apiUrl = this.urlGetPage) {
|
|
19952
|
-
const responsePage = await this.api(apiUrl).
|
|
19971
|
+
const responsePage = await this.api(apiUrl).requestModel(request, QueryResponsePage);
|
|
19953
19972
|
responsePage.list = responsePage.list.map((json) => Transformer.parse(json, this.entityClass));
|
|
19954
19973
|
return responsePage;
|
|
19955
19974
|
}
|
|
@@ -19959,7 +19978,7 @@ class AbstractCurdService extends AbstractService {
|
|
|
19959
19978
|
* @param apiUrl `可选` 自定义请求URL
|
|
19960
19979
|
*/
|
|
19961
19980
|
async getList(request, apiUrl = this.urlGetList) {
|
|
19962
|
-
return this.api(apiUrl).
|
|
19981
|
+
return this.api(apiUrl).requestModelList(request, this.entityClass);
|
|
19963
19982
|
}
|
|
19964
19983
|
/**
|
|
19965
19984
|
* ### 查询树结构数据数组
|
|
@@ -19967,7 +19986,7 @@ class AbstractCurdService extends AbstractService {
|
|
|
19967
19986
|
* @param apiUrl `可选` 自定义请求URL
|
|
19968
19987
|
*/
|
|
19969
19988
|
async getTreeList(request, apiUrl = this.urlGetTreeList) {
|
|
19970
|
-
return this.api(apiUrl).
|
|
19989
|
+
return this.api(apiUrl).requestModelList(request, this.entityClass);
|
|
19971
19990
|
}
|
|
19972
19991
|
/**
|
|
19973
19992
|
* ### 根据 `ID` 获取详情对象
|
|
@@ -19975,7 +19994,7 @@ class AbstractCurdService extends AbstractService {
|
|
|
19975
19994
|
* @param apiUrl `可选` 自定义请求URL
|
|
19976
19995
|
*/
|
|
19977
19996
|
async getDetail(id, apiUrl = this.urlGetDetail) {
|
|
19978
|
-
return this.api(apiUrl).
|
|
19997
|
+
return this.api(apiUrl).requestModel(this.newEntityInstance(id), this.entityClass);
|
|
19979
19998
|
}
|
|
19980
19999
|
/**
|
|
19981
20000
|
* ### 添加一条新的数据
|
|
@@ -19984,7 +20003,7 @@ class AbstractCurdService extends AbstractService {
|
|
|
19984
20003
|
* @param apiUrl `可选` 自定义请求URL
|
|
19985
20004
|
*/
|
|
19986
20005
|
async add(data, message, apiUrl = this.urlAdd) {
|
|
19987
|
-
const saved = await this.api(apiUrl).
|
|
20006
|
+
const saved = await this.api(apiUrl).requestModel(data, this.entityClass);
|
|
19988
20007
|
FeedbackUtil.toastSuccess(message || WebI18n.get().AddSuccess);
|
|
19989
20008
|
return saved.id;
|
|
19990
20009
|
}
|