@quansitech/antd-admin 1.1.29 → 1.1.31

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.
@@ -75,7 +75,7 @@ export default function (props) {
75
75
  aspect = parseInt(aspects[0]) / parseInt(aspects[1]);
76
76
  }
77
77
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ImgCrop, {
78
- quality: ((_props$fieldProps$cro = props.fieldProps.crop) === null || _props$fieldProps$cro === void 0 ? void 0 : _props$fieldProps$cro.quality) || 0.8,
78
+ quality: ((_props$fieldProps$cro = props.fieldProps.crop) === null || _props$fieldProps$cro === void 0 ? void 0 : _props$fieldProps$cro.quality) || 0.92,
79
79
  rotationSlider: true,
80
80
  aspect: aspect
81
81
  }, dom));
@@ -17,7 +17,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
17
17
  import { PageContainer, ProLayout, ProProvider } from "@ant-design/pro-components";
18
18
  import { Button, Dropdown, Menu, Space } from "antd";
19
19
  import { LayoutContext } from "../LayoutContext";
20
- import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
20
+ import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
21
21
  import { routerNavigateTo } from "../../lib/helpers";
22
22
  import http from "../../lib/http";
23
23
  // @ts-ignore
@@ -107,24 +107,6 @@ export default function (_ref) {
107
107
  }
108
108
  setOpenKeys(findKeyPath(layoutContext.props.menuActiveKey, layoutContext.props.menuList || []));
109
109
  }, [layoutContext.props.menuActiveKey]);
