vap1 0.8.5 → 0.8.7
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/cems/admin/utils.d.ts +46 -0
- package/cems/index.d.ts +3 -1
- package/cems/index.js +3 -2
- package/hooks/useApiGlobal.d.ts +3 -1
- package/hooks/useApiGlobal.js +3 -6
- package/package.json +1 -1
package/cems/admin/utils.d.ts
CHANGED
|
@@ -32,6 +32,52 @@ export type GetApiDataXMLHttpRequest = (_url: any, _type: "POST" | 'GET', _param
|
|
|
32
32
|
* @returns 当为同步请求时,返回查询到的所有数据
|
|
33
33
|
*/
|
|
34
34
|
export type GetApiData = (_url: any, _type: "POST" | 'GET', _param?: any, _requestType?: "RequestParam" | "RequestBody", _isAsync?: any, _callBackFun?: any, _headerList?: any, _isEncodeURIComponent?: any) => any;
|
|
35
|
+
/**
|
|
36
|
+
*通过 fetch API发送请求获取数据
|
|
37
|
+
* @param _url 接口地址
|
|
38
|
+
* @param _type 请求类型 "POST"|'GET'
|
|
39
|
+
* @param _param 需要传入的参数例如:{name:"tester"}
|
|
40
|
+
* @param _requestType 后台接口接收的参数类型 "RequestParam"|"RequestBody",不传默认为“RequestBody”
|
|
41
|
+
* @param _callBackFun 请求成功后的回调函数
|
|
42
|
+
* @param _errorCallBackFun 请求失败后的回调函数
|
|
43
|
+
* @param _completeCallBackFun 请求完成后的回调函数(无论成功失败都会执行)
|
|
44
|
+
* @param _headerList 需要放到请求头header中的数据
|
|
45
|
+
* @param _isEncodeURIComponent 是否对参数进行 encodeURIComponent编码
|
|
46
|
+
* @returns Promise<any> 返回解析后的数据
|
|
47
|
+
* @example
|
|
48
|
+
示例一:
|
|
49
|
+
const result = await getApiDataFetch(
|
|
50
|
+
"/api/user/list",
|
|
51
|
+
"POST",
|
|
52
|
+
{ name: "test" },
|
|
53
|
+
"RequestBody",
|
|
54
|
+
(data) => { console.log("Success:", data); }, // _callBackFun
|
|
55
|
+
(xhr, status, err) => { console.error("Error:", err); }, // _errorCallBackFun
|
|
56
|
+
() => { console.log("Complete"); }, // _completeCallBackFun
|
|
57
|
+
{}, // _headerList
|
|
58
|
+
false // _isEncodeURIComponent
|
|
59
|
+
);
|
|
60
|
+
console.log("Returned Data:", result);
|
|
61
|
+
|
|
62
|
+
示例二:
|
|
63
|
+
getApiDataFetch(
|
|
64
|
+
"/api/user/list",
|
|
65
|
+
"GET",
|
|
66
|
+
{ id: 1 },
|
|
67
|
+
"RequestParam",
|
|
68
|
+
(data) => { console.log("Success:", data); },
|
|
69
|
+
(xhr, status, err) => { console.error("Error:", err); },
|
|
70
|
+
() => { console.log("Complete"); }
|
|
71
|
+
)
|
|
72
|
+
.then(data => {
|
|
73
|
+
// 这里也可以处理返回的数据,虽然 callback 已经执行了
|
|
74
|
+
})
|
|
75
|
+
.catch(err => {
|
|
76
|
+
// 错误处理
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
*/
|
|
80
|
+
export type GetApiDataFetch = (_url: string, _type: "POST" | "GET", _param?: any, _requestType?: "RequestParam" | "RequestBody", _callBackFun?: Function, _errorCallBackFun?: Function, _completeCallBackFun?: Function, _headerList?: any, _isEncodeURIComponent?: boolean) => Promise<any>;
|
|
35
81
|
/**
|
|
36
82
|
* 获取指定长度的16进制随机数据,
|
|
37
83
|
* @param len 指定长度,不传默认返回32位
|
package/cems/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ interface BuiltInAdminComponents {
|
|
|
13
13
|
AsyncSelect: AsyncSelectComponent;
|
|
14
14
|
CustomPagination: CustomPaginationComponent;
|
|
15
15
|
}
|
|
16
|
-
import type { GetTreeIconNumByOrgFlag, GetOrgFlagByTreeIconNum, MD5, AES, RSA, InitSchema, ConvertOptions, RegExpTest, CallWhereWhileFunc, GetApiData, GetApiDataXMLHttpRequest, GetUUIDFor16 } from './admin/utils';
|
|
16
|
+
import type { GetTreeIconNumByOrgFlag, GetOrgFlagByTreeIconNum, MD5, AES, RSA, InitSchema, ConvertOptions, RegExpTest, CallWhereWhileFunc, GetApiData, GetApiDataXMLHttpRequest, GetApiDataFetch, GetUUIDFor16 } from './admin/utils';
|
|
17
17
|
import type { Validator } from './admin/validator';
|
|
18
18
|
interface BuiltInAdminUtils {
|
|
19
19
|
getTreeIconNumByOrgFlag: GetTreeIconNumByOrgFlag;
|
|
@@ -28,6 +28,7 @@ interface BuiltInAdminUtils {
|
|
|
28
28
|
regExpTest: RegExpTest;
|
|
29
29
|
callWhereWhileFunc: CallWhereWhileFunc;
|
|
30
30
|
getApiData: GetApiData;
|
|
31
|
+
getApiDataFetch: GetApiDataFetch;
|
|
31
32
|
getApiDataXMLHttpRequest: GetApiDataXMLHttpRequest;
|
|
32
33
|
getUUIDFor16: GetUUIDFor16;
|
|
33
34
|
isOpenInCemsProject: boolean;
|
|
@@ -194,6 +195,7 @@ export declare const convertOptions: ConvertOptions;
|
|
|
194
195
|
export declare const regExpTest: RegExpTest;
|
|
195
196
|
export declare const callWhereWhileFunc: CallWhereWhileFunc;
|
|
196
197
|
export declare const getApiData: GetApiData;
|
|
198
|
+
export declare const getApiDataFetch: GetApiDataFetch;
|
|
197
199
|
export declare const getUUIDFor16: GetUUIDFor16;
|
|
198
200
|
export declare const getApiDataXMLHttpRequest: GetApiDataXMLHttpRequest;
|
|
199
201
|
export declare const isOpenInCemsProject: boolean;
|
package/cems/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.registerCustomComponent = exports.registerComponent = exports.CustomLibrary = exports.ComponentLibrary = exports.useDForm = exports.convertArrayToObject = exports.convertObjectToArray = exports.compareVersion = exports.uuid = exports.checkIpPort = exports.checkIpRange = exports.checkIPRangeIntersect = exports.DDrawer = exports.DIcon = exports.DDiv = exports.DCol = exports.DUpload = exports.DTree = exports.DTimePicker = exports.DPTable = exports.DTab = exports.DSwitch = exports.DSlider = exports.DSelect = exports.DSCTable = exports.DRadio = exports.DLabel = void 0;
|
|
3
|
+
exports.DDynamicTreeSelect = exports.DDynamicSelect = exports.DDatePicker = exports.DColorPicker = exports.DCheckboxGroup = exports.DCheckbox = exports.DButton = exports.DApiTable = exports.DForm = exports.CForm = exports.formatCols = exports.formatColumns = exports.useDApiGlobal = exports.useDApi = exports.useDModals = exports.getReload = exports.AjaxPostData = exports.Patch = exports.DivWidth = exports.Sensitive = exports.DModalInfo = exports.DInfo = exports.DModalTable = exports.DTable = exports.CUpload = exports.ChartPie = exports.ChartBar = exports.ChartBase = exports.isOpenInCemsProject = exports.getApiDataXMLHttpRequest = exports.getUUIDFor16 = exports.getApiDataFetch = exports.getApiData = exports.callWhereWhileFunc = exports.regExpTest = exports.convertOptions = exports.initSchema = exports.rsa = exports.aesDecrypted = exports.aes = exports.md5 = exports.validator = exports.getOrgFlagByTreeIconNum = exports.getTreeIconNumByOrgFlag = exports.CustomPagination = exports.AsyncSelect = exports.EasyuiTree = exports.CardTable = exports.UTILS = exports.COMPONENTS = void 0;
|
|
4
|
+
exports.registerCustomComponent = exports.registerComponent = exports.CustomLibrary = exports.ComponentLibrary = exports.useDForm = exports.convertArrayToObject = exports.convertObjectToArray = exports.compareVersion = exports.uuid = exports.checkIpPort = exports.checkIpRange = exports.checkIPRangeIntersect = exports.DDrawer = exports.DIcon = exports.DDiv = exports.DCol = exports.DUpload = exports.DTree = exports.DTimePicker = exports.DPTable = exports.DTab = exports.DSwitch = exports.DSlider = exports.DSelect = exports.DSCTable = exports.DRadio = exports.DLabel = exports.DInput = void 0;
|
|
5
5
|
/**
|
|
6
6
|
* 说明,如需要使用 `vap2/deps/cems` 请确保是 CEMS 应用/模块
|
|
7
7
|
*/
|
|
@@ -28,6 +28,7 @@ exports.convertOptions = exports.UTILS['convertOptions'];
|
|
|
28
28
|
exports.regExpTest = exports.UTILS['regExpTest'];
|
|
29
29
|
exports.callWhereWhileFunc = exports.UTILS['callWhereWhileFunc'];
|
|
30
30
|
exports.getApiData = exports.UTILS['getApiData'];
|
|
31
|
+
exports.getApiDataFetch = exports.UTILS['getApiDataFetch'];
|
|
31
32
|
exports.getUUIDFor16 = exports.UTILS['getUUIDFor16'];
|
|
32
33
|
exports.getApiDataXMLHttpRequest = exports.UTILS['getApiDataXMLHttpRequest'];
|
|
33
34
|
exports.isOpenInCemsProject = exports.UTILS['isOpenInCemsProject'];
|
package/hooks/useApiGlobal.d.ts
CHANGED
|
@@ -8,4 +8,6 @@ export type ApiGlobalOption = ApiOption & {
|
|
|
8
8
|
*/
|
|
9
9
|
namespace?: string;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
type UseAppGlobal = (option: string | ApiGlobalOption) => ApiListState;
|
|
12
|
+
export declare const useApiGlobal: UseAppGlobal;
|
|
13
|
+
export {};
|
package/hooks/useApiGlobal.js
CHANGED
|
@@ -33,15 +33,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
33
33
|
exports.useApiGlobal = void 0;
|
|
34
34
|
var lodash_1 = __importDefault(require("lodash"));
|
|
35
35
|
var react_1 = require("react");
|
|
36
|
-
|
|
36
|
+
// import { clearURL } from '../utils/PageUtil'
|
|
37
37
|
var _list_1 = require("./_list");
|
|
38
38
|
var useGlobal_1 = require("./useGlobal");
|
|
39
39
|
var useApiBase_1 = require("./useApiBase");
|
|
40
|
+
var useApi_1 = require("./useApi");
|
|
40
41
|
var toKey = function () {
|
|
41
42
|
var pathname = location.pathname, hash = location.hash;
|
|
42
|
-
if (lodash_1.default.has(window, '__MICRO_APP_BASE_ROUTE__')) {
|
|
43
|
-
return (0, PageUtil_1.clearURL)(pathname);
|
|
44
|
-
}
|
|
45
43
|
var root = lodash_1.default.trim(pathname).toLowerCase();
|
|
46
44
|
if (root.endsWith('/'))
|
|
47
45
|
root = root.substring(0, root.length - 1);
|
|
@@ -50,7 +48,7 @@ var toKey = function () {
|
|
|
50
48
|
root = root.replace('/', '-');
|
|
51
49
|
return root + hash;
|
|
52
50
|
};
|
|
53
|
-
|
|
51
|
+
exports.useApiGlobal = (lodash_1.default.has(window, '__MICRO_APP_BASE_ROUTE__') && window['__MICRO_APP_BASE_ROUTE__']) ? useApi_1.useApi : function (options) {
|
|
54
52
|
var config = lodash_1.default.isString(options) ? { api: options } : options;
|
|
55
53
|
var BASE = __assign(__assign({}, _list_1.DEFAULT_STATE), { effect: null });
|
|
56
54
|
BASE.rowKey = config.rowKey || 'id';
|
|
@@ -67,4 +65,3 @@ var useApiGlobal = function (options) {
|
|
|
67
65
|
var _a = __read((0, useGlobal_1.useGlobal)(namespace, BASE), 2), state = _a[0], doLoad = _a[1];
|
|
68
66
|
return (0, useApiBase_1.useApiBase)(config, state, doLoad, 'api-global');
|
|
69
67
|
};
|
|
70
|
-
exports.useApiGlobal = useApiGlobal;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"vap1","version":"0.8.
|
|
1
|
+
{"name":"vap1","version":"0.8.7","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
|