@ccs-ui/rc-pro 2.2.9 → 2.3.0-beta-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/button/group.js +9 -3
- package/es/ccs.d.ts +12 -12
- package/es/dialog/button.d.ts +1 -1
- package/es/layout-keep-alive/index.d.ts +12 -3
- package/es/layout-keep-alive/index.js +127 -26
- package/es/layout-single-page/index.d.ts +2 -2
- package/es/layout-single-page/index.js +18 -13
- package/es/layout-single-page/page.d.ts +2 -2
- package/package.json +1 -1
- package/es/button/index.less +0 -11
package/es/button/group.js
CHANGED
|
@@ -90,9 +90,11 @@ export default function CssButtonGroup(_ref) {
|
|
|
90
90
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
91
91
|
children: [/*#__PURE__*/_jsx(Space, {
|
|
92
92
|
split: /*#__PURE__*/_jsx(Divider, {
|
|
93
|
-
type: "vertical"
|
|
93
|
+
type: "vertical",
|
|
94
|
+
style: {
|
|
95
|
+
margin: 0
|
|
96
|
+
}
|
|
94
97
|
}),
|
|
95
|
-
className: "ccs-group-link",
|
|
96
98
|
children: showBtns === null || showBtns === void 0 ? void 0 : showBtns.map(function (_ref5) {
|
|
97
99
|
var key = _ref5.key,
|
|
98
100
|
label = _ref5.label,
|
|
@@ -101,7 +103,11 @@ export default function CssButtonGroup(_ref) {
|
|
|
101
103
|
onDisabled = _ref5.onDisabled,
|
|
102
104
|
onHidden = _ref5.onHidden,
|
|
103
105
|
restProps = _objectWithoutProperties(_ref5, _excluded2);
|
|
104
|
-
return /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({
|
|
106
|
+
return /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({
|
|
107
|
+
style: {
|
|
108
|
+
padding: 0
|
|
109
|
+
}
|
|
110
|
+
}, restProps), {}, {
|
|
105
111
|
size: size,
|
|
106
112
|
type: "link",
|
|
107
113
|
onClick: function onClick() {
|
package/es/ccs.d.ts
CHANGED
|
@@ -3,20 +3,20 @@ import { Rule } from 'antd/es/form';
|
|
|
3
3
|
import { CSSProperties, MutableRefObject, ReactElement, ReactNode } from 'react';
|
|
4
4
|
import { TableColumn } from './pro-table/table';
|
|
5
5
|
type MenuType = {
|
|
6
|
-
|
|
7
|
-
menuId: string;
|
|
8
|
-
/** 菜单路由 */
|
|
9
|
-
menuUrl: string;
|
|
6
|
+
key: string;
|
|
10
7
|
/** 菜单名称 */
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
label: string;
|
|
9
|
+
/** 图标 */
|
|
10
|
+
icon?: string;
|
|
11
|
+
/** url地址 */
|
|
12
|
+
url?: string;
|
|
13
|
+
/** 菜单权限编码 */
|
|
14
|
+
btnAuth?: {
|
|
15
|
+
name: string;
|
|
16
|
+
code: string;
|
|
17
17
|
}[];
|
|
18
|
-
/**
|
|
19
|
-
|
|
18
|
+
/** 下级菜单 */
|
|
19
|
+
children?: MenuType[];
|
|
20
20
|
};
|
|
21
21
|
type TableData<T> = {
|
|
22
22
|
/** loading */
|
package/es/dialog/button.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type DialogButtonsProps<T> = Pick<CcsDialogModalProps, 'okText' | 'onClos
|
|
|
16
16
|
export type DialogButtonRef = {
|
|
17
17
|
onSetButtons: (e: React.ReactElement) => void;
|
|
18
18
|
};
|
|
19
|
-
export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "
|
|
19
|
+
export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "auth" | "request" | "onClose" | "onOk" | "extraBtn" | "requestFieldNames" | "preventRequestHandle"> & {
|
|
20
20
|
formRef: React.RefObject<DialogFormRef<TParams>>;
|
|
21
21
|
formInitialValues: FormProps['initialValues'];
|
|
22
22
|
buttonRef: RefObject<DialogButtonRef>;
|
|
@@ -2,6 +2,14 @@ import { JSXElementConstructor, ReactElement } from 'react';
|
|
|
2
2
|
import CCS from '..';
|
|
3
3
|
import { MenuType } from '../ccs';
|
|
4
4
|
import './index.less';
|
|
5
|
+
type LayoutMenuType = CCS.MenuType & {
|
|
6
|
+
/** 面包屑数据 */
|
|
7
|
+
breadcrumb?: {
|
|
8
|
+
key: any;
|
|
9
|
+
title: string;
|
|
10
|
+
href?: string;
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
5
13
|
export type CacheComponent = {
|
|
6
14
|
key: string;
|
|
7
15
|
label: string;
|
|
@@ -10,14 +18,15 @@ export type CacheComponent = {
|
|
|
10
18
|
timestamp: number;
|
|
11
19
|
outlet: ReactElement<any, string | JSXElementConstructor<any>> | null;
|
|
12
20
|
children?: ReactElement<any, string | JSXElementConstructor<any>> | null;
|
|
13
|
-
breadcrumb:
|
|
21
|
+
breadcrumb: LayoutMenuType['breadcrumb'];
|
|
14
22
|
};
|
|
15
23
|
type PropsType = {
|
|
16
24
|
maxLen?: number;
|
|
17
25
|
appName: string;
|
|
18
|
-
|
|
26
|
+
menuItems: CCS.MenuType[];
|
|
19
27
|
className?: string;
|
|
20
28
|
history: any;
|
|
21
29
|
};
|
|
22
|
-
export
|
|
30
|
+
export declare function findMenusByUrl(tree: MenuType | MenuType[], targetUrl: string, parents?: MenuType[]): MenuType[] | null;
|
|
31
|
+
export default function KeepAliveTabs({ maxLen, appName, history, menuItems, className, }: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
23
32
|
export {};
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
function
|
|
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; }
|
|
2
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; }
|
|
3
4
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
4
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 _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
7
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
8
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
9
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
10
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
-
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); }
|
|
8
11
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
12
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
|
+
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); }
|
|
14
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
15
|
+
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
16
|
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 _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
12
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
13
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
14
17
|
import { MoreOutlined } from '@ant-design/icons';
|
|
15
18
|
import CcsUtils from '@ccs-ui/utils';
|
|
16
19
|
import { useUpdate, useUpdateEffect } from 'ahooks';
|
|
@@ -32,13 +35,101 @@ var extraItems = [{
|
|
|
32
35
|
label: '关闭所有标签'
|
|
33
36
|
}];
|
|
34
37
|
var RouteHistorys = [];
|
|
38
|
+
// 根据ID查找菜单
|
|
39
|
+
function findMenuById(items, targetId) {
|
|
40
|
+
if (Array.isArray(items)) {
|
|
41
|
+
var _iterator = _createForOfIteratorHelper(items),
|
|
42
|
+
_step;
|
|
43
|
+
try {
|
|
44
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
45
|
+
var node = _step.value;
|
|
46
|
+
var result = findMenuById(node, targetId);
|
|
47
|
+
if (result) {
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
} catch (err) {
|
|
52
|
+
_iterator.e(err);
|
|
53
|
+
} finally {
|
|
54
|
+
_iterator.f();
|
|
55
|
+
}
|
|
56
|
+
} else if (_typeof(items) === 'object' && items !== null) {
|
|
57
|
+
if (items.key === targetId && (!items.children || items.children.length === 0)) {
|
|
58
|
+
return items;
|
|
59
|
+
}
|
|
60
|
+
if (items.children && items.children.length > 0) {
|
|
61
|
+
var _iterator2 = _createForOfIteratorHelper(items.children),
|
|
62
|
+
_step2;
|
|
63
|
+
try {
|
|
64
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
65
|
+
var child = _step2.value;
|
|
66
|
+
var _result = findMenuById(child, targetId);
|
|
67
|
+
if (_result) {
|
|
68
|
+
return _result;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} catch (err) {
|
|
72
|
+
_iterator2.e(err);
|
|
73
|
+
} finally {
|
|
74
|
+
_iterator2.f();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 根据URL获取上下级菜单信息
|
|
82
|
+
export function findMenusByUrl(tree, targetUrl) {
|
|
83
|
+
var parents = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
84
|
+
if (Array.isArray(tree)) {
|
|
85
|
+
var _iterator3 = _createForOfIteratorHelper(tree),
|
|
86
|
+
_step3;
|
|
87
|
+
try {
|
|
88
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
89
|
+
var node = _step3.value;
|
|
90
|
+
var result = findMenusByUrl(node, targetUrl, parents);
|
|
91
|
+
if (result) {
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} catch (err) {
|
|
96
|
+
_iterator3.e(err);
|
|
97
|
+
} finally {
|
|
98
|
+
_iterator3.f();
|
|
99
|
+
}
|
|
100
|
+
} else if (_typeof(tree) === 'object' && tree !== null) {
|
|
101
|
+
var _tree$url;
|
|
102
|
+
if (tree.url === targetUrl || (_tree$url = tree.url) !== null && _tree$url !== void 0 && _tree$url.includes('?') && tree.url.split('?')[0] === targetUrl) {
|
|
103
|
+
return [].concat(_toConsumableArray(parents), [tree]);
|
|
104
|
+
}
|
|
105
|
+
if (tree.children && tree.children.length > 0) {
|
|
106
|
+
var newParents = [].concat(_toConsumableArray(parents), [tree]);
|
|
107
|
+
var _iterator4 = _createForOfIteratorHelper(tree.children),
|
|
108
|
+
_step4;
|
|
109
|
+
try {
|
|
110
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
111
|
+
var child = _step4.value;
|
|
112
|
+
var _result2 = findMenusByUrl(child, targetUrl, newParents);
|
|
113
|
+
if (_result2) {
|
|
114
|
+
return _result2;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
} catch (err) {
|
|
118
|
+
_iterator4.e(err);
|
|
119
|
+
} finally {
|
|
120
|
+
_iterator4.f();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
35
126
|
export default function KeepAliveTabs(_ref) {
|
|
36
127
|
var _ref$maxLen = _ref.maxLen,
|
|
37
128
|
maxLen = _ref$maxLen === void 0 ? 10 : _ref$maxLen,
|
|
38
129
|
appName = _ref.appName,
|
|
39
130
|
history = _ref.history,
|
|
40
|
-
_ref$
|
|
41
|
-
|
|
131
|
+
_ref$menuItems = _ref.menuItems,
|
|
132
|
+
menuItems = _ref$menuItems === void 0 ? [] : _ref$menuItems,
|
|
42
133
|
className = _ref.className;
|
|
43
134
|
var components = useRef([]);
|
|
44
135
|
var location = useLocation();
|
|
@@ -59,28 +150,27 @@ export default function KeepAliveTabs(_ref) {
|
|
|
59
150
|
// 菜单改变,更新用户权限信息
|
|
60
151
|
useUpdateEffect(function () {
|
|
61
152
|
components.current.forEach(function (component) {
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
component.urlAuthList = (menu === null || menu === void 0 ? void 0 :
|
|
153
|
+
var _menu$btnAuth;
|
|
154
|
+
var menu = findMenuById(menuItems, component.key);
|
|
155
|
+
console.log('menu...', menu);
|
|
156
|
+
component.urlAuthList = (menu === null || menu === void 0 || (_menu$btnAuth = menu.btnAuth) === null || _menu$btnAuth === void 0 ? void 0 : _menu$btnAuth.map(function (b) {
|
|
157
|
+
return b.code;
|
|
158
|
+
})) || [];
|
|
66
159
|
component.timestamp = new Date().getTime();
|
|
67
160
|
});
|
|
68
161
|
update();
|
|
69
|
-
}, [
|
|
162
|
+
}, [menuItems]);
|
|
70
163
|
|
|
71
164
|
// 当前菜单
|
|
72
165
|
var curMenu = useMemo(function () {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
return menuUrl === pathname;
|
|
79
|
-
});
|
|
166
|
+
// 上下级菜单
|
|
167
|
+
var menus = findMenusByUrl(menuItems, pathname) || [];
|
|
168
|
+
// 当前菜单
|
|
169
|
+
var menu = menus === null || menus === void 0 ? void 0 : menus.at(-1);
|
|
80
170
|
|
|
81
171
|
// add document title
|
|
82
172
|
setTimeout(function () {
|
|
83
|
-
document.title = "".concat((menu === null || menu === void 0 ? void 0 : menu.
|
|
173
|
+
document.title = "".concat((menu === null || menu === void 0 ? void 0 : menu.label) || (menu === null || menu === void 0 ? void 0 : menu.url), " - ").concat(appName);
|
|
84
174
|
}, 10);
|
|
85
175
|
|
|
86
176
|
// save history route
|
|
@@ -114,7 +204,7 @@ export default function KeepAliveTabs(_ref) {
|
|
|
114
204
|
}
|
|
115
205
|
RouteHistorys.unshift({
|
|
116
206
|
pathName: pathname,
|
|
117
|
-
menuName: (menu === null || menu === void 0 ? void 0 : menu.
|
|
207
|
+
menuName: (menu === null || menu === void 0 ? void 0 : menu.label) || '',
|
|
118
208
|
time: new Date()
|
|
119
209
|
});
|
|
120
210
|
CcsUtils.setStroage('_ROUTE_HISTORY', RouteHistorys);
|
|
@@ -129,29 +219,40 @@ export default function KeepAliveTabs(_ref) {
|
|
|
129
219
|
};
|
|
130
220
|
}();
|
|
131
221
|
if (menu) saveHistory();
|
|
132
|
-
return menu
|
|
222
|
+
return _objectSpread(_objectSpread({}, menu), {}, {
|
|
223
|
+
breadcrumb: menus.map(function (m) {
|
|
224
|
+
return {
|
|
225
|
+
key: m.key,
|
|
226
|
+
title: m.label,
|
|
227
|
+
href: m.url
|
|
228
|
+
};
|
|
229
|
+
})
|
|
230
|
+
});
|
|
133
231
|
}, [pathname]);
|
|
134
232
|
var component = components.current.find(function (c) {
|
|
135
233
|
return c.key === pathname;
|
|
136
234
|
});
|
|
137
235
|
if (!component) {
|
|
138
236
|
var _ref3 = curMenu || {},
|
|
139
|
-
_ref3$
|
|
140
|
-
|
|
237
|
+
_ref3$btnAuth = _ref3.btnAuth,
|
|
238
|
+
btnAuth = _ref3$btnAuth === void 0 ? [] : _ref3$btnAuth,
|
|
141
239
|
_ref3$breadcrumb = _ref3.breadcrumb,
|
|
142
240
|
breadcrumb = _ref3$breadcrumb === void 0 ? [] : _ref3$breadcrumb;
|
|
143
241
|
components.current = [].concat(_toConsumableArray(components.current), [{
|
|
144
242
|
locationKey: locationKey,
|
|
145
243
|
key: pathname,
|
|
146
244
|
timestamp: new Date().getTime(),
|
|
147
|
-
label: curMenu ? curMenu.
|
|
245
|
+
label: (curMenu === null || curMenu === void 0 ? void 0 : curMenu.label) || '未知',
|
|
148
246
|
outlet: curMenu ? outlet : /*#__PURE__*/_jsx(Empty, {
|
|
149
247
|
description: "\u672A\u77E5\u9875\u9762"
|
|
150
248
|
}),
|
|
151
|
-
urlAuthList:
|
|
249
|
+
urlAuthList: btnAuth.map(function (b) {
|
|
250
|
+
return b.code;
|
|
251
|
+
}),
|
|
152
252
|
breadcrumb: breadcrumb
|
|
153
253
|
}]);
|
|
154
254
|
}
|
|
255
|
+
console.log('components.current', components.current);
|
|
155
256
|
|
|
156
257
|
// 页面主动销毁或关闭tab
|
|
157
258
|
var onDestroy = function onDestroy(path) {
|
|
@@ -2,8 +2,8 @@ import CCS from "..";
|
|
|
2
2
|
import './index.less';
|
|
3
3
|
type PropsType = {
|
|
4
4
|
appName: string;
|
|
5
|
-
|
|
5
|
+
menuItems: CCS.MenuType[];
|
|
6
6
|
className?: string;
|
|
7
7
|
};
|
|
8
|
-
export default function SinglePage({ appName,
|
|
8
|
+
export default function SinglePage({ appName, menuItems, className, }: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -2,14 +2,15 @@ import classnames from 'classnames';
|
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { useLocation } from 'react-router';
|
|
4
4
|
import { useOutlet } from 'react-router-dom';
|
|
5
|
+
import { findMenusByUrl } from "../layout-keep-alive";
|
|
5
6
|
import CcsResult from "../result";
|
|
6
7
|
import "./index.less";
|
|
7
8
|
import Page from "./page";
|
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
export default function SinglePage(_ref) {
|
|
10
11
|
var appName = _ref.appName,
|
|
11
|
-
_ref$
|
|
12
|
-
|
|
12
|
+
_ref$menuItems = _ref.menuItems,
|
|
13
|
+
menuItems = _ref$menuItems === void 0 ? [] : _ref$menuItems,
|
|
13
14
|
className = _ref.className;
|
|
14
15
|
var location = useLocation();
|
|
15
16
|
var pathname = location.pathname;
|
|
@@ -17,25 +18,29 @@ export default function SinglePage(_ref) {
|
|
|
17
18
|
|
|
18
19
|
// 当前菜单
|
|
19
20
|
var menuInfo = useMemo(function () {
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return menuUrl.split('?')[0] === pathname;
|
|
24
|
-
}
|
|
25
|
-
return menuUrl === pathname;
|
|
26
|
-
});
|
|
21
|
+
var _menu$btnAuth;
|
|
22
|
+
var menus = findMenusByUrl(menuItems, pathname) || [];
|
|
23
|
+
var menu = menus === null || menus === void 0 ? void 0 : menus.at(-1);
|
|
27
24
|
if (!menu) return undefined;
|
|
28
25
|
|
|
29
26
|
// add document title
|
|
30
27
|
setTimeout(function () {
|
|
31
|
-
document.title = "".concat((menu === null || menu === void 0 ? void 0 : menu.
|
|
28
|
+
document.title = "".concat((menu === null || menu === void 0 ? void 0 : menu.label) || (menu === null || menu === void 0 ? void 0 : menu.url), " - ").concat(appName);
|
|
32
29
|
}, 10);
|
|
33
30
|
return {
|
|
34
|
-
auth: menu.
|
|
35
|
-
|
|
31
|
+
auth: ((_menu$btnAuth = menu.btnAuth) === null || _menu$btnAuth === void 0 ? void 0 : _menu$btnAuth.map(function (b) {
|
|
32
|
+
return b.code;
|
|
33
|
+
})) || [],
|
|
34
|
+
breadcrumb: menus.map(function (m) {
|
|
35
|
+
return {
|
|
36
|
+
key: m.key,
|
|
37
|
+
title: m.label,
|
|
38
|
+
href: m.url
|
|
39
|
+
};
|
|
40
|
+
}),
|
|
36
41
|
menu: menu
|
|
37
42
|
};
|
|
38
|
-
}, [pathname,
|
|
43
|
+
}, [pathname, menuItems]);
|
|
39
44
|
return /*#__PURE__*/_jsx("div", {
|
|
40
45
|
className: classnames(className, "ccs-single-page"),
|
|
41
46
|
children: menuInfo !== null && menuInfo !== void 0 && menuInfo.auth ? /*#__PURE__*/_jsx(Page, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JSXElementConstructor, ReactElement } from 'react';
|
|
2
2
|
import { Location } from 'react-router';
|
|
3
|
-
import {
|
|
4
|
-
export type SinglePageProps = Pick<
|
|
3
|
+
import { CacheComponent } from '../layout-keep-alive';
|
|
4
|
+
export type SinglePageProps = Pick<CacheComponent, 'breadcrumb' | 'urlAuthList'> & {
|
|
5
5
|
/** router location */
|
|
6
6
|
location: Location;
|
|
7
7
|
/** children */
|
package/package.json
CHANGED