@zhubangyun/lowcode-core 5.3.132 → 5.3.182
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/es/components/schema-render/components/schema-render-base.js +1 -1
- package/es/index.d.ts +2 -3
- package/es/index.js +2 -3
- package/es/utils/{common → api}/RestApi.d.ts +9 -7
- package/es/utils/{common → api}/RestApi.js +142 -85
- package/es/utils/api/index.d.ts +2 -0
- package/es/utils/api/index.js +49 -2
- package/es/utils/cache/index.d.ts +9 -0
- package/es/utils/cache/index.js +75 -0
- package/es/utils/common/SingletonInstanceMap.d.ts +7 -0
- package/es/utils/common/SingletonInstanceMap.js +73 -0
- package/es/utils/common/index.d.ts +0 -2
- package/es/utils/common/index.js +1 -30
- package/es/utils/{common/RestFormApi.d.ts → form/form.api.d.ts} +9 -4
- package/es/utils/{common/RestFormApi.js → form/form.api.js} +85 -36
- package/es/utils/form/form.handler.js +0 -0
- package/es/utils/form/form.instance.d.ts +26 -0
- package/es/utils/form/form.instance.js +100 -0
- package/es/utils/form/form.process.js +0 -0
- package/es/utils/index.d.ts +2 -0
- package/es/utils/index.js +2 -0
- package/lib/components/schema-render/components/schema-render-base.js +1 -1
- package/lib/index.d.ts +2 -3
- package/lib/index.js +4 -6
- package/lib/utils/{common → api}/RestApi.d.ts +9 -7
- package/lib/utils/{common → api}/RestApi.js +142 -85
- package/lib/utils/api/index.d.ts +2 -0
- package/lib/utils/api/index.js +51 -2
- package/lib/utils/cache/index.d.ts +9 -0
- package/lib/utils/cache/index.js +80 -0
- package/lib/utils/common/SingletonInstanceMap.d.ts +7 -0
- package/lib/utils/common/SingletonInstanceMap.js +78 -0
- package/lib/utils/common/index.d.ts +0 -2
- package/lib/utils/common/index.js +2 -32
- package/lib/utils/{common/RestFormApi.d.ts → form/form.api.d.ts} +9 -4
- package/lib/utils/{common/RestFormApi.js → form/form.api.js} +85 -36
- package/lib/utils/form/form.handler.js +1 -0
- package/lib/utils/form/form.instance.d.ts +26 -0
- package/lib/utils/form/form.instance.js +105 -0
- package/lib/utils/form/form.process.js +1 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +2 -0
- package/package.json +1 -1
- package/es/utils/common/ClientCache.d.ts +0 -36
- package/es/utils/common/ClientCache.js +0 -120
- package/lib/utils/common/ClientCache.d.ts +0 -36
- package/lib/utils/common/ClientCache.js +0 -125
- /package/es/utils/{common → api}/Request.d.ts +0 -0
- /package/es/utils/{common → api}/Request.js +0 -0
- /package/lib/utils/{common → api}/Request.d.ts +0 -0
- /package/lib/utils/{common → api}/Request.js +0 -0
|
@@ -42,7 +42,7 @@ export var SchemaRenderBase = /*#__PURE__*/function (_Component) {
|
|
|
42
42
|
return _context.abrupt("return");
|
|
43
43
|
case 6:
|
|
44
44
|
_context.next = 8;
|
|
45
|
-
return utils.
|
|
45
|
+
return utils.request.getSchema(schemaId);
|
|
46
46
|
case 8:
|
|
47
47
|
schema = _context.sent;
|
|
48
48
|
_this.setState({
|
package/es/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import utils from "./utils";
|
|
2
|
-
export { RestApi } from "./utils/
|
|
3
|
-
export { RestFormApi } from "./utils/
|
|
4
|
-
export { ClientCache } from "./utils/common/ClientCache";
|
|
2
|
+
export { RestApi } from "./utils/api/RestApi";
|
|
3
|
+
export { RestFormApi } from "./utils/form/form.api";
|
|
5
4
|
export { Layout } from "./components/layout";
|
|
6
5
|
export { SchemaRender } from "./components/schema-render";
|
|
7
6
|
export { ReactRender } from "./components/react-render";
|
package/es/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import utils from "./utils";
|
|
2
|
-
export { RestApi } from "./utils/
|
|
3
|
-
export { RestFormApi } from "./utils/
|
|
4
|
-
export { ClientCache } from "./utils/common/ClientCache";
|
|
2
|
+
export { RestApi } from "./utils/api/RestApi";
|
|
3
|
+
export { RestFormApi } from "./utils/form/form.api";
|
|
5
4
|
export { Layout } from "./components/layout";
|
|
6
5
|
export { SchemaRender } from "./components/schema-render";
|
|
7
6
|
export { ReactRender } from "./components/react-render";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxiosInstance } from "axios";
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
2
2
|
export interface RestApiOptions {
|
|
3
3
|
/**
|
|
4
4
|
* 超时时间
|
|
@@ -9,31 +9,33 @@ export interface RestApiOptions {
|
|
|
9
9
|
*/
|
|
10
10
|
title?: string;
|
|
11
11
|
}
|
|
12
|
-
export declare class RestApi<DataType> {
|
|
12
|
+
export declare abstract class RestApi<DataType> {
|
|
13
13
|
uri: string;
|
|
14
14
|
title: string;
|
|
15
15
|
request: AxiosInstance;
|
|
16
16
|
constructor(uri: string, options?: RestApiOptions);
|
|
17
|
+
abstract handleRequestConfig(config: AxiosRequestConfig): void;
|
|
17
18
|
search(params?: Record<string, any>, page?: number, pageSize?: number): Promise<ManyResult<DataType>>;
|
|
18
19
|
/**
|
|
19
20
|
* 通过id获取
|
|
20
21
|
* @param id
|
|
21
22
|
* @param options
|
|
22
23
|
*/
|
|
23
|
-
getById(id: string, options?: BaseRequestOptions<DataType>): Promise<DataType
|
|
24
|
+
getById(id: string, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
25
|
+
save(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
24
26
|
/**
|
|
25
27
|
* 创建
|
|
26
28
|
*/
|
|
27
|
-
create(data: DataType, options?: BaseRequestOptions<DataType>): Promise<DataType
|
|
29
|
+
create(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
28
30
|
/**
|
|
29
31
|
* 更新
|
|
30
32
|
*/
|
|
31
|
-
update(id: string, data: DataType, options?: BaseRequestOptions<DataType>): Promise<DataType
|
|
33
|
+
update(id: string, data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
32
34
|
/**
|
|
33
35
|
* 通过id删除
|
|
34
36
|
*/
|
|
35
|
-
deleteById(id: string, options?: BaseRequestOptions<DataType>): Promise<
|
|
36
|
-
showError
|
|
37
|
+
deleteById(id: string, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
38
|
+
private showError;
|
|
37
39
|
}
|
|
38
40
|
export interface BaseType {
|
|
39
41
|
/**
|
|
@@ -24,6 +24,8 @@ export var RestApi = /*#__PURE__*/function () {
|
|
|
24
24
|
var _proto = RestApi.prototype;
|
|
25
25
|
_proto.search = /*#__PURE__*/function () {
|
|
26
26
|
var _search = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params, page, pageSize) {
|
|
27
|
+
var _this$handleRequestCo;
|
|
28
|
+
var config;
|
|
27
29
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
28
30
|
while (1) switch (_context.prev = _context.next) {
|
|
29
31
|
case 0:
|
|
@@ -38,13 +40,17 @@ export var RestApi = /*#__PURE__*/function () {
|
|
|
38
40
|
}
|
|
39
41
|
params.page = page;
|
|
40
42
|
params.pageSize = pageSize;
|
|
41
|
-
|
|
43
|
+
config = {
|
|
44
|
+
params: params
|
|
45
|
+
};
|
|
46
|
+
(_this$handleRequestCo = this.handleRequestConfig) === null || _this$handleRequestCo === void 0 ? void 0 : _this$handleRequestCo.call(this, config);
|
|
47
|
+
_context.next = 9;
|
|
42
48
|
return this.request.get("", {
|
|
43
49
|
params: params
|
|
44
50
|
});
|
|
45
|
-
case
|
|
51
|
+
case 9:
|
|
46
52
|
return _context.abrupt("return", _context.sent);
|
|
47
|
-
case
|
|
53
|
+
case 10:
|
|
48
54
|
case "end":
|
|
49
55
|
return _context.stop();
|
|
50
56
|
}
|
|
@@ -65,30 +71,33 @@ export var RestApi = /*#__PURE__*/function () {
|
|
|
65
71
|
/*#__PURE__*/
|
|
66
72
|
function () {
|
|
67
73
|
var _getById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id, options) {
|
|
68
|
-
var
|
|
74
|
+
var _this$handleRequestCo2;
|
|
75
|
+
var config, res, _options$onError, _options$onSuccess;
|
|
69
76
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
70
77
|
while (1) switch (_context2.prev = _context2.next) {
|
|
71
78
|
case 0:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
config = {};
|
|
80
|
+
(_this$handleRequestCo2 = this.handleRequestConfig) === null || _this$handleRequestCo2 === void 0 ? void 0 : _this$handleRequestCo2.call(this, config);
|
|
81
|
+
_context2.next = 4;
|
|
82
|
+
return this.request.get(String(id), config);
|
|
83
|
+
case 4:
|
|
75
84
|
res = _context2.sent;
|
|
76
85
|
if (res.success) {
|
|
77
|
-
_context2.next =
|
|
86
|
+
_context2.next = 11;
|
|
78
87
|
break;
|
|
79
88
|
}
|
|
80
89
|
this.showError("\u83B7\u53D6{" + id + "}\u5931\u8D25!", res.message).then();
|
|
81
|
-
_context2.next =
|
|
90
|
+
_context2.next = 9;
|
|
82
91
|
return options === null || options === void 0 ? void 0 : (_options$onError = options.onError) === null || _options$onError === void 0 ? void 0 : _options$onError.call(options, res);
|
|
83
|
-
case 7:
|
|
84
|
-
_context2.next = 11;
|
|
85
|
-
break;
|
|
86
92
|
case 9:
|
|
87
|
-
_context2.next =
|
|
88
|
-
|
|
93
|
+
_context2.next = 13;
|
|
94
|
+
break;
|
|
89
95
|
case 11:
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
_context2.next = 13;
|
|
97
|
+
return options === null || options === void 0 ? void 0 : (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options, res);
|
|
98
|
+
case 13:
|
|
99
|
+
return _context2.abrupt("return", res);
|
|
100
|
+
case 14:
|
|
92
101
|
case "end":
|
|
93
102
|
return _context2.stop();
|
|
94
103
|
}
|
|
@@ -98,6 +107,45 @@ export var RestApi = /*#__PURE__*/function () {
|
|
|
98
107
|
return _getById.apply(this, arguments);
|
|
99
108
|
}
|
|
100
109
|
return getById;
|
|
110
|
+
}();
|
|
111
|
+
_proto.save = /*#__PURE__*/function () {
|
|
112
|
+
var _save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data, options) {
|
|
113
|
+
var _this$handleRequestCo3;
|
|
114
|
+
var config, res, _options$onError2, _options$onSuccess2;
|
|
115
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
116
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
117
|
+
case 0:
|
|
118
|
+
config = {};
|
|
119
|
+
(_this$handleRequestCo3 = this.handleRequestConfig) === null || _this$handleRequestCo3 === void 0 ? void 0 : _this$handleRequestCo3.call(this, config);
|
|
120
|
+
_context3.next = 4;
|
|
121
|
+
return this.request.post("", data, config);
|
|
122
|
+
case 4:
|
|
123
|
+
res = _context3.sent;
|
|
124
|
+
if (res.success) {
|
|
125
|
+
_context3.next = 11;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
this.showError("\u4FDD\u5B58\u5931\u8D25!", res.message).then();
|
|
129
|
+
_context3.next = 9;
|
|
130
|
+
return options === null || options === void 0 ? void 0 : (_options$onError2 = options.onError) === null || _options$onError2 === void 0 ? void 0 : _options$onError2.call(options, res);
|
|
131
|
+
case 9:
|
|
132
|
+
_context3.next = 13;
|
|
133
|
+
break;
|
|
134
|
+
case 11:
|
|
135
|
+
_context3.next = 13;
|
|
136
|
+
return options === null || options === void 0 ? void 0 : (_options$onSuccess2 = options.onSuccess) === null || _options$onSuccess2 === void 0 ? void 0 : _options$onSuccess2.call(options, res);
|
|
137
|
+
case 13:
|
|
138
|
+
return _context3.abrupt("return", res);
|
|
139
|
+
case 14:
|
|
140
|
+
case "end":
|
|
141
|
+
return _context3.stop();
|
|
142
|
+
}
|
|
143
|
+
}, _callee3, this);
|
|
144
|
+
}));
|
|
145
|
+
function save(_x6, _x7) {
|
|
146
|
+
return _save.apply(this, arguments);
|
|
147
|
+
}
|
|
148
|
+
return save;
|
|
101
149
|
}()
|
|
102
150
|
/**
|
|
103
151
|
* 创建
|
|
@@ -106,37 +154,40 @@ export var RestApi = /*#__PURE__*/function () {
|
|
|
106
154
|
_proto.create =
|
|
107
155
|
/*#__PURE__*/
|
|
108
156
|
function () {
|
|
109
|
-
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
110
|
-
var
|
|
111
|
-
|
|
112
|
-
|
|
157
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data, options) {
|
|
158
|
+
var _this$handleRequestCo4;
|
|
159
|
+
var config, res, _options$onError3, _options$onSuccess3;
|
|
160
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
161
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
113
162
|
case 0:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
163
|
+
config = {};
|
|
164
|
+
(_this$handleRequestCo4 = this.handleRequestConfig) === null || _this$handleRequestCo4 === void 0 ? void 0 : _this$handleRequestCo4.call(this, config);
|
|
165
|
+
_context4.next = 4;
|
|
166
|
+
return this.request.post("", data, config);
|
|
167
|
+
case 4:
|
|
168
|
+
res = _context4.sent;
|
|
118
169
|
if (res.success) {
|
|
119
|
-
|
|
170
|
+
_context4.next = 11;
|
|
120
171
|
break;
|
|
121
172
|
}
|
|
122
173
|
this.showError("\u65B0\u589E\u5931\u8D25!", res.message).then();
|
|
123
|
-
|
|
124
|
-
return options === null || options === void 0 ? void 0 : (_options$
|
|
125
|
-
case 7:
|
|
126
|
-
_context3.next = 11;
|
|
127
|
-
break;
|
|
174
|
+
_context4.next = 9;
|
|
175
|
+
return options === null || options === void 0 ? void 0 : (_options$onError3 = options.onError) === null || _options$onError3 === void 0 ? void 0 : _options$onError3.call(options, res);
|
|
128
176
|
case 9:
|
|
129
|
-
|
|
130
|
-
|
|
177
|
+
_context4.next = 13;
|
|
178
|
+
break;
|
|
131
179
|
case 11:
|
|
132
|
-
|
|
133
|
-
|
|
180
|
+
_context4.next = 13;
|
|
181
|
+
return options === null || options === void 0 ? void 0 : (_options$onSuccess3 = options.onSuccess) === null || _options$onSuccess3 === void 0 ? void 0 : _options$onSuccess3.call(options, res);
|
|
182
|
+
case 13:
|
|
183
|
+
return _context4.abrupt("return", res);
|
|
184
|
+
case 14:
|
|
134
185
|
case "end":
|
|
135
|
-
return
|
|
186
|
+
return _context4.stop();
|
|
136
187
|
}
|
|
137
|
-
},
|
|
188
|
+
}, _callee4, this);
|
|
138
189
|
}));
|
|
139
|
-
function create(
|
|
190
|
+
function create(_x8, _x9) {
|
|
140
191
|
return _create.apply(this, arguments);
|
|
141
192
|
}
|
|
142
193
|
return create;
|
|
@@ -148,37 +199,40 @@ export var RestApi = /*#__PURE__*/function () {
|
|
|
148
199
|
_proto.update =
|
|
149
200
|
/*#__PURE__*/
|
|
150
201
|
function () {
|
|
151
|
-
var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
152
|
-
var
|
|
153
|
-
|
|
154
|
-
|
|
202
|
+
var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(id, data, options) {
|
|
203
|
+
var _this$handleRequestCo5;
|
|
204
|
+
var config, res, _options$onError4, _options$onSuccess4;
|
|
205
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
206
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
155
207
|
case 0:
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
208
|
+
config = {};
|
|
209
|
+
(_this$handleRequestCo5 = this.handleRequestConfig) === null || _this$handleRequestCo5 === void 0 ? void 0 : _this$handleRequestCo5.call(this, config);
|
|
210
|
+
_context5.next = 4;
|
|
211
|
+
return this.request.put(String(id), data, config);
|
|
212
|
+
case 4:
|
|
213
|
+
res = _context5.sent;
|
|
160
214
|
if (res.success) {
|
|
161
|
-
|
|
215
|
+
_context5.next = 11;
|
|
162
216
|
break;
|
|
163
217
|
}
|
|
164
218
|
this.showError("\u66F4\u65B0\u5931\u8D25!", res.message).then();
|
|
165
|
-
|
|
166
|
-
return options === null || options === void 0 ? void 0 : (_options$
|
|
167
|
-
case 7:
|
|
168
|
-
_context4.next = 11;
|
|
169
|
-
break;
|
|
219
|
+
_context5.next = 9;
|
|
220
|
+
return options === null || options === void 0 ? void 0 : (_options$onError4 = options.onError) === null || _options$onError4 === void 0 ? void 0 : _options$onError4.call(options, res);
|
|
170
221
|
case 9:
|
|
171
|
-
|
|
172
|
-
|
|
222
|
+
_context5.next = 13;
|
|
223
|
+
break;
|
|
173
224
|
case 11:
|
|
174
|
-
|
|
175
|
-
|
|
225
|
+
_context5.next = 13;
|
|
226
|
+
return options === null || options === void 0 ? void 0 : (_options$onSuccess4 = options.onSuccess) === null || _options$onSuccess4 === void 0 ? void 0 : _options$onSuccess4.call(options, res);
|
|
227
|
+
case 13:
|
|
228
|
+
return _context5.abrupt("return", res);
|
|
229
|
+
case 14:
|
|
176
230
|
case "end":
|
|
177
|
-
return
|
|
231
|
+
return _context5.stop();
|
|
178
232
|
}
|
|
179
|
-
},
|
|
233
|
+
}, _callee5, this);
|
|
180
234
|
}));
|
|
181
|
-
function update(
|
|
235
|
+
function update(_x10, _x11, _x12) {
|
|
182
236
|
return _update.apply(this, arguments);
|
|
183
237
|
}
|
|
184
238
|
return update;
|
|
@@ -190,54 +244,57 @@ export var RestApi = /*#__PURE__*/function () {
|
|
|
190
244
|
_proto.deleteById =
|
|
191
245
|
/*#__PURE__*/
|
|
192
246
|
function () {
|
|
193
|
-
var _deleteById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
194
|
-
var
|
|
195
|
-
|
|
196
|
-
|
|
247
|
+
var _deleteById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(id, options) {
|
|
248
|
+
var _this$handleRequestCo6;
|
|
249
|
+
var config, res, _options$onError5, _options$onSuccess5;
|
|
250
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
251
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
197
252
|
case 0:
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
253
|
+
config = {};
|
|
254
|
+
(_this$handleRequestCo6 = this.handleRequestConfig) === null || _this$handleRequestCo6 === void 0 ? void 0 : _this$handleRequestCo6.call(this, config);
|
|
255
|
+
_context6.next = 4;
|
|
256
|
+
return this.request["delete"](String(id), config);
|
|
257
|
+
case 4:
|
|
258
|
+
res = _context6.sent;
|
|
202
259
|
if (res.success) {
|
|
203
|
-
|
|
260
|
+
_context6.next = 11;
|
|
204
261
|
break;
|
|
205
262
|
}
|
|
206
263
|
this.showError("\u5220\u9664{" + id + "}\u5931\u8D25!", res.message).then();
|
|
207
|
-
|
|
208
|
-
return options === null || options === void 0 ? void 0 : (_options$
|
|
209
|
-
case 7:
|
|
210
|
-
_context5.next = 11;
|
|
211
|
-
break;
|
|
264
|
+
_context6.next = 9;
|
|
265
|
+
return options === null || options === void 0 ? void 0 : (_options$onError5 = options.onError) === null || _options$onError5 === void 0 ? void 0 : _options$onError5.call(options, res);
|
|
212
266
|
case 9:
|
|
213
|
-
|
|
214
|
-
|
|
267
|
+
_context6.next = 13;
|
|
268
|
+
break;
|
|
215
269
|
case 11:
|
|
216
|
-
|
|
217
|
-
|
|
270
|
+
_context6.next = 13;
|
|
271
|
+
return options === null || options === void 0 ? void 0 : (_options$onSuccess5 = options.onSuccess) === null || _options$onSuccess5 === void 0 ? void 0 : _options$onSuccess5.call(options, res);
|
|
272
|
+
case 13:
|
|
273
|
+
return _context6.abrupt("return", res);
|
|
274
|
+
case 14:
|
|
218
275
|
case "end":
|
|
219
|
-
return
|
|
276
|
+
return _context6.stop();
|
|
220
277
|
}
|
|
221
|
-
},
|
|
278
|
+
}, _callee6, this);
|
|
222
279
|
}));
|
|
223
|
-
function deleteById(
|
|
280
|
+
function deleteById(_x13, _x14) {
|
|
224
281
|
return _deleteById.apply(this, arguments);
|
|
225
282
|
}
|
|
226
283
|
return deleteById;
|
|
227
284
|
}();
|
|
228
285
|
_proto.showError = /*#__PURE__*/function () {
|
|
229
|
-
var _showError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
230
|
-
return _regeneratorRuntime.wrap(function
|
|
231
|
-
while (1) switch (
|
|
286
|
+
var _showError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(type, msg) {
|
|
287
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
288
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
232
289
|
case 0:
|
|
233
290
|
_message === null || _message === void 0 ? void 0 : _message.error("{" + this.title + "}" + type + (msg || "")).then();
|
|
234
291
|
case 1:
|
|
235
292
|
case "end":
|
|
236
|
-
return
|
|
293
|
+
return _context7.stop();
|
|
237
294
|
}
|
|
238
|
-
},
|
|
295
|
+
}, _callee7, this);
|
|
239
296
|
}));
|
|
240
|
-
function showError(
|
|
297
|
+
function showError(_x15, _x16) {
|
|
241
298
|
return _showError.apply(this, arguments);
|
|
242
299
|
}
|
|
243
300
|
return showError;
|
package/es/utils/api/index.d.ts
CHANGED
package/es/utils/api/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
1
3
|
import axios from "axios";
|
|
2
|
-
import { onFulfilled, onRejected } from "
|
|
4
|
+
import { onFulfilled, onRejected } from "./Request";
|
|
5
|
+
import { formApi, schema } from "../cache";
|
|
3
6
|
export var request = axios.create({
|
|
4
7
|
baseURL: "/api",
|
|
5
8
|
// 基础URL
|
|
@@ -9,4 +12,48 @@ export var request = axios.create({
|
|
|
9
12
|
'Content-Type': 'application/json;charset=UTF-8'
|
|
10
13
|
}
|
|
11
14
|
});
|
|
12
|
-
request.interceptors.response.use(onFulfilled, onRejected);
|
|
15
|
+
request.interceptors.response.use(onFulfilled, onRejected);
|
|
16
|
+
export function getSchema(_x, _x2) {
|
|
17
|
+
return _getSchema.apply(this, arguments);
|
|
18
|
+
}
|
|
19
|
+
function _getSchema() {
|
|
20
|
+
_getSchema = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(schemaId, mock) {
|
|
21
|
+
var key;
|
|
22
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
23
|
+
while (1) switch (_context.prev = _context.next) {
|
|
24
|
+
case 0:
|
|
25
|
+
key = mock ? schemaId + "_mock" : schemaId;
|
|
26
|
+
_context.next = 3;
|
|
27
|
+
return schema.getInstance(key);
|
|
28
|
+
case 3:
|
|
29
|
+
return _context.abrupt("return", _context.sent);
|
|
30
|
+
case 4:
|
|
31
|
+
case "end":
|
|
32
|
+
return _context.stop();
|
|
33
|
+
}
|
|
34
|
+
}, _callee);
|
|
35
|
+
}));
|
|
36
|
+
return _getSchema.apply(this, arguments);
|
|
37
|
+
}
|
|
38
|
+
export function getFormApi(_x3, _x4) {
|
|
39
|
+
return _getFormApi.apply(this, arguments);
|
|
40
|
+
}
|
|
41
|
+
function _getFormApi() {
|
|
42
|
+
_getFormApi = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(schemaId, mock) {
|
|
43
|
+
var key;
|
|
44
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
45
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
46
|
+
case 0:
|
|
47
|
+
key = mock ? schemaId + "_mock" : schemaId;
|
|
48
|
+
_context2.next = 3;
|
|
49
|
+
return formApi.getInstance(key);
|
|
50
|
+
case 3:
|
|
51
|
+
return _context2.abrupt("return", _context2.sent);
|
|
52
|
+
case 4:
|
|
53
|
+
case "end":
|
|
54
|
+
return _context2.stop();
|
|
55
|
+
}
|
|
56
|
+
}, _callee2);
|
|
57
|
+
}));
|
|
58
|
+
return _getFormApi.apply(this, arguments);
|
|
59
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SingletonInstanceMap } from "../common/SingletonInstanceMap";
|
|
2
|
+
export declare class SchemaCache extends SingletonInstanceMap<any> {
|
|
3
|
+
createInstance(key: string): Promise<any>;
|
|
4
|
+
}
|
|
5
|
+
export declare const schema: SchemaCache;
|
|
6
|
+
export declare class FormApiCache extends SingletonInstanceMap<any> {
|
|
7
|
+
createInstance(key: string): Promise<any>;
|
|
8
|
+
}
|
|
9
|
+
export declare const formApi: FormApiCache;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
import { SingletonInstanceMap } from "../common/SingletonInstanceMap";
|
|
5
|
+
import { request } from "../api";
|
|
6
|
+
import { RestFormApi } from "../form/form.api";
|
|
7
|
+
export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
|
|
8
|
+
function SchemaCache() {
|
|
9
|
+
return _SingletonInstanceMap.apply(this, arguments) || this;
|
|
10
|
+
}
|
|
11
|
+
_inheritsLoose(SchemaCache, _SingletonInstanceMap);
|
|
12
|
+
var _proto = SchemaCache.prototype;
|
|
13
|
+
_proto.createInstance = /*#__PURE__*/function () {
|
|
14
|
+
var _createInstance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(key) {
|
|
15
|
+
var mock, pageId;
|
|
16
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
17
|
+
while (1) switch (_context.prev = _context.next) {
|
|
18
|
+
case 0:
|
|
19
|
+
mock = key.endsWith("_mock");
|
|
20
|
+
pageId = key.replace("_mock", "");
|
|
21
|
+
_context.next = 4;
|
|
22
|
+
return request.get("pages/" + pageId + "/schema", {
|
|
23
|
+
params: {
|
|
24
|
+
mock: mock
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
case 4:
|
|
28
|
+
return _context.abrupt("return", _context.sent);
|
|
29
|
+
case 5:
|
|
30
|
+
case "end":
|
|
31
|
+
return _context.stop();
|
|
32
|
+
}
|
|
33
|
+
}, _callee);
|
|
34
|
+
}));
|
|
35
|
+
function createInstance(_x) {
|
|
36
|
+
return _createInstance.apply(this, arguments);
|
|
37
|
+
}
|
|
38
|
+
return createInstance;
|
|
39
|
+
}();
|
|
40
|
+
return SchemaCache;
|
|
41
|
+
}(SingletonInstanceMap);
|
|
42
|
+
export var schema = new SchemaCache();
|
|
43
|
+
export var FormApiCache = /*#__PURE__*/function (_SingletonInstanceMap2) {
|
|
44
|
+
function FormApiCache() {
|
|
45
|
+
return _SingletonInstanceMap2.apply(this, arguments) || this;
|
|
46
|
+
}
|
|
47
|
+
_inheritsLoose(FormApiCache, _SingletonInstanceMap2);
|
|
48
|
+
var _proto2 = FormApiCache.prototype;
|
|
49
|
+
_proto2.createInstance = /*#__PURE__*/function () {
|
|
50
|
+
var _createInstance2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(key) {
|
|
51
|
+
var mock, formId, formApi;
|
|
52
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
53
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
54
|
+
case 0:
|
|
55
|
+
mock = key.endsWith("_mock");
|
|
56
|
+
formId = key.replace("_mock", "");
|
|
57
|
+
formApi = new RestFormApi(formId, mock);
|
|
58
|
+
_context2.next = 5;
|
|
59
|
+
return formApi.initialize();
|
|
60
|
+
case 5:
|
|
61
|
+
return _context2.abrupt("return", formApi);
|
|
62
|
+
case 6:
|
|
63
|
+
case "end":
|
|
64
|
+
return _context2.stop();
|
|
65
|
+
}
|
|
66
|
+
}, _callee2);
|
|
67
|
+
}));
|
|
68
|
+
function createInstance(_x2) {
|
|
69
|
+
return _createInstance2.apply(this, arguments);
|
|
70
|
+
}
|
|
71
|
+
return createInstance;
|
|
72
|
+
}();
|
|
73
|
+
return FormApiCache;
|
|
74
|
+
}(SingletonInstanceMap);
|
|
75
|
+
export var formApi = new FormApiCache();
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
export var SingletonInstanceMap = /*#__PURE__*/function () {
|
|
4
|
+
function SingletonInstanceMap() {
|
|
5
|
+
this.valueMap = new Map();
|
|
6
|
+
this.lockMap = new Map();
|
|
7
|
+
}
|
|
8
|
+
var _proto = SingletonInstanceMap.prototype;
|
|
9
|
+
_proto.getInstance = /*#__PURE__*/function () {
|
|
10
|
+
var _getInstance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(key) {
|
|
11
|
+
var self, value;
|
|
12
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
13
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
14
|
+
case 0:
|
|
15
|
+
self = this;
|
|
16
|
+
if (!this.valueMap.has(key)) {
|
|
17
|
+
_context2.next = 5;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
return _context2.abrupt("return", Promise.resolve(this.valueMap.get(key)));
|
|
21
|
+
case 5:
|
|
22
|
+
if (!this.lockMap.get(key)) {
|
|
23
|
+
_context2.next = 9;
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
return _context2.abrupt("return", new Promise(function (resolve, reject) {
|
|
27
|
+
setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
28
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
29
|
+
while (1) switch (_context.prev = _context.next) {
|
|
30
|
+
case 0:
|
|
31
|
+
resolve(self.getInstance(key));
|
|
32
|
+
case 1:
|
|
33
|
+
case "end":
|
|
34
|
+
return _context.stop();
|
|
35
|
+
}
|
|
36
|
+
}, _callee);
|
|
37
|
+
})), 1000);
|
|
38
|
+
}));
|
|
39
|
+
case 9:
|
|
40
|
+
_context2.prev = 9;
|
|
41
|
+
this.lockMap.set(key, true);
|
|
42
|
+
_context2.next = 13;
|
|
43
|
+
return this.createInstance(key);
|
|
44
|
+
case 13:
|
|
45
|
+
value = _context2.sent;
|
|
46
|
+
this.valueMap.set(key, value);
|
|
47
|
+
this.lockMap.set(key, false);
|
|
48
|
+
return _context2.abrupt("return", Promise.resolve(value));
|
|
49
|
+
case 19:
|
|
50
|
+
_context2.prev = 19;
|
|
51
|
+
_context2.t0 = _context2["catch"](9);
|
|
52
|
+
throw _context2.t0;
|
|
53
|
+
case 22:
|
|
54
|
+
_context2.prev = 22;
|
|
55
|
+
this.lockMap.set(key, false);
|
|
56
|
+
return _context2.finish(22);
|
|
57
|
+
case 25:
|
|
58
|
+
case "end":
|
|
59
|
+
return _context2.stop();
|
|
60
|
+
}
|
|
61
|
+
}, _callee2, this, [[9, 19, 22, 25]]);
|
|
62
|
+
}));
|
|
63
|
+
function getInstance(_x) {
|
|
64
|
+
return _getInstance.apply(this, arguments);
|
|
65
|
+
}
|
|
66
|
+
return getInstance;
|
|
67
|
+
}();
|
|
68
|
+
_proto.clear = function clear() {
|
|
69
|
+
this.lockMap.clear();
|
|
70
|
+
this.valueMap.clear();
|
|
71
|
+
};
|
|
72
|
+
return SingletonInstanceMap;
|
|
73
|
+
}();
|