@ccs-ui/rc-pro 2.3.4 → 2.3.6-alpha-1
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/es/aj-captcha/index.d.ts +5 -2
- package/es/aj-captcha/index.js +6 -2
- package/es/auth/index.d.ts +3 -0
- package/es/auth/index.js +3 -0
- package/es/button/dropdown.js +5 -17
- package/es/button/group.js +47 -65
- package/es/button/index.d.ts +4 -11
- package/es/button/index.js +10 -13
- package/es/cascader/index.d.ts +6 -3
- package/es/cascader/index.js +11 -7
- package/es/ccs.d.ts +9 -10
- package/es/color-picker/index.d.ts +5 -1
- package/es/color-picker/index.js +6 -2
- package/es/context/index.d.ts +24 -2
- package/es/date-picker/index.d.ts +1 -0
- package/es/date-picker/index.js +3 -0
- package/es/dialog/HookDrawer.js +3 -1
- package/es/dialog/HookModal.js +3 -1
- package/es/dialog/context.d.ts +2 -1
- package/es/dialog/hook.d.ts +10 -0
- package/es/dialog/index.d.ts +3 -1
- package/es/dialog/index.js +3 -0
- package/es/editor/index.d.ts +1 -0
- package/es/editor/index.js +3 -0
- package/es/ellipsis/index.d.ts +21 -5
- package/es/ellipsis/index.js +117 -28
- package/es/ellipsis/index.less +5 -0
- package/es/ellipsis/useMeasure.d.ts +9 -0
- package/es/ellipsis/useMeasure.js +142 -0
- package/es/ellipsis/useResizeEffect.d.ts +2 -0
- package/es/ellipsis/useResizeEffect.js +28 -0
- package/es/ellipsis/withStopPropagation.d.ts +4 -0
- package/es/ellipsis/withStopPropagation.js +38 -0
- package/es/hooks/use-app.d.ts +7 -2
- package/es/hooks/use-app.js +8 -3
- package/es/hooks/use-selection.d.ts +28 -0
- package/es/hooks/use-selection.js +146 -0
- package/es/index.d.ts +3 -2
- package/es/index.js +3 -2
- package/es/interval-button/index.js +3 -0
- package/es/layout-keep-alive/index.d.ts +10 -13
- package/es/layout-keep-alive/index.js +98 -60
- package/es/layout-keep-alive/page.d.ts +3 -5
- package/es/layout-keep-alive/page.js +9 -5
- package/es/layout-single-page/index.d.ts +5 -3
- package/es/layout-single-page/index.js +14 -20
- package/es/layout-single-page/page.d.ts +3 -5
- package/es/layout-single-page/page.js +7 -2
- package/es/loading/index.d.ts +4 -1
- package/es/loading/index.js +4 -1
- package/es/pro-table/head.d.ts +8 -7
- package/es/pro-table/head.js +54 -100
- package/es/pro-table/index.d.ts +8 -8
- package/es/pro-table/index.js +8 -3
- package/es/pro-table/index.less +8 -3
- package/es/pro-table/selection-alert.d.ts +18 -0
- package/es/pro-table/selection-alert.js +52 -0
- package/es/pro-table/summary.d.ts +8 -0
- package/es/pro-table/summary.js +32 -0
- package/es/pro-table/table.d.ts +37 -30
- package/es/pro-table/table.js +485 -265
- package/es/pro-table/tree.d.ts +1 -1
- package/es/pro-table/tree.js +9 -15
- package/es/pro-tabs/index.d.ts +5 -2
- package/es/pro-tabs/index.js +16 -6
- package/es/resize-observer.d.ts +2 -2
- package/es/resize-observer.js +2 -2
- package/es/result/index.d.ts +11 -15
- package/es/result/index.js +57 -54
- package/es/select/ modal.d.ts +16 -0
- package/es/select/ modal.js +100 -0
- package/es/select/api.d.ts +25 -0
- package/es/select/api.js +67 -0
- package/es/select/customize.d.ts +35 -0
- package/es/select/customize.js +140 -0
- package/es/select/index.d.ts +20 -20
- package/es/select/index.js +70 -80
- package/es/status-tag/index.d.ts +5 -1
- package/es/status-tag/index.js +6 -2
- package/es/table/index.d.ts +5 -2
- package/es/table/index.js +82 -42
- package/es/table/index.less +27 -42
- package/es/trigger/index.d.ts +1 -0
- package/es/trigger/index.js +1 -0
- package/es/upload/index.d.ts +4 -3
- package/es/upload/index.js +6 -3
- package/es/water-mark/index.d.ts +4 -1
- package/es/water-mark/index.js +3 -0
- package/package.json +5 -4
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RowSelectMethod } from 'antd/es/table/interface';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface PropsType<T> {
|
|
4
|
+
/** 表单受控 value */
|
|
5
|
+
value?: any[];
|
|
6
|
+
/** 默认选择行数据,一般用于回显数据 */
|
|
7
|
+
defaultRows?: T[];
|
|
8
|
+
/** 是否多选 */
|
|
9
|
+
multiple?: boolean;
|
|
10
|
+
/** 字段配置,默认 { key: 'key'; label: 'label' } */
|
|
11
|
+
keyField: string;
|
|
12
|
+
/** 表单受控 onChange*/
|
|
13
|
+
onChange?: (value: any) => void;
|
|
14
|
+
/** 设置选项 */
|
|
15
|
+
onChangeRows?: (options: any[]) => void;
|
|
16
|
+
}
|
|
17
|
+
export default function useTableSelection<T = any>(props: PropsType<T>): {
|
|
18
|
+
onChange: (keys: React.Key[], rows: T[], info: {
|
|
19
|
+
type: RowSelectMethod;
|
|
20
|
+
}) => void;
|
|
21
|
+
onClear: (key?: React.Key) => void;
|
|
22
|
+
selectedRowKeys?: React.Key[] | undefined;
|
|
23
|
+
selectedRows?: T[] | undefined;
|
|
24
|
+
info: {
|
|
25
|
+
type: RowSelectMethod;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import { useMemoizedFn, useUpdateEffect } from 'ahooks';
|
|
14
|
+
import { useEffect, useRef, useState } from 'react';
|
|
15
|
+
// 判断相对
|
|
16
|
+
function isEq(obj1, obj2) {
|
|
17
|
+
var o1 = obj1 !== null && obj1 !== void 0 ? obj1 : [];
|
|
18
|
+
var o2 = obj2 !== null && obj2 !== void 0 ? obj2 : [];
|
|
19
|
+
if (!Array.isArray(o1)) {
|
|
20
|
+
o1 = [o1];
|
|
21
|
+
}
|
|
22
|
+
return JSON.stringify(o1) !== JSON.stringify(o2);
|
|
23
|
+
}
|
|
24
|
+
export default function useTableSelection(props) {
|
|
25
|
+
var _ref = props || {},
|
|
26
|
+
value = _ref.value,
|
|
27
|
+
defaultRows = _ref.defaultRows,
|
|
28
|
+
_ref$keyField = _ref.keyField,
|
|
29
|
+
keyField = _ref$keyField === void 0 ? 'key' : _ref$keyField,
|
|
30
|
+
multiple = _ref.multiple,
|
|
31
|
+
onChangeValue = _ref.onChange,
|
|
32
|
+
onChangeRows = _ref.onChangeRows;
|
|
33
|
+
var _useState = useState({}),
|
|
34
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
+
setUpdate = _useState2[1];
|
|
36
|
+
var selectionRef = useRef({
|
|
37
|
+
selectedRowKeys: ['number', 'string'].includes(_typeof(value)) ? [value] : value,
|
|
38
|
+
selectedRows: defaultRows,
|
|
39
|
+
info: {
|
|
40
|
+
type: 'none'
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
var handleOnChange = useMemoizedFn(function () {
|
|
44
|
+
var _selectionRef$current = selectionRef.current.selectedRowKeys,
|
|
45
|
+
selectedRowKeys = _selectionRef$current === void 0 ? [] : _selectionRef$current;
|
|
46
|
+
if (multiple) {
|
|
47
|
+
// 受控调用onChange
|
|
48
|
+
onChangeValue === null || onChangeValue === void 0 || onChangeValue(selectedRowKeys);
|
|
49
|
+
} else {
|
|
50
|
+
onChangeValue === null || onChangeValue === void 0 || onChangeValue(selectedRowKeys[0]);
|
|
51
|
+
}
|
|
52
|
+
if (!onChangeValue) setUpdate({});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// 生成默认选中数据
|
|
56
|
+
useEffect(function () {
|
|
57
|
+
if (defaultRows && !selectionRef.current.selectedRows) {
|
|
58
|
+
selectionRef.current.selectedRows = defaultRows;
|
|
59
|
+
|
|
60
|
+
// 生成选项
|
|
61
|
+
if (onChangeRows) onChangeRows(defaultRows);
|
|
62
|
+
setUpdate({});
|
|
63
|
+
}
|
|
64
|
+
}, [defaultRows]);
|
|
65
|
+
|
|
66
|
+
// value 变更,与当前选中数据不匹配
|
|
67
|
+
useUpdateEffect(function () {
|
|
68
|
+
if (isEq(value, selectionRef.current.selectedRowKeys)) {
|
|
69
|
+
var _selectionRef$current2;
|
|
70
|
+
var rows = (_selectionRef$current2 = selectionRef.current.selectedRows) === null || _selectionRef$current2 === void 0 ? void 0 : _selectionRef$current2.filter(function () {
|
|
71
|
+
var _ref2;
|
|
72
|
+
var row = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
73
|
+
return (_ref2 = value || []) === null || _ref2 === void 0 ? void 0 : _ref2.includes(row[keyField]);
|
|
74
|
+
});
|
|
75
|
+
selectionRef.current = {
|
|
76
|
+
selectedRowKeys: value,
|
|
77
|
+
selectedRows: rows,
|
|
78
|
+
info: {
|
|
79
|
+
type: 'none'
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
setUpdate({});
|
|
83
|
+
}
|
|
84
|
+
}, [value]);
|
|
85
|
+
|
|
86
|
+
// 选中改变
|
|
87
|
+
var onChange = useMemoizedFn(function (keys, rows, info) {
|
|
88
|
+
selectionRef.current = {
|
|
89
|
+
selectedRowKeys: keys,
|
|
90
|
+
selectedRows: rows,
|
|
91
|
+
info: info
|
|
92
|
+
};
|
|
93
|
+
// 未知选中数据,在初始化传入数据中匹配
|
|
94
|
+
if (defaultRows && defaultRows.length > 0) {
|
|
95
|
+
rows.forEach(function (row, index) {
|
|
96
|
+
if (!row) {
|
|
97
|
+
var defaultRow = defaultRows.find(function (r) {
|
|
98
|
+
return r[keyField] === keys[index];
|
|
99
|
+
});
|
|
100
|
+
if (defaultRow) rows[index] = defaultRow;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
onChangeRows === null || onChangeRows === void 0 || onChangeRows(rows);
|
|
105
|
+
handleOnChange();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// 删除
|
|
109
|
+
var onClear = useMemoizedFn(function (key) {
|
|
110
|
+
// 未传入key,删除全部
|
|
111
|
+
if (!key) {
|
|
112
|
+
selectionRef.current = {
|
|
113
|
+
selectedRowKeys: undefined,
|
|
114
|
+
selectedRows: undefined,
|
|
115
|
+
info: {
|
|
116
|
+
type: 'none'
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
} else {
|
|
120
|
+
var _selectionRef$current3 = selectionRef.current,
|
|
121
|
+
_selectionRef$current4 = _selectionRef$current3.selectedRowKeys,
|
|
122
|
+
selectedRowKeys = _selectionRef$current4 === void 0 ? [] : _selectionRef$current4,
|
|
123
|
+
_selectionRef$current5 = _selectionRef$current3.selectedRows,
|
|
124
|
+
selectedRows = _selectionRef$current5 === void 0 ? [] : _selectionRef$current5;
|
|
125
|
+
var newRows = selectedRows.filter(function () {
|
|
126
|
+
var r = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
127
|
+
return r[keyField] !== key;
|
|
128
|
+
});
|
|
129
|
+
var newKey = selectedRowKeys.filter(function (k) {
|
|
130
|
+
return k !== key;
|
|
131
|
+
});
|
|
132
|
+
selectionRef.current = {
|
|
133
|
+
selectedRowKeys: newKey,
|
|
134
|
+
selectedRows: newRows,
|
|
135
|
+
info: {
|
|
136
|
+
type: 'none'
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
handleOnChange();
|
|
141
|
+
});
|
|
142
|
+
return _objectSpread(_objectSpread({}, selectionRef.current), {}, {
|
|
143
|
+
onChange: onChange,
|
|
144
|
+
onClear: onClear
|
|
145
|
+
});
|
|
146
|
+
}
|
package/es/index.d.ts
CHANGED
|
@@ -7,11 +7,12 @@ export { default as CcsAppConfig } from './config';
|
|
|
7
7
|
export { default as CcsDatePicker } from './date-picker';
|
|
8
8
|
export { default as CcsDialog } from './dialog';
|
|
9
9
|
export { default as CcsEditor } from './editor';
|
|
10
|
-
export { default as
|
|
10
|
+
export { default as CcsEllipsis } from './ellipsis';
|
|
11
11
|
export { default as CcsFullScreenButton } from './full-screen';
|
|
12
12
|
export { default as useAppConfig } from './hooks/use-app';
|
|
13
13
|
export { default as useCcsOnceEvent } from './hooks/use-once-event';
|
|
14
14
|
export { default as useCcsPage } from './hooks/use-page';
|
|
15
|
+
export { default as useTableSelection } from './hooks/use-selection';
|
|
15
16
|
export { default as useCcsTabs } from './hooks/use-tabs';
|
|
16
17
|
export { default as useCcsWindow } from './hooks/use-window';
|
|
17
18
|
export { default as CcsIntervalButton } from './interval-button';
|
|
@@ -23,7 +24,7 @@ export { default as CcsProTable } from './pro-table';
|
|
|
23
24
|
export { default as CcsProTabs } from './pro-tabs';
|
|
24
25
|
export { default as CcsResizeObserver } from './resize-observer';
|
|
25
26
|
export { default as CcsResult } from './result';
|
|
26
|
-
export { default as
|
|
27
|
+
export { default as CcsSelect } from './select';
|
|
27
28
|
export { default as CcsStatusTag } from './status-tag';
|
|
28
29
|
export { default as CcsTable } from './table';
|
|
29
30
|
export { default as CcsTimePicker } from './time-picker';
|
package/es/index.js
CHANGED
|
@@ -7,11 +7,12 @@ export { default as CcsAppConfig } from "./config";
|
|
|
7
7
|
export { default as CcsDatePicker } from "./date-picker";
|
|
8
8
|
export { default as CcsDialog } from "./dialog";
|
|
9
9
|
export { default as CcsEditor } from "./editor";
|
|
10
|
-
export { default as
|
|
10
|
+
export { default as CcsEllipsis } from "./ellipsis";
|
|
11
11
|
export { default as CcsFullScreenButton } from "./full-screen";
|
|
12
12
|
export { default as useAppConfig } from "./hooks/use-app";
|
|
13
13
|
export { default as useCcsOnceEvent } from "./hooks/use-once-event";
|
|
14
14
|
export { default as useCcsPage } from "./hooks/use-page";
|
|
15
|
+
export { default as useTableSelection } from "./hooks/use-selection";
|
|
15
16
|
export { default as useCcsTabs } from "./hooks/use-tabs";
|
|
16
17
|
export { default as useCcsWindow } from "./hooks/use-window";
|
|
17
18
|
export { default as CcsIntervalButton } from "./interval-button";
|
|
@@ -23,7 +24,7 @@ export { default as CcsProTable } from "./pro-table";
|
|
|
23
24
|
export { default as CcsProTabs } from "./pro-tabs";
|
|
24
25
|
export { default as CcsResizeObserver } from "./resize-observer";
|
|
25
26
|
export { default as CcsResult } from "./result";
|
|
26
|
-
export { default as
|
|
27
|
+
export { default as CcsSelect } from "./select";
|
|
27
28
|
export { default as CcsStatusTag } from "./status-tag";
|
|
28
29
|
export { default as CcsTable } from "./table";
|
|
29
30
|
export { default as CcsTimePicker } from "./time-picker";
|
|
@@ -122,4 +122,7 @@ function IntervalButton(_ref, ref) {
|
|
|
122
122
|
children: disabled ? "".concat(count, "\u79D2").concat(disabledText) : "".concat(children)
|
|
123
123
|
}));
|
|
124
124
|
}
|
|
125
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
126
|
+
IntervalButton.displayName = 'CcsIntervalButton';
|
|
127
|
+
}
|
|
125
128
|
export default /*#__PURE__*/forwardRef(IntervalButton);
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
+
import { BreadcrumbProps } from 'antd';
|
|
1
2
|
import { JSXElementConstructor, ReactElement } from 'react';
|
|
3
|
+
import { Location } from 'react-router';
|
|
2
4
|
import CCS from '..';
|
|
3
5
|
import { MenuType } from '../ccs';
|
|
4
6
|
import './index.less';
|
|
5
|
-
type
|
|
6
|
-
/** 面包屑数据 */
|
|
7
|
-
breadcrumb?: {
|
|
8
|
-
key: any;
|
|
9
|
-
title: string;
|
|
10
|
-
href?: string;
|
|
11
|
-
}[];
|
|
12
|
-
};
|
|
13
|
-
export type CacheComponent = {
|
|
7
|
+
export type CacheRouter = {
|
|
14
8
|
key: string;
|
|
15
9
|
label: string;
|
|
16
|
-
locationKey: string;
|
|
17
10
|
urlAuthList: string[];
|
|
18
11
|
timestamp: number;
|
|
19
12
|
outlet: ReactElement<any, string | JSXElementConstructor<any>> | null;
|
|
20
13
|
children?: ReactElement<any, string | JSXElementConstructor<any>> | null;
|
|
21
|
-
breadcrumb:
|
|
14
|
+
breadcrumb: BreadcrumbProps['items'];
|
|
15
|
+
pageLocation: Location;
|
|
22
16
|
};
|
|
23
17
|
type PropsType = {
|
|
24
18
|
maxLen?: number;
|
|
@@ -28,5 +22,8 @@ type PropsType = {
|
|
|
28
22
|
history: any;
|
|
29
23
|
};
|
|
30
24
|
export declare function findMenusByUrl(tree: MenuType | MenuType[], targetUrl: string, parents?: MenuType[]): MenuType[] | null;
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
declare function KeepAliveTabs({ maxLen, appName, history, menuItems, className, }: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
declare namespace KeepAliveTabs {
|
|
27
|
+
var displayName: string;
|
|
28
|
+
}
|
|
29
|
+
export default KeepAliveTabs;
|
|
@@ -19,11 +19,11 @@ import CcsUtils from '@ccs-ui/utils';
|
|
|
19
19
|
import { useUpdate, useUpdateEffect } from 'ahooks';
|
|
20
20
|
import { Button, Dropdown, Empty, Tabs } from 'antd';
|
|
21
21
|
import classnames from 'classnames';
|
|
22
|
+
import updateHelper from 'immutability-helper';
|
|
22
23
|
import { useMemo, useRef } from 'react';
|
|
23
24
|
import { useLocation } from 'react-router';
|
|
24
25
|
import { useOutlet } from 'react-router-dom';
|
|
25
26
|
import { useAppConfig } from '..';
|
|
26
|
-
import CcsBreadcrumb from "../breadcrumb";
|
|
27
27
|
import "./index.less";
|
|
28
28
|
import Page from "./page";
|
|
29
29
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -124,7 +124,7 @@ export function findMenusByUrl(tree, targetUrl) {
|
|
|
124
124
|
}
|
|
125
125
|
return null;
|
|
126
126
|
}
|
|
127
|
-
|
|
127
|
+
function KeepAliveTabs(_ref) {
|
|
128
128
|
var _ref$maxLen = _ref.maxLen,
|
|
129
129
|
maxLen = _ref$maxLen === void 0 ? 10 : _ref$maxLen,
|
|
130
130
|
appName = _ref.appName,
|
|
@@ -132,10 +132,9 @@ export default function KeepAliveTabs(_ref) {
|
|
|
132
132
|
_ref$menuItems = _ref.menuItems,
|
|
133
133
|
menuItems = _ref$menuItems === void 0 ? [] : _ref$menuItems,
|
|
134
134
|
className = _ref.className;
|
|
135
|
-
var
|
|
135
|
+
var routers = useRef([]);
|
|
136
136
|
var location = useLocation();
|
|
137
|
-
var pathname = location.pathname
|
|
138
|
-
locationKey = location.key;
|
|
137
|
+
var pathname = location.pathname;
|
|
139
138
|
var outlet = useOutlet();
|
|
140
139
|
var update = useUpdate();
|
|
141
140
|
var _useAppConfig = useAppConfig(),
|
|
@@ -144,19 +143,19 @@ export default function KeepAliveTabs(_ref) {
|
|
|
144
143
|
var isColorful = theme === 'colorful';
|
|
145
144
|
|
|
146
145
|
// 超过缓存数量,删除第一个
|
|
147
|
-
if (
|
|
148
|
-
|
|
146
|
+
if (routers.current.length >= maxLen) {
|
|
147
|
+
routers.current = routers.current.slice(1);
|
|
149
148
|
}
|
|
150
149
|
|
|
151
150
|
// 菜单改变,更新用户权限信息
|
|
152
151
|
useUpdateEffect(function () {
|
|
153
|
-
|
|
152
|
+
routers.current.forEach(function (router) {
|
|
154
153
|
var _menu$btnAuth;
|
|
155
|
-
var menu = findMenuById(menuItems,
|
|
156
|
-
|
|
154
|
+
var menu = findMenuById(menuItems, router.key);
|
|
155
|
+
router.urlAuthList = (menu === null || menu === void 0 || (_menu$btnAuth = menu.btnAuth) === null || _menu$btnAuth === void 0 ? void 0 : _menu$btnAuth.map(function (b) {
|
|
157
156
|
return b.code;
|
|
158
157
|
})) || [];
|
|
159
|
-
|
|
158
|
+
router.timestamp = new Date().getTime();
|
|
160
159
|
});
|
|
161
160
|
update();
|
|
162
161
|
}, [menuItems]);
|
|
@@ -221,84 +220,124 @@ export default function KeepAliveTabs(_ref) {
|
|
|
221
220
|
if (menu) saveHistory();
|
|
222
221
|
|
|
223
222
|
// 面包屑数据
|
|
224
|
-
var breadcrumb = menus.map(function (m
|
|
223
|
+
var breadcrumb = menus.map(function (m) {
|
|
225
224
|
return {
|
|
226
225
|
key: m.key,
|
|
227
|
-
title: m.label
|
|
228
|
-
href: index !== menus.length - 1 ? m.url : undefined
|
|
226
|
+
title: m.label
|
|
229
227
|
};
|
|
230
228
|
});
|
|
231
229
|
breadcrumb.unshift({
|
|
232
230
|
key: '-1',
|
|
233
|
-
title: '首页'
|
|
234
|
-
href: '/'
|
|
231
|
+
title: '首页'
|
|
235
232
|
});
|
|
236
233
|
return _objectSpread(_objectSpread({}, menu), {}, {
|
|
237
234
|
breadcrumb: breadcrumb
|
|
238
235
|
});
|
|
239
236
|
}, [pathname]);
|
|
240
|
-
var
|
|
241
|
-
|
|
237
|
+
var activeKey = location.key;
|
|
238
|
+
// 路由数据
|
|
239
|
+
var routerIndex = routers.current.findIndex(function (c) {
|
|
240
|
+
return c.pageLocation.pathname === pathname;
|
|
242
241
|
});
|
|
243
|
-
if (
|
|
242
|
+
if (routerIndex > -1) {
|
|
243
|
+
// 路由已存在、判断search,state是否改变,如改变则更新路由数据
|
|
244
|
+
var router = routers.current[routerIndex];
|
|
245
|
+
if (router.pageLocation.search !== location.search || CcsUtils.jsonStringify(router.pageLocation.state) !== CcsUtils.jsonStringify(location.state)) {
|
|
246
|
+
// 更新路由数据,变更key,路由将重新加载
|
|
247
|
+
routers.current = updateHelper(routers.current, _defineProperty({}, routerIndex, {
|
|
248
|
+
key: {
|
|
249
|
+
$set: location.key
|
|
250
|
+
},
|
|
251
|
+
pageLocation: {
|
|
252
|
+
$set: location
|
|
253
|
+
}
|
|
254
|
+
}));
|
|
255
|
+
} else {
|
|
256
|
+
activeKey = router.pageLocation.key;
|
|
257
|
+
}
|
|
258
|
+
} else {
|
|
259
|
+
// 路由不存在,保存路由数据
|
|
244
260
|
var _ref3 = curMenu || {},
|
|
245
261
|
_ref3$btnAuth = _ref3.btnAuth,
|
|
246
262
|
btnAuth = _ref3$btnAuth === void 0 ? [] : _ref3$btnAuth,
|
|
247
263
|
_ref3$breadcrumb = _ref3.breadcrumb,
|
|
248
264
|
breadcrumb = _ref3$breadcrumb === void 0 ? [] : _ref3$breadcrumb;
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
265
|
+
routers.current = updateHelper(routers.current, {
|
|
266
|
+
$push: [{
|
|
267
|
+
key: location.key,
|
|
268
|
+
timestamp: new Date().getTime(),
|
|
269
|
+
label: (curMenu === null || curMenu === void 0 ? void 0 : curMenu.label) || '未知',
|
|
270
|
+
outlet: curMenu ? outlet : /*#__PURE__*/_jsx(Empty, {
|
|
271
|
+
description: "\u672A\u77E5\u9875\u9762"
|
|
272
|
+
}),
|
|
273
|
+
urlAuthList: btnAuth.map(function (b) {
|
|
274
|
+
return b.code;
|
|
275
|
+
}),
|
|
276
|
+
breadcrumb: breadcrumb,
|
|
277
|
+
pageLocation: location
|
|
278
|
+
}]
|
|
279
|
+
});
|
|
262
280
|
}
|
|
263
281
|
|
|
282
|
+
// tab路由切换,携带search,state参数
|
|
283
|
+
var onHistory = function onHistory(key) {
|
|
284
|
+
var tab = routers.current.find(function (c) {
|
|
285
|
+
return c.key === key;
|
|
286
|
+
});
|
|
287
|
+
if (tab) {
|
|
288
|
+
var _tab$pageLocation = tab.pageLocation,
|
|
289
|
+
_pathname = _tab$pageLocation.pathname,
|
|
290
|
+
state = _tab$pageLocation.state,
|
|
291
|
+
search = _tab$pageLocation.search;
|
|
292
|
+
history.push("".concat(_pathname).concat(search), state);
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
|
|
264
296
|
// 页面主动销毁或关闭tab
|
|
265
|
-
var onDestroy = function onDestroy(
|
|
266
|
-
var index =
|
|
267
|
-
return c.key ===
|
|
297
|
+
var onDestroy = function onDestroy(key) {
|
|
298
|
+
var index = routers.current.findIndex(function (c) {
|
|
299
|
+
return c.key === key;
|
|
268
300
|
});
|
|
301
|
+
// 删除的路由
|
|
302
|
+
var delRouter = routers.current[index];
|
|
269
303
|
if (index >= 0) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
304
|
+
routers.current = updateHelper(routers.current, {
|
|
305
|
+
$splice: [[index, 1]]
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
// 不是删的自己
|
|
309
|
+
if (delRouter.key !== key) {
|
|
273
310
|
update();
|
|
274
311
|
return;
|
|
275
312
|
}
|
|
276
313
|
|
|
277
314
|
// 显示首页
|
|
278
|
-
if (
|
|
315
|
+
if (routers.current.length === 0) {
|
|
279
316
|
history.push('/');
|
|
280
317
|
return;
|
|
281
318
|
}
|
|
282
319
|
|
|
283
320
|
// 显示前一个
|
|
284
|
-
if (index ===
|
|
285
|
-
|
|
321
|
+
if (index === routers.current.length) {
|
|
322
|
+
onHistory(routers.current[index - 1].key);
|
|
286
323
|
return;
|
|
287
324
|
}
|
|
288
325
|
|
|
289
326
|
// 显示后一个
|
|
290
|
-
|
|
327
|
+
onHistory(routers.current[index].key);
|
|
291
328
|
}
|
|
292
329
|
};
|
|
330
|
+
|
|
331
|
+
// 扩展操作
|
|
293
332
|
var onCloseTab = function onCloseTab(key) {
|
|
294
333
|
// 关闭其他标签
|
|
295
334
|
if (key === '1') {
|
|
296
|
-
|
|
335
|
+
routers.current = routers.current.filter(function (c) {
|
|
297
336
|
return c.key === pathname;
|
|
298
337
|
});
|
|
299
338
|
update();
|
|
300
339
|
} else {
|
|
301
|
-
|
|
340
|
+
routers.current = [];
|
|
302
341
|
history.push('/');
|
|
303
342
|
}
|
|
304
343
|
};
|
|
@@ -321,36 +360,35 @@ export default function KeepAliveTabs(_ref) {
|
|
|
321
360
|
id: "keep-alive-tabs",
|
|
322
361
|
hideAdd: true,
|
|
323
362
|
size: "small",
|
|
324
|
-
onChange:
|
|
325
|
-
history.push(e);
|
|
326
|
-
},
|
|
363
|
+
onChange: onHistory,
|
|
327
364
|
className: classnames(_defineProperty(_defineProperty(_defineProperty({}, 'ccs-keep-alive-tabs', !isColorful), 'dark', isDark), 'ccs-keep-alive-tabs-colorful', isColorful)),
|
|
328
|
-
activeKey:
|
|
365
|
+
activeKey: activeKey,
|
|
329
366
|
type: "editable-card",
|
|
330
367
|
onEdit: function onEdit(e) {
|
|
331
368
|
return onDestroy(e);
|
|
332
369
|
},
|
|
333
|
-
items:
|
|
334
|
-
tabBarExtraContent:
|
|
335
|
-
}),
|
|
370
|
+
items: routers.current,
|
|
371
|
+
tabBarExtraContent: routers.current.length > 2 ? tabBarExtraContent : null
|
|
372
|
+
}), routers.current.map(function (_ref4) {
|
|
336
373
|
var key = _ref4.key,
|
|
337
374
|
urlAuthList = _ref4.urlAuthList,
|
|
338
375
|
timestamp = _ref4.timestamp,
|
|
339
376
|
outlet = _ref4.outlet,
|
|
340
|
-
breadcrumb = _ref4.breadcrumb
|
|
377
|
+
breadcrumb = _ref4.breadcrumb,
|
|
378
|
+
pageLocation = _ref4.pageLocation;
|
|
341
379
|
return /*#__PURE__*/_jsx(Page, {
|
|
342
|
-
active:
|
|
343
|
-
location:
|
|
380
|
+
active: pageLocation.pathname === pathname,
|
|
381
|
+
location: pageLocation,
|
|
344
382
|
onDestroy: onDestroy,
|
|
345
383
|
urlAuthList: urlAuthList,
|
|
346
384
|
timestamp: timestamp,
|
|
347
|
-
|
|
348
|
-
history: history,
|
|
349
|
-
className: "ccs-breadcrumb",
|
|
350
|
-
items: breadcrumb
|
|
351
|
-
}),
|
|
385
|
+
breadcrumb: breadcrumb,
|
|
352
386
|
children: outlet
|
|
353
387
|
}, key);
|
|
354
388
|
})]
|
|
355
389
|
});
|
|
356
|
-
}
|
|
390
|
+
}
|
|
391
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
392
|
+
KeepAliveTabs.displayName = 'CcsKeepAliveTabs';
|
|
393
|
+
}
|
|
394
|
+
export default KeepAliveTabs;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { Location } from 'react-router';
|
|
3
|
-
import {
|
|
4
|
-
export type CachePageProps = Pick<
|
|
3
|
+
import { CacheRouter } from '.';
|
|
4
|
+
export type CachePageProps = Pick<CacheRouter, 'breadcrumb' | 'urlAuthList' | 'children' | 'timestamp'> & {
|
|
5
5
|
/** 选中状态 */
|
|
6
6
|
active: boolean;
|
|
7
7
|
/** router location */
|
|
8
8
|
location: Location;
|
|
9
|
-
/** 面包屑 */
|
|
10
|
-
breadcrumbNode: ReactNode;
|
|
11
9
|
/** 销毁页面 */
|
|
12
10
|
onDestroy: (path: string) => void;
|
|
13
11
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Breadcrumb } from 'antd';
|
|
1
2
|
import classNames from 'classnames';
|
|
2
3
|
import { memo, useRef } from 'react';
|
|
3
4
|
import Scrollbars from 'react-custom-scrollbars';
|
|
@@ -6,20 +7,20 @@ import { DialogElementsHolder } from "../dialog/hook";
|
|
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
8
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
9
|
export default /*#__PURE__*/memo(function (props) {
|
|
9
|
-
var locationRef = useRef(props.location);
|
|
10
10
|
var children = props.children,
|
|
11
11
|
active = props.active,
|
|
12
12
|
urlAuthList = props.urlAuthList,
|
|
13
13
|
onDestroy = props.onDestroy,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
breadcrumb = props.breadcrumb,
|
|
15
|
+
location = props.location;
|
|
16
|
+
var id = "_tab_content_".concat(location.key);
|
|
16
17
|
var dialogHolderRef = useRef(null);
|
|
17
18
|
return /*#__PURE__*/_jsx(PageContext.Provider, {
|
|
18
19
|
value: {
|
|
19
20
|
id: id,
|
|
20
21
|
dialogHolderRef: dialogHolderRef,
|
|
21
22
|
isActive: active,
|
|
22
|
-
location:
|
|
23
|
+
location: location,
|
|
23
24
|
onDestroy: onDestroy,
|
|
24
25
|
onAuth: function onAuth(e) {
|
|
25
26
|
return urlAuthList.includes(e);
|
|
@@ -37,7 +38,10 @@ export default /*#__PURE__*/memo(function (props) {
|
|
|
37
38
|
className: classNames('ccs-sticky-scroll', {
|
|
38
39
|
'route-avtive': active
|
|
39
40
|
}),
|
|
40
|
-
children: [
|
|
41
|
+
children: [/*#__PURE__*/_jsx(Breadcrumb, {
|
|
42
|
+
items: breadcrumb,
|
|
43
|
+
className: "ccs-breadcrumb"
|
|
44
|
+
}), children, /*#__PURE__*/_jsx(DialogElementsHolder, {
|
|
41
45
|
ref: dialogHolderRef
|
|
42
46
|
}, "modal-drawer-holder")]
|
|
43
47
|
})
|
|
@@ -4,7 +4,9 @@ type PropsType = {
|
|
|
4
4
|
appName: string;
|
|
5
5
|
menuItems: CCS.MenuType[];
|
|
6
6
|
className?: string;
|
|
7
|
-
history: any;
|
|
8
7
|
};
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
declare function SinglePage({ appName, menuItems, className }: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare namespace SinglePage {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
12
|
+
export default SinglePage;
|