react-toolkits 2.27.12 → 2.27.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/CHANGELOG.md +6 -0
- package/README.md +33 -12
- package/lib/index.css +1 -1063
- package/lib/index.js +3 -14008
- package/locale/context.js +2 -1473
- package/locale/hooks.js +14 -53902
- package/locale/index.js +14 -53902
- package/package.json +4 -2
- package/lib/index.js.map +0 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -19,9 +19,10 @@ pnpm add react-toolkits
|
|
|
19
19
|
|
|
20
20
|
对等依赖(需由你的应用提供):
|
|
21
21
|
|
|
22
|
-
- react、react-dom:^
|
|
23
|
-
- antd:^
|
|
24
|
-
- react-router-dom:^
|
|
22
|
+
- react、react-dom:^19
|
|
23
|
+
- antd:^6
|
|
24
|
+
- react-router-dom:^7
|
|
25
|
+
- @tanstack/react-query:^5
|
|
25
26
|
|
|
26
27
|
样式:
|
|
27
28
|
|
|
@@ -32,6 +33,7 @@ import 'react-toolkits/style.css'
|
|
|
32
33
|
## 快速上手
|
|
33
34
|
|
|
34
35
|
```tsx
|
|
36
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
35
37
|
import 'react-toolkits/style.css'
|
|
36
38
|
import { createRoot } from 'react-dom/client'
|
|
37
39
|
import { RouterProvider } from 'react-router-dom'
|
|
@@ -40,21 +42,40 @@ import { PermissionMode } from 'react-toolkits/constants'
|
|
|
40
42
|
|
|
41
43
|
import router from './router'
|
|
42
44
|
|
|
45
|
+
// 创建 QueryClient 实例
|
|
46
|
+
const queryClient = new QueryClient({
|
|
47
|
+
defaultOptions: {
|
|
48
|
+
queries: {
|
|
49
|
+
refetchOnWindowFocus: false,
|
|
50
|
+
retry: false,
|
|
51
|
+
staleTime: 5 * 60 * 1000,
|
|
52
|
+
gcTime: 10 * 60 * 1000,
|
|
53
|
+
},
|
|
54
|
+
mutations: {
|
|
55
|
+
retry: false,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
|
|
43
60
|
const root = createRoot(document.getElementById('root') as HTMLElement)
|
|
44
61
|
|
|
45
62
|
root.render(
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
<QueryClientProvider client={queryClient}>
|
|
64
|
+
<ToolkitsProvider
|
|
65
|
+
collapsible
|
|
66
|
+
gameApiV2
|
|
67
|
+
permissionMode={PermissionMode.GROUP_BASED}
|
|
68
|
+
loginPath="/sign_in"
|
|
69
|
+
mainPagePath="/"
|
|
70
|
+
>
|
|
71
|
+
<RouterProvider router={router} />
|
|
72
|
+
</ToolkitsProvider>
|
|
73
|
+
</QueryClientProvider>,
|
|
55
74
|
)
|
|
56
75
|
```
|
|
57
76
|
|
|
77
|
+
**重要提示**:`QueryClientProvider` 必须包裹 `ToolkitsProvider`,因为 `react-toolkits` 内部使用了 `@tanstack/react-query` 的 hooks(如 `useQueryClient`、`useQuery`、`useMutation`)。
|
|
78
|
+
|
|
58
79
|
### 配置项(`ToolkitsProvider`)
|
|
59
80
|
|
|
60
81
|
- **loginPath**: 登录页路径(未鉴权时会跳转)
|