Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sun
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
谢林臻
sun
Commits
5b5e54a5
Commit
5b5e54a5
authored
Nov 16, 2018
by
Davve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
关闭权限认证
parent
d2380993
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
54 additions
and
28 deletions
+54
-28
account.py
api/account.py
+34
-9
group.py
api/group.py
+4
-4
urls.py
api/urls.py
+2
-2
login.js
vu/src/api/login.js
+1
-1
index.js
vu/src/mock/index.js
+1
-1
permission.js
vu/src/store/modules/permission.js
+8
-8
user.js
vu/src/store/modules/user.js
+3
-3
index.js
vu/src/utils/index.js
+1
-0
No files found.
api/account.py
View file @
5b5e54a5
...
...
@@ -15,13 +15,14 @@ class AccountList(APIView):
data
=
self
.
rpc
[
'venus/community/pick/get'
](
offset
=
page
,
limit
=
limit
,
filters
=
filter
)
.
unwrap
()
except
Exception
as
e
:
# raise e
data
=
{
'total'
:
100
,
'data'
:
[
{
'id'
:
1
,
'nickname'
:
'鹿晗1'
,
'password'
:
'21233423'
,
'email'
:
'www.baidu.com'
,
'username'
:
'admin1'
},
{
'id'
:
2
,
'nickname'
:
'鹿晗2'
,
'password'
:
'21233423'
,
'email'
:
'www.baidu.com'
,
'username'
:
'admin2'
},
{
'id'
:
3
,
'nickname'
:
'鹿晗3'
,
'password'
:
'21233423'
,
'email'
:
'www.baidu.com'
,
'username'
:
'admin3'
},
{
'id'
:
4
,
'nickname'
:
'鹿晗4'
,
'password'
:
'21233423'
,
'email'
:
'www.baidu.com'
,
'username'
:
'admin4'
},
pass
data
=
{
'total'
:
100
,
'data'
:
[
{
'id'
:
1
,
'nickname'
:
'鹿晗1'
,
'password'
:
'21233423'
,
'email'
:
'www.baidu.com'
,
'username'
:
'admin1'
},
{
'id'
:
2
,
'nickname'
:
'鹿晗2'
,
'password'
:
'21233423'
,
'email'
:
'www.baidu.com'
,
'username'
:
'admin2'
},
{
'id'
:
3
,
'nickname'
:
'鹿晗3'
,
'password'
:
'21233423'
,
'email'
:
'www.baidu.com'
,
'username'
:
'admin3'
},
{
'id'
:
4
,
'nickname'
:
'鹿晗4'
,
'password'
:
'21233423'
,
'email'
:
'www.baidu.com'
,
'username'
:
'admin4'
},
]
}
return
data
...
...
@@ -65,4 +66,28 @@ class LoginView(APIView):
class
LogoutView
(
APIView
):
def
post
(
self
,
request
):
pass
\ No newline at end of file
pass
class
AccountUpdateOrCreateView
(
APIView
):
def
get
(
self
,
request
):
map
=
{
'admin'
:
{
'roles'
:
[
'admin'
],
'token'
:
'admin'
,
'introduction'
:
'我是超级管理员'
,
'avatar'
:
'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif'
,
'name'
:
'Super Admin'
},
'editor'
:
{
'roles'
:
[
'editor'
],
'token'
:
'editor'
,
'introduction'
:
'我是编辑'
,
'avatar'
:
'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif'
,
'name'
:
'Normal Editor'
}
}
token
=
request
.
GET
.
get
(
'token'
)
return
{
'data'
:
map
[
'admin'
]
}
\ No newline at end of file
api/group.py
View file @
5b5e54a5
...
...
@@ -8,11 +8,11 @@ from utils.base import APIView
class
GroupListView
(
APIView
):
def
get
(
self
,
request
):
page
=
request
.
GET
.
get
(
'page'
,
1
)
limi
t
=
request
.
GET
.
get
(
'limit'
,
10
)
filter
=
self
.
handle_filter
(
request
.
GET
.
get
(
'filter'
,
""
))
offset
=
request
.
GET
.
get
(
'page'
,
1
)
coun
t
=
request
.
GET
.
get
(
'limit'
,
10
)
filter
s
=
self
.
handle_filter
(
request
.
GET
.
get
(
'filter'
,
""
))
try
:
data
=
self
.
rpc
[
'venus/community/group/
get'
](
offset
=
page
,
limit
=
limit
,
filters
=
filter
)
.
unwrap
()
data
=
self
.
rpc
[
'venus/community/group/
list'
](
filters
=
filters
,
offset
=
offset
,
count
=
count
)
.
unwrap
()
except
Exception
as
e
:
# raise e
data
=
{
...
...
api/urls.py
View file @
5b5e54a5
...
...
@@ -20,8 +20,8 @@ urlpatterns = [
url
(
r'account/logout'
,
LogoutView
.
as_view
()),
url
(
r'account/list'
,
AccountList
.
as_view
()),
url
(
r'account/update'
,
AccountList
.
as_view
()),
url
(
r'account/get'
,
UpdateOrCreateView
.
as_view
()),
url
(
r'account/create'
,
UpdateOrCreateView
.
as_view
()),
url
(
r'account/get'
,
Account
UpdateOrCreateView
.
as_view
()),
url
(
r'account/create'
,
Account
UpdateOrCreateView
.
as_view
()),
# user相关
url
(
r'user/list$'
,
UserListView
.
as_view
()),
...
...
vu/src/api/login.js
View file @
5b5e54a5
...
...
@@ -21,7 +21,7 @@ export function logout() {
export
function
getUserInfo
(
token
)
{
return
request
({
url
:
'/
user/info
'
,
url
:
'/
api/account/get
'
,
method
:
'get'
,
params
:
{
token
}
})
...
...
vu/src/mock/index.js
View file @
5b5e54a5
...
...
@@ -19,7 +19,7 @@ Mock.XHR.prototype.send = function() {
// })
// 登录相关
//
Mock.mock(/\/login\/login/, 'post', loginAPI.loginByUsername)
Mock
.
mock
(
/
\/
login
\/
login/
,
'post'
,
loginAPI
.
loginByUsername
)
Mock
.
mock
(
/
\/
login
\/
logout/
,
'post'
,
loginAPI
.
logout
)
Mock
.
mock
(
/
\/
user
\/
info
\.
*/
,
'get'
,
loginAPI
.
getUserInfo
)
...
...
vu/src/store/modules/permission.js
View file @
5b5e54a5
...
...
@@ -48,14 +48,14 @@ const permission = {
actions
:
{
GenerateRoutes
({
commit
},
data
)
{
return
new
Promise
(
resolve
=>
{
const
{
roles
}
=
data
let
accessedRouters
if
(
roles
.
includes
(
'admin'
))
{
accessedRouters
=
asyncRouterMap
}
else
{
accessedRouters
=
filterAsyncRouter
(
asyncRouterMap
,
roles
)
}
commit
(
'SET_ROUTERS'
,
a
ccessedRouters
)
//
const { roles } = data
// const accessedRouters = asyncRouterMap
//
if (roles.includes('admin')) {
//
accessedRouters = asyncRouterMap
//
} else {
//
accessedRouters = filterAsyncRouter(asyncRouterMap, roles)
//
}
commit
(
'SET_ROUTERS'
,
a
syncRouterMap
)
resolve
()
})
}
...
...
vu/src/store/modules/user.js
View file @
5b5e54a5
...
...
@@ -53,7 +53,8 @@ const user = {
const
username
=
userInfo
.
username
.
trim
()
return
new
Promise
((
resolve
,
reject
)
=>
{
loginByUsername
(
username
,
userInfo
.
password
).
then
(
response
=>
{
const
data
=
response
.
data
.
data
const
data
=
response
.
data
console
.
log
(
data
)
commit
(
'SET_TOKEN'
,
data
.
token
)
commit
(
'SET_ID'
,
data
.
id
)
setToken
(
response
.
data
.
token
)
...
...
@@ -71,8 +72,7 @@ const user = {
if
(
!
response
.
data
)
{
// 由于mockjs 不支持自定义状态码只能这样hack
reject
(
'error'
)
}
const
data
=
response
.
data
const
data
=
response
.
data
.
data
.
data
if
(
data
.
roles
&&
data
.
roles
.
length
>
0
)
{
// 验证返回的roles是否是一个非空数组
commit
(
'SET_ROLES'
,
data
.
roles
)
}
else
{
...
...
vu/src/utils/index.js
View file @
5b5e54a5
...
...
@@ -127,6 +127,7 @@ export function param2Obj(url) {
if
(
!
search
)
{
return
{}
}
console
.
log
(
url
)
return
JSON
.
parse
(
'{"'
+
decodeURIComponent
(
search
)
...
...
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