Add proper PWA install icons and sim-aware app manifest.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-16 16:38:37 +08:00
parent f66b4c3fb3
commit 960565482f
16 changed files with 247 additions and 26 deletions
+69 -2
View File
@@ -4953,10 +4953,19 @@ def login():
return redirect("/")
else:
flash("账号或密码错误")
is_sim = False
try:
from lib.sim.mode_lib import is_sim_mode as _is_sim_mode_fn
is_sim = bool(_is_sim_mode_fn(get_db))
except Exception:
is_sim = False
from lib.instance.instance_embed_lib import pwa_app_name
return render_template(
"login.html",
exchange_display=EXCHANGE_DISPLAY_NAME,
pwa_app_name="OKX 交易系统",
pwa_app_name=pwa_app_name("okx", is_sim=is_sim),
)
@app.route("/logout")
@@ -5319,7 +5328,7 @@ def render_main_page(page="options", embed_mode=None):
funding_usdt=funding_usdt,
exchange_pnl_sync=exchange_pnl_sync,
**strategy_extra,
**embed_context_extras("okx"),
**embed_context_extras("okx", is_sim=_sim_mode_for_header),
**_display_ctx,
**settings_page_context(
page,
@@ -7016,6 +7025,64 @@ def delete_journal(jid):
return jsonify({"ok": True})
@app.route("/manifest.webmanifest")
@app.route("/static/icons/manifest.webmanifest")
def pwa_manifest():
"""安装 App 用 manifest;模拟盘 short_name=OKX_sim."""
is_sim = False
try:
from lib.sim.mode_lib import is_sim_mode as _is_sim_mode_fn
is_sim = bool(_is_sim_mode_fn(get_db))
except Exception:
is_sim = False
from lib.instance.instance_embed_lib import pwa_app_name
name = pwa_app_name("okx", is_sim=is_sim)
short = "OKX_sim" if is_sim else "OKX"
payload = {
"name": name,
"short_name": short,
"description": "OKX 期权与对冲交易监控",
"id": "/",
"start_url": "/",
"scope": "/",
"display": "standalone",
"background_color": "#0b0d14",
"theme_color": "#0b0d14",
"icons": [
{
"src": "/static/icons/icon-192.png?v=2",
"sizes": "192x192",
"type": "image/png",
"purpose": "any",
},
{
"src": "/static/icons/icon-512.png?v=2",
"sizes": "512x512",
"type": "image/png",
"purpose": "any",
},
{
"src": "/static/icons/icon-192-maskable.png?v=2",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable",
},
{
"src": "/static/icons/icon-512-maskable.png?v=2",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable",
},
],
}
resp = jsonify(payload)
resp.headers["Content-Type"] = "application/manifest+json; charset=utf-8"
resp.headers["Cache-Control"] = "no-cache"
return resp
_REPO_STATIC_DIR = common_static_dir(_REPO_ROOT)
_FORM_SUBMIT_GUARD_JS = os.path.join(_REPO_STATIC_DIR, "form_submit_guard.js")
_MANUAL_ORDER_RR_PREVIEW_JS = os.path.join(_REPO_STATIC_DIR, "manual_order_rr_preview.js")