优化下界面显示

This commit is contained in:
ngfchl
2023-01-04 21:09:49 +08:00
parent 8af923dc33
commit 5d13b0e1d7
2 changed files with 32 additions and 10 deletions

View File

@@ -1123,9 +1123,12 @@ def get_config_html(request):
def save_config_api(request):
file_path = os.path.join(BASE_DIR, 'db/ptools.toml')
content = json.loads(request.body.decode())
logger.info(content.get('settings'))
if content.get('name') == 'ptools.toml':
file_path = os.path.join(BASE_DIR, 'db/ptools.toml')
if content.get('name') == 'hosts':
file_path = '/etc/hosts'
try:
with open(file_path, 'w') as f:
f.write(content.get('settings'))
@@ -1133,8 +1136,9 @@ def save_config_api(request):
msg='配置文件保存成功!'
).to_dict(), safe=False)
except Exception as e:
raise
return JsonResponse(data=CommonResponse.error(
msg='获取配置文件信息失败!'
msg=f'获取配置文件信息失败!{e}'
).to_dict(), safe=False)