listpage_cli 0.0.226 → 0.0.228

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": "listpage_cli",
3
- "version": "0.0.226",
3
+ "version": "0.0.228",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "listpage_cli": "bin/cli.js"
@@ -23,7 +23,7 @@
23
23
  "class-transformer": "^0.5.1",
24
24
  "class-validator": "~0.14.2",
25
25
  "rxjs": "^7.8.1",
26
- "listpage-next-nest": "~0.0.226"
26
+ "listpage-next-nest": "~0.0.228"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@nestjs/schematics": "^11.0.0",
@@ -12,7 +12,7 @@
12
12
  "dependencies": {
13
13
  "react": "^19.2.0",
14
14
  "react-dom": "^19.2.0",
15
- "listpage-next": "~0.0.226",
15
+ "listpage-next": "~0.0.228",
16
16
  "react-router-dom": ">=6.0.0",
17
17
  "@ant-design/v5-patch-for-react-19": "~1.0.3",
18
18
  "ahooks": "^3.9.5",
@@ -1,5 +1,5 @@
1
1
  import { RouterProvider } from 'react-router-dom';
2
- import router from './router';
2
+ import { router } from './router';
3
3
  import './App.css';
4
4
 
5
5
  const App = () => {
@@ -0,0 +1,28 @@
1
+ import { Menu, PageLayout } from 'listpage-next';
2
+ import React, { useMemo } from 'react';
3
+ import { Outlet, useNavigate } from 'react-router-dom';
4
+ import { OpenAIOutlined } from '@ant-design/icons';
5
+
6
+ import { getDefaultMenu, menus } from './menus';
7
+
8
+ export const Layout: React.FC = () => {
9
+ const navigate = useNavigate();
10
+ const defaultActiveKey = useMemo(getDefaultMenu, [location.pathname]);
11
+
12
+ return (
13
+ <PageLayout
14
+ logo={{
15
+ icon: <OpenAIOutlined />,
16
+ title: 'AI中心',
17
+ }}
18
+ sider={
19
+ <Menu
20
+ menus={menus}
21
+ defaultActiveKey={defaultActiveKey}
22
+ onSelect={(path) => navigate(path)}
23
+ />
24
+ }
25
+ content={<Outlet />}
26
+ />
27
+ );
28
+ };
@@ -1,5 +1,7 @@
1
1
  import { createBrowserRouter } from 'react-router-dom';
2
- import Layout from '../Layout';
2
+ import { Layout } from './Layout';
3
+
4
+ export const basename = '__APP_NAME__';
3
5
 
4
6
  export const router = createBrowserRouter([
5
7
  {
@@ -8,7 +10,5 @@ export const router = createBrowserRouter([
8
10
  children: [],
9
11
  },
10
12
  ], {
11
- basename: '__APP_NAME__',
12
- });
13
-
14
- export default router;
13
+ basename,
14
+ });
@@ -0,0 +1,21 @@
1
+ import { MenuItem, detectActiveMenu } from 'listpage-next';
2
+ import { basename } from '.';
3
+
4
+ export const menus: MenuItem[] = [
5
+ {
6
+ key: 'menu1',
7
+ label: '菜单一',
8
+ },
9
+ {
10
+ key: 'menu2',
11
+ label: '菜单二',
12
+ },
13
+ ];
14
+
15
+ export const getDefaultMenu = () => {
16
+ let pathname = window.location.pathname;
17
+ if (pathname.startsWith(`/${basename}`)) {
18
+ pathname = pathname.slice(basename.length + 2);
19
+ }
20
+ return detectActiveMenu(pathname, menus);
21
+ };
@@ -9,7 +9,7 @@
9
9
  "publish": "ts-node src/publish.ts"
10
10
  },
11
11
  "dependencies": {
12
- "listpage-next-deploy": "0.0.226"
12
+ "listpage-next-deploy": "0.0.228"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@types/node": "^20.0.0",
@@ -1,21 +0,0 @@
1
- import { Menu, PageLayout } from 'listpage-next';
2
- import React from 'react';
3
- import { Outlet } from 'react-router-dom';
4
- import { OpenAIOutlined } from '@ant-design/icons';
5
-
6
- import { menus } from './router/menus';
7
-
8
- const Layout: React.FC = () => {
9
- return (
10
- <PageLayout
11
- logo={{
12
- icon: <OpenAIOutlined />,
13
- title: 'AI中心',
14
- }}
15
- sider={<Menu menus={menus} />}
16
- content={<Outlet />}
17
- />
18
- );
19
- };
20
-
21
- export default Layout;
@@ -1,12 +0,0 @@
1
- import { MenuItem } from 'listpage-next';
2
-
3
- export const menus: MenuItem[] = [
4
- {
5
- key: 'menu1',
6
- label: '菜单一',
7
- },
8
- {
9
- key: 'menu2',
10
- label: '菜单二',
11
- },
12
- ];