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
39257d20
Commit
39257d20
authored
Dec 04, 2018
by
Davve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改问题
parent
10763992
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
93 additions
and
49 deletions
+93
-49
account.py
api/account.py
+12
-4
group.py
api/group.py
+6
-3
push.py
api/push.py
+4
-1
topic.py
api/topic.py
+2
-2
user.py
api/user.py
+2
-2
time_utils.py
utils/time_utils.py
+1
-1
permission.js
vu/src/permission.js
+1
-1
account.js
vu/src/router/modules/account.js
+4
-2
group.js
vu/src/router/modules/group.js
+2
-1
pick.js
vu/src/router/modules/pick.js
+2
-1
push.js
vu/src/router/modules/push.js
+2
-1
star.js
vu/src/router/modules/star.js
+2
-1
tag.js
vu/src/router/modules/tag.js
+2
-1
topic.js
vu/src/router/modules/topic.js
+2
-1
user.js
vu/src/router/modules/user.js
+2
-1
permission.js
vu/src/store/modules/permission.js
+10
-8
user.js
vu/src/store/modules/user.js
+1
-1
index.vue
vu/src/views/dashboard/index.vue
+2
-2
list.vue
vu/src/views/group/list.vue
+13
-11
list.vue
vu/src/views/tag/list.vue
+4
-0
TopicDetail.vue
vu/src/views/topic/components/TopicDetail.vue
+3
-0
UserDetail.vue
vu/src/views/user/components/UserDetail.vue
+7
-4
list.vue
vu/src/views/user/list.vue
+7
-0
No files found.
api/account.py
View file @
39257d20
...
...
@@ -78,6 +78,10 @@ class LoginView(APIView):
data
.
update
({
'avatar'
:
settings
.
AVATAR
})
if
data
[
'is_staff'
]:
data
.
update
({
'roles'
:
[
'staff'
]})
else
:
data
.
update
({
'roles'
:
[
'anonymous'
]})
except
Exception
as
e
:
error_logger
.
error
(
u'获取用户信息失败,
%
s'
%
(
id
,
e
))
raise
...
...
@@ -94,7 +98,7 @@ class LoginView(APIView):
try
:
data
=
self
.
rpc
[
'venus/sun/account/login'
](
username
=
username
,
password
=
password
)
.
unwrap
()
if
data
[
'success'
]
or
all
([
username
==
settings
.
USERNAME
,
password
==
settings
.
PASSWORD
]):
data
=
{
ret
=
{
'id'
:
data
[
'id'
],
'avatar'
:
settings
.
AVATAR
,
'name'
:
data
[
'username'
],
...
...
@@ -102,19 +106,23 @@ class LoginView(APIView):
'success'
:
1
,
}
else
:
data
=
{
ret
=
{
'id'
:
data
[
'id'
],
'avatar'
:
settings
.
AVATAR
,
'name'
:
''
,
'session_key'
:
data
[
'session'
],
'success'
:
0
,
'message'
:
data
[
'message'
]
'message'
:
data
[
'message'
]
,
}
except
Exception
as
e
:
error_logger
.
error
(
u'登陆失败
%
s'
,
e
)
raise
if
data
[
'is_staff'
]:
ret
.
update
({
'roles'
:
[
'staff'
]})
else
:
ret
.
update
({
'roles'
:
[
'anonymous'
]})
return
{
'data'
:
data
'data'
:
ret
}
...
...
api/group.py
View file @
39257d20
...
...
@@ -52,14 +52,17 @@ class GroupUpdateOrCreate(APIView):
try
:
data
=
self
.
rpc
[
'venus/sun/group/get'
](
id
=
id
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'获取
%
d
用户信息失败
%
s'
%
(
id
,
e
))
error_logger
.
error
(
u'获取
%
s
用户信息失败
%
s'
%
(
id
,
e
))
raise
return
data
def
post
(
self
,
request
):
id
=
request
.
POST
.
get
(
'id'
)
star_ids
=
list
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
(
request
.
POST
.
get
(
'star'
,
'[]'
))))
group_user_ids
=
list
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
(
request
.
POST
.
get
(
'group_users'
,
'[]'
))))
try
:
group_user_ids
=
list
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
(
request
.
POST
.
get
(
'group_users'
,
'[]'
))))
except
:
group_user_ids
=
json
.
loads
(
request
.
POST
.
get
(
'group_users'
,
'[]'
))
data
=
{
'name'
:
request
.
POST
.
get
(
'name'
,
''
),
'description'
:
request
.
POST
.
get
(
'description'
,
''
),
...
...
@@ -73,7 +76,7 @@ class GroupUpdateOrCreate(APIView):
try
:
self
.
rpc
[
'venus/sun/group/edit'
](
id
=
id
,
data
=
data
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'编辑
%
d
用户信息失败
%
s'
%
(
id
,
e
))
error_logger
.
error
(
u'编辑
%
s
用户信息失败
%
s'
%
(
id
,
e
))
raise
return
{
'message'
:
'更新成功'
...
...
api/push.py
View file @
39257d20
...
...
@@ -37,11 +37,14 @@ class PushUpdateOrCreateView(APIView):
push_time
=
analysis_time
(
request
.
POST
.
get
(
'push_time'
,
0
))
group_topic_id
=
request
.
POST
.
get
(
'group_topic_id'
,
''
)
full_url
=
request
.
POST
.
get
(
'url'
,
''
)
+
group_topic_id
icon
=
request
.
POST
.
get
(
'icon'
,
''
)
if
icon
.
endswith
(
'-w'
):
icon
=
request
.
POST
.
get
(
'icon'
,
''
)[:
-
2
]
data
=
{
'url'
:
full_url
,
'push_time'
:
push_time
,
'icon'
:
request
.
POST
.
get
(
'icon'
,
''
)[:
-
2
]
,
'icon'
:
icon
,
'content'
:
request
.
POST
.
get
(
'content'
,
''
),
'title'
:
request
.
POST
.
get
(
'title'
,
''
),
'creator_id'
:
creator_id
...
...
api/topic.py
View file @
39257d20
...
...
@@ -41,7 +41,6 @@ class TopicUpdateOrCreateView(APIView):
def
post
(
self
,
request
):
id
=
request
.
POST
.
get
(
'id'
,
''
)
posting_time
=
analysis_time
(
request
.
POST
.
get
(
'posting_time'
,
0
))
topic_images
=
list
(
map
(
lambda
x
:
x
[:
-
2
],
json
.
loads
(
request
.
POST
.
get
(
'topic_images'
,
[]))))
tag_ids
=
list
(
map
(
lambda
x
:
x
.
split
(
':'
)[
0
],
json
.
loads
(
request
.
POST
.
get
(
'tags'
,
'[]'
))))
...
...
@@ -73,7 +72,7 @@ class ReplyUpdateOrCreateView(APIView):
offset
=
int
(
request
.
GET
.
get
(
'page'
,
0
))
limit
=
int
(
request
.
GET
.
get
(
'limit'
,
10
))
filter
=
self
.
handle_filter
(
request
.
GET
.
get
(
'filter'
,
""
))
filter
.
update
({
'topic_id'
:
id
,
'is_online'
:
1
})
filter
.
update
({
'topic_id'
:
id
})
try
:
data
=
self
.
rpc
[
'venus/sun/topic/reply/list'
](
offset
=
(
offset
-
1
)
*
limit
,
limit
=
limit
,
filters
=
filter
)
.
unwrap
()
except
Exception
as
e
:
...
...
@@ -95,6 +94,7 @@ class ReplyUpdateOrCreateView(APIView):
class
ReplyCreate
(
APIView
):
def
post
(
self
,
request
):
request
.
POST
.
get
(
'be_replied_id'
,
None
)
data
=
{
'user_id'
:
request
.
POST
.
get
(
'user_id'
)
.
split
(
':'
)[
0
],
'replied_id'
:
request
.
POST
.
get
(
"replied_id"
,
None
),
...
...
api/user.py
View file @
39257d20
...
...
@@ -32,7 +32,7 @@ class UserUpdateOrCreate(APIView):
try
:
data
=
self
.
rpc
[
'venus/sun/user/get'
](
id
=
id
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'获取
%
d
用户详情失败
%
s'
%
(
id
,
e
))
error_logger
.
error
(
u'获取
%
s
用户详情失败
%
s'
%
(
id
,
e
))
raise
return
data
...
...
@@ -59,7 +59,7 @@ class UserUpdateOrCreate(APIView):
try
:
self
.
rpc
[
'venus/sun/user/edit'
](
id
=
id
,
data
=
data
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'创建/编辑
%
d
用户详情失败
%
s'
%
(
id
,
e
))
error_logger
.
error
(
u'创建/编辑
%
s
用户详情失败
%
s'
%
(
id
,
e
))
raise
return
{
'message'
:
'更新成功'
...
...
utils/time_utils.py
View file @
39257d20
...
...
@@ -54,7 +54,7 @@ def analysis_time(time):
:return:
"""
try
:
target_time
=
unix_time_to_datetime
(
int
(
time
)
/
1000
)
target_time
=
unix_time_to_datetime
(
int
(
float
(
time
)
)
/
1000
)
except
ValueError
:
target_time
=
utc_to_datetime
(
time
[:
-
5
]
+
'Z'
)
...
...
vu/src/permission.js
View file @
39257d20
...
...
@@ -26,7 +26,7 @@ router.beforeEach((to, from, next) => {
}
else
{
if
(
store
.
getters
.
roles
.
length
===
0
)
{
// 判断当前用户是否已拉取完user_info信息
store
.
dispatch
(
'GetUserInfo'
).
then
(
res
=>
{
// 拉取user_info
const
roles
=
res
.
data
.
roles
// note: roles must be a array! such as: ['editor','develop']
const
roles
=
res
.
data
.
data
.
data
.
roles
// note: roles must be a array! such as: ['editor','develop']
store
.
dispatch
(
'GenerateRoutes'
,
{
roles
}).
then
(()
=>
{
// 根据roles权限生成可访问的路由表
router
.
addRoutes
(
store
.
getters
.
addRouters
)
// 动态添加可访问路由表
next
({
...
to
,
replace
:
true
})
// hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
...
...
vu/src/router/modules/account.js
View file @
39257d20
...
...
@@ -9,14 +9,16 @@ const AccountRouter = {
name
:
'Account'
,
meta
:
{
title
:
'账号管理'
,
icon
:
'component'
icon
:
'component'
,
roles
:
[
'staff'
]
},
children
:
[
{
path
:
'list'
,
component
:
()
=>
import
(
'@/views/account/list'
),
name
:
'AccountList'
,
meta
:
{
title
:
'账户列表'
,
icon
:
'list'
}
meta
:
{
title
:
'账户列表'
,
icon
:
'list'
}
},
{
path
:
'create'
,
...
...
vu/src/router/modules/group.js
View file @
39257d20
...
...
@@ -9,7 +9,8 @@ const GroupRouter = {
name
:
'Group'
,
meta
:
{
title
:
'小组管理'
,
icon
:
'component'
icon
:
'component'
,
roles
:
[
'staff'
]
},
children
:
[
{
...
...
vu/src/router/modules/pick.js
View file @
39257d20
...
...
@@ -9,7 +9,8 @@ const PickRouter = {
name
:
'Pick'
,
meta
:
{
title
:
'Pick管理'
,
icon
:
'component'
icon
:
'component'
,
roles
:
[
'staff'
]
},
children
:
[
{
...
...
vu/src/router/modules/push.js
View file @
39257d20
...
...
@@ -9,7 +9,8 @@ const PushRouter = {
name
:
'Push'
,
meta
:
{
title
:
'Push管理'
,
icon
:
'component'
icon
:
'component'
,
roles
:
[
'staff'
]
},
children
:
[
{
...
...
vu/src/router/modules/star.js
View file @
39257d20
...
...
@@ -9,7 +9,8 @@ const StarRouter = {
name
:
'Star'
,
meta
:
{
title
:
'明星管理'
,
icon
:
'component'
icon
:
'component'
,
roles
:
[
'staff'
]
},
children
:
[
{
...
...
vu/src/router/modules/tag.js
View file @
39257d20
...
...
@@ -7,7 +7,8 @@ const TagRouter = {
name
:
'Tag'
,
meta
:
{
title
:
'标签管理'
,
icon
:
'component'
icon
:
'component'
,
roles
:
[
'staff'
,
'anonymous'
]
},
children
:
[
{
...
...
vu/src/router/modules/topic.js
View file @
39257d20
...
...
@@ -9,7 +9,8 @@ const TopicRouter = {
name
:
'Topic'
,
meta
:
{
title
:
'帖子管理'
,
icon
:
'component'
icon
:
'component'
,
roles
:
[
'staff'
,
'anonymous'
]
},
children
:
[
{
...
...
vu/src/router/modules/user.js
View file @
39257d20
...
...
@@ -9,7 +9,8 @@ const GroupRouter = {
name
:
'User'
,
meta
:
{
title
:
'用户管理'
,
icon
:
'component'
icon
:
'component'
,
roles
:
[
'staff'
,
'anonymous'
]
},
children
:
[
{
...
...
vu/src/store/modules/permission.js
View file @
39257d20
...
...
@@ -48,14 +48,16 @@ const permission = {
actions
:
{
GenerateRoutes
({
commit
},
data
)
{
return
new
Promise
(
resolve
=>
{
// const { roles } = data
// const accessedRouters = asyncRouterMap
// if (roles.includes('admin')) {
// accessedRouters = asyncRouterMap
// } else {
// accessedRouters = filterAsyncRouter(asyncRouterMap, roles)
// }
commit
(
'SET_ROUTERS'
,
asyncRouterMap
)
const
{
roles
}
=
data
let
accessedRouters
if
(
roles
.
includes
(
'staff'
))
{
accessedRouters
=
asyncRouterMap
console
.
log
(
accessedRouters
,
'-----'
)
}
else
{
accessedRouters
=
filterAsyncRouter
(
asyncRouterMap
,
roles
)
console
.
log
(
accessedRouters
)
}
commit
(
'SET_ROUTERS'
,
accessedRouters
)
resolve
()
})
}
...
...
vu/src/store/modules/user.js
View file @
39257d20
...
...
@@ -83,7 +83,7 @@ const user = {
reject
(
'error'
)
}
const
data
=
response
.
data
.
data
.
data
data
.
roles
=
[
'admin'
]
//
data.roles = ['admin']
if
(
data
.
roles
&&
data
.
roles
.
length
>
0
)
{
// 验证返回的roles是否是一个非空数组
commit
(
'SET_ROLES'
,
data
.
roles
)
}
else
{
...
...
vu/src/views/dashboard/index.vue
View file @
39257d20
...
...
@@ -23,8 +23,8 @@ export default {
])
},
created
()
{
if
(
!
this
.
roles
.
includes
(
'
admin
'
))
{
this
.
currentRole
=
'
editor
Dashboard'
if
(
!
this
.
roles
.
includes
(
'
staff
'
))
{
this
.
currentRole
=
'
admin
Dashboard'
}
}
}
...
...
vu/src/views/group/list.vue
View file @
39257d20
...
...
@@ -48,17 +48,21 @@
<el-table-column
align=
"center"
label=
"用户数"
>
<
template
slot-scope=
"scope"
>
<router-link
:to=
"
{path: '/user/list/', query: {group_id: scope.row.id}}" class="link-type">
<router-link
:to=
"
{path: '/user/list/', query: {group_id: scope.row.id}}" class="link-type"
v-if="this.adminRole"
>
<span>
{{
scope
.
row
.
user_nums
}}
</span>
</router-link>
<span
v-else
>
{{
scope
.
row
.
user_nums
}}
</span>
</
template
>
</el-table-column>
<el-table-column
align=
"center"
label=
"帖子数"
>
<
template
slot-scope=
"scope"
>
<router-link
:to=
"
{path: '/topic/list/', query: {group_id: scope.row.id}}" class="link-type">
<router-link
:to=
"
{path: '/topic/list/', query: {group_id: scope.row.id}}" class="link-type"
v-if="this.adminRole"
>
<span>
{{
scope
.
row
.
topic_nums
}}
</span>
</router-link>
<span
v-else
>
{{
scope
.
row
.
topic_nums
}}
</span>
</
template
>
</el-table-column>
...
...
@@ -89,6 +93,7 @@
</template>
<
script
>
import
{
mapGetters
}
from
'vuex'
import
{
fetchList
,
OffLineOrOnLine
}
from
'@/api/group'
import
Pagination
from
'@/components/Pagination'
// Secondary package based on el-pagination
import
waves
from
'@/directive/waves'
...
...
@@ -104,15 +109,12 @@ export default {
0
:
'info'
,
}
return
statusMap
[
status
]
},
genderFilter
(
status
)
{
const
statusMap
=
{
'男'
:
'success'
,
'女'
:
'info'
,
'全部'
:
'danger'
}
return
statusMap
[
status
]
},
}
},
computed
:
{
...
mapGetters
([
'roles'
])
},
data
()
{
return
{
...
...
vu/src/views/tag/list.vue
View file @
39257d20
...
...
@@ -131,6 +131,10 @@ export default {
},
handleFilter
()
{
this
.
listQuery
.
offset
=
1
if
(
this
.
listQuery
.
filter
.
key
==
'id'
&&
!
/^
\d
+$/
.
test
(
this
.
listQuery
.
filter
.
value
)){
this
.
$message
.
error
(
"搜索条件不合法, 重新输入"
)
return
false
;
}
this
.
getList
()
},
handleCreate
()
{
...
...
vu/src/views/topic/components/TopicDetail.vue
View file @
39257d20
...
...
@@ -407,6 +407,7 @@
temp
:
{
user_id
:
''
,
content
:
''
,
be_replied_id
:
''
,
},
dialogFormVisible
:
false
,
dialogStatus
:
''
,
...
...
@@ -675,11 +676,13 @@
this
.
temp
=
{
user_id
:
''
,
content
:
''
,
be_replied_id
:
''
,
}
},
reply
(
row
)
{
this
.
resetTemp
()
if
(
row
){
// this.temp.be_replied_id = row.be_reply_user.id
this
.
temp
.
replied_id
=
row
.
id
}
this
.
dialogStatus
=
'create'
...
...
vu/src/views/user/components/UserDetail.vue
View file @
39257d20
...
...
@@ -45,7 +45,8 @@
</el-row>
<el-row>
<el-col
:span=
"12"
>
<el-form-item
style=
"margin-bottom: 20px;"
label-width=
"75px"
label=
"用户名:"
prop=
"nick_name"
>
<el-form-item
style=
"margin-bottom: 20px;"
label-width=
"75px"
label=
"*用户名:"
prop=
"nick_name"
>
<el-input
v-model=
"postForm.nick_name"
type=
"text"
style=
"width: 230px"
/>
</el-form-item>
</el-col>
...
...
@@ -70,7 +71,7 @@
</el-row>
<el-row>
<el-col
:span=
"12"
>
<el-form-item
label-width=
"75px"
label=
"性别:"
prop=
"gender"
>
<el-form-item
label-width=
"75px"
label=
"
*
性别:"
prop=
"gender"
>
<el-select
v-model=
"postForm.gender"
:placeholder=
"'性别:'"
clearable
class=
"postInfo-container-item"
style=
"width: 230px"
>
...
...
@@ -80,7 +81,7 @@
</el-form-item>
</el-col>
<el-col
:span=
"12"
>
<el-form-item
label-width=
"75px"
label=
"城市:"
>
<el-form-item
label-width=
"75px"
label=
"
*
城市:"
>
<el-select
v-model=
"city"
:remote-method=
"getRemoteCityList"
filterable
remote
clearable
value-key=
"id"
placeholder=
"搜索城市"
style=
"width: 230px"
>
...
...
@@ -125,7 +126,7 @@
</el-row>
<div
style=
"margin-bottom: 20px;"
>
<el-form-item
style=
"margin-bottom: 40px;"
label-width=
"
75px"
label=
"
用户头像:"
prop=
"avatar"
>
<el-form-item
style=
"margin-bottom: 40px;"
label-width=
"
85px"
label=
"*
用户头像:"
prop=
"avatar"
>
<span
v-model=
"uploadType"
></span>
<Upload
v-model=
"postForm.avatar"
:uploadType=
"uploadType"
/>
</el-form-item>
...
...
@@ -160,6 +161,7 @@
password
:
''
,
avatar
:
''
,
nick_name
:
''
,
gender
:
''
,
tags
:
[],
is_puppet
:
1
,
...
...
@@ -248,6 +250,7 @@
this
.
loading
=
false
return
false
}
console
.
log
(
this
.
postForm
.
gender
)
if
(
this
.
postForm
.
gender
===
''
){
this
.
$message
.
error
(
'性别必填~'
)
this
.
loading
=
false
...
...
vu/src/views/user/list.vue
View file @
39257d20
...
...
@@ -110,6 +110,7 @@
import
{
fetchList
,
OffLineOrOnLine
}
from
'@/api/user'
import
Pagination
from
'@/components/Pagination'
// Secondary package based on el-pagination
import
waves
from
'@/directive/waves'
import
{
mapGetters
}
from
'vuex'
export
default
{
name
:
'UserList'
,
...
...
@@ -134,6 +135,7 @@
directives
:
{
waves
},
data
()
{
return
{
adminRole
:
true
,
list
:
null
,
total
:
0
,
listLoading
:
true
,
...
...
@@ -174,6 +176,11 @@
created
()
{
this
.
getList
()
},
computed
:
{
...
mapGetters
([
'roles'
])
},
methods
:
{
getList
()
{
this
.
listLoading
=
true
...
...
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