@teamias/pro-layout 0.0.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.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +1 -0
  5. package/dist/markdowns/example1/BasicRexProLayout/index.d.ts +3 -0
  6. package/dist/markdowns/example1/BasicRexProLayout/index.js +83 -0
  7. package/dist/markdowns/example1/BasicRexProLayout/pages/Home.d.ts +1 -0
  8. package/dist/markdowns/example1/BasicRexProLayout/pages/Home.js +21 -0
  9. package/dist/markdowns/example1/BasicRexProLayout/pages/Level1.d.ts +1 -0
  10. package/dist/markdowns/example1/BasicRexProLayout/pages/Level1.js +21 -0
  11. package/dist/markdowns/example1/BasicRexProLayout/pages/Level2.d.ts +1 -0
  12. package/dist/markdowns/example1/BasicRexProLayout/pages/Level2.js +21 -0
  13. package/dist/markdowns/example1/BasicRexProLayout/testData.d.ts +53 -0
  14. package/dist/markdowns/example1/BasicRexProLayout/testData.js +82 -0
  15. package/dist/pro-layout/assets/login-bg.png +0 -0
  16. package/dist/pro-layout/assets/logo.png +0 -0
  17. package/dist/pro-layout/components/AvatarItem.d.ts +3 -0
  18. package/dist/pro-layout/components/AvatarItem.js +93 -0
  19. package/dist/pro-layout/components/Collapsed.d.ts +5 -0
  20. package/dist/pro-layout/components/Collapsed.js +23 -0
  21. package/dist/pro-layout/components/DocumentTitle.d.ts +4 -0
  22. package/dist/pro-layout/components/DocumentTitle.js +24 -0
  23. package/dist/pro-layout/components/KeepAlive/KeepAliveClass.d.ts +44 -0
  24. package/dist/pro-layout/components/KeepAlive/KeepAliveClass.js +448 -0
  25. package/dist/pro-layout/components/KeepAlive/index.d.ts +13 -0
  26. package/dist/pro-layout/components/KeepAlive/index.js +17 -0
  27. package/dist/pro-layout/components/KeepAlive/modules/useCacheTabsLayout.d.ts +26 -0
  28. package/dist/pro-layout/components/KeepAlive/modules/useCacheTabsLayout.js +75 -0
  29. package/dist/pro-layout/components/KeepAlive/types.d.ts +25 -0
  30. package/dist/pro-layout/components/KeepAlive/types.js +9 -0
  31. package/dist/pro-layout/components/Login/Account.d.ts +1 -0
  32. package/dist/pro-layout/components/Login/Account.js +41 -0
  33. package/dist/pro-layout/components/Login/index.d.ts +3 -0
  34. package/dist/pro-layout/components/Login/index.js +127 -0
  35. package/dist/pro-layout/components/Login/style.d.ts +2 -0
  36. package/dist/pro-layout/components/Login/style.js +5 -0
  37. package/dist/pro-layout/components/Menu/index.d.ts +8 -0
  38. package/dist/pro-layout/components/Menu/index.js +142 -0
  39. package/dist/pro-layout/components/Menu/style.d.ts +7 -0
  40. package/dist/pro-layout/components/Menu/style.js +19 -0
  41. package/dist/pro-layout/components/NoFoundPage/index.d.ts +4 -0
  42. package/dist/pro-layout/components/NoFoundPage/index.js +45 -0
  43. package/dist/pro-layout/components/PageLoading.d.ts +2 -0
  44. package/dist/pro-layout/components/PageLoading.js +14 -0
  45. package/dist/pro-layout/components/SystemId.d.ts +3 -0
  46. package/dist/pro-layout/components/SystemId.js +17 -0
  47. package/dist/pro-layout/components/TabsLayout/index.d.ts +2 -0
  48. package/dist/pro-layout/components/TabsLayout/index.js +193 -0
  49. package/dist/pro-layout/constant/index.d.ts +20 -0
  50. package/dist/pro-layout/constant/index.js +19 -0
  51. package/dist/pro-layout/context/index.d.ts +6 -0
  52. package/dist/pro-layout/context/index.js +84 -0
  53. package/dist/pro-layout/core/index.d.ts +4 -0
  54. package/dist/pro-layout/core/index.js +222 -0
  55. package/dist/pro-layout/hooks/index.d.ts +14 -0
  56. package/dist/pro-layout/hooks/index.js +65 -0
  57. package/dist/pro-layout/index.d.ts +4 -0
  58. package/dist/pro-layout/index.js +4 -0
  59. package/dist/pro-layout/style/index.d.ts +27 -0
  60. package/dist/pro-layout/style/index.js +57 -0
  61. package/dist/pro-layout/types/index.d.ts +154 -0
  62. package/dist/pro-layout/types/index.js +1 -0
  63. package/dist/pro-layout/utils/index.d.ts +25 -0
  64. package/dist/pro-layout/utils/index.js +63 -0
  65. package/dist/pro-layout/utils/menu.d.ts +15 -0
  66. package/dist/pro-layout/utils/menu.js +122 -0
  67. package/dist/types/svg.d.ts +24 -0
  68. package/package.json +108 -0
