中控支持一键安装到桌面,HTTPS 下可装成独立应用。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-05 18:54:59 +08:00
parent 470c6ba261
commit 0327f49f4e
15 changed files with 220 additions and 5 deletions
+24
View File
@@ -362,6 +362,8 @@ def api_hub_backup_create():
env_path=str(ENV_PATH),
db_path=_resolved_hub_db_path(),
label="manual",
username=hub_username(),
password=hub_password(),
)
return jsonify(result)
except Exception as exc:
@@ -395,6 +397,12 @@ def api_hub_backup_restore():
env_path=str(ENV_PATH),
db_path=_resolved_hub_db_path(),
)
if result.get("ok"):
u = str(result.get("hub_username") or "").strip()
p = result.get("hub_password")
if u or p is not None:
set_hub_credentials(u or hub_username(), "" if p is None else str(p))
result.pop("hub_password", None)
return jsonify(result), (200 if result.get("ok") else 400)
@@ -517,6 +525,7 @@ try:
env_path=str(ENV_PATH),
db_path_fn=_resolved_hub_db_path,
hour=3,
get_credentials=lambda: (hub_username(), hub_password()),
)
except Exception as _hub_bak_err:
print(f"[backup] scheduler: {_hub_bak_err}")
@@ -781,6 +790,21 @@ def api_cond_orders_exit(hub_order_id: str):
return jsonify(post_cond_exit(inst, hub_order_id, payload))
@app.route("/manifest.webmanifest")
def pwa_manifest():
path = ROOT / "static" / "icons" / "manifest.webmanifest"
return send_file(path, mimetype="application/manifest+json; charset=utf-8")
@app.route("/sw.js")
def pwa_service_worker():
path = ROOT / "static" / "sw.js"
resp = send_file(path, mimetype="application/javascript; charset=utf-8")
resp.headers["Cache-Control"] = "no-cache"
resp.headers["Service-Worker-Allowed"] = "/"
return resp
if __name__ == "__main__":
# PM2 下禁止 debug reloader,否则会 Bad file descriptor 崩循环
_debug = (os.getenv("APP_DEBUG") or "").strip().lower() in ("1", "true", "yes", "on")