@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.
- package/es/components/react-render/index.d.ts +5 -8
- package/es/components/react-render/index.js +12 -19
- package/es/components/react-render/react-render-factory.d.ts +3 -0
- package/es/components/react-render/react-render-factory.js +50 -0
- 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 +10 -8
- 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/react-render/index.d.ts +5 -8
- package/lib/components/react-render/index.js +12 -21
- package/lib/components/react-render/react-render-factory.d.ts +3 -0
- package/lib/components/react-render/react-render-factory.js +55 -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 +10 -8
- 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
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
components?: any;
|
|
5
|
-
style?: React.CSSProperties;
|
|
6
|
-
}> {
|
|
1
|
+
import { PureComponent } from 'react';
|
|
2
|
+
import { IRendererProps } from "@zhubangyun/lowcode-render-core/lib/types";
|
|
3
|
+
export declare class ReactRender extends PureComponent<IRendererProps & {}> {
|
|
7
4
|
key: string;
|
|
8
|
-
|
|
9
|
-
render(): JSX.Element;
|
|
5
|
+
node: any;
|
|
6
|
+
render(): import("react").JSX.Element;
|
|
10
7
|
}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
3
|
-
import
|
|
4
|
-
var _window$antd, _window$antd2;
|
|
5
|
-
import RendererCore, { adapter } from "@zhubangyun/lowcode-render-core";
|
|
6
|
-
import React, { PureComponent } from "react";
|
|
7
|
-
import utils from "../../utils";
|
|
3
|
+
import { PureComponent } from 'react';
|
|
8
4
|
import { createFetchHandler } from "@alilc/lowcode-datasource-fetch-handler";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
var LocalConfig = ((_window$antd2 = window.antd) === null || _window$antd2 === void 0 ? void 0 : _window$antd2.ConfigProvider) || _ConfigProvider;
|
|
5
|
+
import ReactRenderFactory from "./react-render-factory";
|
|
6
|
+
import utils from "../../utils";
|
|
13
7
|
export var ReactRender = /*#__PURE__*/function (_PureComponent) {
|
|
14
8
|
function ReactRender() {
|
|
15
9
|
var _this;
|
|
@@ -18,25 +12,24 @@ export var ReactRender = /*#__PURE__*/function (_PureComponent) {
|
|
|
18
12
|
}
|
|
19
13
|
_this = _PureComponent.call.apply(_PureComponent, [this].concat(args)) || this;
|
|
20
14
|
_this.key = Date.now().toString(36);
|
|
21
|
-
_this.
|
|
15
|
+
_this.node = void 0;
|
|
22
16
|
return _this;
|
|
23
17
|
}
|
|
24
18
|
_inheritsLoose(ReactRender, _PureComponent);
|
|
25
19
|
var _proto = ReactRender.prototype;
|
|
26
20
|
_proto.render = function render() {
|
|
27
21
|
var _this2 = this;
|
|
28
|
-
var
|
|
22
|
+
var components = this.props.components;
|
|
29
23
|
// @ts-ignore
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
ref: function ref(
|
|
34
|
-
|
|
24
|
+
return /*#__PURE__*/React.createElement(ReactRenderFactory, _extends({
|
|
25
|
+
key: this.key
|
|
26
|
+
}, this.props, {
|
|
27
|
+
ref: function ref(node) {
|
|
28
|
+
console.log(node);
|
|
29
|
+
_this2.node = node === null || node === void 0 ? void 0 : node.__ref;
|
|
35
30
|
},
|
|
36
|
-
schema: this.props.schema,
|
|
37
31
|
thisRequiredInJSE: true,
|
|
38
|
-
|
|
39
|
-
components: components,
|
|
32
|
+
components: components || window.components || {},
|
|
40
33
|
appHelper: {
|
|
41
34
|
utils: utils,
|
|
42
35
|
requestHandlersMap: {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
2
|
+
import _ConfigProvider from "antd/es/config-provider";
|
|
3
|
+
var _window$antd;
|
|
4
|
+
import { Component, PureComponent, createElement, createContext, forwardRef } from 'react';
|
|
5
|
+
import { findDOMNode } from "react-dom";
|
|
6
|
+
import { adapter, pageRendererFactory, componentRendererFactory, blockRendererFactory, addonRendererFactory, tempRendererFactory, rendererFactory } from '@zhubangyun/lowcode-render-core';
|
|
7
|
+
adapter.setRuntime({
|
|
8
|
+
Component: Component,
|
|
9
|
+
PureComponent: PureComponent,
|
|
10
|
+
createContext: createContext,
|
|
11
|
+
createElement: createElement,
|
|
12
|
+
forwardRef: forwardRef,
|
|
13
|
+
findDOMNode: findDOMNode
|
|
14
|
+
});
|
|
15
|
+
adapter.setRenderers({
|
|
16
|
+
PageRenderer: pageRendererFactory(),
|
|
17
|
+
ComponentRenderer: componentRendererFactory(),
|
|
18
|
+
BlockRenderer: blockRendererFactory(),
|
|
19
|
+
AddonRenderer: addonRendererFactory(),
|
|
20
|
+
TempRenderer: tempRendererFactory(),
|
|
21
|
+
DivRenderer: blockRendererFactory()
|
|
22
|
+
});
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
adapter.setConfigProvider(((_window$antd = window.antd) === null || _window$antd === void 0 ? void 0 : _window$antd.ConfigProvider) || _ConfigProvider);
|
|
25
|
+
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
window.___adapter = adapter;
|
|
28
|
+
function factory() {
|
|
29
|
+
var Renderer = rendererFactory();
|
|
30
|
+
return /*#__PURE__*/function (_Renderer) {
|
|
31
|
+
function ReactRenderer(props, context) {
|
|
32
|
+
var _this;
|
|
33
|
+
_this = _Renderer.call(this, props, context) || this;
|
|
34
|
+
_this.props = void 0;
|
|
35
|
+
_this.context = void 0;
|
|
36
|
+
_this.setState = void 0;
|
|
37
|
+
_this.forceUpdate = void 0;
|
|
38
|
+
_this.refs = void 0;
|
|
39
|
+
return _this;
|
|
40
|
+
}
|
|
41
|
+
_inheritsLoose(ReactRenderer, _Renderer);
|
|
42
|
+
var _proto = ReactRenderer.prototype;
|
|
43
|
+
_proto.isValidComponent = function isValidComponent(obj) {
|
|
44
|
+
var _obj$prototype;
|
|
45
|
+
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 Component;
|
|
46
|
+
};
|
|
47
|
+
return ReactRenderer;
|
|
48
|
+
}(Renderer);
|
|
49
|
+
}
|
|
50
|
+
export default factory();
|
|
@@ -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
|
-
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
|
|
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;
|