@@ -0,0 +1,193 @@
1
+ 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); }
2
+ 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; }
3
+ 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); } }
4
+ 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
+ /*
6
+ * @Description: 自定义多标签页
7
+ * @Version: 2.0
8
+ */
9
+ import { Icons, useStateData } from '@teamias/rex-design';
10
+ import { Badge, Dropdown, Space, Tabs, message } from 'antd';
11
+ import { eq } from 'lodash-es';
12
+ import { useEffect } from 'react';
13
+ import { useLocation, useNavigate } from 'react-router-dom';
14
+ import { TABS_LAYOUT } from "../../constant";
15
+ import { useLayoutContext } from "../../context";
16
+ import { keepAliveControl, useKeepAlivePages } from "../KeepAlive";
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ import { jsxs as _jsxs } from "react/jsx-runtime";
19
+ export var TabsLayout = function TabsLayout() {
20
+ // hooks 调用
21
+ var _useLocation = useLocation(),
22
+ pathname = _useLocation.pathname;
23
+ var navigate = useNavigate();
24
+ var layoutContext = useLayoutContext();
25
+ /** 获取当前所有 Tab 标签页的路由 */
26
+ var pathNameList = useKeepAlivePages();
27
+ var _useStateData = useStateData(function () {
28
+ return {
29
+ activeKey: ''
30
+ };
31
+ }),
32
+ state = _useStateData.state,
33
+ update = _useStateData.update;
34
+ var linkPage = function linkPage(to) {
35
+ if (typeof to === 'string') {
36
+ var _pathNameList$find;
37
+ var search = (_pathNameList$find = pathNameList.find(function (ii) {
38
+ return ii.pathname === to;
39
+ })) === null || _pathNameList$find === void 0 ? void 0 : _pathNameList$find.search;
40
+ navigate("".concat(to).concat(search));
41
+ } else {
42
+ navigate(to);
43
+ }
44
+ };
45
+
46
+ /**
47
+ * @description: 点击菜单回调
48
+ */
49
+ var handleClickMenu = /*#__PURE__*/function () {
50
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, pathname) {
51
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
52
+ while (1) switch (_context.prev = _context.next) {
53
+ case 0:
54
+ _context.t0 = key;
55
+ _context.next = _context.t0 === TABS_LAYOUT.REFRESH ? 3 : _context.t0 === TABS_LAYOUT.OTHERS ? 9 : 14;
56
+ break;
57
+ case 3:
58
+ linkPage(pathname);
59
+ _context.next = 6;
60
+ return update();
61
+ case 6:
62
+ _context.next = 8;
63
+ return keepAliveControl.refreshPage(pathname);
64
+ case 8:
65
+ return _context.abrupt("break", 14);
66
+ case 9:
67
+ linkPage(pathname);
68
+ _context.next = 12;
69
+ return update();
70
+ case 12:
71
+ keepAliveControl.closeOtherPage(false, [pathname]);
72
+ return _context.abrupt("break", 14);
73
+ case 14:
74
+ case "end":
75
+ return _context.stop();
76
+ }
77
+ }, _callee);
78
+ }));
79
+ return function handleClickMenu(_x, _x2) {
80
+ return _ref.apply(this, arguments);
81
+ };
82
+ }();
83
+
84
+ /**
85
+ * @description: 右键菜单配置项
86
+ */
87
+ var renderMenuItem = function renderMenuItem(key, label, icon) {
88
+ return {
89
+ label: label,
90
+ icon: /*#__PURE__*/_jsx(Icons, {
91
+ type: "iconify",
92
+ name: icon,
93
+ size: 16
94
+ }),
95
+ key: key
96
+ };
97
+ };
98
+
99
+ // console.log(page);
100
+
101
+ useEffect(function () {
102
+ state.activeKey = pathname;
103
+ update();
104
+ }, [pathname]);
105
+ return /*#__PURE__*/_jsx(Tabs, {
106
+ hideAdd: true,
107
+ onChange: linkPage,
108
+ activeKey: state.activeKey,
109
+ type: "editable-card",
110
+ onEdit: ( /*#__PURE__*/function () {
111
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(targetKey) {
112
+ var oldIndex, _pathNameList$oldInde;
113
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
114
+ while (1) switch (_context2.prev = _context2.next) {
115
+ case 0:
116
+ if (!(pathNameList.length <= 1)) {
117
+ _context2.next = 3;
118
+ break;
119
+ }
120
+ message.info('至少要保留一个窗口');
121
+ return _context2.abrupt("return");
122
+ case 3:
123
+ // 获取关闭 tab 的索引
124
+ oldIndex = pathNameList.findIndex(function (ii) {
125
+ return ii.pathname === targetKey;
126
+ }); // 清空当前页面的状态
127
+ if (typeof targetKey === 'string') {
128
+ // console.log(targetKey);
129
+ keepAliveControl.closePage(targetKey);
130
+ }
131
+
132
+ // await update();
133
+
134
+ // 获取当前 tab 的索引为 -1 时候,页面说明不存在,需要跳转页面
135
+ if (pathNameList.findIndex(function (ii) {
136
+ return ii.pathname === pathname;
137
+ }) === -1) {
138
+ // 关闭后,判断当前位置页面是否存在,有就用当前位置页面显示,没有就后退一位
139
+ linkPage((_pathNameList$oldInde = pathNameList[oldIndex]) !== null && _pathNameList$oldInde !== void 0 ? _pathNameList$oldInde : pathNameList[Math.max(oldIndex - 1, 0)]);
140
+ }
141
+ case 6:
142
+ case "end":
143
+ return _context2.stop();
144
+ }
145
+ }, _callee2);
146
+ }));
147
+ return function (_x3) {
148
+ return _ref2.apply(this, arguments);
149
+ };
150
+ }()),
151
+ items: pathNameList.map(function (_ref3) {
152
+ var _layoutContext$routeM;
153
+ var pathname = _ref3.pathname;
154
+ // 判断是否当前活跃标签
155
+ var isCurrent = eq(state.activeKey, pathname);
156
+ var menuRawItem = (_layoutContext$routeM = layoutContext.routeMenu) === null || _layoutContext$routeM === void 0 || (_layoutContext$routeM = _layoutContext$routeM.fullPathDataMap[pathname]) === null || _layoutContext$routeM === void 0 ? void 0 : _layoutContext$routeM.raw;
157
+
158
+ // 只有当前活跃的标签页才能操作
159
+ var dom = /*#__PURE__*/_jsxs(Space, {
160
+ size: 5,
161
+ children: [isCurrent && /*#__PURE__*/_jsx(Badge, {
162
+ status: "processing"
163
+ }), menuRawItem === null || menuRawItem === void 0 ? void 0 : menuRawItem.title]
164
+ });
165
+ return {
166
+ key: pathname,
167
+ label: /*#__PURE__*/_jsx(Dropdown, {
168
+ menu: {
169
+ items: [
170
+ // 重新加载
171
+ renderMenuItem(TABS_LAYOUT.REFRESH, '重新加载', 'ri:refresh-line'), {
172
+ type: 'divider'
173
+ },
174
+ // 关闭右侧
175
+ // renderMenuItem(TABS_LAYOUT.RIGHT, 'ri:skip-right-line'),
176
+ // 关闭左侧
177
+ // renderMenuItem(TABS_LAYOUT.LEFT, 'ri:skip-left-line'),
178
+ // {type: 'divider'},
179
+ // 关闭其它
180
+ renderMenuItem(TABS_LAYOUT.OTHERS, '关闭其它', 'ri:arrow-left-right-line')],
181
+ onClick: function onClick(_ref4) {
182
+ var key = _ref4.key;
183
+ return handleClickMenu(key, pathname);
184
+ }
185
+ },
186
+ trigger: ['contextMenu'],
187
+ children: dom
188
+ })
189
+ };
190
+ }),
191
+ size: "small"
192
+ });
193
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @description: 存储在 localstorage 的 key
3
+ */
4
+ export declare enum LOCAL_STORAGE {
5
+ /** ACCESS_TOKEN */
6
+ ACCESS_TOKEN = "ACCESS_TOKEN",
7
+ /** 折叠状态 */
8
+ COLLAPSED = "COLLAPSED",
9
+ /** 低代码组件工具存储key */
10
+ /** 缓存用户tabs 数据 */
11
+ TABS_LAYOUT = "TABS_LAYOUT"
12
+ }
13
+ /**
14
+ * @description: TabsLayout 多标签类型
15
+ */
16
+ export declare enum TABS_LAYOUT {
17
+ CLOSE = "close",// 关闭当前
18
+ REFRESH = "refresh",// 重新加载
19
+ OTHERS = "others"
20
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @description: 存储在 localstorage 的 key
3
+ */
4
+ export var LOCAL_STORAGE = /*#__PURE__*/function (LOCAL_STORAGE) {
5
+ LOCAL_STORAGE["ACCESS_TOKEN"] = "ACCESS_TOKEN";
6
+ LOCAL_STORAGE["COLLAPSED"] = "COLLAPSED";
7
+ LOCAL_STORAGE["TABS_LAYOUT"] = "TABS_LAYOUT";
8
+ return LOCAL_STORAGE;
9
+ }({});
10
+
11
+ /**
12
+ * @description: TabsLayout 多标签类型
13
+ */
14
+ export var TABS_LAYOUT = /*#__PURE__*/function (TABS_LAYOUT) {
15
+ TABS_LAYOUT["CLOSE"] = "close";
16
+ TABS_LAYOUT["REFRESH"] = "refresh";
17
+ TABS_LAYOUT["OTHERS"] = "others";
18
+ return TABS_LAYOUT;
19
+ }({}); // 关闭其它
@@ -0,0 +1,6 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { TLayoutContext } from '../types';
3
+ export declare const LayoutContextProvide: FC<Omit<TLayoutContext, 'updateData'> & {
4
+ children: ReactNode;
5
+ }>;
6
+ export declare const useLayoutContext: () => TLayoutContext;
@@ -0,0 +1,84 @@
1
+ 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); }
2
+ var _excluded = ["children"];
3
+ 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; }
4
+ 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); } }
5
+ 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); }); }; }
6
+ 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; }
7
+ 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; }
8
+ 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; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
+ 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); }
11
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
12
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
13
+ import { useStateData } from '@teamias/rex-design';
14
+ import { createContext, useContext } from 'react';
15
+ import { LOCAL_STORAGE } from "../constant";
16
+ import { getLocalStorageItem } from "../utils";
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ var LayoutContext = /*#__PURE__*/createContext(null);
19
+ export var LayoutContextProvide = function LayoutContextProvide(_ref) {
20
+ var children = _ref.children,
21
+ otherValue = _objectWithoutProperties(_ref, _excluded);
22
+ var _useStateData = useStateData(function () {
23
+ return {
24
+ value: _objectSpread({}, otherValue)
25
+ };
26
+ }),
27
+ state = _useStateData.state,
28
+ update = _useStateData.update;
29
+
30
+ /** 有部分保护字段 */
31
+ var getRetainField = function getRetainField() {
32
+ /** 几个 ui 相关字段 */
33
+ var keys = ['collapsed', 'asideWidth'];
34
+ var retainField = {};
35
+ keys.forEach(function (key) {
36
+ if (state.value[key] !== undefined) {
37
+ retainField[key] = state.value[key];
38
+ }
39
+ });
40
+ return Object.assign({}, otherValue, retainField);
41
+ };
42
+ return /*#__PURE__*/_jsx(LayoutContext.Provider, {
43
+ value: _objectSpread(_objectSpread({}, state.value), {}, {
44
+ token: getLocalStorageItem(LOCAL_STORAGE.ACCESS_TOKEN) || '',
45
+ updateData: function () {
46
+ var _updateData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {
47
+ var cover,
48
+ _args = arguments;
49
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
50
+ while (1) switch (_context.prev = _context.next) {
51
+ case 0:
52
+ cover = _args.length > 1 && _args[1] !== undefined ? _args[1] : 'merge';
53
+ if (cover === 'merge') {
54
+ Object.assign(state.value, data);
55
+ } else {
56
+ state.value = data;
57
+ }
58
+
59
+ // 有部分保护字段
60
+ Object.assign(state.value, getRetainField());
61
+ _context.next = 5;
62
+ return update();
63
+ case 5:
64
+ case "end":
65
+ return _context.stop();
66
+ }
67
+ }, _callee);
68
+ }));
69
+ function updateData(_x) {
70
+ return _updateData.apply(this, arguments);
71
+ }
72
+ return updateData;
73
+ }()
74
+ }),
75
+ children: children
76
+ });
77
+ };
78
+ export var useLayoutContext = function useLayoutContext() {
79
+ var context = useContext(LayoutContext);
80
+ if (!context) {
81
+ throw new Error('useLayoutContext must be used within a LayoutProvider');
82
+ }
83
+ return context;
84
+ };
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { IProLayoutProps } from '../types';
3
+ export declare const ProLayout: FC<IProLayoutProps>;
4
+ export declare const ProLayoutMemo: import("react").NamedExoticComponent<IProLayoutProps>;
@@ -0,0 +1,222 @@
1
+ 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); }
2
+ 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; }
3
+ 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); } }
4
+ 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
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+ 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."); }
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
+ 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; }
9
+ 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; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ import { useDebounceEffect } from 'ahooks';
12
+ import { memo, useMemo, useState } from 'react';
13
+ import loginBgPng from "../assets/login-bg.png";
14
+ import logoPng from "../assets/logo.png";
15
+ import { AvatarItem } from "../components/AvatarItem";
16
+ import { Collapsed } from "../components/Collapsed";
17
+ import { DocumentTitle } from "../components/DocumentTitle";
18
+ import { KeepAliveRoot } from "../components/KeepAlive";
19
+ import { Login } from "../components/Login";
20
+ import { Menu } from "../components/Menu";
21
+ import { PageLoading } from "../components/PageLoading";
22
+ import { SystemId } from "../components/SystemId";
23
+ import { TabsLayout } from "../components/TabsLayout";
24
+ import { LOCAL_STORAGE } from "../constant";
25
+ import { LayoutContextProvide, useLayoutContext } from "../context";
26
+ import { Aside, ContentBox, Header, HeaderLogo, Layout, Main, TopBox, TopHoverBox } from "../style";
27
+ import { getLocalStorageItem, setLocalStorageItem } from "../utils";
28
+ import { handleMenuData } from "../utils/menu";
29
+ import { jsx as _jsx } from "react/jsx-runtime";
30
+ import { jsxs as _jsxs } from "react/jsx-runtime";
31
+ import { Fragment as _Fragment } from "react/jsx-runtime";
32
+ var InlineProLayout = function InlineProLayout(_ref) {
33
+ var smallLogoImg = _ref.smallLogoImg,
34
+ childrens = _ref.childrens,
35
+ projectTitle = _ref.projectTitle,
36
+ loginBgImg = _ref.loginBgImg,
37
+ requestUserInfoMenuData = _ref.requestUserInfoMenuData,
38
+ renderSelectLang = _ref.renderSelectLang,
39
+ onLogin = _ref.onLogin,
40
+ onLogout = _ref.onLogout;
41
+ var layoutContext = useLayoutContext();
42
+ var _useState = useState(true),
43
+ _useState2 = _slicedToArray(_useState, 2),
44
+ pageLoading = _useState2[0],
45
+ setPageLoading = _useState2[1];
46
+ var getData = /*#__PURE__*/function () {
47
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
48
+ var res;
49
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
50
+ while (1) switch (_context.prev = _context.next) {
51
+ case 0:
52
+ _context.prev = 0;
53
+ _context.next = 3;
54
+ return requestUserInfoMenuData();
55
+ case 3:
56
+ res = _context.sent;
57
+ _context.next = 6;
58
+ return layoutContext.updateData({
59
+ userInfo: res.userInfo,
60
+ routeMenu: handleMenuData(res.menuData)
61
+ });
62
+ case 6:
63
+ _context.next = 11;
64
+ break;
65
+ case 8:
66
+ _context.prev = 8;
67
+ _context.t0 = _context["catch"](0);
68
+ console.error('获取用户信息失败', _context.t0);
69
+ case 11:
70
+ case "end":
71
+ return _context.stop();
72
+ }
73
+ }, _callee, null, [[0, 8]]);
74
+ }));
75
+ return function getData() {
76
+ return _ref2.apply(this, arguments);
77
+ };
78
+ }();
79
+ useDebounceEffect(function () {
80
+ _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
81
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
82
+ while (1) switch (_context2.prev = _context2.next) {
83
+ case 0:
84
+ if (layoutContext.token) {
85
+ _context2.next = 3;
86
+ break;
87
+ }
88
+ setPageLoading(false);
89
+ return _context2.abrupt("return");
90
+ case 3:
91
+ setPageLoading(true);
92
+ _context2.next = 6;
93
+ return getData();
94
+ case 6:
95
+ // await sleep(100);
96
+ setPageLoading(false);
97
+ case 7:
98
+ case "end":
99
+ return _context2.stop();
100
+ }
101
+ }, _callee2);
102
+ }))();
103
+ }, [layoutContext.token], {
104
+ wait: 0
105
+ });
106
+ if (pageLoading) return /*#__PURE__*/_jsx(PageLoading, {});
107
+ return /*#__PURE__*/_jsxs(_Fragment, {
108
+ children: [layoutContext.token ? /*#__PURE__*/_jsxs(_Fragment, {
109
+ children: [/*#__PURE__*/_jsx(DocumentTitle, {}), /*#__PURE__*/_jsxs(Layout, {
110
+ children: [/*#__PURE__*/_jsxs(Header, {
111
+ children: [/*#__PURE__*/_jsxs(HeaderLogo, {
112
+ "data-aside-width": layoutContext.defaultMaxAsideWidth,
113
+ style: {
114
+ height: layoutContext.headerHeight
115
+ },
116
+ children: [/*#__PURE__*/_jsx(SystemId, {
117
+ smallLogoImg: smallLogoImg,
118
+ projectTitle: projectTitle
119
+ }), /*#__PURE__*/_jsx(Collapsed, {
120
+ value: layoutContext.collapsed,
121
+ onChange: function onChange() {
122
+ var val = !layoutContext.collapsed;
123
+ layoutContext.updateData({
124
+ collapsed: val,
125
+ asideWidth: val ? layoutContext.defaultMinAsideWidth : layoutContext.defaultMaxAsideWidth
126
+ });
127
+ setLocalStorageItem(LOCAL_STORAGE.COLLAPSED, val);
128
+ }
129
+ })]
130
+ }), /*#__PURE__*/_jsxs(TopBox, {
131
+ style: {
132
+ height: layoutContext.headerHeight
133
+ },
134
+ children: [/*#__PURE__*/_jsx(TabsLayout, {}), /*#__PURE__*/_jsx(TopHoverBox, {
135
+ children: /*#__PURE__*/_jsx(AvatarItem, {
136
+ onLogout: onLogout
137
+ })
138
+ }), renderSelectLang && /*#__PURE__*/_jsx(TopHoverBox, {
139
+ "data-lang": true,
140
+ children: renderSelectLang()
141
+ })]
142
+ })]
143
+ }), /*#__PURE__*/_jsxs(Main, {
144
+ children: [/*#__PURE__*/_jsx(Aside, {
145
+ children: /*#__PURE__*/_jsx(Menu, {
146
+ height: "calc(100vh - ".concat(layoutContext.headerHeight, ")"),
147
+ asideWidth: layoutContext.asideWidth,
148
+ minAsideWidth: layoutContext.defaultMinAsideWidth,
149
+ collapsed: layoutContext.collapsed
150
+ })
151
+ }), /*#__PURE__*/_jsx(ContentBox, {
152
+ style: {
153
+ height: "calc(100vh - ".concat(layoutContext.headerHeight, ")")
154
+ },
155
+ children: /*#__PURE__*/_jsx(KeepAliveRoot, {})
156
+ })]
157
+ })]
158
+ }), childrens === null || childrens === void 0 ? void 0 : childrens.loggedIn]
159
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
160
+ children: [/*#__PURE__*/_jsx(DocumentTitle, {
161
+ title: "\u767B\u5F55\u9875"
162
+ }), /*#__PURE__*/_jsx(Login, {
163
+ onLogin: onLogin,
164
+ projectTitle: projectTitle,
165
+ loginBgImg: loginBgImg,
166
+ smallLogoImg: smallLogoImg,
167
+ renderSelectLang: renderSelectLang
168
+ }), childrens === null || childrens === void 0 ? void 0 : childrens.unLoggedIn]
169
+ }), childrens === null || childrens === void 0 ? void 0 : childrens.common]
170
+ });
171
+ };
172
+ export var ProLayout = function ProLayout(_ref4) {
173
+ var _ref4$projectTitle = _ref4.projectTitle,
174
+ projectTitle = _ref4$projectTitle === void 0 ? ' Pro' : _ref4$projectTitle,
175
+ _ref4$defaultMaxAside = _ref4.defaultMaxAsideWidth,
176
+ defaultMaxAsideWidth = _ref4$defaultMaxAside === void 0 ? '260px' : _ref4$defaultMaxAside,
177
+ _ref4$defaultMinAside = _ref4.defaultMinAsideWidth,
178
+ defaultMinAsideWidth = _ref4$defaultMinAside === void 0 ? '40px' : _ref4$defaultMinAside,
179
+ _ref4$defaultHeaderHe = _ref4.defaultHeaderHeight,
180
+ defaultHeaderHeight = _ref4$defaultHeaderHe === void 0 ? '40px' : _ref4$defaultHeaderHe,
181
+ _ref4$defaultCollapse = _ref4.defaultCollapsed,
182
+ defaultCollapsed = _ref4$defaultCollapse === void 0 ? false : _ref4$defaultCollapse,
183
+ _ref4$smallLogoImg = _ref4.smallLogoImg,
184
+ smallLogoImg = _ref4$smallLogoImg === void 0 ? logoPng : _ref4$smallLogoImg,
185
+ _ref4$loginBgImg = _ref4.loginBgImg,
186
+ loginBgImg = _ref4$loginBgImg === void 0 ? loginBgPng : _ref4$loginBgImg,
187
+ _ref4$basename = _ref4.basename,
188
+ basename = _ref4$basename === void 0 ? '/' : _ref4$basename,
189
+ projectId = _ref4.projectId,
190
+ childrens = _ref4.childrens,
191
+ pageComponentMap = _ref4.pageComponentMap,
192
+ access = _ref4.access,
193
+ requestUserInfoMenuData = _ref4.requestUserInfoMenuData,
194
+ renderSelectLang = _ref4.renderSelectLang,
195
+ onLogin = _ref4.onLogin,
196
+ onLogout = _ref4.onLogout;
197
+ return useMemo(function () {
198
+ var collapsed = !!getLocalStorageItem(LOCAL_STORAGE.COLLAPSED, defaultCollapsed);
199
+ return /*#__PURE__*/_jsx(LayoutContextProvide, {
200
+ projectId: projectId,
201
+ headerHeight: defaultHeaderHeight,
202
+ asideWidth: collapsed ? defaultMinAsideWidth : defaultMaxAsideWidth,
203
+ defaultMaxAsideWidth: defaultMaxAsideWidth,
204
+ defaultMinAsideWidth: defaultMinAsideWidth,
205
+ pageComponentMap: pageComponentMap,
206
+ collapsed: collapsed,
207
+ access: access,
208
+ basename: basename,
209
+ children: /*#__PURE__*/_jsx(InlineProLayout, {
210
+ renderSelectLang: renderSelectLang,
211
+ projectTitle: projectTitle,
212
+ smallLogoImg: smallLogoImg,
213
+ loginBgImg: loginBgImg,
214
+ requestUserInfoMenuData: requestUserInfoMenuData,
215
+ childrens: childrens,
216
+ onLogin: onLogin,
217
+ onLogout: onLogout
218
+ })
219
+ });
220
+ }, []);
221
+ };
222
+ export var ProLayoutMemo = /*#__PURE__*/memo(ProLayout);
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ /** 这里初始化获取后,除了initialState 变化,会发生更新,其余的 pathname 不会变化 */
3
+ export declare const useApiRouter: () => import("..").TMenuData | undefined;
4
+ /** 权限router */
5
+ export declare const useAccessRouter: () => {
6
+ page: {
7
+ element?: import("react").ReactNode;
8
+ access?: string | undefined;
9
+ };
10
+ location: import("react-router-dom").Location & {
11
+ pageStatus: 200 | 404 | 403;
12
+ pageTitle: string;
13
+ };
14
+ };