From 9d599b5e64751aa007ca96e547a7b0d3f507dc36 Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Mon, 25 Nov 2024 18:48:21 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=8F=98=E9=87=8F=E8=B4=A6=E5=8F=B7=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=95=88=E9=80=BB=E8=BE=91=20#42?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复首次部署管理账号密码环境变量不生效 - 使用环境变量优先设置用户名和密码 --- app/run.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/app/run.py b/app/run.py index 427b37c..d3716e7 100644 --- a/app/run.py +++ b/app/run.py @@ -288,16 +288,12 @@ def init(): dest.write(src.read()) data = read_json() # 默认管理账号 - if not data.get("webui"): - data["webui"] = { - "username": "admin", - "password": "admin123", - } - elif os.environ.get("WEBUI_USERNAME") and os.environ.get("WEBUI_PASSWORD"): - data["webui"] = { - "username": os.environ.get("WEBUI_USERNAME"), - "password": os.environ.get("WEBUI_PASSWORD"), - } + data["webui"] = { + "username": os.environ.get("WEBUI_USERNAME") + or data.get("webui", {}).get("username", "admin"), + "password": os.environ.get("WEBUI_PASSWORD") + or data.get("webui", {}).get("password", "admin123"), + } # 默认定时规则 if not data.get("crontab"): data["crontab"] = "0 8,18,20 * * *"