Add responsive mobile layout, records cards, and tablet settings fold fix.
Mobile gets compact trade/records UI with detail modals; static assets are cache-busted and settings cards fold correctly on tablet grid layout. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -218,11 +218,45 @@ def require_nav(key: str):
|
||||
return decorator
|
||||
|
||||
|
||||
def _static_asset_v() -> str:
|
||||
base = os.path.dirname(os.path.abspath(__file__))
|
||||
rels = (
|
||||
"static/js/trade.js",
|
||||
"static/js/orientation.js",
|
||||
"static/css/records.css",
|
||||
"static/js/records.js",
|
||||
"static/js/settings.js",
|
||||
"static/css/mobile.css",
|
||||
"static/css/responsive.css",
|
||||
"static/css/trade.css",
|
||||
"static/css/base.css",
|
||||
)
|
||||
mtimes = []
|
||||
for rel in rels:
|
||||
path = os.path.join(base, rel.replace("/", os.sep))
|
||||
if os.path.isfile(path):
|
||||
mtimes.append(os.path.getmtime(path))
|
||||
return str(int(max(mtimes))) if mtimes else "0"
|
||||
|
||||
|
||||
def _ua_is_phone(ua: str) -> bool:
|
||||
ua_l = (ua or "").lower()
|
||||
if "ipad" in ua_l:
|
||||
return False
|
||||
if "android" in ua_l and "mobile" not in ua_l:
|
||||
return False
|
||||
if any(x in ua_l for x in ("iphone", "ipod", "windows phone", "iemobile")):
|
||||
return True
|
||||
if "android" in ua_l and "mobile" in ua_l:
|
||||
return True
|
||||
if "mobile" in ua_l or "harmonyos" in ua_l or "openharmony" in ua_l:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@app.context_processor
|
||||
def inject_globals():
|
||||
trade_js = os.path.join(os.path.dirname(os.path.abspath(__file__)), "static", "js", "trade.js")
|
||||
asset_v = str(int(os.path.getmtime(trade_js))) if os.path.isfile(trade_js) else "0"
|
||||
return {"nav_items": get_nav_items(get_setting), "asset_v": asset_v}
|
||||
return {"nav_items": get_nav_items(get_setting), "asset_v": _static_asset_v()}
|
||||
|
||||
|
||||
def _trading_mode() -> str:
|
||||
@@ -755,8 +789,18 @@ def index():
|
||||
|
||||
@app.route("/manifest.webmanifest")
|
||||
def web_manifest():
|
||||
response = app.send_static_file("manifest.json")
|
||||
import json
|
||||
|
||||
manifest_path = os.path.join(app.static_folder, "manifest.json")
|
||||
with open(manifest_path, encoding="utf-8") as fh:
|
||||
data = json.load(fh)
|
||||
if _ua_is_phone(request.headers.get("User-Agent", "")):
|
||||
data["orientation"] = "portrait-primary"
|
||||
else:
|
||||
data["orientation"] = "any"
|
||||
response = app.make_response(json.dumps(data, ensure_ascii=False))
|
||||
response.mimetype = "application/manifest+json"
|
||||
response.headers["Cache-Control"] = "no-cache"
|
||||
return response
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user