fix: 安装依赖错误,swagger文档无法访问,前端env文件,数据库迁移文件,忽略poetry.lock文件
This commit is contained in:
parent
dbe8e519a9
commit
fd43ade906
|
@ -164,4 +164,5 @@ ui/dist
|
|||
apps/static
|
||||
data
|
||||
.idea
|
||||
.dev
|
||||
.dev
|
||||
poetry.lock
|
|
@ -42,28 +42,46 @@ schema_view = get_schema_view(
|
|||
|
||||
urlpatterns = [
|
||||
path("api/", include("users.urls")),
|
||||
# 暴露静态主要是swagger资源
|
||||
re_path(r'^static/(?P<path>.*)$', static.serve, {'document_root': settings.STATIC_ROOT}, name='static'),
|
||||
# 暴露ui静态资源
|
||||
re_path(r'^ui/(?P<path>.*)$', static.serve, {'document_root': os.path.join(settings.STATIC_ROOT, "ui")}, name='ui'),
|
||||
]
|
||||
|
||||
|
||||
def pro():
|
||||
# 暴露静态主要是swagger资源
|
||||
urlpatterns.append(
|
||||
re_path(r'^static/(?P<path>.*)$', static.serve, {'document_root': settings.STATIC_ROOT}, name='static'),
|
||||
)
|
||||
# 暴露ui静态资源
|
||||
urlpatterns.append(
|
||||
re_path(r'^ui/(?P<path>.*)$', static.serve, {'document_root': os.path.join(settings.STATIC_ROOT, "ui")},
|
||||
name='ui'),
|
||||
)
|
||||
|
||||
|
||||
if not settings.DEBUG:
|
||||
pro()
|
||||
|
||||
|
||||
def page_not_found(request, exception):
|
||||
"""
|
||||
页面不存在处理
|
||||
"""
|
||||
if request.path.startswith("/api/"):
|
||||
return Result(response_status=status.HTTP_404_NOT_FOUND, code=404, message="找不到接口")
|
||||
else:
|
||||
index_path = os.path.join(PROJECT_DIR, 'apps', "static", 'ui', 'index.html')
|
||||
if not os.path.exists(index_path):
|
||||
return HttpResponse("页面不存在", status=404)
|
||||
file = open(index_path, "r", encoding='utf-8')
|
||||
content = file.read()
|
||||
file.close()
|
||||
return HttpResponse(content, status=200)
|
||||
|
||||
|
||||
handler404 = page_not_found
|
||||
|
||||
urlpatterns += [
|
||||
re_path(r'^doc(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0),
|
||||
name='schema-json'), # 导出
|
||||
path('doc/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
|
||||
path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
|
||||
]
|
||||
|
||||
|
||||
def page_not_found(request, exception):
|
||||
if request.path.startswith("/api/"):
|
||||
return Result(response_status=status.HTTP_404_NOT_FOUND, code=404, message="找不到接口")
|
||||
else:
|
||||
file = open(os.path.join(PROJECT_DIR, 'apps', "static", 'ui', 'index.html'), "r", encoding='utf-8')
|
||||
content = file.read()
|
||||
file.close()
|
||||
return HttpResponse(content, status=200)
|
||||
|
||||
|
||||
handler404 = page_not_found
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
# Generated by Django 4.1.10 on 2023-09-20 02:58
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='User',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('email', models.EmailField(max_length=254, unique=True, verbose_name='邮箱')),
|
||||
('username', models.CharField(max_length=150, unique=True, verbose_name='用户名')),
|
||||
('password', models.CharField(max_length=150, verbose_name='密码')),
|
||||
('role', models.CharField(max_length=150, verbose_name='角色')),
|
||||
('is_active', models.BooleanField(default=True)),
|
||||
],
|
||||
options={
|
||||
'db_table': 'user',
|
||||
},
|
||||
),
|
||||
]
|
1
main.py
1
main.py
|
@ -69,4 +69,5 @@ if __name__ == '__main__':
|
|||
elif action == "collect_static":
|
||||
collect_static()
|
||||
else:
|
||||
collect_static()
|
||||
start_services()
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,7 +13,7 @@ drf-yasg = "1.21.7"
|
|||
django-filter = "23.2"
|
||||
elasticsearch = "8.9.0"
|
||||
langchain = "0.0.274"
|
||||
psycopg2 = "2.9.7"
|
||||
psycopg2-binary = "2.9.7"
|
||||
jieba = "^0.42.1"
|
||||
diskcache = "^5.6.3"
|
||||
pillow = "9.5.0"
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
VITE_APP_NAME=ui
|
||||
VITE_BASE_PATH=/ui/
|
||||
VITE_APP_PORT=3000
|
Loading…
Reference in New Issue