@quansitech/antd-admin 1.1.31 → 1.1.33
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/components/Layout/New.js +63 -67
- package/dist/components/Table.js +1 -1
- package/dist/lib/upload.js +22 -17
- package/package.json +1 -1
|
@@ -26,7 +26,6 @@ import { MoonOutlined, SunOutlined } from "@ant-design/icons";
|
|
|
26
26
|
import { usePage } from "@inertiajs/react";
|
|
27
27
|
import "./New.scss";
|
|
28
28
|
export default function (_ref) {
|
|
29
|
-
var _layoutContext$props$;
|
|
30
29
|
var children = _ref.children,
|
|
31
30
|
pageTitle = _ref.pageTitle,
|
|
32
31
|
setDarkMode = _ref.setDarkMode;
|
|
@@ -48,44 +47,48 @@ export default function (_ref) {
|
|
|
48
47
|
_useState2 = _slicedToArray(_useState, 2),
|
|
49
48
|
openKeys = _useState2[0],
|
|
50
49
|
setOpenKeys = _useState2[1];
|
|
50
|
+
var mapMenuListToRoutes = function mapMenuListToRoutes(menuList) {
|
|
51
|
+
return menuList === null || menuList === void 0 ? void 0 : menuList.map(function (menu) {
|
|
52
|
+
var _menu$children;
|
|
53
|
+
return {
|
|
54
|
+
name: menu.name,
|
|
55
|
+
key: menu.key,
|
|
56
|
+
children: (_menu$children = menu.children) === null || _menu$children === void 0 ? void 0 : _menu$children.map(function (child) {
|
|
57
|
+
return {
|
|
58
|
+
name: child.name,
|
|
59
|
+
key: child.key
|
|
60
|
+
};
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
};
|
|
51
65
|
var _useState3 = useState({
|
|
52
66
|
key: '/',
|
|
53
|
-
routes: (
|
|
54
|
-
var _menu$children;
|
|
55
|
-
return {
|
|
56
|
-
name: menu.name,
|
|
57
|
-
key: menu.key,
|
|
58
|
-
children: (_menu$children = menu.children) === null || _menu$children === void 0 ? void 0 : _menu$children.map(function (child) {
|
|
59
|
-
return {
|
|
60
|
-
name: child.name,
|
|
61
|
-
key: child.key
|
|
62
|
-
};
|
|
63
|
-
})
|
|
64
|
-
};
|
|
65
|
-
})
|
|
67
|
+
routes: mapMenuListToRoutes(layoutContext.props.menuList)
|
|
66
68
|
}),
|
|
67
69
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
68
70
|
route = _useState4[0],
|
|
69
71
|
setRoute = _useState4[1];
|
|
70
72
|
useEffect(function () {
|
|
71
|
-
var _layoutContext$props$2;
|
|
72
73
|
setRoute({
|
|
73
74
|
key: '/',
|
|
74
|
-
routes: (
|
|
75
|
-
var _menu$children2;
|
|
76
|
-
return {
|
|
77
|
-
name: menu.name,
|
|
78
|
-
key: menu.key,
|
|
79
|
-
children: (_menu$children2 = menu.children) === null || _menu$children2 === void 0 ? void 0 : _menu$children2.map(function (child) {
|
|
80
|
-
return {
|
|
81
|
-
name: child.name,
|
|
82
|
-
key: child.key
|
|
83
|
-
};
|
|
84
|
-
})
|
|
85
|
-
};
|
|
86
|
-
})
|
|
75
|
+
routes: mapMenuListToRoutes(layoutContext.props.menuList)
|
|
87
76
|
});
|
|
88
77
|
}, [layoutContext.props.menuList]);
|
|
78
|
+
var useWindowResize = function useWindowResize(callback) {
|
|
79
|
+
useEffect(function () {
|
|
80
|
+
callback();
|
|
81
|
+
window.addEventListener('resize', callback);
|
|
82
|
+
return function () {
|
|
83
|
+
return window.removeEventListener('resize', callback);
|
|
84
|
+
};
|
|
85
|
+
}, [callback]);
|
|
86
|
+
};
|
|
87
|
+
useWindowResize(function () {
|
|
88
|
+
if (contentRef.current) {
|
|
89
|
+
contentRef.current.style.minHeight = Math.max(window.innerHeight - 200, 200) + 'px';
|
|
90
|
+
}
|
|
91
|
+
});
|
|
89
92
|
useEffect(function () {
|
|
90
93
|
function findKeyPath(key, list) {
|
|
91
94
|
for (var i = 0; i < list.length; i++) {
|
|
@@ -102,28 +105,31 @@ export default function (_ref) {
|
|
|
102
105
|
}
|
|
103
106
|
return [];
|
|
104
107
|
}
|
|
105
|
-
if (
|
|
106
|
-
|
|
108
|
+
if (layoutContext.props.menuActiveKey) {
|
|
109
|
+
setOpenKeys(findKeyPath(layoutContext.props.menuActiveKey, layoutContext.props.menuList || []));
|
|
107
110
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
}, [layoutContext.props.menuActiveKey, layoutContext.props.menuList]);
|
|
112
|
+
var handleMenuNavigation = function handleMenuNavigation(path, menuKey) {
|
|
113
|
+
assignProps({
|
|
114
|
+
loading: true
|
|
115
|
+
});
|
|
116
|
+
routerNavigateTo(path, {
|
|
117
|
+
onSuccess: function onSuccess() {
|
|
118
|
+
assignProps({
|
|
119
|
+
menuActiveKey: menuKey
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
onFinish: function onFinish() {
|
|
123
|
+
assignProps({
|
|
124
|
+
loading: false
|
|
125
|
+
});
|
|
115
126
|
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
window.addEventListener('resize', onResize);
|
|
119
|
-
return function () {
|
|
120
|
-
window.removeEventListener('resize', onResize);
|
|
121
|
-
};
|
|
122
|
-
}, []);
|
|
127
|
+
});
|
|
128
|
+
};
|
|
123
129
|
var onMenuClick = function onMenuClick(info) {
|
|
124
|
-
var _layoutContext$props
|
|
130
|
+
var _layoutContext$props$, _menu;
|
|
125
131
|
var keyPath = info.keyPath.reverse();
|
|
126
|
-
var menu = (_layoutContext$props$
|
|
132
|
+
var menu = (_layoutContext$props$ = layoutContext.props.menuList) === null || _layoutContext$props$ === void 0 ? void 0 : _layoutContext$props$.find(function (menu) {
|
|
127
133
|
return menu.key === keyPath[0];
|
|
128
134
|
});
|
|
129
135
|
var _loop = function _loop(i) {
|
|
@@ -136,30 +142,20 @@ export default function (_ref) {
|
|
|
136
142
|
_loop(i);
|
|
137
143
|
}
|
|
138
144
|
if ((_menu = menu) !== null && _menu !== void 0 && _menu.path) {
|
|
139
|
-
|
|
140
|
-
loading: true
|
|
141
|
-
});
|
|
142
|
-
routerNavigateTo(menu.path, {
|
|
143
|
-
onSuccess: function onSuccess() {
|
|
144
|
-
assignProps({
|
|
145
|
-
menuActiveKey: info.key
|
|
146
|
-
});
|
|
147
|
-
},
|
|
148
|
-
onFinish: function onFinish() {
|
|
149
|
-
assignProps({
|
|
150
|
-
loading: false
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
});
|
|
145
|
+
handleMenuNavigation(menu.path, info.key);
|
|
154
146
|
}
|
|
155
147
|
};
|
|
156
148
|
var proContext = useContext(ProProvider);
|
|
149
|
+
var toggleDarkMode = function toggleDarkMode() {
|
|
150
|
+
var newDarkMode = !proContext.dark;
|
|
151
|
+
setDarkMode(newDarkMode);
|
|
152
|
+
return newDarkMode;
|
|
153
|
+
};
|
|
157
154
|
var actionsRender = function actionsRender() {
|
|
158
155
|
return /*#__PURE__*/React.createElement(React.Fragment, null, layoutContext.props.headerActions, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Button, {
|
|
159
|
-
type:
|
|
160
|
-
onClick:
|
|
161
|
-
|
|
162
|
-
}
|
|
156
|
+
type: "text",
|
|
157
|
+
onClick: toggleDarkMode,
|
|
158
|
+
"aria-label": proContext.dark ? "Switch to light mode" : "Switch to dark mode"
|
|
163
159
|
}, proContext.dark ? /*#__PURE__*/React.createElement(MoonOutlined, null) : /*#__PURE__*/React.createElement(SunOutlined, null))));
|
|
164
160
|
};
|
|
165
161
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ProLayout, {
|
|
@@ -186,10 +182,10 @@ export default function (_ref) {
|
|
|
186
182
|
avatarProps: {
|
|
187
183
|
title: layoutProps.userName,
|
|
188
184
|
render: function render(p, dom) {
|
|
189
|
-
var _layoutContext$props$
|
|
185
|
+
var _layoutContext$props$2;
|
|
190
186
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Dropdown, {
|
|
191
187
|
menu: {
|
|
192
|
-
items: ((_layoutContext$props$
|
|
188
|
+
items: ((_layoutContext$props$2 = layoutContext.props.userMenu) === null || _layoutContext$props$2 === void 0 ? void 0 : _layoutContext$props$2.map(function (menu) {
|
|
193
189
|
return {
|
|
194
190
|
label: menu.title,
|
|
195
191
|
key: menu.url,
|
package/dist/components/Table.js
CHANGED
|
@@ -217,7 +217,7 @@ export default function (props) {
|
|
|
217
217
|
});
|
|
218
218
|
setSearchUrl(s);
|
|
219
219
|
}
|
|
220
|
-
setLastQuery(props.defaultSearchValue);
|
|
220
|
+
setLastQuery(props.defaultSearchValue || {});
|
|
221
221
|
if (!modalContext.inModal) {
|
|
222
222
|
var query = qs.parse(window.location.search.replace(/^\?/, ''));
|
|
223
223
|
if (query && Object.keys(query).length) {
|
package/dist/lib/upload.js
CHANGED
|
@@ -17,11 +17,16 @@ export function customRequest(_x) {
|
|
|
17
17
|
function _customRequest() {
|
|
18
18
|
_customRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
19
19
|
var _options$file;
|
|
20
|
-
var policyRes, formData, url, key, res, err, _e$response;
|
|
20
|
+
var filename, ext, policyRes, formData, url, key, res, err, _e$response;
|
|
21
21
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
22
22
|
while (1) switch (_context.prev = _context.next) {
|
|
23
23
|
case 0:
|
|
24
|
-
|
|
24
|
+
filename = options.file.name;
|
|
25
|
+
ext = filename.match(/(\.[^.]+)$/);
|
|
26
|
+
if (ext) {
|
|
27
|
+
filename = filename.replace(ext[1], ext[1].toLowerCase());
|
|
28
|
+
}
|
|
29
|
+
_context.next = 5;
|
|
25
30
|
return http({
|
|
26
31
|
url: options.action,
|
|
27
32
|
method: 'get',
|
|
@@ -30,22 +35,22 @@ function _customRequest() {
|
|
|
30
35
|
noHandle: true
|
|
31
36
|
},
|
|
32
37
|
params: {
|
|
33
|
-
title:
|
|
38
|
+
title: filename,
|
|
34
39
|
hash_id: options.file.hash_id,
|
|
35
40
|
file_type: ((_options$file = options.file) === null || _options$file === void 0 ? void 0 : _options$file.type) || ''
|
|
36
41
|
}
|
|
37
42
|
});
|
|
38
|
-
case
|
|
43
|
+
case 5:
|
|
39
44
|
policyRes = _context.sent;
|
|
40
45
|
if (!policyRes.data.status) {
|
|
41
|
-
_context.next =
|
|
46
|
+
_context.next = 9;
|
|
42
47
|
break;
|
|
43
48
|
}
|
|
44
49
|
options.onSuccess && options.onSuccess(_objectSpread(_objectSpread({}, policyRes.data), {}, {
|
|
45
50
|
url: policyRes.data.url || policyRes.data.file_url
|
|
46
51
|
}));
|
|
47
52
|
return _context.abrupt("return");
|
|
48
|
-
case
|
|
53
|
+
case 9:
|
|
49
54
|
formData = new FormData();
|
|
50
55
|
url = '';
|
|
51
56
|
if (policyRes.data.server_url) {
|
|
@@ -59,8 +64,8 @@ function _customRequest() {
|
|
|
59
64
|
}
|
|
60
65
|
}
|
|
61
66
|
formData.append('file', options.file);
|
|
62
|
-
_context.prev =
|
|
63
|
-
_context.next =
|
|
67
|
+
_context.prev = 14;
|
|
68
|
+
_context.next = 17;
|
|
64
69
|
return http({
|
|
65
70
|
url: url,
|
|
66
71
|
method: 'post',
|
|
@@ -75,25 +80,25 @@ function _customRequest() {
|
|
|
75
80
|
});
|
|
76
81
|
}
|
|
77
82
|
});
|
|
78
|
-
case
|
|
83
|
+
case 17:
|
|
79
84
|
res = _context.sent;
|
|
80
85
|
err = res.data.info || res.data.err_msg;
|
|
81
86
|
if (!err) {
|
|
82
|
-
_context.next =
|
|
87
|
+
_context.next = 23;
|
|
83
88
|
break;
|
|
84
89
|
}
|
|
85
90
|
message.error(err);
|
|
86
91
|
options.onError && options.onError(new Error(err), res.data);
|
|
87
92
|
return _context.abrupt("return");
|
|
88
|
-
case
|
|
93
|
+
case 23:
|
|
89
94
|
options.onSuccess && options.onSuccess(_objectSpread(_objectSpread({}, res.data), {}, {
|
|
90
95
|
url: res.data.url || res.data.file_url
|
|
91
96
|
}));
|
|
92
|
-
_context.next =
|
|
97
|
+
_context.next = 31;
|
|
93
98
|
break;
|
|
94
|
-
case
|
|
95
|
-
_context.prev =
|
|
96
|
-
_context.t0 = _context["catch"](
|
|
99
|
+
case 26:
|
|
100
|
+
_context.prev = 26;
|
|
101
|
+
_context.t0 = _context["catch"](14);
|
|
97
102
|
if (_context.t0 instanceof AxiosError) {
|
|
98
103
|
options.onError && options.onError(_context.t0, (_e$response = _context.t0.response) === null || _e$response === void 0 ? void 0 : _e$response.data);
|
|
99
104
|
}
|
|
@@ -106,11 +111,11 @@ function _customRequest() {
|
|
|
106
111
|
});
|
|
107
112
|
}
|
|
108
113
|
throw _context.t0;
|
|
109
|
-
case
|
|
114
|
+
case 31:
|
|
110
115
|
case "end":
|
|
111
116
|
return _context.stop();
|
|
112
117
|
}
|
|
113
|
-
}, _callee, null, [[
|
|
118
|
+
}, _callee, null, [[14, 26]]);
|
|
114
119
|
}));
|
|
115
120
|
return _customRequest.apply(this, arguments);
|
|
116
121
|
}
|