Slim embed tab rendering to cut memory use and restore calculator.
Load only per-tab data for embed fragments, skip exchange capital fetches on tab switches, and harden calculator market imports/timeouts. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -55,8 +55,23 @@ def path_to_embed_tab(path: str) -> str | None:
|
||||
return PATH_TO_EMBED_TAB.get(base)
|
||||
|
||||
|
||||
def embed_shell_enabled() -> bool:
|
||||
return (os.getenv("HUB_EMBED_SHELL") or "1").strip().lower() in ("1", "true", "yes", "on")
|
||||
|
||||
|
||||
def rewrite_embed_dest(path: str, hub_theme: str | None = None) -> str:
|
||||
"""embed=1 打开时:/trade → /embed?tab=trade&embed=1"""
|
||||
if not embed_shell_enabled():
|
||||
split = urlsplit(path or "/")
|
||||
q = dict(parse_qsl(split.query, keep_blank_values=True))
|
||||
q["embed"] = "1"
|
||||
ht = (hub_theme or q.get("hub_theme") or "").strip().lower()
|
||||
if ht in ("light", "dark"):
|
||||
q["hub_theme"] = ht
|
||||
dest = split.path or "/"
|
||||
if q:
|
||||
return f"{dest}?{urlencode(q)}"
|
||||
return dest + "?embed=1"
|
||||
split = urlsplit(path or "/")
|
||||
tab = path_to_embed_tab(split.path)
|
||||
q = dict(parse_qsl(split.query, keep_blank_values=True))
|
||||
|
||||
Reference in New Issue
Block a user