Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TOSTUMI
Project
Project
Details
Activity
Releases
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
Maple
TOSTUMI
Commits
254019ff
Commit
254019ff
authored
Nov 24, 2020
by
Sixiang_Zzb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权限校验以及测试问题处理
parent
f0bf87b9
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
100 additions
and
10 deletions
+100
-10
config.ts
config/config.ts
+3
-0
TableShow.tsx
src/components/TableShow/TableShow.tsx
+6
-1
SecurityLayout.tsx
src/layouts/SecurityLayout.tsx
+67
-5
403.tsx
src/pages/403.tsx
+18
-0
Users.tsx
src/pages/UserManagement/LIFEUserManagement/Users.tsx
+1
-2
UsersDetail.tsx
src/pages/UserManagement/LIFEUserManagement/UsersDetail.tsx
+5
-2
No files found.
config/config.ts
View file @
254019ff
...
...
@@ -375,6 +375,9 @@ export default defineConfig({
{
component
:
'./404'
,
},
{
component
:
'./403'
,
},
],
// Theme for antd: https://ant.design/docs/react/customize-theme-cn
...
...
src/components/TableShow/TableShow.tsx
View file @
254019ff
import
React
,
{
useEffect
}
from
'react'
;
import
{
Row
,
Col
,
Table
,
Space
,
Tabs
,
Button
}
from
'antd'
;
import
{
Row
,
Col
,
Table
,
Space
,
Tabs
,
Button
,
message
}
from
'antd'
;
const
{
TabPane
}
=
Tabs
;
import
{
objectColumns
}
from
'@/utils/string'
;
...
...
@@ -9,6 +9,11 @@ const TableShow = (props: any) => {
const
dataRow
=
data
.
rows
;
const
goTo
=
(
values
:
any
,
e
:
any
)
=>
{
const
permissionArr
=
JSON
.
parse
(
localStorage
.
getItem
(
'permission'
)
||
'[]'
);
if
(
permissionArr
.
indexOf
(
'6'
)
<
0
)
{
message
.
error
(
'No Permissions!!!'
,
3
);
return
;
}
console
.
log
(
values
);
props
.
onSubmit
(
values
);
};
...
...
src/layouts/SecurityLayout.tsx
View file @
254019ff
import
React
from
'react'
;
import
{
PageLoading
}
from
'@ant-design/pro-layout'
;
import
{
Redirect
,
connect
,
ConnectProps
,
StateType
,
history
}
from
'umi'
;
import
{
Redirect
,
connect
,
ConnectProps
,
StateType
,
history
,
Link
}
from
'umi'
;
import
{
stringify
}
from
'querystring'
;
import
{
ConnectState
}
from
'@/models/connect'
;
import
{
CurrentUser
}
from
'@/models/user'
;
import
{
getCookie
}
from
'@/utils/method'
;
import
{
Result
,
Button
}
from
'antd'
;
interface
SecurityLayoutProps
extends
ConnectProps
{
loading
?:
boolean
;
...
...
@@ -46,12 +47,73 @@ class SecurityLayout extends React.Component<SecurityLayoutProps, SecurityLayout
// }
render
()
{
const
{
isReady
,
token
}
=
this
.
state
;
const
{
children
,
loading
,
currentUser
,
login
}
=
this
.
props
;
const
{
children
,
loading
}
=
this
.
props
;
// You can replace it to your authentication rule (such as check token exists)
// 你可以把它替换成你自己的登录认证规则(比如判断 token 是否存在)
// console.log("是否已登录" + getCookie("token"))
const
perList
=
[
{
path
:
'/UserManagement/LIFEUserManagement'
,
key
:
'1'
,
},
{
path
:
'/UserManagement/ServiceProviderManagement'
,
key
:
'8'
,
},
{
path
:
'/PropertyManagement'
,
key
:
'15'
,
},
{
path
:
'/CommercialService/CommunityMaintenance'
,
key
:
'17'
,
},
{
path
:
'/CommercialService/OwnerComplaints'
,
key
:
'20'
,
},
{
path
:
'/CommercialService/ProblemFeedback'
,
key
:
'23'
,
},
{
path
:
'/CommercialService/RenovationApplication'
,
key
:
'26'
,
},
{
path
:
'/CommercialService/AccessCardApplication'
,
key
:
'29'
,
},
{
path
:
'/CommercialService/ReportOnline'
,
key
:
'33'
,
},
{
path
:
'/CommercialService/ShelfLifeService'
,
key
:
'36'
,
},
];
const
permission
=
JSON
.
parse
(
localStorage
.
getItem
(
'permission'
)
||
'[]'
);
console
.
log
(
'验证权限'
+
location
.
pathname
);
console
.
log
(
'拿取所有权限'
+
permission
);
// 判断是否有权限
// if (perList.indexOf("")) {
// }
let
perObj
=
perList
.
filter
((
obj
)
=>
{
return
obj
.
path
===
location
.
pathname
;
});
console
.
log
(
perObj
);
if
(
perObj
.
length
!==
0
)
{
if
(
permission
.
indexOf
(
perObj
[
0
].
key
)
<
0
)
{
console
.
log
(
'无权限'
);
history
.
push
(
'/403'
);
}
}
// const isLogin = currentUser && currentUser.name;//isLogin为关键点
var
isLogin
=
false
;
...
...
src/pages/403.tsx
0 → 100644
View file @
254019ff
import
{
Button
,
Result
}
from
'antd'
;
import
React
from
'react'
;
import
{
history
}
from
'umi'
;
const
NoFoundPage
:
React
.
FC
<
{}
>
=
()
=>
(
<
Result
status=
"403"
title=
"403"
subTitle=
"Sorry, you are not authorized to access this page."
extra=
{
<
Button
type=
"primary"
onClick=
{
()
=>
history
.
push
(
'/'
)
}
>
Back Home
</
Button
>
}
/>
);
export
default
NoFoundPage
;
src/pages/UserManagement/LIFEUserManagement/Users.tsx
View file @
254019ff
...
...
@@ -10,8 +10,7 @@ import TitleSearch from '../../../components/TitleSearch/TitleSearch';
import
{
timestampToTime
}
from
'../../../utils/time'
;
import
{
RA
,
getCookie
,
URL
,
filterObjbyTg
,
urlEncode
,
filterObj
}
from
'@/utils/method'
;
console
.
log
(
'检查是否有权限'
);
import
{
remove
}
from
'lodash'
;
const
module
=
'User'
;
const
module2
=
'History'
;
...
...
src/pages/UserManagement/LIFEUserManagement/UsersDetail.tsx
View file @
254019ff
...
...
@@ -32,7 +32,7 @@ const UsersDetail = (props: any) => {
const
MemberResultClear
=
()
=>
{
dispatch
({
type
:
'User/MemberResultClear'
});
};
const
permissionArr
=
JSON
.
parse
(
localStorage
.
getItem
(
'permission'
)
||
'[]'
);
const
[
memberDetail
,
setMemberDetail
]
=
useState
(
false
);
const
[
memberData
,
setMemberData
]
=
useState
(
null
as
any
);
const
[
editFlag
,
setEditFlag
]
=
useState
(
false
);
...
...
@@ -140,7 +140,6 @@ const UsersDetail = (props: any) => {
};
const
deleteUnit
=
(
values
:
any
)
=>
{
const
permissionArr
=
JSON
.
parse
(
localStorage
.
getItem
(
'permission'
)
||
'[]'
);
if
(
permissionArr
.
indexOf
(
'5'
)
<
0
)
{
message
.
error
(
'No Permissions!!!'
,
3
);
return
;
...
...
@@ -169,6 +168,10 @@ const UsersDetail = (props: any) => {
const
DeleteMember
=
(
values
:
any
,
e
:
any
)
=>
{
console
.
log
(
values
);
if
(
permissionArr
.
indexOf
(
'7'
)
<
0
)
{
message
.
error
(
'No Permissions!!!'
,
3
);
return
;
}
RA
(
39
,
{
id
:
values
.
id
,
ownerId
:
values
.
owner_id
});
};
...
...
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