mirror of
https://github.com/hequan2017/seal.git
synced 2026-02-03 10:13:27 +08:00
动态菜单
This commit is contained in:
@@ -234,7 +234,7 @@ REST_FRAMEWORK = {
|
||||
'rest_framework.renderers.BrowsableAPIRenderer' #注释掉 可以关闭 api web界面
|
||||
),
|
||||
'DEFAULT_PERMISSION_CLASSES': (
|
||||
# 'rest_framework.permissions.AllowAny',
|
||||
'rest_framework.permissions.AllowAny',
|
||||
'rest_framework.permissions.IsAuthenticated',
|
||||
),
|
||||
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from django.urls import path
|
||||
from system.views import login_view, UserPasswordUpdateView, logout_view, UserInfo, UserLogout
|
||||
from system.views import login_view, UserPasswordUpdateView, logout_view, UserInfo, UserLogout,MockMenu
|
||||
|
||||
app_name = "system"
|
||||
|
||||
@@ -10,5 +10,6 @@ urlpatterns = [
|
||||
|
||||
|
||||
path('api/user_info', UserInfo.as_view()),
|
||||
path('api/logout', UserLogout.as_view())
|
||||
path('api/logout', UserLogout.as_view()),
|
||||
path('mock_menu',MockMenu.as_view())
|
||||
]
|
||||
|
||||
@@ -34,7 +34,8 @@ class UserInfo(APIView):
|
||||
result = {
|
||||
'name': obj.username,
|
||||
'user_id': obj.id,
|
||||
'access': list(obj.get_all_permissions())+['admin'] if obj.is_superuser else list(obj.get_all_permissions()),
|
||||
'access': list(obj.get_all_permissions()) + ['admin'] if obj.is_superuser else list(
|
||||
obj.get_all_permissions()),
|
||||
'token': token,
|
||||
'avatar': 'https://file.iviewui.com/dist/a0e88e83800f138b94d2414621bd9704.png'
|
||||
}
|
||||
@@ -49,11 +50,63 @@ class UserLogout(APIView):
|
||||
obj = Token.objects.get(key=token)
|
||||
obj.delete()
|
||||
result = {
|
||||
"status": True
|
||||
"status": True
|
||||
}
|
||||
return HttpResponse(json.dumps(result))
|
||||
|
||||
|
||||
class MockMenu(APIView):
|
||||
|
||||
def post(self, request):
|
||||
result = [
|
||||
|
||||
{
|
||||
"path": '/assets',
|
||||
"name": 'assets',
|
||||
"meta": {
|
||||
"icon": 'md-menu',
|
||||
"title": '资产管理'
|
||||
},
|
||||
"component": 'Main',
|
||||
"children": [
|
||||
{
|
||||
'path': 'ecs',
|
||||
'name': 'ecs',
|
||||
'meta': {
|
||||
'access': ['assets.view_ecs'],
|
||||
'icon': 'md-funnel',
|
||||
'title': 'ecs'
|
||||
},
|
||||
'component': 'assets/ecs/ecs-list'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": '/multilevel',
|
||||
"name": 'multilevel',
|
||||
"meta": {
|
||||
"icon": 'md-menu',
|
||||
"title": '多级菜单'
|
||||
},
|
||||
"component": 'Main',
|
||||
"children": [
|
||||
{
|
||||
"path": '/level_2_1',
|
||||
"name": 'level_2_1',
|
||||
"meta": {
|
||||
"icon": 'md-funnel',
|
||||
"title": '二级-1'
|
||||
},
|
||||
"component": 'multilevel/level-2-1'
|
||||
},
|
||||
|
||||
]
|
||||
}
|
||||
]
|
||||
print(result)
|
||||
return HttpResponse(json.dumps(result))
|
||||
|
||||
|
||||
class CustomBackend(ModelBackend):
|
||||
"""
|
||||
用户名字/邮箱名字 登录
|
||||
|
||||
Reference in New Issue
Block a user