ls-pro-common 3.1.12 → 3.1.13
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/RecordLog/index.d.ts +5 -1
- package/es/components/RecordLog/index.js +15 -4
- package/es/hooks/useDict.d.ts +6 -5
- package/es/hooks/useGetState.d.ts +5 -2
- package/es/hooks/useGetState.js +7 -9
- package/es/hooks/useSyncState.d.ts +1 -0
- package/es/hooks/useSyncState.js +1 -0
- package/es/utils/modal.d.ts +6 -6
- package/es/utils/modal.js +19 -13
- package/lib/components/RecordLog/index.d.ts +5 -1
- package/lib/components/RecordLog/index.js +15 -4
- package/lib/hooks/useDict.d.ts +6 -5
- package/lib/hooks/useGetState.d.ts +5 -2
- package/lib/hooks/useGetState.js +7 -9
- package/lib/hooks/useSyncState.d.ts +1 -0
- package/lib/hooks/useSyncState.js +1 -0
- package/lib/utils/modal.d.ts +6 -6
- package/lib/utils/modal.js +19 -13
- package/package.json +1 -1
|
@@ -14,7 +14,11 @@ export interface RecordLogProps {
|
|
|
14
14
|
style?: React.CSSProperties;
|
|
15
15
|
className?: string;
|
|
16
16
|
showKey?: boolean;
|
|
17
|
-
fieldValueMap?: Record<string, Record<string | number, any
|
|
17
|
+
fieldValueMap?: Record<string, Record<string | number, any> | {
|
|
18
|
+
label: string;
|
|
19
|
+
value: number | string;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}[]>;
|
|
18
22
|
}
|
|
19
23
|
declare const RecordLog: (props: RecordLogProps) => JSX.Element;
|
|
20
24
|
export default RecordLog;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "antd/es/empty/style";
|
|
2
2
|
import _Empty from "antd/es/empty";
|
|
3
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
4
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
6
|
/**
|
|
@@ -58,13 +59,23 @@ var RecordLog = function RecordLog(props) {
|
|
|
58
59
|
row.content.forEach(function (item) {
|
|
59
60
|
var o = item.oldValue || '';
|
|
60
61
|
var map = fieldValueMap[item.fieldName];
|
|
61
|
-
if (map && map
|
|
62
|
+
if (map && Array.isArray(map)) {
|
|
63
|
+
var _map$find;
|
|
64
|
+
item.oldValue = ((_map$find = map.find(function (f) {
|
|
65
|
+
return f.value == o;
|
|
66
|
+
})) === null || _map$find === void 0 ? void 0 : _map$find.label) || o;
|
|
67
|
+
} else if (map && map[o] && _typeof(map) === 'object') {
|
|
62
68
|
item.oldValue = map[o];
|
|
63
69
|
} else {
|
|
64
70
|
item.oldValue = !o || o == '[]' || (o === null || o === void 0 ? void 0 : o.length) == 0 ? '空' : o + '';
|
|
65
71
|
}
|
|
66
72
|
var n = item.newValue || '';
|
|
67
|
-
if (map && map
|
|
73
|
+
if (map && Array.isArray(map)) {
|
|
74
|
+
var _map$find2;
|
|
75
|
+
item.newValue = ((_map$find2 = map.find(function (f) {
|
|
76
|
+
return f.value == n;
|
|
77
|
+
})) === null || _map$find2 === void 0 ? void 0 : _map$find2.label) || n;
|
|
78
|
+
} else if (map && map[n] && _typeof(map) === 'object') {
|
|
68
79
|
item.newValue = map[n];
|
|
69
80
|
} else {
|
|
70
81
|
item.newValue = !n || n == '[]' || (n === null || n === void 0 ? void 0 : n.length) == 0 ? '空' : n + '';
|
|
@@ -92,14 +103,14 @@ var RecordLog = function RecordLog(props) {
|
|
|
92
103
|
className: "log-item-label"
|
|
93
104
|
}, field.fieldDisPlayName, " :"), /*#__PURE__*/React.createElement("span", {
|
|
94
105
|
className: "log-item-value"
|
|
95
|
-
}, field.oldValue), /*#__PURE__*/React.createElement(ArrowRightOutlined, {
|
|
106
|
+
}, field.oldValue + ''), /*#__PURE__*/React.createElement(ArrowRightOutlined, {
|
|
96
107
|
style: {
|
|
97
108
|
fontSize: '14px',
|
|
98
109
|
margin: '0 10px'
|
|
99
110
|
}
|
|
100
111
|
}), /*#__PURE__*/React.createElement("span", {
|
|
101
112
|
className: "log-item-value"
|
|
102
|
-
}, field.newValue));
|
|
113
|
+
}, field.newValue + ''));
|
|
103
114
|
});
|
|
104
115
|
};
|
|
105
116
|
var LogDom = useMemo(function () {
|
package/es/hooks/useDict.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
declare type TOption = {
|
|
2
|
-
label: string;
|
|
3
|
-
value:
|
|
4
|
-
text?: string;
|
|
5
|
-
status?: number;
|
|
6
|
-
}
|
|
3
|
+
label: string | number | React.ReactNode;
|
|
4
|
+
value: string | number;
|
|
5
|
+
text?: string | number | React.ReactNode;
|
|
6
|
+
status?: number | boolean;
|
|
7
|
+
} & Record<string, any>;
|
|
7
8
|
declare type TDictItem = {
|
|
8
9
|
dict: string;
|
|
9
10
|
showValue?: boolean;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare type Getter<T> = () => T;
|
|
2
|
+
declare type Setter<T> = (pre: T) => T;
|
|
3
|
+
/** 第一,二个返回值跟原来的 useState 一样, 第三个返回值是一个函数,用于在useEffect, useCallback, useMemo 等 hooks 中不传依赖时获取最新的值 */
|
|
4
|
+
export default function useGetState<T>(initVal: T | Getter<T>): readonly [T, (newVal: T | Setter<T>) => void, Getter<T>];
|
|
5
|
+
export {};
|
package/es/hooks/useGetState.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import { useState, useRef } from 'react';
|
|
3
|
-
/**
|
|
4
|
-
export default function (initVal) {
|
|
2
|
+
import { useState, useRef, useCallback } from 'react';
|
|
3
|
+
/** 第一,二个返回值跟原来的 useState 一样, 第三个返回值是一个函数,用于在useEffect, useCallback, useMemo 等 hooks 中不传依赖时获取最新的值 */
|
|
4
|
+
export default function useGetState(initVal) {
|
|
5
5
|
var _useState = useState(initVal),
|
|
6
6
|
_useState2 = _slicedToArray(_useState, 2),
|
|
7
7
|
state = _useState2[0],
|
|
8
8
|
setState = _useState2[1];
|
|
9
|
-
var ref = useRef(initVal);
|
|
9
|
+
var ref = useRef(typeof initVal === 'function' ? initVal() : initVal);
|
|
10
10
|
var changeState = function changeState(newVal) {
|
|
11
11
|
if (typeof newVal === 'function') {
|
|
12
12
|
newVal = newVal(ref.current);
|
|
13
13
|
}
|
|
14
14
|
ref.current = newVal;
|
|
15
|
-
setState(
|
|
16
|
-
return newVal;
|
|
17
|
-
});
|
|
15
|
+
setState(newVal);
|
|
18
16
|
};
|
|
19
|
-
var getState = function
|
|
17
|
+
var getState = useCallback(function () {
|
|
20
18
|
return ref.current;
|
|
21
|
-
};
|
|
19
|
+
}, []);
|
|
22
20
|
return [state, changeState, getState];
|
|
23
21
|
}
|
package/es/hooks/useSyncState.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import React from 'react';
|
|
3
|
+
/** 通过ref处理返回值,一直得到最新的值 */
|
|
3
4
|
export default function useSyncState(defaultValue) {
|
|
4
5
|
var _React$useState = React.useState(0),
|
|
5
6
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
package/es/utils/modal.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ModalFuncProps } from 'antd';
|
|
1
|
+
import { ModalFuncProps, MessageArgsProps } from 'antd';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
/** @name 获取全屏元素 */
|
|
4
4
|
export declare const getFullScreenElement: () => any;
|
|
5
5
|
/** @name 显示错误 */
|
|
6
|
-
export declare const showError: (text: string, duration?: number) => void;
|
|
6
|
+
export declare const showError: (text: string, duration?: number, opts?: MessageArgsProps | undefined) => void;
|
|
7
7
|
/** @name 显示警示 */
|
|
8
|
-
export declare const showWarn: (text: string, duration?: number) => void;
|
|
8
|
+
export declare const showWarn: (text: string, duration?: number, opts?: MessageArgsProps | undefined) => void;
|
|
9
9
|
/** @name 显示成功 */
|
|
10
|
-
export declare const showSuccess: (text: string, duration?: number) => void;
|
|
10
|
+
export declare const showSuccess: (text: string, duration?: number, opts?: MessageArgsProps | undefined) => void;
|
|
11
11
|
/**
|
|
12
12
|
* 弹框提示
|
|
13
13
|
*
|
|
@@ -17,7 +17,7 @@ export declare const showSuccess: (text: string, duration?: number) => void;
|
|
|
17
17
|
* @param opts 附加参数
|
|
18
18
|
* @returns Promise<Boolean>
|
|
19
19
|
*/
|
|
20
|
-
export declare const showAlert: (text: React.ReactDOM | string, title?: string, type?: 'error' | 'info' | 'success' | 'warn', opts?: ModalFuncProps) => Promise<unknown>;
|
|
20
|
+
export declare const showAlert: (text: React.ReactDOM | string, title?: string, type?: 'error' | 'info' | 'success' | 'warn' | 'confirm', opts?: ModalFuncProps) => Promise<unknown>;
|
|
21
21
|
/**
|
|
22
22
|
* 请求接口出错
|
|
23
23
|
*
|
|
@@ -30,7 +30,7 @@ export declare const httpError: (retMsg?: string | undefined, retCode?: string |
|
|
|
30
30
|
/** 销毁所有弹框 */
|
|
31
31
|
export declare const exitAlert: () => void;
|
|
32
32
|
/** @name 显示确认 */
|
|
33
|
-
export declare const showConfirm: (text: string, title?: string) => Promise<unknown>;
|
|
33
|
+
export declare const showConfirm: (text: string, title?: string, opts?: ModalFuncProps) => Promise<unknown>;
|
|
34
34
|
/**
|
|
35
35
|
* Token过期重新登录
|
|
36
36
|
*
|
package/es/utils/modal.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "antd/es/spin/style";
|
|
2
2
|
import _Spin from "antd/es/spin";
|
|
3
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
3
|
import "antd/es/modal/style";
|
|
5
4
|
import _Modal from "antd/es/modal";
|
|
5
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
6
6
|
import "antd/es/message/style";
|
|
7
7
|
import _message from "antd/es/message";
|
|
8
8
|
import React from "react";
|
|
@@ -25,10 +25,11 @@ export var getFullScreenElement = function getFullScreenElement() {
|
|
|
25
25
|
/** @name 显示错误 */
|
|
26
26
|
export var showError = function showError(text) {
|
|
27
27
|
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
|
|
28
|
+
var opts = arguments.length > 2 ? arguments[2] : undefined;
|
|
28
29
|
if (!text) {
|
|
29
30
|
text = '出错了!!';
|
|
30
31
|
}
|
|
31
|
-
_message.error({
|
|
32
|
+
_message.error(_objectSpread({
|
|
32
33
|
content: text,
|
|
33
34
|
duration: duration,
|
|
34
35
|
getPopupContainer: function getPopupContainer(e) {
|
|
@@ -51,15 +52,16 @@ export var showError = function showError(text) {
|
|
|
51
52
|
} catch (e) {}
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
|
-
});
|
|
55
|
+
}, opts));
|
|
55
56
|
};
|
|
56
57
|
/** @name 显示警示 */
|
|
57
58
|
export var showWarn = function showWarn(text) {
|
|
58
59
|
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
|
|
60
|
+
var opts = arguments.length > 2 ? arguments[2] : undefined;
|
|
59
61
|
if (!text) {
|
|
60
62
|
text = '请注意!';
|
|
61
63
|
}
|
|
62
|
-
_message.warn({
|
|
64
|
+
_message.warn(_objectSpread({
|
|
63
65
|
content: text,
|
|
64
66
|
duration: duration,
|
|
65
67
|
getPopupContainer: function getPopupContainer(e) {
|
|
@@ -82,15 +84,16 @@ export var showWarn = function showWarn(text) {
|
|
|
82
84
|
} catch (e) {}
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
|
-
});
|
|
87
|
+
}, opts));
|
|
86
88
|
};
|
|
87
89
|
/** @name 显示成功 */
|
|
88
90
|
export var showSuccess = function showSuccess(text) {
|
|
89
91
|
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
|
|
92
|
+
var opts = arguments.length > 2 ? arguments[2] : undefined;
|
|
90
93
|
if (!text) {
|
|
91
94
|
text = '操作成功!';
|
|
92
95
|
}
|
|
93
|
-
_message.success({
|
|
96
|
+
_message.success(_objectSpread({
|
|
94
97
|
content: text,
|
|
95
98
|
duration: duration,
|
|
96
99
|
getPopupContainer: function getPopupContainer(e) {
|
|
@@ -113,7 +116,7 @@ export var showSuccess = function showSuccess(text) {
|
|
|
113
116
|
} catch (e) {}
|
|
114
117
|
}
|
|
115
118
|
}
|
|
116
|
-
});
|
|
119
|
+
}, opts));
|
|
117
120
|
};
|
|
118
121
|
/**
|
|
119
122
|
* 弹框提示
|
|
@@ -129,17 +132,18 @@ export var showAlert = function showAlert(text) {
|
|
|
129
132
|
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'error';
|
|
130
133
|
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
131
134
|
return new Promise(function (resolve, reject) {
|
|
132
|
-
_Modal[type](_objectSpread({
|
|
135
|
+
_Modal[type](_objectSpread(_objectSpread({
|
|
133
136
|
content: text,
|
|
134
137
|
title: title,
|
|
135
|
-
getContainer: getFullScreenElement() || document.body
|
|
138
|
+
getContainer: getFullScreenElement() || document.body
|
|
139
|
+
}, opts), {}, {
|
|
136
140
|
onOk: function onOk() {
|
|
137
141
|
resolve(true);
|
|
138
142
|
},
|
|
139
143
|
onCancel: function onCancel() {
|
|
140
144
|
reject(false);
|
|
141
145
|
}
|
|
142
|
-
}
|
|
146
|
+
}));
|
|
143
147
|
});
|
|
144
148
|
};
|
|
145
149
|
/**
|
|
@@ -162,8 +166,9 @@ export var exitAlert = function exitAlert() {
|
|
|
162
166
|
/** @name 显示确认 */
|
|
163
167
|
export var showConfirm = function showConfirm(text) {
|
|
164
168
|
var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '系统提示';
|
|
169
|
+
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
165
170
|
return new Promise(function (resolve, reject) {
|
|
166
|
-
_Modal.confirm({
|
|
171
|
+
_Modal.confirm(_objectSpread(_objectSpread({
|
|
167
172
|
title: title,
|
|
168
173
|
content: text,
|
|
169
174
|
icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null),
|
|
@@ -172,14 +177,15 @@ export var showConfirm = function showConfirm(text) {
|
|
|
172
177
|
cancelButtonProps: {
|
|
173
178
|
className: 'ant-btn-gray'
|
|
174
179
|
},
|
|
175
|
-
getContainer: getFullScreenElement() || document.body
|
|
180
|
+
getContainer: getFullScreenElement() || document.body
|
|
181
|
+
}, opts), {}, {
|
|
176
182
|
onOk: function onOk() {
|
|
177
183
|
resolve(true);
|
|
178
184
|
},
|
|
179
185
|
onCancel: function onCancel() {
|
|
180
186
|
reject(false);
|
|
181
187
|
}
|
|
182
|
-
});
|
|
188
|
+
}));
|
|
183
189
|
});
|
|
184
190
|
};
|
|
185
191
|
/**
|
|
@@ -14,7 +14,11 @@ export interface RecordLogProps {
|
|
|
14
14
|
style?: React.CSSProperties;
|
|
15
15
|
className?: string;
|
|
16
16
|
showKey?: boolean;
|
|
17
|
-
fieldValueMap?: Record<string, Record<string | number, any
|
|
17
|
+
fieldValueMap?: Record<string, Record<string | number, any> | {
|
|
18
|
+
label: string;
|
|
19
|
+
value: number | string;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}[]>;
|
|
18
22
|
}
|
|
19
23
|
declare const RecordLog: (props: RecordLogProps) => JSX.Element;
|
|
20
24
|
export default RecordLog;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "antd/es/empty/style";
|
|
2
2
|
import _Empty from "antd/es/empty";
|
|
3
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
4
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
6
|
/**
|
|
@@ -58,13 +59,23 @@ var RecordLog = function RecordLog(props) {
|
|
|
58
59
|
row.content.forEach(function (item) {
|
|
59
60
|
var o = item.oldValue || '';
|
|
60
61
|
var map = fieldValueMap[item.fieldName];
|
|
61
|
-
if (map && map
|
|
62
|
+
if (map && Array.isArray(map)) {
|
|
63
|
+
var _map$find;
|
|
64
|
+
item.oldValue = ((_map$find = map.find(function (f) {
|
|
65
|
+
return f.value == o;
|
|
66
|
+
})) === null || _map$find === void 0 ? void 0 : _map$find.label) || o;
|
|
67
|
+
} else if (map && map[o] && _typeof(map) === 'object') {
|
|
62
68
|
item.oldValue = map[o];
|
|
63
69
|
} else {
|
|
64
70
|
item.oldValue = !o || o == '[]' || (o === null || o === void 0 ? void 0 : o.length) == 0 ? '空' : o + '';
|
|
65
71
|
}
|
|
66
72
|
var n = item.newValue || '';
|
|
67
|
-
if (map && map
|
|
73
|
+
if (map && Array.isArray(map)) {
|
|
74
|
+
var _map$find2;
|
|
75
|
+
item.newValue = ((_map$find2 = map.find(function (f) {
|
|
76
|
+
return f.value == n;
|
|
77
|
+
})) === null || _map$find2 === void 0 ? void 0 : _map$find2.label) || n;
|
|
78
|
+
} else if (map && map[n] && _typeof(map) === 'object') {
|
|
68
79
|
item.newValue = map[n];
|
|
69
80
|
} else {
|
|
70
81
|
item.newValue = !n || n == '[]' || (n === null || n === void 0 ? void 0 : n.length) == 0 ? '空' : n + '';
|
|
@@ -92,14 +103,14 @@ var RecordLog = function RecordLog(props) {
|
|
|
92
103
|
className: "log-item-label"
|
|
93
104
|
}, field.fieldDisPlayName, " :"), /*#__PURE__*/React.createElement("span", {
|
|
94
105
|
className: "log-item-value"
|
|
95
|
-
}, field.oldValue), /*#__PURE__*/React.createElement(ArrowRightOutlined, {
|
|
106
|
+
}, field.oldValue + ''), /*#__PURE__*/React.createElement(ArrowRightOutlined, {
|
|
96
107
|
style: {
|
|
97
108
|
fontSize: '14px',
|
|
98
109
|
margin: '0 10px'
|
|
99
110
|
}
|
|
100
111
|
}), /*#__PURE__*/React.createElement("span", {
|
|
101
112
|
className: "log-item-value"
|
|
102
|
-
}, field.newValue));
|
|
113
|
+
}, field.newValue + ''));
|
|
103
114
|
});
|
|
104
115
|
};
|
|
105
116
|
var LogDom = useMemo(function () {
|
package/lib/hooks/useDict.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
declare type TOption = {
|
|
2
|
-
label: string;
|
|
3
|
-
value:
|
|
4
|
-
text?: string;
|
|
5
|
-
status?: number;
|
|
6
|
-
}
|
|
3
|
+
label: string | number | React.ReactNode;
|
|
4
|
+
value: string | number;
|
|
5
|
+
text?: string | number | React.ReactNode;
|
|
6
|
+
status?: number | boolean;
|
|
7
|
+
} & Record<string, any>;
|
|
7
8
|
declare type TDictItem = {
|
|
8
9
|
dict: string;
|
|
9
10
|
showValue?: boolean;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare type Getter<T> = () => T;
|
|
2
|
+
declare type Setter<T> = (pre: T) => T;
|
|
3
|
+
/** 第一,二个返回值跟原来的 useState 一样, 第三个返回值是一个函数,用于在useEffect, useCallback, useMemo 等 hooks 中不传依赖时获取最新的值 */
|
|
4
|
+
export default function useGetState<T>(initVal: T | Getter<T>): readonly [T, (newVal: T | Setter<T>) => void, Getter<T>];
|
|
5
|
+
export {};
|
package/lib/hooks/useGetState.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import { useState, useRef } from 'react';
|
|
3
|
-
/**
|
|
4
|
-
export default function (initVal) {
|
|
2
|
+
import { useState, useRef, useCallback } from 'react';
|
|
3
|
+
/** 第一,二个返回值跟原来的 useState 一样, 第三个返回值是一个函数,用于在useEffect, useCallback, useMemo 等 hooks 中不传依赖时获取最新的值 */
|
|
4
|
+
export default function useGetState(initVal) {
|
|
5
5
|
var _useState = useState(initVal),
|
|
6
6
|
_useState2 = _slicedToArray(_useState, 2),
|
|
7
7
|
state = _useState2[0],
|
|
8
8
|
setState = _useState2[1];
|
|
9
|
-
var ref = useRef(initVal);
|
|
9
|
+
var ref = useRef(typeof initVal === 'function' ? initVal() : initVal);
|
|
10
10
|
var changeState = function changeState(newVal) {
|
|
11
11
|
if (typeof newVal === 'function') {
|
|
12
12
|
newVal = newVal(ref.current);
|
|
13
13
|
}
|
|
14
14
|
ref.current = newVal;
|
|
15
|
-
setState(
|
|
16
|
-
return newVal;
|
|
17
|
-
});
|
|
15
|
+
setState(newVal);
|
|
18
16
|
};
|
|
19
|
-
var getState = function
|
|
17
|
+
var getState = useCallback(function () {
|
|
20
18
|
return ref.current;
|
|
21
|
-
};
|
|
19
|
+
}, []);
|
|
22
20
|
return [state, changeState, getState];
|
|
23
21
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import React from 'react';
|
|
3
|
+
/** 通过ref处理返回值,一直得到最新的值 */
|
|
3
4
|
export default function useSyncState(defaultValue) {
|
|
4
5
|
var _React$useState = React.useState(0),
|
|
5
6
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
package/lib/utils/modal.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ModalFuncProps } from 'antd';
|
|
1
|
+
import { ModalFuncProps, MessageArgsProps } from 'antd';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
/** @name 获取全屏元素 */
|
|
4
4
|
export declare const getFullScreenElement: () => any;
|
|
5
5
|
/** @name 显示错误 */
|
|
6
|
-
export declare const showError: (text: string, duration?: number) => void;
|
|
6
|
+
export declare const showError: (text: string, duration?: number, opts?: MessageArgsProps | undefined) => void;
|
|
7
7
|
/** @name 显示警示 */
|
|
8
|
-
export declare const showWarn: (text: string, duration?: number) => void;
|
|
8
|
+
export declare const showWarn: (text: string, duration?: number, opts?: MessageArgsProps | undefined) => void;
|
|
9
9
|
/** @name 显示成功 */
|
|
10
|
-
export declare const showSuccess: (text: string, duration?: number) => void;
|
|
10
|
+
export declare const showSuccess: (text: string, duration?: number, opts?: MessageArgsProps | undefined) => void;
|
|
11
11
|
/**
|
|
12
12
|
* 弹框提示
|
|
13
13
|
*
|
|
@@ -17,7 +17,7 @@ export declare const showSuccess: (text: string, duration?: number) => void;
|
|
|
17
17
|
* @param opts 附加参数
|
|
18
18
|
* @returns Promise<Boolean>
|
|
19
19
|
*/
|
|
20
|
-
export declare const showAlert: (text: React.ReactDOM | string, title?: string, type?: 'error' | 'info' | 'success' | 'warn', opts?: ModalFuncProps) => Promise<unknown>;
|
|
20
|
+
export declare const showAlert: (text: React.ReactDOM | string, title?: string, type?: 'error' | 'info' | 'success' | 'warn' | 'confirm', opts?: ModalFuncProps) => Promise<unknown>;
|
|
21
21
|
/**
|
|
22
22
|
* 请求接口出错
|
|
23
23
|
*
|
|
@@ -30,7 +30,7 @@ export declare const httpError: (retMsg?: string | undefined, retCode?: string |
|
|
|
30
30
|
/** 销毁所有弹框 */
|
|
31
31
|
export declare const exitAlert: () => void;
|
|
32
32
|
/** @name 显示确认 */
|
|
33
|
-
export declare const showConfirm: (text: string, title?: string) => Promise<unknown>;
|
|
33
|
+
export declare const showConfirm: (text: string, title?: string, opts?: ModalFuncProps) => Promise<unknown>;
|
|
34
34
|
/**
|
|
35
35
|
* Token过期重新登录
|
|
36
36
|
*
|
package/lib/utils/modal.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "antd/es/spin/style";
|
|
2
2
|
import _Spin from "antd/es/spin";
|
|
3
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
3
|
import "antd/es/modal/style";
|
|
5
4
|
import _Modal from "antd/es/modal";
|
|
5
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
6
6
|
import "antd/es/message/style";
|
|
7
7
|
import _message from "antd/es/message";
|
|
8
8
|
import React from "react";
|
|
@@ -25,10 +25,11 @@ export var getFullScreenElement = function getFullScreenElement() {
|
|
|
25
25
|
/** @name 显示错误 */
|
|
26
26
|
export var showError = function showError(text) {
|
|
27
27
|
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
|
|
28
|
+
var opts = arguments.length > 2 ? arguments[2] : undefined;
|
|
28
29
|
if (!text) {
|
|
29
30
|
text = '出错了!!';
|
|
30
31
|
}
|
|
31
|
-
_message.error({
|
|
32
|
+
_message.error(_objectSpread({
|
|
32
33
|
content: text,
|
|
33
34
|
duration: duration,
|
|
34
35
|
getPopupContainer: function getPopupContainer(e) {
|
|
@@ -51,15 +52,16 @@ export var showError = function showError(text) {
|
|
|
51
52
|
} catch (e) {}
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
|
-
});
|
|
55
|
+
}, opts));
|
|
55
56
|
};
|
|
56
57
|
/** @name 显示警示 */
|
|
57
58
|
export var showWarn = function showWarn(text) {
|
|
58
59
|
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
|
|
60
|
+
var opts = arguments.length > 2 ? arguments[2] : undefined;
|
|
59
61
|
if (!text) {
|
|
60
62
|
text = '请注意!';
|
|
61
63
|
}
|
|
62
|
-
_message.warn({
|
|
64
|
+
_message.warn(_objectSpread({
|
|
63
65
|
content: text,
|
|
64
66
|
duration: duration,
|
|
65
67
|
getPopupContainer: function getPopupContainer(e) {
|
|
@@ -82,15 +84,16 @@ export var showWarn = function showWarn(text) {
|
|
|
82
84
|
} catch (e) {}
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
|
-
});
|
|
87
|
+
}, opts));
|
|
86
88
|
};
|
|
87
89
|
/** @name 显示成功 */
|
|
88
90
|
export var showSuccess = function showSuccess(text) {
|
|
89
91
|
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
|
|
92
|
+
var opts = arguments.length > 2 ? arguments[2] : undefined;
|
|
90
93
|
if (!text) {
|
|
91
94
|
text = '操作成功!';
|
|
92
95
|
}
|
|
93
|
-
_message.success({
|
|
96
|
+
_message.success(_objectSpread({
|
|
94
97
|
content: text,
|
|
95
98
|
duration: duration,
|
|
96
99
|
getPopupContainer: function getPopupContainer(e) {
|
|
@@ -113,7 +116,7 @@ export var showSuccess = function showSuccess(text) {
|
|
|
113
116
|
} catch (e) {}
|
|
114
117
|
}
|
|
115
118
|
}
|
|
116
|
-
});
|
|
119
|
+
}, opts));
|
|
117
120
|
};
|
|
118
121
|
/**
|
|
119
122
|
* 弹框提示
|
|
@@ -129,17 +132,18 @@ export var showAlert = function showAlert(text) {
|
|
|
129
132
|
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'error';
|
|
130
133
|
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
131
134
|
return new Promise(function (resolve, reject) {
|
|
132
|
-
_Modal[type](_objectSpread({
|
|
135
|
+
_Modal[type](_objectSpread(_objectSpread({
|
|
133
136
|
content: text,
|
|
134
137
|
title: title,
|
|
135
|
-
getContainer: getFullScreenElement() || document.body
|
|
138
|
+
getContainer: getFullScreenElement() || document.body
|
|
139
|
+
}, opts), {}, {
|
|
136
140
|
onOk: function onOk() {
|
|
137
141
|
resolve(true);
|
|
138
142
|
},
|
|
139
143
|
onCancel: function onCancel() {
|
|
140
144
|
reject(false);
|
|
141
145
|
}
|
|
142
|
-
}
|
|
146
|
+
}));
|
|
143
147
|
});
|
|
144
148
|
};
|
|
145
149
|
/**
|
|
@@ -162,8 +166,9 @@ export var exitAlert = function exitAlert() {
|
|
|
162
166
|
/** @name 显示确认 */
|
|
163
167
|
export var showConfirm = function showConfirm(text) {
|
|
164
168
|
var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '系统提示';
|
|
169
|
+
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
165
170
|
return new Promise(function (resolve, reject) {
|
|
166
|
-
_Modal.confirm({
|
|
171
|
+
_Modal.confirm(_objectSpread(_objectSpread({
|
|
167
172
|
title: title,
|
|
168
173
|
content: text,
|
|
169
174
|
icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null),
|
|
@@ -172,14 +177,15 @@ export var showConfirm = function showConfirm(text) {
|
|
|
172
177
|
cancelButtonProps: {
|
|
173
178
|
className: 'ant-btn-gray'
|
|
174
179
|
},
|
|
175
|
-
getContainer: getFullScreenElement() || document.body
|
|
180
|
+
getContainer: getFullScreenElement() || document.body
|
|
181
|
+
}, opts), {}, {
|
|
176
182
|
onOk: function onOk() {
|
|
177
183
|
resolve(true);
|
|
178
184
|
},
|
|
179
185
|
onCancel: function onCancel() {
|
|
180
186
|
reject(false);
|
|
181
187
|
}
|
|
182
|
-
});
|
|
188
|
+
}));
|
|
183
189
|
});
|
|
184
190
|
};
|
|
185
191
|
/**
|