@lxzy/code-snippet 0.0.12 → 0.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lxzy/code-snippet",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "files": [
5
5
  "*",
6
6
  "!dist",
package/routes/menu.ts CHANGED
@@ -5,6 +5,12 @@ export default [
5
5
  component: 'home',
6
6
  icon: 'smile',
7
7
  },
8
+ {
9
+ path: '/login',
10
+ name: '登录',
11
+ component: 'login',
12
+ layout: false,
13
+ },
8
14
  {
9
15
  path: '/activityCenter',
10
16
  name: '活动中心',
@@ -1,9 +1,8 @@
1
- import React, { useState, useEffect } from 'react';
2
- import { Avatar, Dropdown, Menu, Space } from 'antd';
3
1
  import ProLayout from '@ant-design/pro-layout';
4
2
  import history from '@/umi';
5
3
  import menuRoutes from '../../routes/menu';
6
4
  import getIcon from '@/utils/getIcon';
5
+ import { useLocation } from 'react-router-dom';
7
6
 
8
7
  const menuDataRender = (menuList) => {
9
8
  return menuList.map((item) => {
@@ -18,18 +17,28 @@ const menuDataRender = (menuList) => {
18
17
 
19
18
  const BasicLayout = (props) => {
20
19
  const { children } = props;
21
- const [location, setLocation] = useState(history.location);
20
+ const location = useLocation();
22
21
 
23
- useEffect(() => {
24
- const unlisten = history.listen((location) => {
25
- setLocation(location);
26
- });
27
- return () => unlisten();
28
- }, []);
22
+ const isLayoutFalse = (routes, pathname) => {
23
+ for (const route of routes) {
24
+ if (pathname === route.path || pathname.startsWith(route.path + '/')) {
25
+ if (route.layout === false) return true;
26
+ }
27
+ if (route.routes) {
28
+ if (isLayoutFalse(route.routes, pathname)) return true;
29
+ }
30
+ }
31
+ return false;
32
+ };
33
+
34
+ if (isLayoutFalse(menuRoutes, location.pathname)) {
35
+ return <>{children}</>;
36
+ }
29
37
 
30
38
  return (
31
39
  <ProLayout
32
40
  title="管理平台"
41
+ // pure
33
42
  logo={false}
34
43
  layout="mix"
35
44
  fixSiderbar={false}
@@ -0,0 +1,5 @@
1
+ import React, { useState } from 'react';
2
+
3
+ export default function Login() {
4
+ return <div>login</div>;
5
+ }