Skip to content

Commit

Permalink
Merge pull request #224 from yaob421123/master
Browse files Browse the repository at this point in the history
fix(base): 移除swr插件及调整BasicLayout/PorTable组件
  • Loading branch information
ChenlingasMx committed Apr 27, 2023
2 parents 07b2ede + 632ee56 commit 07ca6d5
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 37 deletions.
1 change: 1 addition & 0 deletions examples/base/config/.kktprc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default {
routesOutletElement: '@/routesOutletElement',
},
initModel: true,
queryClient: true,
define: {
AUTH: false,
STORAGE: 'local',
Expand Down
2 changes: 1 addition & 1 deletion examples/base/config/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"children": [
{
"index": true,
"redirect": "/tableList"
"redirect": "/home"
},
{
"path": "/home",
Expand Down
21 changes: 10 additions & 11 deletions examples/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,20 @@
"@swc/core": ">=1.3.55"
},
"dependencies": {
"@kkt/pro": "^1.0.13",
"@uiw-admin/authorized": "6.1.6",
"@uiw-admin/basic-layouts": "6.1.6",
"@uiw-admin/components": "6.1.6",
"@uiw-admin/config": "6.1.6",
"@uiw-admin/document-title": "6.1.6",
"@uiw-admin/exceptions": "6.1.6",
"@uiw-admin/layout-tabs": "6.1.6",
"@uiw-admin/user-login": "6.1.6",
"@uiw-admin/utils": "6.1.6",
"@kkt/pro": "^1.0.14",
"@uiw-admin/authorized": "6.1.9",
"@uiw-admin/basic-layouts": "6.1.9",
"@uiw-admin/components": "6.1.9",
"@uiw-admin/config": "6.1.9",
"@uiw-admin/document-title": "6.1.9",
"@uiw-admin/exceptions": "6.1.9",
"@uiw-admin/layout-tabs": "6.1.9",
"@uiw-admin/user-login": "6.1.9",
"@uiw-admin/utils": "6.1.9",
"@uiw/reset.css": "~1.0.5",
"axios": "^0.27.0",
"classnames": "~2.3.1",
"styled-components": "^5.3.5",
"swr": "2.1.0",
"uiw": "^4.21.26"
},
"devDependencies": {
Expand Down
14 changes: 7 additions & 7 deletions examples/base/src/layouts/BasicLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Badge, Icon } from 'uiw'
import useSWR from 'swr'
import AuthPage from '@uiw-admin/authorized'
import { KktproPageProps } from '@kkt/pro'
import { KktproPageProps, useReactMutation } from '@kkt/pro'
import BasicLayout, {
useLayouts,
BasicLayoutProps,
Expand All @@ -13,16 +12,17 @@ function BasicLayoutScreen(props: KktproPageProps) {

const layouts = useLayouts()

const { mutate } = useSWR(['/api/reloadAuth', { method: 'POST' }], {
revalidateOnMount: false,
revalidateOnFocus: false,
onSuccess: (data) => {
const { mutate } = useReactMutation({
url: '/api/reloadAuth',
method: 'POST',
onSuccess: (data: any) => {
if (data && data.code === 200) {
sessionStorage.setItem('token', data.token)
sessionStorage.setItem('auth', JSON.stringify(data.authList || []))
localStorage.setItem('token', data.token)
localStorage.setItem('auth', JSON.stringify(data.authList || []))
window.location.reload()
// window.location.reload()
layouts.closeMenu()
}
},
})
Expand Down
18 changes: 3 additions & 15 deletions examples/base/src/routesOutletElement/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { cloneElement } from 'react'
import { SWRConfig } from 'swr'
import { request } from '@uiw-admin/utils'
import { KktproRoutesProps } from '@kkt/pro'
import '@uiw/reset.css'
import './index.css'
Expand All @@ -12,18 +10,8 @@ interface RoutesOutletElementProps {
const RoutesOutletElement = (props: RoutesOutletElementProps) => {
const { routes } = props

return (
<SWRConfig
value={{
fetcher: (resource, init) => {
return request(resource, init)
},
provider: () => new Map(),
}}>
{cloneElement(props.children as JSX.Element, {
router: routes,
})}
</SWRConfig>
)
return cloneElement(props.children as JSX.Element, {
router: routes,
})
}
export default RoutesOutletElement
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"publish": "npm run build && lerna publish from-package",
"start": "lerna exec --scope @examples/base npm run start",
"start:website": "lerna exec --scope website npm run start",
"preview": "lerna exec --scope @examples/preview npm run start",
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
"clean": "lerna clean && npm run remove && rm -rf ./package-lock.json && rm -rf node_modules && npm run remove:c ",
"remove": " lerna exec --scope @uiw-admin/* --scope @example/* -- rm -rf package-lock.json",
Expand Down
2 changes: 1 addition & 1 deletion packages/basic-layouts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"@babel/runtime": "~7.21.0",
"@kkt/pro": "^1.0.13",
"@uiw-admin/document-title": "6.1.6",
"@uiw-admin/document-title": "6.1.9",
"classnames": "2.3.1",
"pinyin": "~2.11.2"
},
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/ProTable/BaseTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ const BaseTable: React.FC<BaseTableProps> = ({
};

const pageSize = formatQuery().pageSize || 10;

// 调接口
const { mutate, data, isLoading }: any = useReactMutation({
mutationFn: async () => {
Expand All @@ -118,7 +117,7 @@ const BaseTable: React.FC<BaseTableProps> = ({
useEffect(() => {
// 第一次加载
mutate();
}, [mutate]);
}, []);

// table数据
const tableData =
Expand Down

0 comments on commit 07ca6d5

Please sign in to comment.