vap1 0.1.0 → 0.1.1
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/components/Box/Box.js +9 -2
- package/components/Tables/ApiTable.d.ts +2 -2
- package/components/Tables/ApiTableModal.d.ts +1 -1
- package/components/Tables/TopTable.js +14 -15
- package/components/Tables/VTable.js +6 -4
- package/components/Trees/ActionTree.js +1 -1
- package/components/Trees/BaseTree.d.ts +2 -6
- package/components/Trees/BaseTree.js +2 -1
- package/components/Trees/DTree.js +2 -8
- package/components/Trees/FTree.js +6 -1
- package/components/Trees/STree.js +6 -1
- package/components/UForm/UForm.d.ts +1 -17
- package/components/UForm/UForm.js +26 -58
- package/components/UForm/UInfoModal.js +0 -3
- package/components/UForm/index.d.ts +16 -0
- package/components/Upload/UploadFile.js +0 -1
- package/components/_adapt/ColorPicker.d.ts +23 -4
- package/components/_adapt/ColorPicker.js +103 -39
- package/components/_adapt/InputNumber.d.ts +2 -2
- package/components/_adapt/InputNumber.js +8 -29
- package/components/_adapt/Layout.js +3 -2
- package/components/_adapt/Table.js +5 -8
- package/components/_common/AutoComplete.js +1 -1
- package/components/_setup/SearchField/SearchFieldSelect.js +6 -4
- package/components/_setup/UForm/UFormAdvanceInput.js +59 -34
- package/components/_setup/UForm/UFormInput.js +20 -23
- package/components/_setup/UForm/UFormJSON.js +2 -2
- package/components/_setup/UForm/UFormSelect.js +2 -2
- package/hooks/_list.d.ts +5 -2
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +3 -1
- package/hooks/useApi.d.ts +2 -68
- package/hooks/useApi.js +5 -333
- package/hooks/useApiBase.d.ts +68 -0
- package/hooks/useApiBase.js +331 -0
- package/hooks/useApiGlobal.d.ts +11 -0
- package/hooks/useApiGlobal.js +39 -5
- package/index.d.ts +1 -2
- package/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.useApiBase = void 0;
|
|
16
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
17
|
+
;
|
|
18
|
+
const react_1 = require("react");
|
|
19
|
+
const utils_1 = require("../utils");
|
|
20
|
+
const Const_1 = require("../components/_setup/Const");
|
|
21
|
+
const antd_1 = require("antd");
|
|
22
|
+
const chean = (param) => {
|
|
23
|
+
lodash_1.default.keys(param).map(key => {
|
|
24
|
+
if (param[key] === undefined || param[key] === '' || param[key] === null) {
|
|
25
|
+
lodash_1.default.unset(param, key);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return param;
|
|
29
|
+
};
|
|
30
|
+
const effectKey = (prevEffect, next, rowKey) => {
|
|
31
|
+
if (!lodash_1.default.has(next, rowKey))
|
|
32
|
+
return null;
|
|
33
|
+
if (next[rowKey] != prevEffect)
|
|
34
|
+
return next[rowKey];
|
|
35
|
+
return '_' + next[rowKey];
|
|
36
|
+
};
|
|
37
|
+
const SHOWTIP = (isSuccess, action, data, options) => {
|
|
38
|
+
let name = '';
|
|
39
|
+
if (options.tipLabel)
|
|
40
|
+
name = options.tipLabel;
|
|
41
|
+
if (options.tipField && lodash_1.default.has(data, options.tipField))
|
|
42
|
+
name += (' : ' + data[options.tipField]);
|
|
43
|
+
name = lodash_1.default.trim(name);
|
|
44
|
+
switch (action) {
|
|
45
|
+
case 'ADD':
|
|
46
|
+
if (isSuccess) {
|
|
47
|
+
antd_1.message.success(utils_1.i18n.txt(name ? Const_1.V.ACT_ADD_SUCCESS_NAMED : Const_1.V.ACT_ADD_SUCCESS, name));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
antd_1.message.error(utils_1.i18n.txt(name ? Const_1.V.ACT_ADD_FAIL_NAMED : Const_1.V.ACT_ADD_FAIL, name));
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
case 'UPDATE':
|
|
54
|
+
if (isSuccess) {
|
|
55
|
+
antd_1.message.success(utils_1.i18n.txt(name ? Const_1.V.ACT_UPDATE_SUCCESS_NAMED : Const_1.V.ACT_UPDATE_SUCCESS, name));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
antd_1.message.error(utils_1.i18n.txt(name ? Const_1.V.ACT_UPDATE_FAIL_NAMED : Const_1.V.ACT_UPDATE_FAIL, name));
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
case 'DELETE':
|
|
62
|
+
if (isSuccess) {
|
|
63
|
+
antd_1.message.success(utils_1.i18n.txt(name ? Const_1.V.ACT_DELETE_SUCCESS_NAMED : Const_1.V.ACT_DELETE_SUCCESS, name));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
antd_1.message.error(utils_1.i18n.txt(name ? Const_1.V.ACT_DELETE_FAIL_NAMED : Const_1.V.ACT_DELETE_FAIL, name));
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const useApiBase = (config, state, doLoad, mode = 'api') => {
|
|
74
|
+
const { list, effect, pageNo, pageSize, total, totalAcc, isQuerying, param, cost } = state;
|
|
75
|
+
const rowKey = config.rowKey || 'id';
|
|
76
|
+
const delKey = config.delKey || 'ids';
|
|
77
|
+
let lastQuery = (0, react_1.useRef)(config.param || {});
|
|
78
|
+
var AOP = {};
|
|
79
|
+
if (config.aop)
|
|
80
|
+
AOP = config.aop;
|
|
81
|
+
var TIP = { ADD: true, UPDATE: true, DELETE: true };
|
|
82
|
+
if (config.tipDisabled) {
|
|
83
|
+
if (config.tipDisabled === true) {
|
|
84
|
+
TIP = { ADD: false, UPDATE: false, DELETE: false };
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
if (config.tipDisabled.add)
|
|
88
|
+
TIP.ADD = false;
|
|
89
|
+
if (config.tipDisabled.update)
|
|
90
|
+
TIP.UPDATE = false;
|
|
91
|
+
if (config.tipDisabled.delete)
|
|
92
|
+
TIP.DELETE = false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const queryHook = (0, react_1.useCallback)((_param, _page = null, _order = null) => {
|
|
96
|
+
if (_param) {
|
|
97
|
+
lastQuery.current = chean(lodash_1.default.merge(lastQuery.current, _param));
|
|
98
|
+
lastQuery.current.start_ = 0;
|
|
99
|
+
lastQuery.current.count_ = pageSize;
|
|
100
|
+
doLoad({ param: lastQuery.current, pageNo: 1, isQuerying: true });
|
|
101
|
+
_query(lastQuery.current);
|
|
102
|
+
}
|
|
103
|
+
else if (_page) {
|
|
104
|
+
lastQuery.current.start_ = _page.pageSize * (_page.pageNo - 1);
|
|
105
|
+
lastQuery.current.count_ = _page.pageSize;
|
|
106
|
+
doLoad({ param: lastQuery.current, pageNo: _page.pageNo, pageSize: _page.pageSize, isQuerying: true });
|
|
107
|
+
_query(lastQuery.current);
|
|
108
|
+
}
|
|
109
|
+
else if (_order) {
|
|
110
|
+
if (_order.order) {
|
|
111
|
+
lastQuery.current.order_ = _order.order;
|
|
112
|
+
lastQuery.current.by_ = _order.by == 'asc' ? 'asc' : 'desc';
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
lodash_1.default.unset(lastQuery.current, 'order_');
|
|
116
|
+
lodash_1.default.unset(lastQuery.current, 'by_');
|
|
117
|
+
}
|
|
118
|
+
lastQuery.current.start_ = 0;
|
|
119
|
+
doLoad({ param: lastQuery.current, pageNo: 1, isQuerying: true });
|
|
120
|
+
_query(lastQuery.current);
|
|
121
|
+
}
|
|
122
|
+
}, [param, pageNo, pageSize]);
|
|
123
|
+
const _query = (param) => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
|
+
let _start = Date.now();
|
|
125
|
+
const queryParam = lodash_1.default.isFunction(AOP.beforeQuery) ? AOP.beforeQuery(param) : param;
|
|
126
|
+
const response = yield utils_1.Ajax.POST(config.api, queryParam);
|
|
127
|
+
if (response.code != '0') {
|
|
128
|
+
doLoad({ isQuerying: false, cost: 0 }, () => {
|
|
129
|
+
if (lodash_1.default.isFunction(AOP.afterQuery)) {
|
|
130
|
+
AOP.afterQuery(false, queryParam, response);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
throw response;
|
|
134
|
+
}
|
|
135
|
+
doLoad({
|
|
136
|
+
list: response.list, total: response.total, totalAcc: response.totalAcc || response.total,
|
|
137
|
+
cost: Date.now() - _start,
|
|
138
|
+
isQuerying: false
|
|
139
|
+
}, () => {
|
|
140
|
+
if (lodash_1.default.isFunction(AOP.afterQuery)) {
|
|
141
|
+
AOP.afterQuery(true, queryParam, response);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
const query = (param, clean = false) => {
|
|
146
|
+
if (clean)
|
|
147
|
+
lastQuery.current = {};
|
|
148
|
+
queryHook(param);
|
|
149
|
+
};
|
|
150
|
+
const all = (loader = true) => __awaiter(void 0, void 0, void 0, function* () {
|
|
151
|
+
const resp = yield utils_1.Ajax.GET(config.api);
|
|
152
|
+
let list;
|
|
153
|
+
if (resp.code == '0') {
|
|
154
|
+
list = lodash_1.default.isArray(resp.data) ? resp.data : (lodash_1.default.isArray(resp.list) ? resp.list : []);
|
|
155
|
+
}
|
|
156
|
+
if (loader) {
|
|
157
|
+
doLoad({
|
|
158
|
+
total: list.length,
|
|
159
|
+
totalAcc: list.length,
|
|
160
|
+
list: list,
|
|
161
|
+
pageSize: list.length,
|
|
162
|
+
pageNo: 1,
|
|
163
|
+
param: {},
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return list;
|
|
167
|
+
});
|
|
168
|
+
const pageTo = (pageNo, pageSize) => queryHook(null, { pageNo, pageSize });
|
|
169
|
+
const orderBy = (order, by) => queryHook(null, null, { order, by });
|
|
170
|
+
const doAdd = (data) => doLoad(prev => ({
|
|
171
|
+
effect: effectKey(prev.effect, data, rowKey),
|
|
172
|
+
total: prev.total + 1,
|
|
173
|
+
totalAcc: prev.totalAcc + 1,
|
|
174
|
+
list: utils_1.ArrayUtil.add(prev.list, data),
|
|
175
|
+
}));
|
|
176
|
+
const add = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
177
|
+
const param = lodash_1.default.isFunction(AOP.beforeQuery) ? AOP.beforeQuery(data) : data;
|
|
178
|
+
const response = yield utils_1.Ajax.PUT(config.api, param);
|
|
179
|
+
if (TIP.ADD) {
|
|
180
|
+
SHOWTIP(response.code == '0', 'ADD', data, config);
|
|
181
|
+
}
|
|
182
|
+
const isSuccess = response.code == '0';
|
|
183
|
+
if (AOP.afterAdd) {
|
|
184
|
+
AOP.afterAdd(isSuccess, param, response);
|
|
185
|
+
}
|
|
186
|
+
else if (AOP.afterAll) {
|
|
187
|
+
AOP.afterAll('ADD', isSuccess, param, response);
|
|
188
|
+
}
|
|
189
|
+
if (!isSuccess)
|
|
190
|
+
throw response;
|
|
191
|
+
doAdd(response.data || param);
|
|
192
|
+
return response;
|
|
193
|
+
});
|
|
194
|
+
const doUpdate = (obj) => doLoad(prev => ({
|
|
195
|
+
effect: effectKey(prev.effect, obj, rowKey),
|
|
196
|
+
list: utils_1.ArrayUtil.update(prev.list, obj, rowKey)
|
|
197
|
+
}));
|
|
198
|
+
const update = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
199
|
+
const param = lodash_1.default.isFunction(AOP.beforeUpdate) ? AOP.beforeUpdate(data) : data;
|
|
200
|
+
const response = yield utils_1.Ajax.PATCH(config.api, param);
|
|
201
|
+
if (TIP.UPDATE) {
|
|
202
|
+
SHOWTIP(response.code == '0', 'UPDATE', param, config);
|
|
203
|
+
}
|
|
204
|
+
const isSuccess = response.code == '0';
|
|
205
|
+
if (AOP.afterUpdate) {
|
|
206
|
+
AOP.afterUpdate(isSuccess, param, response);
|
|
207
|
+
}
|
|
208
|
+
else if (AOP.afterAll) {
|
|
209
|
+
AOP.afterAll('UPDATE', isSuccess, param, response);
|
|
210
|
+
}
|
|
211
|
+
if (!isSuccess)
|
|
212
|
+
throw response;
|
|
213
|
+
doUpdate(response.data || param);
|
|
214
|
+
return response;
|
|
215
|
+
});
|
|
216
|
+
const doDelete = (obj) => {
|
|
217
|
+
const keys = [];
|
|
218
|
+
if (lodash_1.default.isArray(obj)) {
|
|
219
|
+
obj.map(item => {
|
|
220
|
+
if (lodash_1.default.isPlainObject(item) && lodash_1.default.has(item, rowKey)) {
|
|
221
|
+
keys.push(item[rowKey]);
|
|
222
|
+
}
|
|
223
|
+
else if (lodash_1.default.isString(item) || lodash_1.default.isNumber(item)) {
|
|
224
|
+
keys.push(item);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
else if (lodash_1.default.isString(obj) || lodash_1.default.isNumber(obj)) {
|
|
229
|
+
keys.push(obj);
|
|
230
|
+
}
|
|
231
|
+
else if (lodash_1.default.has(obj, rowKey)) {
|
|
232
|
+
keys.push(obj[rowKey]);
|
|
233
|
+
}
|
|
234
|
+
doLoad(prev => ({
|
|
235
|
+
list: utils_1.ArrayUtil.del(prev.list, keys, rowKey),
|
|
236
|
+
total: prev.total - keys.length,
|
|
237
|
+
totalAcc: prev.totalAcc - keys.length,
|
|
238
|
+
}));
|
|
239
|
+
};
|
|
240
|
+
const delArr = (arr) => __awaiter(void 0, void 0, void 0, function* () {
|
|
241
|
+
const keys = [];
|
|
242
|
+
arr.map(item => {
|
|
243
|
+
if (lodash_1.default.isPlainObject(item)) {
|
|
244
|
+
keys.push(item[rowKey]);
|
|
245
|
+
}
|
|
246
|
+
else if (lodash_1.default.isString(item) || lodash_1.default.isNumber(item)) {
|
|
247
|
+
keys.push(item);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
if (keys.length == 0)
|
|
251
|
+
return;
|
|
252
|
+
let keyStr = keys.length == 1 ? keys[0] : keys.join(',');
|
|
253
|
+
const response = yield utils_1.Ajax.DELETE(config.api, { [delKey]: keyStr });
|
|
254
|
+
const isSuccess = response.code == '0';
|
|
255
|
+
if (TIP.DELETE) {
|
|
256
|
+
if (isSuccess) {
|
|
257
|
+
antd_1.message.success(utils_1.i18n.txt(Const_1.V.ACT_DELETE_SUCCESS_COUNT, keys.length + ''));
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
antd_1.message.error(utils_1.i18n.txt(Const_1.V.ACT_DELETE_FAIL_COUNT, keys.length + ''));
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (isSuccess)
|
|
264
|
+
doDelete(arr);
|
|
265
|
+
return response;
|
|
266
|
+
});
|
|
267
|
+
const delSingle = (0, react_1.useCallback)((data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
268
|
+
let key;
|
|
269
|
+
if (lodash_1.default.isString(data) || lodash_1.default.isNumber(data)) {
|
|
270
|
+
key = data;
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
key = data[rowKey];
|
|
274
|
+
}
|
|
275
|
+
const response = yield utils_1.Ajax.DELETE(config.api, { [delKey]: key });
|
|
276
|
+
const isSuccess = response.code == '0';
|
|
277
|
+
if (TIP.DELETE) {
|
|
278
|
+
let obj = {};
|
|
279
|
+
if (lodash_1.default.isObject(data)) {
|
|
280
|
+
obj = data;
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
obj = lodash_1.default.find(list, { [rowKey]: key }) || {};
|
|
284
|
+
}
|
|
285
|
+
SHOWTIP(isSuccess, 'DELETE', obj, config);
|
|
286
|
+
// let name;
|
|
287
|
+
// if (config.tipField) {
|
|
288
|
+
// if (_.isPlainObject(data)) {
|
|
289
|
+
// name = data[config.tipField]
|
|
290
|
+
// } else {
|
|
291
|
+
// let obj = _.find(list, { [rowKey]: key });
|
|
292
|
+
// if (obj && obj[config.tipField]) {
|
|
293
|
+
// name = obj[config.tipField];
|
|
294
|
+
// }
|
|
295
|
+
// }
|
|
296
|
+
// }
|
|
297
|
+
}
|
|
298
|
+
if (isSuccess)
|
|
299
|
+
doDelete(data);
|
|
300
|
+
return response;
|
|
301
|
+
}), [list]);
|
|
302
|
+
const del = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
303
|
+
const param = lodash_1.default.isFunction(AOP.beforeDelete) ? AOP.beforeDelete(data) : data;
|
|
304
|
+
var response;
|
|
305
|
+
if (lodash_1.default.isArray(param)) {
|
|
306
|
+
response = yield delArr(param);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
response = yield delSingle(param);
|
|
310
|
+
}
|
|
311
|
+
const isSuccess = response.code == '0';
|
|
312
|
+
if (AOP.afterDelete) {
|
|
313
|
+
AOP.afterDelete(isSuccess, param, response);
|
|
314
|
+
}
|
|
315
|
+
else if (AOP.afterAll) {
|
|
316
|
+
AOP.afterAll('DELETE', isSuccess, param, response);
|
|
317
|
+
}
|
|
318
|
+
if (response.code != '0')
|
|
319
|
+
throw response;
|
|
320
|
+
return response;
|
|
321
|
+
});
|
|
322
|
+
return {
|
|
323
|
+
mode: mode,
|
|
324
|
+
rowKey, cost, list, effect, pageNo, pageSize, total, totalAcc, isQuerying, param,
|
|
325
|
+
query, all, pageTo, orderBy, doLoad,
|
|
326
|
+
add, doAdd,
|
|
327
|
+
update, doUpdate,
|
|
328
|
+
del, doDelete,
|
|
329
|
+
};
|
|
330
|
+
};
|
|
331
|
+
exports.useApiBase = useApiBase;
|
package/hooks/useApiGlobal.d.ts
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ApiOption } from './useApiBase';
|
|
2
|
+
import type { ApiListState } from './_list';
|
|
3
|
+
export type ApiGlobalOption = ApiOption & {
|
|
4
|
+
/**
|
|
5
|
+
* 指定存储空间,
|
|
6
|
+
* 不指定时会以当前页面的URL做为存储空间。
|
|
7
|
+
* 当同一个页面使用两个 不同的 useApiGlobal ,必须为两个 hook 分别指定,应用内唯一NAMESPACE
|
|
8
|
+
*/
|
|
9
|
+
namespace?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const useApiGlobal: (options: string | ApiGlobalOption) => ApiListState;
|
package/hooks/useApiGlobal.js
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useApiGlobal = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const useGlobal_1 = require("./useGlobal");
|
|
10
|
+
const _list_1 = require("./_list");
|
|
11
|
+
const useApiBase_1 = require("./useApiBase");
|
|
12
|
+
const toKey = (pathname, hash) => {
|
|
13
|
+
let root = lodash_1.default.toLower(lodash_1.default.trim(pathname));
|
|
14
|
+
if (root.endsWith('/'))
|
|
15
|
+
root = root.substring(0, root.length - 1);
|
|
16
|
+
if (root.startsWith('/'))
|
|
17
|
+
root = root.substring(1);
|
|
18
|
+
root = root.replace('/', '-');
|
|
19
|
+
return root + hash;
|
|
20
|
+
};
|
|
21
|
+
const useApiGlobal = (options) => {
|
|
22
|
+
const config = lodash_1.default.isString(options) ? { api: options } : options;
|
|
23
|
+
const BASE = Object.assign(Object.assign({}, _list_1.DEFAULT_STATE), { effect: null });
|
|
24
|
+
BASE.rowKey = config.rowKey || 'id';
|
|
25
|
+
;
|
|
26
|
+
if (config.list)
|
|
27
|
+
BASE.list = config.list;
|
|
28
|
+
if (config.pageSize)
|
|
29
|
+
BASE.pageSize = config.pageSize;
|
|
30
|
+
const namespace = (0, react_1.useMemo)(() => {
|
|
31
|
+
if (config.namespace)
|
|
32
|
+
return config.namespace;
|
|
33
|
+
const { pathname, hash } = location;
|
|
34
|
+
return toKey(pathname, hash);
|
|
35
|
+
}, []);
|
|
36
|
+
const [state, doLoad] = (0, useGlobal_1.useGlobal)(namespace, BASE);
|
|
37
|
+
return (0, useApiBase_1.useApiBase)(config, state, doLoad, 'api-global');
|
|
38
|
+
};
|
|
39
|
+
exports.useApiGlobal = useApiGlobal;
|
package/index.d.ts
CHANGED
|
@@ -132,8 +132,7 @@ export { VTable, ApiTable, ApiTableModal, STable, TopTable, TopTableModal } from
|
|
|
132
132
|
export { STree, DTree, FTree } from './components/Trees';
|
|
133
133
|
export { UploadFile, UploadImage, UploadModal } from './components/Upload';
|
|
134
134
|
export { SList } from './components/Lists/SList';
|
|
135
|
-
export type { UFromProps, UModalProps, UFormField, UFormFieldGroup, LinkResult, UDescriptionsProps, } from './components/UForm';
|
|
136
|
-
export type { UFormFunctions } from './components/UForm/UForm';
|
|
135
|
+
export type { UFromProps, UModalProps, UFormField, UFormFieldGroup, LinkResult, UDescriptionsProps, UFormFunctions } from './components/UForm';
|
|
137
136
|
export type { TableColumn } from './components/Tables/index';
|
|
138
137
|
export type { VTableProps } from './components/Tables/VTable';
|
|
139
138
|
export type { ApiTableProps } from './components/Tables/ApiTable';
|
package/index.js
CHANGED
|
@@ -132,7 +132,7 @@ Object.defineProperty(exports, "ColorPicker", { enumerable: true, get: function
|
|
|
132
132
|
// Enrich antd Components
|
|
133
133
|
var Upagination_1 = require("./components/_common/Upagination"); // 增强版 Pagination
|
|
134
134
|
Object.defineProperty(exports, "UPagination", { enumerable: true, get: function () { return Upagination_1.UPagination; } });
|
|
135
|
-
// VAP Data Components
|
|
135
|
+
// VAP Data Components
|
|
136
136
|
var UForm_1 = require("./components/UForm"); // UForm 系列
|
|
137
137
|
Object.defineProperty(exports, "UForm", { enumerable: true, get: function () { return UForm_1.UForm; } });
|
|
138
138
|
Object.defineProperty(exports, "UFormModal", { enumerable: true, get: function () { return UForm_1.UFormModal; } });
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"vap1","version":"0.1.
|
|
1
|
+
{"name":"vap1","version":"0.1.1","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
|