Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
e48dd5a3
Unverified
Commit
e48dd5a3
authored
Aug 11, 2023
by
yqwoe
Committed by
GitHub
Aug 11, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature][Web] Menu permission control (#2200)
* feat: 菜单权限控制
parent
ed6b27ed
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
77 additions
and
48 deletions
+77
-48
application-mysql.yml
dinky-admin/src/main/resources/application-mysql.yml
+1
-2
routes.ts
dinky-web/config/routes.ts
+2
-0
access.ts
dinky-web/src/access.ts
+13
-1
app.tsx
dinky-web/src/app.tsx
+18
-0
index.tsx
...b/src/pages/AuthCenter/Menu/components/MenuForm/index.tsx
+0
-0
index.tsx
...b/src/pages/AuthCenter/Menu/components/MenuList/index.tsx
+12
-13
index.tsx
...b/src/pages/AuthCenter/Menu/components/MenuTree/index.tsx
+2
-3
index.tsx
dinky-web/src/pages/AuthCenter/Menu/index.tsx
+10
-11
index.tsx
dinky-web/src/pages/Home/index.tsx
+19
-18
No files found.
dinky-admin/src/main/resources/application-mysql.yml
View file @
e48dd5a3
...
...
@@ -20,4 +20,4 @@ spring:
url
:
jdbc:mysql://${MYSQL_ADDR:127.0.0.1:3306}/${MYSQL_DATABASE:dinky}?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username
:
${MYSQL_USERNAME:dinky}
password
:
${MYSQL_PASSWORD:dinky}
driver-class-name
:
com.mysql.cj.jdbc.Driver
\ No newline at end of file
driver-class-name
:
com.mysql.cj.jdbc.Driver
dinky-web/config/routes.ts
View file @
e48dd5a3
...
...
@@ -261,6 +261,8 @@ export default [
{
path
:
'/account/center'
,
footerRender
:
false
,
name
:
'center'
,
hideInMenu
:
true
,
component
:
'./Other/PersonCenter'
,
},
{
...
...
dinky-web/src/access.ts
View file @
e48dd5a3
...
...
@@ -15,7 +15,7 @@
* limitations under the License.
*/
import
{
API
}
from
"./services/data"
;
import
{
API
}
from
'./services/data'
;
/**
* @see https://umijs.org/zh-CN/plugins/plugin-access
...
...
@@ -24,5 +24,17 @@ export default function access(initialState: { currentUser?: API.CurrentUser } |
const
{
currentUser
}
=
initialState
??
{};
return
{
canAdmin
:
currentUser
&&
currentUser
.
user
.
superAdminFlag
,
canAuth
({
path
,
...
route
})
{
if
(
currentUser
&&
currentUser
.
user
.
superAdminFlag
)
{
return
true
;
}
//TODO根据path判断应用、目录、菜单、按钮,判断返回true,false
//TODOpath可以是window.location.href、key
return
currentUser
?.
menuList
?.
some
?.(
(
item
)
=>
item
?.
path
?.
startsWith
(
path
)
||
item
?.
path
?.
endsWith
(
path
),
);
},
};
}
dinky-web/src/app.tsx
View file @
e48dd5a3
...
...
@@ -36,6 +36,24 @@ import { API } from "./services/data";
// const isDev = process.env.NODE_ENV === "development";
const
loginPath
=
API_CONSTANTS
.
LOGIN_PATH
;
const
whiteList
=
[
'/user'
,
'/user/login'
]
/**
* 初始化路由鉴权
* @param param0
*/
export
function
patchRoutes
({
routes
}:
any
)
{
Object
.
keys
(
routes
).
forEach
(
key
=>
{
let
route
=
routes
[
key
];
if
(
!
whiteList
.
includes
(
route
.
path
)){
routes
[
key
]
=
{...
route
,
access
:
'canAuth'
}
}
})
}
/**
* @see https://umijs.org/zh-CN/plugins/plugin-initial-state
* */
...
...
dinky-web/src/pages/AuthCenter/Menu/components/MenuForm/index.tsx
View file @
e48dd5a3
This diff is collapsed.
Click to expand it.
dinky-web/src/pages/AuthCenter/Menu/components/MenuList/index.tsx
View file @
e48dd5a3
...
...
@@ -18,19 +18,19 @@
*/
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
{
Button
,
Space
}
from
'antd'
;
import
{
handleAddOrUpdate
,
handleRemoveById
,
queryDataByParams
}
from
"@/services/BusinessCrud"
;
import
{
ProCard
}
from
"@ant-design/pro-components"
;
import
{
MenuInfo
}
from
"rc-menu/es/interface"
;
import
{
RIGHT_CONTEXT_MENU
}
from
"@/pages/AuthCenter/Menu/components/MenuList/constants"
;
import
{
SysMenu
}
from
"@/types/RegCenter/data"
;
import
{
PlusSquareTwoTone
,
ReloadOutlined
}
from
"@ant-design/icons"
;
import
OpHelper
from
"@/pages/AuthCenter/Menu/components/MenuList/OpHelper"
;
import
{
l
}
from
"@/utils/intl"
;
import
RightContextMenu
from
"@/components/RightContextMenu"
;
import
MenuForm
from
"@/pages/AuthCenter/Menu/components/MenuForm"
;
import
OpHelper
from
"@/pages/AuthCenter/Menu/components/MenuList/OpHelper"
;
import
{
RIGHT_CONTEXT_MENU
}
from
"@/pages/AuthCenter/Menu/components/MenuList/constants"
;
import
MenuTree
from
"@/pages/AuthCenter/Menu/components/MenuTree"
;
import
{
handleAddOrUpdate
,
handleRemoveById
,
queryDataByParams
}
from
"@/services/BusinessCrud"
;
import
{
SysMenu
}
from
"@/types/RegCenter/data"
;
import
{
l
}
from
"@/utils/intl"
;
import
{
PlusSquareTwoTone
,
ReloadOutlined
}
from
"@ant-design/icons"
;
import
{
ProCard
}
from
"@ant-design/pro-components"
;
import
{
Button
,
Space
}
from
'antd'
;
import
{
MenuInfo
}
from
"rc-menu/es/interface"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
const
MenuList
:
React
.
FC
=
()
=>
{
/**
...
...
@@ -245,7 +245,7 @@ const MenuList: React.FC = () => {
</>
}
console
.
log
(
treeData
,
buildMenuFormTree
(
treeData
,
''
,
true
))
/**
* render
*/
...
...
@@ -279,4 +279,4 @@ const MenuList: React.FC = () => {
}
;
export
default
MenuList
;
\ No newline at end of file
export
default
MenuList
;
dinky-web/src/pages/AuthCenter/Menu/components/MenuTree/index.tsx
View file @
e48dd5a3
...
...
@@ -36,7 +36,7 @@ type MenuTreeProps = {
loading
:
boolean
,
}
const
MenuTree
:
React
.
FC
<
MenuTreeProps
>
=
(
props
)
=>
{
const
{
treeData
,
selectedKeys
,
onNodeClick
,
onRightClick
,
loading
}
=
props
;
const
{
treeData
=
[]
,
selectedKeys
,
onNodeClick
,
onRightClick
,
loading
}
=
props
;
const
[
searchValue
,
setSearchValue
]
=
useState
(
''
);
...
...
@@ -74,4 +74,4 @@ const MenuTree: React.FC<MenuTreeProps> = (props) => {
</>
}
export
default
MenuTree
;
\ No newline at end of file
export
default
MenuTree
;
dinky-web/src/pages/AuthCenter/Menu/index.tsx
View file @
e48dd5a3
...
...
@@ -17,20 +17,19 @@
*
*/
import
React
from
"react"
;
import
{
PageContainer
}
from
'@ant-design/pro-layout'
;
import
SlowlyAppear
from
"@/components/Animation/SlowlyAppear"
;
import
MenuList
from
"@/pages/AuthCenter/Menu/components/MenuList"
;
import
SlowlyAppear
from
'@/components/Animation/SlowlyAppear'
;
import
MenuList
from
'@/pages/AuthCenter/Menu/components/MenuList'
;
import
{
PageContainer
}
from
'@ant-design/pro-layout'
;
export
default
()
=>
{
/**
* render
*/
return
<
SlowlyAppear
>
<
PageContainer
title=
{
false
}
>
<
MenuList
/>
</
PageContainer
>
</
SlowlyAppear
>
return
(
<
SlowlyAppear
>
<
PageContainer
title=
{
false
}
>
<
MenuList
/>
</
PageContainer
>
</
SlowlyAppear
>
);
};
dinky-web/src/pages/Home/index.tsx
View file @
e48dd5a3
...
...
@@ -16,23 +16,24 @@
* limitations under the License.
*
*/
import
{
Col
,
Row
}
from
'antd'
;
import
JobOverView
from
"@/pages/Home/JobOverView"
;
import
{
PageContainer
}
from
"@ant-design/pro-components"
;
import
DevOverView
from
"@/pages/Home/DevOverView"
;
import
DevOverView
from
'@/pages/Home/DevOverView'
;
import
JobOverView
from
'@/pages/Home/JobOverView'
;
import
{
PageContainer
}
from
'@ant-design/pro-components'
;
import
{
Col
,
Row
}
from
'antd'
;
export
default
()
=>
{
return
<
PageContainer
title=
{
false
}
>
<
Row
style=
{
{
marginTop
:
'5px'
,
marginBottom
:
'10px'
}
}
>
<
Col
span=
{
24
}
>
<
JobOverView
/>
</
Col
>
</
Row
>
<
Row
>
<
Col
span=
{
24
}
>
<
DevOverView
/>
</
Col
>
</
Row
>
</
PageContainer
>
}
return
(
<
PageContainer
title=
{
false
}
>
<
Row
style=
{
{
marginTop
:
'5px'
,
marginBottom
:
'10px'
}
}
>
<
Col
span=
{
24
}
>
<
JobOverView
/>
</
Col
>
</
Row
>
<
Row
>
<
Col
span=
{
24
}
>
<
DevOverView
/>
</
Col
>
</
Row
>
</
PageContainer
>
);
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment