@quansitech/antd-admin 1.1.32 → 1.1.34
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/lib/upload.js +12 -11
- 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/lib/upload.js
CHANGED
|
@@ -58,9 +58,10 @@ function _customRequest() {
|
|
|
58
58
|
formData.append(key, policyRes.data.params[key]);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
+
formData.append('Content-Type', options.file.type);
|
|
61
62
|
formData.append('file', options.file);
|
|
62
|
-
_context.prev =
|
|
63
|
-
_context.next =
|
|
63
|
+
_context.prev = 12;
|
|
64
|
+
_context.next = 15;
|
|
64
65
|
return http({
|
|
65
66
|
url: url,
|
|
66
67
|
method: 'post',
|
|
@@ -75,25 +76,25 @@ function _customRequest() {
|
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
78
|
});
|
|
78
|
-
case
|
|
79
|
+
case 15:
|
|
79
80
|
res = _context.sent;
|
|
80
81
|
err = res.data.info || res.data.err_msg;
|
|
81
82
|
if (!err) {
|
|
82
|
-
_context.next =
|
|
83
|
+
_context.next = 21;
|
|
83
84
|
break;
|
|
84
85
|
}
|
|
85
86
|
message.error(err);
|
|
86
87
|
options.onError && options.onError(new Error(err), res.data);
|
|
87
88
|
return _context.abrupt("return");
|
|
88
|
-
case
|
|
89
|
+
case 21:
|
|
89
90
|
options.onSuccess && options.onSuccess(_objectSpread(_objectSpread({}, res.data), {}, {
|
|
90
91
|
url: res.data.url || res.data.file_url
|
|
91
92
|
}));
|
|
92
|
-
_context.next =
|
|
93
|
+
_context.next = 29;
|
|
93
94
|
break;
|
|
94
|
-
case
|
|
95
|
-
_context.prev =
|
|
96
|
-
_context.t0 = _context["catch"](
|
|
95
|
+
case 24:
|
|
96
|
+
_context.prev = 24;
|
|
97
|
+
_context.t0 = _context["catch"](12);
|
|
97
98
|
if (_context.t0 instanceof AxiosError) {
|
|
98
99
|
options.onError && options.onError(_context.t0, (_e$response = _context.t0.response) === null || _e$response === void 0 ? void 0 : _e$response.data);
|
|
99
100
|
}
|
|
@@ -106,11 +107,11 @@ function _customRequest() {
|
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
109
|
throw _context.t0;
|
|
109
|
-
case
|
|
110
|
+
case 29:
|
|
110
111
|
case "end":
|
|
111
112
|
return _context.stop();
|
|
112
113
|
}
|
|
113
|
-
}, _callee, null, [[
|
|
114
|
+
}, _callee, null, [[12, 24]]);
|
|
114
115
|
}));
|
|
115
116
|
return _customRequest.apply(this, arguments);
|
|
116
117
|
}
|