diff --git a/auto_pt/urls.py b/auto_pt/urls.py index ace8384..429ea14 100644 --- a/auto_pt/urls.py +++ b/auto_pt/urls.py @@ -33,6 +33,7 @@ urlpatterns = [ path(r'show_log_list', views.show_log_list, name='show_log_list'), path(r'get_log_content', views.get_log_content, name='get_log_content'), path(r'download_log_file', views.download_log_file, name='download_log_file'), + path(r'get_config_setting', views.get_config_setting, name='get_config_setting'), path(r'remove_log_api', views.remove_log_api, name='remove_log_api'), path(r'get_site_list', views.get_site_list, name='get_site_list'), path(r'edit_my_site', views.edit_my_site, name='edit_my_site'), diff --git a/auto_pt/views.py b/auto_pt/views.py index e7d34a2..39831a9 100644 --- a/auto_pt/views.py +++ b/auto_pt/views.py @@ -10,6 +10,7 @@ import docker import git import qbittorrentapi import transmission_rpc +import yaml from django.contrib.auth.decorators import login_required from django.http import JsonResponse, FileResponse from django.shortcuts import render @@ -1093,3 +1094,25 @@ def get_site_torrents(request): return JsonResponse(data=CommonResponse.success( msg='种子抓取操作成功!' ).to_dict(), safe=False) + + +def get_config_setting(request): + file_path = os.path.join(BASE_DIR, 'db/ptools.yaml') + if not os.path.exists(file_path): + with open(file_path, 'r') as f: + f.write() + try: + with open(file_path, 'r') as f: + data = yaml.load(f, Loader=yaml.FullLoader) + print(data) + + with open(file_path, 'r') as f: + logs = f.readlines() + logger.info(f'日志行数:{len(logs)}') + return render(request, 'auto_pt/settings.html', context={ + 'config': logs + }) + except Exception as e: + return render(request, 'auto_pt/settings.html', context={ + 'config': f'{e}' + }) diff --git a/ptools/settings.py b/ptools/settings.py index c1d9395..44af1d0 100644 --- a/ptools/settings.py +++ b/ptools/settings.py @@ -284,5 +284,14 @@ SIMPLEUI_CONFIG = { 'icon': 'fab fa-blogger', 'url': '/tasks/show_log_list' }, ] + }, { + 'app': 'update', + 'name': '系统配置', + 'icon': 'fas fa-cog', + 'models': [{ + 'name': '修改配置', + 'icon': 'fas fa-edit', + 'url': '/tasks/get_config_setting' + }, ] }] } diff --git a/templates/auto_pt/settings.html b/templates/auto_pt/settings.html new file mode 100644 index 0000000..52c2390 --- /dev/null +++ b/templates/auto_pt/settings.html @@ -0,0 +1,41 @@ +{% load static %} + + + +
+ + +
+