ls-pro-common 1.0.59 → 1.0.61
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/dist/common.js +1 -1
- package/dist/common.min.js +1 -1
- package/es/components/DtlLayout.d.ts +4 -0
- package/es/components/DtlLayout.js +52 -23
- package/es/hooks/useDtl/index.js +15 -6
- package/es/hooks/usePermission/index.d.ts +7 -0
- package/es/hooks/usePermission/index.js +9 -2
- package/es/hooks/useSingle/index.js +13 -7
- package/es/http/index.js +2 -1
- package/es/utils/index.d.ts +7 -1
- package/es/utils/index.js +28 -3
- package/lib/components/DtlLayout.d.ts +4 -0
- package/lib/components/DtlLayout.js +52 -22
- package/lib/hooks/useDtl/index.js +16 -6
- package/lib/hooks/usePermission/index.d.ts +7 -0
- package/lib/hooks/usePermission/index.js +9 -2
- package/lib/hooks/useSingle/index.js +13 -7
- package/lib/http/index.js +2 -1
- package/lib/utils/index.d.ts +7 -1
- package/lib/utils/index.js +33 -5
- package/package.json +1 -1
|
@@ -46,7 +46,13 @@ var _excluded = ["current", "pageSize"];
|
|
|
46
46
|
function useSingle(inParam) {
|
|
47
47
|
var _usePermission = (0, _usePermission2.default)(),
|
|
48
48
|
resourceId = _usePermission.resourceId,
|
|
49
|
-
checkRight = _usePermission.checkRight
|
|
49
|
+
checkRight = _usePermission.checkRight,
|
|
50
|
+
canAdd = _usePermission.canAdd,
|
|
51
|
+
canEdit = _usePermission.canEdit,
|
|
52
|
+
canDelete = _usePermission.canDelete,
|
|
53
|
+
canAudit = _usePermission.canAudit,
|
|
54
|
+
canImport = _usePermission.canImport,
|
|
55
|
+
canExport = _usePermission.canExport;
|
|
50
56
|
|
|
51
57
|
var service = inParam.service,
|
|
52
58
|
toolConfig = inParam.toolConfig,
|
|
@@ -733,21 +739,21 @@ function useSingle(inParam) {
|
|
|
733
739
|
}, [auditStatus, statusField, selectedRows]); // 处理内置 table 按钮,新增,编辑,删除,审核,导入,导出
|
|
734
740
|
|
|
735
741
|
var tableTools = (0, _react.useMemo)(function () {
|
|
736
|
-
return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) &&
|
|
742
|
+
return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && canAdd ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
737
743
|
key: "add",
|
|
738
744
|
onClick: function onClick() {
|
|
739
745
|
return onAdd(null);
|
|
740
746
|
},
|
|
741
747
|
disabled: btnDisabled('add'),
|
|
742
748
|
icon: /*#__PURE__*/_react.default.createElement(_icons.PlusCircleOutlined, null)
|
|
743
|
-
}, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) &&
|
|
749
|
+
}, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) && canEdit ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
744
750
|
key: "edit",
|
|
745
751
|
disabled: btnDisabled('edit'),
|
|
746
752
|
onClick: function onClick() {
|
|
747
753
|
return onEdit(null);
|
|
748
754
|
},
|
|
749
755
|
icon: /*#__PURE__*/_react.default.createElement(_icons.EditOutlined, null)
|
|
750
|
-
}, "\u7F16\u8F91") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) &&
|
|
756
|
+
}, "\u7F16\u8F91") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) && canDelete ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
751
757
|
key: "remove",
|
|
752
758
|
onClick: function onClick() {
|
|
753
759
|
return onRemove(null);
|
|
@@ -755,14 +761,14 @@ function useSingle(inParam) {
|
|
|
755
761
|
danger: true,
|
|
756
762
|
disabled: btnDisabled('remove'),
|
|
757
763
|
icon: /*#__PURE__*/_react.default.createElement(_icons.DeleteOutlined, null)
|
|
758
|
-
}, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.audit) &&
|
|
764
|
+
}, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.audit) && canAudit ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
759
765
|
key: "audit",
|
|
760
766
|
onClick: function onClick() {
|
|
761
767
|
return onAudit(null);
|
|
762
768
|
},
|
|
763
769
|
disabled: btnDisabled('audit'),
|
|
764
770
|
icon: /*#__PURE__*/_react.default.createElement(_icons.AuditOutlined, null)
|
|
765
|
-
}, "\u5BA1\u6838") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) &&
|
|
771
|
+
}, "\u5BA1\u6838") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) && canImport ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
766
772
|
key: "import",
|
|
767
773
|
onClick: function onClick() {
|
|
768
774
|
var _tableRef$current2, _tableRef$current2$sh;
|
|
@@ -771,7 +777,7 @@ function useSingle(inParam) {
|
|
|
771
777
|
},
|
|
772
778
|
disabled: btnDisabled('import'),
|
|
773
779
|
icon: /*#__PURE__*/_react.default.createElement(_icons.ImportOutlined, null)
|
|
774
|
-
}, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) &&
|
|
780
|
+
}, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) && canExport ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
775
781
|
key: "export",
|
|
776
782
|
onClick: function onClick() {
|
|
777
783
|
var _tableRef$current3, _tableRef$current3$sh;
|
package/lib/http/index.js
CHANGED
|
@@ -33,7 +33,7 @@ request.interceptors.request.use(function (url, options) {
|
|
|
33
33
|
var token = (0, _utils.getCache)("token");
|
|
34
34
|
var opts = (0, _objectSpread2.default)({}, options);
|
|
35
35
|
|
|
36
|
-
if (token) {
|
|
36
|
+
if (token && url.indexOf('noToken=1') === -1) {
|
|
37
37
|
Object.assign(opts, {
|
|
38
38
|
headers: {
|
|
39
39
|
token: token
|
|
@@ -41,6 +41,7 @@ request.interceptors.request.use(function (url, options) {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
url = url.replace('noToken=1', '').replace('&&', '&').replace('?&', '?');
|
|
44
45
|
var param = {
|
|
45
46
|
resCode: (0, _utils.getUrlQuery)('resCode') || (0, _utils.getUrlQuery)('resourceId') || (0, _utils.getResourceProps)('resourceId'),
|
|
46
47
|
_t1: Date.now()
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export declare const getCookie: (name: string) => string | null;
|
|
|
66
66
|
* @param {*} value Cookie 值
|
|
67
67
|
* @param { Number } day 有效天数 默认1天,
|
|
68
68
|
*/
|
|
69
|
-
export declare const setCookie: (key: string, value: string | number, day?: number) => void;
|
|
69
|
+
export declare const setCookie: (key: string, value: string | number, day?: number, sameSite?: boolean) => void;
|
|
70
70
|
/**
|
|
71
71
|
* 判断是否登录
|
|
72
72
|
* @returns
|
|
@@ -86,6 +86,12 @@ export declare const setCache: (key: string, data: any, session?: boolean) => vo
|
|
|
86
86
|
* @returns 关键字对应的值
|
|
87
87
|
*/
|
|
88
88
|
export declare const getCache: (key: string, session?: boolean) => string | null;
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* @param key 关键字,不传清除所有
|
|
92
|
+
* @param session 是否session storage , 默认 localStorage
|
|
93
|
+
*/
|
|
94
|
+
export declare const clearCache: (key?: string | undefined, session?: boolean) => void;
|
|
89
95
|
/** @name 显示错误 */
|
|
90
96
|
export declare const showError: (text: string) => void;
|
|
91
97
|
/** @name 显示警示 */
|
package/lib/utils/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.dateAdd = exports.appPath = void 0;
|
|
8
|
+
exports.dateAdd = exports.clearCache = exports.appPath = void 0;
|
|
9
9
|
Object.defineProperty(exports, "dateFormat", {
|
|
10
10
|
enumerable: true,
|
|
11
11
|
get: function get() {
|
|
@@ -220,12 +220,22 @@ exports.getCookie = getCookie;
|
|
|
220
220
|
|
|
221
221
|
var setCookie = function setCookie(key, value) {
|
|
222
222
|
var day = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
223
|
+
var sameSite = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
223
224
|
|
|
224
225
|
if (day !== 0) {
|
|
225
226
|
var d = new Date(Date.now() + day * 24 * 60 * 60 * 1000);
|
|
226
|
-
|
|
227
|
+
|
|
228
|
+
if (sameSite) {
|
|
229
|
+
document.cookie = "".concat(key, "=").concat(value, ";expires=").concat(d.toUTCString(), ";path=/;sameSite=None;secure=true");
|
|
230
|
+
} else {
|
|
231
|
+
document.cookie = "".concat(key, "=").concat(value, ";expires=").concat(d.toUTCString(), ";path=/");
|
|
232
|
+
}
|
|
227
233
|
} else {
|
|
228
|
-
|
|
234
|
+
if (sameSite) {
|
|
235
|
+
document.cookie = key + "=" + value + ";path=/;sameSite=None;secure=true";
|
|
236
|
+
} else {
|
|
237
|
+
document.cookie = key + "=" + value + ";path=/";
|
|
238
|
+
}
|
|
229
239
|
}
|
|
230
240
|
};
|
|
231
241
|
/**
|
|
@@ -278,11 +288,29 @@ var getCache = function getCache(key) {
|
|
|
278
288
|
|
|
279
289
|
return data;
|
|
280
290
|
};
|
|
281
|
-
/**
|
|
291
|
+
/**
|
|
292
|
+
*
|
|
293
|
+
* @param key 关键字,不传清除所有
|
|
294
|
+
* @param session 是否session storage , 默认 localStorage
|
|
295
|
+
*/
|
|
282
296
|
|
|
283
297
|
|
|
284
298
|
exports.getCache = getCache;
|
|
285
299
|
|
|
300
|
+
var clearCache = function clearCache(key) {
|
|
301
|
+
var session = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
302
|
+
|
|
303
|
+
if (key) {
|
|
304
|
+
session ? sessionStorage.removeItem(key) : localStorage.removeItem(key);
|
|
305
|
+
} else {
|
|
306
|
+
session ? sessionStorage.clear() : localStorage.clear();
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
/** @name 显示错误 */
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
exports.clearCache = clearCache;
|
|
313
|
+
|
|
286
314
|
var showError = function showError(text) {
|
|
287
315
|
_message2.default.error(text);
|
|
288
316
|
};
|
|
@@ -343,7 +371,7 @@ var reLogin = function reLogin() {
|
|
|
343
371
|
maskClosable: false,
|
|
344
372
|
afterClose: function afterClose() {
|
|
345
373
|
timeout = false;
|
|
346
|
-
location.href = '/login?redirect=' + encodeURI(location.href);
|
|
374
|
+
location.href = location.pathname === '/' ? '/login' : '/login?redirect=' + encodeURI(location.href);
|
|
347
375
|
}
|
|
348
376
|
});
|
|
349
377
|
};
|