110
- useCallback(function () {
111
- var _pageProps$layoutProp, _pageProps$layoutProp2;
112
- if ((_pageProps$layoutProp = pageProps.layoutProps) !== null && _pageProps$layoutProp !== void 0 && _pageProps$layoutProp.menuActiveKey) {
113
- assignProps({
114
- menuActiveKey: pageProps.layoutProps.menuActiveKey
115
- });
116
- }
117
- var title = layoutContext.props.title || layoutProps.title;
118
- if ((_pageProps$layoutProp2 = pageProps.layoutProps) !== null && _pageProps$layoutProp2 !== void 0 && _pageProps$layoutProp2.metaTitle) {
119
- assignProps({
120
- metaTitle: pageProps.layoutProps.metaTitle + ' | ' + title
121
- });
122
- } else {
123
- assignProps({
124
- metaTitle: title
125
- });
126
- }
127
- }, [pageProps.layoutProps]);
128
110
  useEffect(function () {
129
111
  // 设置内容高度
130
112
  function onResize() {
@@ -173,7 +155,7 @@ export default function (_ref) {
173
155
  };
174
156
  var proContext = useContext(ProProvider);
175
157
  var actionsRender = function actionsRender() {
176
- return /*#__PURE__*/React.createElement(React.Fragment, null, layoutProps.headerActions, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Button, {
158
+ return /*#__PURE__*/React.createElement(React.Fragment, null, layoutContext.props.headerActions, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Button, {
177
159
  type: 'text',
178
160
  onClick: function onClick() {
179
161
  setDarkMode(!proContext.dark);
@@ -193,7 +175,7 @@ export default function (_ref) {
193
175
  return "".concat(pageTitle, " | ").concat(layoutProps.title, " \u540E\u53F0\u7BA1\u7406");
194
176
  },
195
177
  footerRender: function footerRender() {
196
- return /*#__PURE__*/React.createElement(React.Fragment, null, layoutProps.footer !== undefined ? /*#__PURE__*/React.createElement(React.Fragment, null, layoutProps.footer) : /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement("a", {
178
+ return /*#__PURE__*/React.createElement(React.Fragment, null, layoutContext.props.footer !== undefined ? /*#__PURE__*/React.createElement(React.Fragment, null, layoutContext.props.footer) : /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement("a", {
197
179
  href: "https://www.quansitech.com/",
198
180
  target: '_blank'
199
181
  }, "\u5168\u601D\u79D1\u6280"), /*#__PURE__*/React.createElement("a", {
@@ -0,0 +1,2 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export default function ({ children }: PropsWithChildren): any;
@@ -0,0 +1,18 @@
1
+ import { useContext, useEffect } from 'react';
2
+ import { LayoutContext } from "../../LayoutContext";
3
+ export default function (_ref) {
4
+ var children = _ref.children;
5
+ var layoutContext = useContext(LayoutContext);
6
+ useEffect(function () {
7
+ var footer = layoutContext.props.footer;
8
+ layoutContext.assignProps({
9
+ footer: children
10
+ });
11
+ return function () {
12
+ layoutContext.assignProps({
13
+ footer: footer
14
+ });
15
+ };
16
+ }, []);
17
+ return null;
18
+ }
@@ -0,0 +1,2 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export default function ({ children }: PropsWithChildren): any;
@@ -0,0 +1,18 @@
1
+ import { useContext, useEffect } from 'react';
2
+ import { LayoutContext } from "../../LayoutContext";
3
+ export default function (_ref) {
4
+ var children = _ref.children;
5
+ var layoutContext = useContext(LayoutContext);
6
+ useEffect(function () {
7
+ var headerActions = layoutContext.props.headerActions;
8
+ layoutContext.assignProps({
9
+ headerActions: children
10
+ });
11
+ return function () {
12
+ layoutContext.assignProps({
13
+ headerActions: headerActions
14
+ });
15
+ };
16
+ }, []);
17
+ return null;
18
+ }
@@ -31,27 +31,27 @@ import { diffTree, getValueByPath, routerNavigateTo } from "../lib/helpers";
31
31
  import qs from 'qs';
32
32
  import { TabsContext } from "./TabsContext";
33
33
  export default function (props) {
34
- var searchUrl = props.searchUrl;
35
34
  var request = /*#__PURE__*/function () {
36
35
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params, sort, filter) {
37
- var _formRef$current;
38
36
  var data, only, res;
39
37
  return _regeneratorRuntime().wrap(function _callee$(_context) {
40
38
  while (1) switch (_context.prev = _context.next) {
41
39
  case 0:
42
- setLoading(true);
43
- data = _objectSpread(_objectSpread(_objectSpread({}, filter), (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldsValue()), {}, {
40
+ data = _objectSpread(_objectSpread(_objectSpread({}, params), filter), {}, {
44
41
  sort: sort
45
42
  });
46
43
  if (props.pagination) {
47
44
  data[props.pagination.paramName || 'page'] = params.current;
45
+ delete data.current;
46
+ delete data.pageSize;
48
47
  }
49
48
  setEditableKeys([]);
50
49
  setEditableValues([]);
51
50
  if (modalContext.inModal) {
52
- _context.next = 10;
51
+ _context.next = 9;
53
52
  break;
54
53
  }
54
+ // 如果不在 modal 中,则使用 routerNavigateTo
55
55
  only = ['dataSource', 'pagination', 'extraRenderValues'];
56
56
  if (tabsContext.inTabs) {
57
57
  only.push('tabs');
@@ -77,16 +77,16 @@ export default function (props) {
77
77
  }
78
78
  });
79
79
  return _context.abrupt("return");
80
- case 10:
81
- _context.prev = 10;
82
- _context.next = 13;
80
+ case 9:
81
+ _context.prev = 9;
82
+ _context.next = 12;
83
83
  return http.get(searchUrl, {
84
84
  params: data,
85
85
  headers: {
86
86
  'X-Table-Search': '1'
87
87
  }
88
88
  });
89
- case 13:
89
+ case 12:
90
90
  res = _context.sent;
91
91
  if (res.data.pagination) {
92
92
  setPagination(_objectSpread(_objectSpread({}, res.data.pagination), {}, {
@@ -101,15 +101,15 @@ export default function (props) {
101
101
  data: res.data.dataSource || [],
102
102
  success: true
103
103
  });
104
- case 18:
105
- _context.prev = 18;
104
+ case 17:
105
+ _context.prev = 17;
106
106
  setLoading(false);
107
- return _context.finish(18);
108
- case 21:
107
+ return _context.finish(17);
108
+ case 20:
109
109
  case "end":
110
110
  return _context.stop();
111
111
  }
112
- }, _callee, null, [[10,, 18, 21]]);
112
+ }, _callee, null, [[9,, 17, 20]]);
113
113
  }));
114
114
  return function request(_x, _x2, _x3) {
115
115
  return _ref.apply(this, arguments);
@@ -150,47 +150,51 @@ export default function (props) {
150
150
  return row;
151
151
  });
152
152
  };
153
+ var _useState = useState(props.searchUrl),
154
+ _useState2 = _slicedToArray(_useState, 2),
155
+ searchUrl = _useState2[0],
156
+ setSearchUrl = _useState2[1];
153
157
  var formRef = useRef();
154
158
  var actionRef = useRef();
155
- var _useState = useState({}),
156
- _useState2 = _slicedToArray(_useState, 2),
157
- lastQuery = _useState2[0],
158
- setLastQuery = _useState2[1];
159
- var _useState3 = useState(function () {
159
+ var _useState3 = useState({}),
160
+ _useState4 = _slicedToArray(_useState3, 2),
161
+ lastQuery = _useState4[0],
162
+ setLastQuery = _useState4[1];
163
+ var _useState5 = useState(function () {
160
164
  return [];
161
165
  }),
162
- _useState4 = _slicedToArray(_useState3, 2),
163
- editableKeys = _useState4[0],
164
- setEditableKeys = _useState4[1];
165
- var _useState5 = useState([]),
166
166
  _useState6 = _slicedToArray(_useState5, 2),
167
- selectedRows = _useState6[0],
168
- setSelectedRows = _useState6[1];
167
+ editableKeys = _useState6[0],
168
+ setEditableKeys = _useState6[1];
169
169
  var _useState7 = useState([]),
170
170
  _useState8 = _slicedToArray(_useState7, 2),
171
- editableValues = _useState8[0],
172
- setEditableValues = _useState8[1];
173
- var _useState9 = useState(false),
171
+ selectedRows = _useState8[0],
172
+ setSelectedRows = _useState8[1];
173
+ var _useState9 = useState([]),
174
174
  _useState10 = _slicedToArray(_useState9, 2),
175
- loading = _useState10[0],
176
- setLoading = _useState10[1];
177
- // @ts-ignore
178
- var _useState11 = useState(props.pagination),
175
+ editableValues = _useState10[0],
176
+ setEditableValues = _useState10[1];
177
+ var _useState11 = useState(false),
179
178
  _useState12 = _slicedToArray(_useState11, 2),
180
- pagination = _useState12[0],
181
- setPagination = _useState12[1];
182
- var _useState13 = useState(postData(props.dataSource)),
179
+ loading = _useState12[0],
180
+ setLoading = _useState12[1];
181
+ // @ts-ignore
182
+ var _useState13 = useState(props.pagination),
183
183
  _useState14 = _slicedToArray(_useState13, 2),
184
- dataSource = _useState14[0],
185
- setDataSource = _useState14[1];
186
- var _useState15 = useState(true),
184
+ pagination = _useState14[0],
185
+ setPagination = _useState14[1];
186
+ var _useState15 = useState(postData(props.dataSource)),
187
187
  _useState16 = _slicedToArray(_useState15, 2),
188
- sticky = _useState16[0],
189
- setSticky = _useState16[1];
190
- var _useState17 = useState(props.extraRenderValues),
188
+ dataSource = _useState16[0],
189
+ setDataSource = _useState16[1];
190
+ var _useState17 = useState(true),
191
191
  _useState18 = _slicedToArray(_useState17, 2),
192
- extraRenderValues = _useState18[0],
193
- setExtraRenderValues = _useState18[1];
192
+ sticky = _useState18[0],
193
+ setSticky = _useState18[1];
194
+ var _useState19 = useState(props.extraRenderValues),
195
+ _useState20 = _slicedToArray(_useState19, 2),
196
+ extraRenderValues = _useState20[0],
197
+ setExtraRenderValues = _useState20[1];
194
198
  var modalContext = useContext(ModalContext);
195
199
  var tabsContext = useContext(TabsContext);
196
200
  useEffect(function () {
@@ -204,19 +208,26 @@ export default function (props) {
204
208
 
205
209
  // 搜索
206
210
  if (!searchUrl) {
207
- searchUrl = window.location.href;
211
+ var s = window.location.href;
212
+ s = s.replace(/page=\d+&?/, '');
213
+ columns.filter(function (c) {
214
+ return c.search !== false;
215
+ }).map(function (c) {
216
+ s = s.replace(new RegExp("".concat(c.dataIndex, "=[^&]*&?")), '');
217
+ });
218
+ setSearchUrl(s);
208
219
  }
209
220
  setLastQuery(props.defaultSearchValue);
210
221
  if (!modalContext.inModal) {
211
222
  var query = qs.parse(window.location.search.replace(/^\?/, ''));
212
223
  if (query && Object.keys(query).length) {
213
- var _formRef$current2;
224
+ var _formRef$current;
214
225
  Object.keys(query).forEach(function (key) {
215
226
  if (typeof query[key] === 'string') {
216
227
  /^\d+$/.test(query[key]) && (query[key] = parseInt(query[key]));
217
228
  }
218
229
  });
219
- (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.setFieldsValue(query);
230
+ (_formRef$current = formRef.current) === null || _formRef$current === void 0 || _formRef$current.setFieldsValue(query);
220
231
  }
221
232
  }
222
233
  }, []);
@@ -257,7 +268,7 @@ export default function (props) {
257
268
  form: {
258
269
  initialValues: props.defaultSearchValue,
259
270
  onValuesChange: function onValuesChange(changedValues, allValues) {
260
- var _formRef$current3;
271
+ var _formRef$current2;
261
272
  var submit = columns.filter(function (c) {
262
273
  if (!c.searchOnChange) {
263
274
  return false;
@@ -268,7 +279,7 @@ export default function (props) {
268
279
  return;
269
280
  }
270
281
  // 是否立即搜索
271
- (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 || _formRef$current3.submit();
282
+ (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.submit();
272
283
  }
273
284
  },
274
285
  rowSelection: props.rowSelection && {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quansitech/antd-admin",
3
- "version": "1.1.29",
3
+ "version": "1.1.31",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
package/readme.md CHANGED
@@ -12,10 +12,10 @@ npm install @quansitech/antd-admin
12
12
 
13
13
  ### Layout组件Props
14
14
 
15
- | 属性 | 说明 | 类型 | 默认值 |
16
- |---------------|------|-----------|---------------|
17
- | headerActions | 顶部操作 | ReactNode | - |
18
- | footer | 底部内容 | ReactNode | 全思科技 - Github |
15
+ | 属性 | 替换组件 | 说明 | 类型 | 默认值 |
16
+ |---------------|---------------|------|-----------|---------------|
17
+ | headerActions | HeaderActions | 顶部操作 | ReactNode | - |
18
+ | footer | Footer | 底部内容 | ReactNode | 全思科技 - Github |
19
19
 
20
20
  可在项目目录 `/resources/js/backend/app.tsx` 中修改,如:
21
21
 
@@ -37,6 +37,23 @@ createInertiaApp({
37
37
  })
38
38
  ```
39
39
 
40
+ 对于单独页面修改Layout组件属性,可在页面中调用对应的 Replacement 组件,如:
41
+
42
+ ```tsx
43
+ import HeaderActions from "@quansitech/antd-admin/dist/components/Layout/Replacement/HeaderActions";
44
+
45
+ export default function () {
46
+
47
+ return <>
48
+ <HeaderActions>
49
+ 修改的内容
50
+ </HeaderActions>
51
+ 页面内容
52
+ </>
53
+ }
54
+
55
+ ```
56
+
40
57
  ### valueType列表
41
58
 
42
59
  参考 [ant-design-pro#valueType](https://procomponents.ant.design/components/schema#valuetype-%E5%88%97%E8%A1%A8)