react-toolkits 0.1.1 → 0.1.2
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/CHANGELOG.md +6 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +8 -3
- package/.eslintignore +0 -2
- package/.eslintrc.js +0 -4
- package/.turbo/turbo-build.log +0 -20
- package/postcss.config.js +0 -9
- package/src/assets/512_orange_nobackground.png +0 -0
- package/src/components/DynamicTags/index.tsx +0 -160
- package/src/components/FilterForm/index.tsx +0 -63
- package/src/components/FormModal/hooks.tsx +0 -47
- package/src/components/FormModal/index.tsx +0 -137
- package/src/components/GameSelect/index.tsx +0 -83
- package/src/components/Highlight/index.tsx +0 -51
- package/src/components/Layout/index.tsx +0 -99
- package/src/components/NavMenu/index.tsx +0 -142
- package/src/components/PermissionButton/index.tsx +0 -36
- package/src/components/QueryList/index.tsx +0 -152
- package/src/components/ReactToolkitsProvider/context.ts +0 -76
- package/src/components/ReactToolkitsProvider/index.tsx +0 -23
- package/src/components/UserWidget/index.tsx +0 -46
- package/src/components/index.ts +0 -51
- package/src/constants/index.ts +0 -1
- package/src/features/permission/components/PermissionCollapse/index.tsx +0 -121
- package/src/features/permission/components/PermissionList/index.tsx +0 -28
- package/src/features/permission/components/PermissionListV1/index.tsx +0 -42
- package/src/features/permission/components/PermissionListV2/index.tsx +0 -146
- package/src/features/permission/hooks/index.ts +0 -140
- package/src/features/permission/index.ts +0 -5
- package/src/features/permission/types/index.ts +0 -40
- package/src/hooks/index.ts +0 -2
- package/src/hooks/use-http-client.ts +0 -85
- package/src/hooks/use-permission.ts +0 -75
- package/src/index.ts +0 -7
- package/src/pages/base/Login/default.tsx +0 -864
- package/src/pages/base/Login/index.tsx +0 -101
- package/src/pages/base/NotFound/index.tsx +0 -27
- package/src/pages/base/index.tsx +0 -20
- package/src/pages/index.ts +0 -4
- package/src/pages/permission/RoleDetail/index.tsx +0 -40
- package/src/pages/permission/RoleList/index.tsx +0 -251
- package/src/pages/permission/UserList/index.tsx +0 -236
- package/src/pages/permission/index.tsx +0 -56
- package/src/shims.d.ts +0 -20
- package/src/stores/index.ts +0 -2
- package/src/stores/query-list.ts +0 -61
- package/src/stores/token.ts +0 -39
- package/src/styles/index.css +0 -5
- package/src/types/index.ts +0 -10
- package/tailwind.config.js +0 -5
- package/tsconfig.json +0 -20
- package/tsup.config.ts +0 -28
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { lazy } from 'react'
|
|
2
|
-
import type { RouteObject } from 'react-router-dom'
|
|
3
|
-
import { Navigate, Outlet } from 'react-router-dom'
|
|
4
|
-
import { Layout, ReactToolkitsProvider, useReactToolkitsContext } from '@/components'
|
|
5
|
-
import { SWRConfig } from 'swr'
|
|
6
|
-
import { useHttpClient } from '@/hooks'
|
|
7
|
-
|
|
8
|
-
const UserList = lazy(() => import('./UserList'))
|
|
9
|
-
const RoleList = lazy(() => import('./RoleList'))
|
|
10
|
-
const RoleDetail = lazy(() => import('./RoleDetail'))
|
|
11
|
-
|
|
12
|
-
const PermissionRoot = () => {
|
|
13
|
-
const httpClient = useHttpClient()
|
|
14
|
-
const configs = useReactToolkitsContext(state => state)
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
// NOTE: 目前嵌套的 ReactToolkitsProvider 只能手动注入父级 ReactToolkitsProvider 的配置
|
|
18
|
-
<ReactToolkitsProvider {...configs} isGlobalNS>
|
|
19
|
-
<SWRConfig
|
|
20
|
-
value={{
|
|
21
|
-
fetcher: httpClient.request,
|
|
22
|
-
shouldRetryOnError: false,
|
|
23
|
-
}}
|
|
24
|
-
>
|
|
25
|
-
<Layout>
|
|
26
|
-
<Outlet />
|
|
27
|
-
</Layout>
|
|
28
|
-
</SWRConfig>
|
|
29
|
-
</ReactToolkitsProvider>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const routes: RouteObject = {
|
|
34
|
-
path: 'permission',
|
|
35
|
-
element: <PermissionRoot />,
|
|
36
|
-
children: [
|
|
37
|
-
{
|
|
38
|
-
index: true,
|
|
39
|
-
element: <Navigate relative="path" to="user" />,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
path: 'user',
|
|
43
|
-
element: <UserList />,
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
path: 'role',
|
|
47
|
-
element: <RoleList />,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
path: 'role/:name',
|
|
51
|
-
element: <RoleDetail />,
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export default routes
|
package/src/shims.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
declare module '*.jpg' {
|
|
3
|
-
const content: any
|
|
4
|
-
export default content
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare module '*.png' {
|
|
8
|
-
const content: any
|
|
9
|
-
export default content
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare module '*.svg' {
|
|
13
|
-
const content: any
|
|
14
|
-
export default content
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
declare module '*.yaml' {
|
|
18
|
-
const content: any
|
|
19
|
-
export default content
|
|
20
|
-
}
|
package/src/stores/index.ts
DELETED
package/src/stores/query-list.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { QueryListKey } from '@/components/QueryList'
|
|
2
|
-
import type { PaginationParams } from '@/types'
|
|
3
|
-
import { create } from 'zustand'
|
|
4
|
-
|
|
5
|
-
type RefreshFunction = (arg?: Partial<PaginationParams>) => void
|
|
6
|
-
|
|
7
|
-
export interface QueryListState {
|
|
8
|
-
data: Map<
|
|
9
|
-
QueryListKey,
|
|
10
|
-
{
|
|
11
|
-
pagination?: PaginationParams
|
|
12
|
-
refresh?: RefreshFunction
|
|
13
|
-
}
|
|
14
|
-
>
|
|
15
|
-
getPaginationData: (key: QueryListKey) => PaginationParams
|
|
16
|
-
setPaginationData: (key: QueryListKey, pagination?: Partial<PaginationParams>) => void
|
|
17
|
-
refresh: (key: QueryListKey, arg?: Partial<PaginationParams>) => void
|
|
18
|
-
setRefresh: (key: QueryListKey, trigger: RefreshFunction) => void
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const useQueryListStore = create<QueryListState>((set, get) => ({
|
|
22
|
-
data: new Map(),
|
|
23
|
-
getPaginationData: (key: QueryListKey) => {
|
|
24
|
-
const pagination = get().data.get(key)?.pagination
|
|
25
|
-
return {
|
|
26
|
-
page: pagination?.page ?? 1,
|
|
27
|
-
size: pagination?.size ?? 10,
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
setPaginationData: (key: QueryListKey, pagination?: Partial<PaginationParams>) => {
|
|
31
|
-
set({
|
|
32
|
-
data: new Map(get().data).set(key, {
|
|
33
|
-
...get().data.get(key),
|
|
34
|
-
pagination: {
|
|
35
|
-
page: pagination?.page ?? get().getPaginationData(key).page,
|
|
36
|
-
size: pagination?.size ?? get().getPaginationData(key).size,
|
|
37
|
-
},
|
|
38
|
-
}),
|
|
39
|
-
})
|
|
40
|
-
},
|
|
41
|
-
refresh: (key: QueryListKey, pagination?: Partial<PaginationParams>) => {
|
|
42
|
-
const refresh = get().data.get(key)?.refresh
|
|
43
|
-
|
|
44
|
-
if (refresh) {
|
|
45
|
-
refresh({
|
|
46
|
-
page: pagination?.page ?? get().getPaginationData(key).page,
|
|
47
|
-
size: pagination?.size ?? get().getPaginationData(key).size,
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
setRefresh: (key: QueryListKey, refresh: RefreshFunction) => {
|
|
52
|
-
const data = get().data
|
|
53
|
-
|
|
54
|
-
set({
|
|
55
|
-
data: new Map(data).set(key, {
|
|
56
|
-
...data.get(key),
|
|
57
|
-
refresh,
|
|
58
|
-
}),
|
|
59
|
-
})
|
|
60
|
-
},
|
|
61
|
-
}))
|
package/src/stores/token.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { create } from 'zustand'
|
|
2
|
-
import { persist } from 'zustand/middleware'
|
|
3
|
-
import jwtDecode from 'jwt-decode'
|
|
4
|
-
|
|
5
|
-
interface UserInfo {
|
|
6
|
-
authorityId: string
|
|
7
|
-
exp: number
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface TokenState {
|
|
11
|
-
token: string
|
|
12
|
-
getUser: () => UserInfo | null
|
|
13
|
-
setToken: (token: string) => void
|
|
14
|
-
clearToken: () => void
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const useTokenStore = create<TokenState>()(
|
|
18
|
-
persist(
|
|
19
|
-
(set, get) => ({
|
|
20
|
-
token: '',
|
|
21
|
-
getUser: () => {
|
|
22
|
-
try {
|
|
23
|
-
return jwtDecode(get().token) as UserInfo
|
|
24
|
-
} catch (_) {
|
|
25
|
-
return null
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
setToken: token => set({ token }),
|
|
29
|
-
clearToken: () => {
|
|
30
|
-
set({ token: '' })
|
|
31
|
-
useTokenStore.persist.clearStorage()
|
|
32
|
-
},
|
|
33
|
-
}),
|
|
34
|
-
{
|
|
35
|
-
name: 'token',
|
|
36
|
-
partialize: state => ({ token: state.token }),
|
|
37
|
-
},
|
|
38
|
-
),
|
|
39
|
-
)
|
package/src/styles/index.css
DELETED
package/src/types/index.ts
DELETED
package/tailwind.config.js
DELETED
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "tsconfig/react-library.json",
|
|
3
|
-
"include": [
|
|
4
|
-
"./src",
|
|
5
|
-
"tsup.config.ts"
|
|
6
|
-
],
|
|
7
|
-
"exclude": [
|
|
8
|
-
"dist",
|
|
9
|
-
"node_modules"
|
|
10
|
-
],
|
|
11
|
-
"compilerOptions": {
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"baseUrl": ".",
|
|
14
|
-
"paths": {
|
|
15
|
-
"@/*": [
|
|
16
|
-
"./src/*"
|
|
17
|
-
]
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
package/tsup.config.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup'
|
|
2
|
-
import * as process from 'process'
|
|
3
|
-
import packageJson from './package.json'
|
|
4
|
-
|
|
5
|
-
const isProduction = process.env.NODE_ENV === 'production'
|
|
6
|
-
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
entry: ['src/index.ts'],
|
|
9
|
-
format: ['esm'],
|
|
10
|
-
sourcemap: true,
|
|
11
|
-
minify: isProduction,
|
|
12
|
-
treeshake: true,
|
|
13
|
-
splitting: false,
|
|
14
|
-
dts: true,
|
|
15
|
-
clean: true,
|
|
16
|
-
shims: true,
|
|
17
|
-
external: Object.keys(packageJson.peerDependencies),
|
|
18
|
-
loader: {
|
|
19
|
-
'.jpg': 'base64',
|
|
20
|
-
'.png': 'copy',
|
|
21
|
-
'.webp': 'file',
|
|
22
|
-
},
|
|
23
|
-
outExtension({ format }) {
|
|
24
|
-
return {
|
|
25
|
-
js: `.${format}.js`,
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
})
|