react-toolkits 0.0.7 → 0.1.0

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 (39) hide show
  1. package/.turbo/turbo-build.log +8 -6
  2. package/CHANGELOG.md +12 -0
  3. package/README.md +41 -0
  4. package/dist/index.css +252 -1
  5. package/dist/index.css.map +1 -0
  6. package/dist/index.d.mts +55 -54
  7. package/dist/index.esm.js +3576 -15
  8. package/dist/index.esm.js.map +1 -0
  9. package/package.json +2 -1
  10. package/src/components/GameSelect/index.tsx +82 -0
  11. package/src/components/Layout/index.tsx +90 -0
  12. package/src/{layouts/NavBar.tsx → components/NavMenu/index.tsx} +8 -17
  13. package/src/components/ReactToolkitsProvider/context.ts +76 -0
  14. package/src/components/ReactToolkitsProvider/index.tsx +23 -0
  15. package/src/components/UserWidget/index.tsx +46 -0
  16. package/src/components/index.ts +25 -1
  17. package/src/features/permission/components/PermissionCollapse/index.tsx +121 -0
  18. package/src/features/permission/components/PermissionList/index.tsx +17 -118
  19. package/src/features/permission/components/PermissionListV1/index.tsx +42 -0
  20. package/src/features/permission/components/PermissionListV2/index.tsx +146 -0
  21. package/src/features/permission/hooks/index.ts +24 -9
  22. package/src/features/permission/types/index.ts +8 -1
  23. package/src/hooks/use-http-client.tsx +9 -0
  24. package/src/hooks/use-permission.tsx +10 -2
  25. package/src/index.ts +0 -1
  26. package/src/pages/{Login → base/Login}/index.tsx +3 -16
  27. package/src/pages/{NoMatch → base/NotFound}/index.tsx +4 -4
  28. package/src/pages/base/index.tsx +20 -0
  29. package/src/pages/index.ts +3 -4
  30. package/src/pages/permission/RoleList/index.tsx +63 -36
  31. package/src/pages/permission/UserList/index.tsx +2 -2
  32. package/src/pages/permission/index.tsx +26 -1
  33. package/src/stores/index.ts +0 -1
  34. package/src/stores/token.ts +15 -1
  35. package/tsup.config.ts +6 -6
  36. package/src/layouts/Layout.tsx +0 -103
  37. package/src/layouts/index.ts +0 -6
  38. package/src/stores/menu.ts +0 -27
  39. /package/src/pages/{Login → base/Login}/default.tsx +0 -0
package/tsup.config.ts CHANGED
@@ -1,12 +1,13 @@
1
- import type { Options } from 'tsup'
2
1
  import { defineConfig } from 'tsup'
3
2
  import * as process from 'process'
4
3
 
