Skip to content

Commit 632ee56

Browse files
committed
fix(base): 移除swr插件及调整BasicLayout/PorTable组件
1 parent 07b2ede commit 632ee56

File tree

8 files changed

+25
-37
lines changed

8 files changed

+25
-37
lines changed

examples/base/config/.kktprc.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export default {
44
routesOutletElement: '@/routesOutletElement',
55
},
66
initModel: true,
7+
queryClient: true,
78
define: {
89
AUTH: false,
910
STORAGE: 'local',

examples/base/config/routes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"children": [
1010
{
1111
"index": true,
12-
"redirect": "/tableList"
12+
"redirect": "/home"
1313
},
1414
{
1515
"path": "/home",

examples/base/package.json

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,20 @@
2424
"@swc/core": ">=1.3.55"
2525
},
2626
"dependencies": {
27-
"@kkt/pro": "^1.0.13",
28-
"@uiw-admin/authorized": "6.1.6",
29-
"@uiw-admin/basic-layouts": "6.1.6",
30-
"@uiw-admin/components": "6.1.6",
31-
"@uiw-admin/config": "6.1.6",
32-
"@uiw-admin/document-title": "6.1.6",
33-
"@uiw-admin/exceptions": "6.1.6",
34-
"@uiw-admin/layout-tabs": "6.1.6",
35-
"@uiw-admin/user-login": "6.1.6",
36-
"@uiw-admin/utils": "6.1.6",
27+
"@kkt/pro": "^1.0.14",
28+
"@uiw-admin/authorized": "6.1.9",
29+
"@uiw-admin/basic-layouts": "6.1.9",
30+
"@uiw-admin/components": "6.1.9",
31+
"@uiw-admin/config": "6.1.9",
32+
"@uiw-admin/document-title": "6.1.9",
33+
"@uiw-admin/exceptions": "6.1.9",
34+
"@uiw-admin/layout-tabs": "6.1.9",
35+
"@uiw-admin/user-login": "6.1.9",
36+
"@uiw-admin/utils": "6.1.9",
3737
"@uiw/reset.css": "~1.0.5",
3838
"axios": "^0.27.0",
3939
"classnames": "~2.3.1",
4040
"styled-components": "^5.3.5",
41-
"swr": "2.1.0",
4241
"uiw": "^4.21.26"
4342
},
4443
"devDependencies": {

examples/base/src/layouts/BasicLayout.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Badge, Icon } from 'uiw'
2-
import useSWR from 'swr'
32
import AuthPage from '@uiw-admin/authorized'
4-
import { KktproPageProps } from '@kkt/pro'
3+
import { KktproPageProps, useReactMutation } from '@kkt/pro'
54
import BasicLayout, {
65
useLayouts,
76
BasicLayoutProps,
@@ -13,16 +12,17 @@ function BasicLayoutScreen(props: KktproPageProps) {
1312

1413
const layouts = useLayouts()
1514

16-
const { mutate } = useSWR(['/api/reloadAuth', { method: 'POST' }], {
17-
revalidateOnMount: false,
18-
revalidateOnFocus: false,
19-
onSuccess: (data) => {
15+
const { mutate } = useReactMutation({
16+
url: '/api/reloadAuth',
17+
method: 'POST',
18+
onSuccess: (data: any) => {
2019
if (data && data.code === 200) {
2120
sessionStorage.setItem('token', data.token)
2221
sessionStorage.setItem('auth', JSON.stringify(data.authList || []))
2322
localStorage.setItem('token', data.token)
2423
localStorage.setItem('auth', JSON.stringify(data.authList || []))
25-
window.location.reload()
24+
// window.location.reload()
25+
layouts.closeMenu()
2626
}
2727
},
2828
})
Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { cloneElement } from 'react'
2-
import { SWRConfig } from 'swr'
3-
import { request } from '@uiw-admin/utils'
42
import { KktproRoutesProps } from '@kkt/pro'
53
import '@uiw/reset.css'
64
import './index.css'
@@ -12,18 +10,8 @@ interface RoutesOutletElementProps {
1210
const RoutesOutletElement = (props: RoutesOutletElementProps) => {
1311
const { routes } = props
1412

15-
return (
16-
<SWRConfig
17-
value={{
18-
fetcher: (resource, init) => {
19-
return request(resource, init)
20-
},
21-
provider: () => new Map(),
22-
}}>
23-
{cloneElement(props.children as JSX.Element, {
24-
router: routes,
25-
})}
26-
</SWRConfig>
27-
)
13+
return cloneElement(props.children as JSX.Element, {
14+
router: routes,
15+
})
2816
}
2917
export default RoutesOutletElement

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"publish": "npm run build && lerna publish from-package",
5858
"start": "lerna exec --scope @examples/base npm run start",
5959
"start:website": "lerna exec --scope website npm run start",
60+
"preview": "lerna exec --scope @examples/preview npm run start",
6061
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
6162
"clean": "lerna clean && npm run remove && rm -rf ./package-lock.json && rm -rf node_modules && npm run remove:c ",
6263
"remove": " lerna exec --scope @uiw-admin/* --scope @example/* -- rm -rf package-lock.json",

packages/basic-layouts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"dependencies": {
4646
"@babel/runtime": "~7.21.0",
4747
"@kkt/pro": "^1.0.13",
48-
"@uiw-admin/document-title": "6.1.6",
48+
"@uiw-admin/document-title": "6.1.9",
4949
"classnames": "2.3.1",
5050
"pinyin": "~2.11.2"
5151
},

packages/components/src/ProTable/BaseTable.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ const BaseTable: React.FC<BaseTableProps> = ({
9494
};
9595

9696
const pageSize = formatQuery().pageSize || 10;
97-
9897
// 调接口
9998
const { mutate, data, isLoading }: any = useReactMutation({
10099
mutationFn: async () => {
@@ -118,7 +117,7 @@ const BaseTable: React.FC<BaseTableProps> = ({
118117
useEffect(() => {
119118
// 第一次加载
120119
mutate();
121-
}, [mutate]);
120+
}, []);
122121

123122
// table数据
124123
const tableData =

0 commit comments

Comments
 (0)