mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-07-06 03:26:33 +00:00
feat: 修改docs的url
This commit is contained in:
parent
96551856a2
commit
7c479c2479
@ -67,14 +67,14 @@ if settings.XPACK_ENABLED:
|
||||
)
|
||||
|
||||
js_i18n_patterns = i18n_patterns(
|
||||
# path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),
|
||||
path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),
|
||||
)
|
||||
|
||||
|
||||
apps = [
|
||||
'users', 'assets', 'perms', 'terminal', 'ops', 'audits', 'orgs', 'auth',
|
||||
'applications', 'tickets', 'settings', 'xpack'
|
||||
'flower', 'luna', 'koko', 'ws', 'i18n', 'jsi18n', 'docs', 'redocs',
|
||||
'flower', 'luna', 'koko', 'ws', 'docs', 'redocs',
|
||||
]
|
||||
|
||||
|
||||
@ -94,23 +94,25 @@ urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \
|
||||
+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||
urlpatterns += js_i18n_patterns
|
||||
|
||||
# 兼容之前的
|
||||
old_app_pattern = '|'.join(apps)
|
||||
urlpatterns += [re_path(old_app_pattern, views.redirect_old_apps_view)]
|
||||
|
||||
handler404 = 'jumpserver.views.handler404'
|
||||
handler500 = 'jumpserver.views.handler500'
|
||||
|
||||
if settings.DEBUG:
|
||||
app_view_patterns += [
|
||||
re_path('^swagger(?P<format>\.json|\.yaml)$',
|
||||
urlpatterns += [
|
||||
re_path('^api/swagger(?P<format>\.json|\.yaml)$',
|
||||
views.get_swagger_view().without_ui(cache_timeout=1), name='schema-json'),
|
||||
path('docs/', views.get_swagger_view().with_ui('swagger', cache_timeout=1), name="docs"),
|
||||
path('redoc/', views.get_swagger_view().with_ui('redoc', cache_timeout=1), name='redoc'),
|
||||
path('api/docs/', views.get_swagger_view().with_ui('swagger', cache_timeout=1), name="docs"),
|
||||
path('api/redoc/', views.get_swagger_view().with_ui('redoc', cache_timeout=1), name='redoc'),
|
||||
|
||||
re_path('^v2/swagger(?P<format>\.json|\.yaml)$',
|
||||
re_path('^api/v2/swagger(?P<format>\.json|\.yaml)$',
|
||||
views.get_swagger_view().without_ui(cache_timeout=1), name='schema-json'),
|
||||
path('docs/v2/', views.get_swagger_view("v2").with_ui('swagger', cache_timeout=1), name="docs"),
|
||||
path('redoc/v2/', views.get_swagger_view("v2").with_ui('redoc', cache_timeout=1), name='redoc'),
|
||||
path('api/docs/v2/', views.get_swagger_view("v2").with_ui('swagger', cache_timeout=1), name="docs"),
|
||||
path('api/redoc/v2/', views.get_swagger_view("v2").with_ui('redoc', cache_timeout=1), name='redoc'),
|
||||
]
|
||||
|
||||
|
||||
# 兼容之前的
|
||||
old_app_pattern = '|'.join(apps)
|
||||
urlpatterns += [re_path(old_app_pattern, views.redirect_old_apps_view)]
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@ import time
|
||||
from django.http import HttpResponseRedirect, JsonResponse, Http404
|
||||
from django.conf import settings
|
||||
from django.views.generic import View
|
||||
from django.shortcuts import redirect
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from rest_framework.views import APIView
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
@ -55,6 +56,8 @@ def redirect_old_apps_view(request, *args, **kwargs):
|
||||
path = request.get_full_path()
|
||||
if path.find('/core') != -1:
|
||||
raise Http404()
|
||||
if path in ['/docs/', '/docs', '/core/docs/', '/core/docs']:
|
||||
return redirect('/api/docs/')
|
||||
new_path = '/core{}'.format(path)
|
||||
return HttpResponseTemporaryRedirect(new_path)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user