5
- export default defineConfig((options: Options) => ({
4
+ const isProduction = process.env.NODE_ENV === 'production'
5
+
6
+ export default defineConfig({
6
7
  entry: ['src/index.ts'],
7
8
  format: ['esm'],
8
- sourcemap: process.env.NODE_ENV !== 'production',
9
- minify: process.env.NODE_ENV === 'production',
9
+ sourcemap: true,
10
+ minify: false,
10
11
  treeshake: true,
11
12
  splitting: false,
12
13
  dts: true,
@@ -23,5 +24,4 @@ export default defineConfig((options: Options) => ({
23
24
  js: `.${format}.js`,
24
25
  }
25
26
  },
26
- ...options,
27
- }))
27
+ })
@@ -1,103 +0,0 @@
1
- import logo from '@/assets/512_orange_nobackground.png'
2
- import { Alert, Layout as AntdLayout, Spin, theme } from 'antd'
3
- import type { FC, PropsWithChildren, ReactNode } from 'react'
4
- import { Suspense } from 'react'
5
- import { Link } from 'react-router-dom'
6
- import type { ItemType2 } from './NavBar'
7
- import NavBar from './NavBar'
8
- import { usePermission } from '@/hooks'
9
-
10
- const { Header, Sider, Content } = AntdLayout
11
- const { ErrorBoundary } = Alert
12
-
13
- export interface LayoutProps {
14
- title?: ReactNode
15
- items: ItemType2[]
16
- header?: ReactNode
17
- }
18
-
19
- const Layout: FC<PropsWithChildren<LayoutProps>> = props => {
20
- const { title, items, header, children } = props
21
- const {
22
- token: { colorBgContainer, colorBorder },
23
- } = theme.useToken()
24
-
25
- // 为了验证 token 是否过期的请求,此处无其他用处。
26
- usePermission('100001')
27
-
28
- return (
29
- <AntdLayout hasSider className="h-screen">
30
- <ErrorBoundary>
31
- <Suspense
32
- fallback={
33
- <Spin
34
- style={{
35
- display: 'flex',
36
- justifyContent: 'center',
37
- alignItems: 'center',
38
- width: '100vw',
39
- height: '100vh',
40
- }}
41
- />
42
- }
43
- >
44
- <Sider
45
- width={256}
46
- style={{
47
- overflow: 'auto',
48
- height: '100vh',
49
- position: 'fixed',
50
- left: 0,
51
- top: 0,
52
- bottom: 0,
53
- borderRightWidth: 1,
54
- borderRightStyle: 'solid',
55
- borderRightColor: colorBorder,
56
- }}
57
- theme="light"
58
- >
59
- <div className="flex items-end px-6 py-4">
60
- <img src={logo} alt="logo" className="w-8 h-8" />
61
- <Link className="font-bold text-lg ml-2" to="/">
62
- {title}
63
- </Link>
64
- </div>
65
-
66
- <NavBar items={items} />
67
- </Sider>
68
- <AntdLayout className="ml-64">
69
- <Header
70
- style={{
71
- padding: '0 24px',
72
- background: colorBgContainer,
73
- borderBottomWidth: 1,
74
- borderBottomStyle: 'solid',
75
- borderBottomColor: colorBorder,
76
- }}
77
- >
78
- {header}
79
- </Header>
80
- <Content className="p-6 overflow-auto bg-gray-50">
81
- <Suspense
82
- fallback={
83
- <Spin
84
- style={{
85
- display: 'flex',
86
- justifyContent: 'center',
87
- alignItems: 'center',
88
- height: '50vh',
89
- }}
90
- />
91
- }
92
- >
93
- {children}
94
- </Suspense>
95
- </Content>
96
- </AntdLayout>
97
- </Suspense>
98
- </ErrorBoundary>
99
- </AntdLayout>
100
- )
101
- }
102
-
103
- export default Layout
@@ -1,6 +0,0 @@
1
- import type { LayoutProps } from './Layout'
2
- import Layout from './Layout'
3
- import type { ItemType2, NavBarProps } from './NavBar'
4
-
5
- export { Layout }
6
- export type { ItemType2, LayoutProps, NavBarProps }
@@ -1,27 +0,0 @@
1
- import { create } from 'zustand'
2
- import { persist } from 'zustand/middleware'
3
-
4
- export interface MenuState {
5
- openKeys: string[]
6
- selectedKeys: string[]
7
- setOpenKeys: (keys: string[]) => void
8
- setSelectedKeys: (keys: string[]) => void
9
- }
10
-
11
- export const useMenuStore = create<MenuState>()(
12
- persist(
13
- set => ({
14
- openKeys: [],
15
- selectedKeys: [],
16
- setOpenKeys: keys => set({ openKeys: keys }),
17
- setSelectedKeys: keys => set({ selectedKeys: keys }),
18
- }),
19
- {
20
- name: 'menu',
21
- partialize: state => ({
22
- openKeys: state.openKeys,
23
- selectedKeys: state.selectedKeys,
24
- }),
25
- },
26
- ),
27
- )
File without changes