@zhubangyun/lowcode-core 5.3.131 → 5.3.181

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