@teamias/pro-layout 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pro-layout/components/AvatarItem.js +8 -8
- package/dist/pro-layout/components/KeepAlive/KeepAliveClass.d.ts +2 -2
- package/dist/pro-layout/components/KeepAlive/index.d.ts +1 -1
- package/dist/pro-layout/core/index.js +4 -0
- package/dist/pro-layout/hooks/index.d.ts +3 -1
- package/dist/pro-layout/hooks/index.js +21 -5
- package/dist/pro-layout/types/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -4,9 +4,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
4
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
5
|
import { LogoutOutlined, UserOutlined } from '@ant-design/icons';
|
|
6
6
|
import { Avatar, Dropdown, Modal } from 'antd';
|
|
7
|
-
import { LOCAL_STORAGE } from "../constant";
|
|
8
7
|
import { useLayoutContext } from "../context";
|
|
9
|
-
import { setLocalStorageItem } from "../utils";
|
|
10
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
10
|
export var AvatarItem = function AvatarItem(_ref) {
|
|
@@ -27,19 +25,21 @@ export var AvatarItem = function AvatarItem(_ref) {
|
|
|
27
25
|
_context.next = 3;
|
|
28
26
|
return onLogout();
|
|
29
27
|
case 3:
|
|
30
|
-
setLocalStorageItem(LOCAL_STORAGE.ACCESS_TOKEN, '');
|
|
28
|
+
// setLocalStorageItem(LOCAL_STORAGE.ACCESS_TOKEN, '');
|
|
29
|
+
localStorage.clear();
|
|
30
|
+
sessionStorage.clear();
|
|
31
31
|
updateData({}, 'replace');
|
|
32
|
-
_context.next =
|
|
32
|
+
_context.next = 11;
|
|
33
33
|
break;
|
|
34
|
-
case
|
|
35
|
-
_context.prev =
|
|
34
|
+
case 8:
|
|
35
|
+
_context.prev = 8;
|
|
36
36
|
_context.t0 = _context["catch"](0);
|
|
37
37
|
console.error(_context.t0);
|
|
38
|
-
case
|
|
38
|
+
case 11:
|
|
39
39
|
case "end":
|
|
40
40
|
return _context.stop();
|
|
41
41
|
}
|
|
42
|
-
}, _callee, null, [[0,
|
|
42
|
+
}, _callee, null, [[0, 8]]);
|
|
43
43
|
}));
|
|
44
44
|
function onOk() {
|
|
45
45
|
return _onOk.apply(this, arguments);
|
|
@@ -17,7 +17,7 @@ export declare class KeepAliveClass {
|
|
|
17
17
|
updateAllComponent(type?: 'all' | 'pagesHook' | 'context'): Promise<void>;
|
|
18
18
|
/** 获取页面数据 */
|
|
19
19
|
getPages(): (import("react-router-dom").Location & {
|
|
20
|
-
pageStatus: 200 |
|
|
20
|
+
pageStatus: 200 | 404 | 403;
|
|
21
21
|
pageTitle: string;
|
|
22
22
|
})[];
|
|
23
23
|
/** 关闭页面 */
|
|
@@ -32,7 +32,7 @@ export declare class KeepAliveClass {
|
|
|
32
32
|
useLifeCycle: (callback: IPageLifeCycleCallback) => void;
|
|
33
33
|
/** 获取缓存页面数组 */
|
|
34
34
|
useKeepAlivePages: () => (import("react-router-dom").Location & {
|
|
35
|
-
pageStatus: 200 |
|
|
35
|
+
pageStatus: 200 | 404 | 403;
|
|
36
36
|
pageTitle: string;
|
|
37
37
|
})[];
|
|
38
38
|
/** 更新当前路由页面 */
|
|
@@ -6,7 +6,7 @@ export declare const keepAliveControl: KeepAliveClass;
|
|
|
6
6
|
export declare const useLifeCycle: (callback: import("./types").IPageLifeCycleCallback) => void;
|
|
7
7
|
/** 获取页面数组 */
|
|
8
8
|
export declare const useKeepAlivePages: () => (import("react-router-dom").Location & {
|
|
9
|
-
pageStatus: 200 |
|
|
9
|
+
pageStatus: 200 | 404 | 403;
|
|
10
10
|
pageTitle: string;
|
|
11
11
|
})[];
|
|
12
12
|
/** 根 */
|
|
@@ -110,6 +110,10 @@ var InlineProLayout = function InlineProLayout(_ref) {
|
|
|
110
110
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
111
111
|
children: [layoutContext.token ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
112
112
|
children: [/*#__PURE__*/_jsx(DocumentTitle, {}), /*#__PURE__*/_jsxs(Layout, {
|
|
113
|
+
style: {
|
|
114
|
+
'--header-height': layoutContext.headerHeight,
|
|
115
|
+
'--content-height': "calc(100vh - ".concat(layoutContext.headerHeight, ")")
|
|
116
|
+
},
|
|
113
117
|
children: [/*#__PURE__*/_jsxs(Header, {
|
|
114
118
|
children: [/*#__PURE__*/_jsxs(HeaderLogo, {
|
|
115
119
|
"data-aside-width": layoutContext.defaultMaxAsideWidth,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
/** 这里初始化获取后,除了initialState 变化,会发生更新,其余的 pathname 不会变化 */
|
|
3
|
-
export declare const useApiRouter: () => import("
|
|
3
|
+
export declare const useApiRouter: () => import("../types").TMenuData | undefined;
|
|
4
4
|
/** 权限router */
|
|
5
5
|
export declare const useAccessRouter: () => {
|
|
6
6
|
page: {
|
|
7
7
|
element?: import("react").ReactNode;
|
|
8
8
|
access?: string | undefined;
|
|
9
|
+
path?: string | undefined;
|
|
10
|
+
name?: string | undefined;
|
|
9
11
|
};
|
|
10
12
|
location: import("react-router-dom").Location & {
|
|
11
13
|
pageStatus: 200 | 404 | 403;
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
+
import { useIntl } from 'react-intl';
|
|
1
2
|
import { matchPath, useLocation } from 'react-router-dom';
|
|
2
3
|
import { NoFoundPage } from "../components/NoFoundPage";
|
|
3
4
|
import { useLayoutContext } from "../context";
|
|
4
|
-
|
|
5
|
-
/** 这里初始化获取后,除了initialState 变化,会发生更新,其余的 pathname 不会变化 */
|
|
6
5
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
var getMenuFormattedTitle = function getMenuFormattedTitle(pageComponentMap, menuKey, defaultName) {
|
|
8
|
+
// 先通过原生的路由配置,找到初始的配置路径
|
|
9
|
+
// 主要针对动态参数的那种 (/product/list/:code)
|
|
10
|
+
|
|
11
|
+
/** 本地配置的页面路由 */
|
|
12
|
+
var localConfigPath = Object.keys(pageComponentMap || {}).find(function (p) {
|
|
13
|
+
return matchPath(p, menuKey);
|
|
14
|
+
}) || menuKey;
|
|
15
|
+
return {
|
|
16
|
+
id: "menu".concat(localConfigPath.replaceAll('/', '.')),
|
|
17
|
+
defaultMessage: defaultName || '',
|
|
18
|
+
localConfigPath: localConfigPath
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** 这里初始化获取后,除了initialState 变化,会发生更新,其余的 pathname 不会变化 */
|
|
8
23
|
export var useApiRouter = function useApiRouter() {
|
|
9
24
|
var _layoutContext$routeM;
|
|
10
25
|
var location = useLocation();
|
|
@@ -16,11 +31,13 @@ export var useApiRouter = function useApiRouter() {
|
|
|
16
31
|
|
|
17
32
|
/** 权限router */
|
|
18
33
|
export var useAccessRouter = function useAccessRouter() {
|
|
19
|
-
var _layoutContext$routeM2, _fullPathDataMap
|
|
34
|
+
var _layoutContext$routeM2, _fullPathDataMap, _currentPage;
|
|
20
35
|
var layoutContext = useLayoutContext();
|
|
21
36
|
var location = useLocation();
|
|
22
37
|
var fullPathDataMap = ((_layoutContext$routeM2 = layoutContext.routeMenu) === null || _layoutContext$routeM2 === void 0 ? void 0 : _layoutContext$routeM2.fullPathDataMap) || {};
|
|
23
38
|
var pageComponentMap = layoutContext.pageComponentMap || {};
|
|
39
|
+
var _useIntl = useIntl(),
|
|
40
|
+
formatMessage = _useIntl.formatMessage;
|
|
24
41
|
var access = layoutContext.access;
|
|
25
42
|
|
|
26
43
|
/** 匹配路径对应组件 */
|
|
@@ -30,7 +47,7 @@ export var useAccessRouter = function useAccessRouter() {
|
|
|
30
47
|
|
|
31
48
|
// 补充数据
|
|
32
49
|
location.pageStatus = 200;
|
|
33
|
-
location.pageTitle = ((_fullPathDataMap
|
|
50
|
+
location.pageTitle = ((_fullPathDataMap = fullPathDataMap[((_currentPage = currentPage) === null || _currentPage === void 0 ? void 0 : _currentPage.path) || location.pathname]) === null || _fullPathDataMap === void 0 || (_fullPathDataMap = _fullPathDataMap.raw) === null || _fullPathDataMap === void 0 ? void 0 : _fullPathDataMap.title) || formatMessage(getMenuFormattedTitle(pageComponentMap, location.pathname, '未知页面'));
|
|
34
51
|
|
|
35
52
|
// 路由不存在, 但有菜单, 使用默认页面
|
|
36
53
|
if (!currentPage && fullPathDataMap[location.pathname]) {
|
|
@@ -40,7 +57,6 @@ export var useAccessRouter = function useAccessRouter() {
|
|
|
40
57
|
children: "\u8BF7\u521B\u5EFA\u8DEF\u7531\u5BF9\u5E94\u7684\u7EC4\u4EF6"
|
|
41
58
|
})
|
|
42
59
|
};
|
|
43
|
-
// currentPage = { element: <>低代码页面</> };
|
|
44
60
|
}
|
|
45
61
|
|
|
46
62
|
// 判断页面是否需要权限判断
|