From 69cf94d1dfce29b2e0980fed3974dcdbb6e68fab Mon Sep 17 00:00:00 2001 From: dekun Date: Fri, 26 Jun 2026 22:31:46 +0800 Subject: [PATCH] Fix symbol dropdown broken by JS syntax error in symbol.js. Co-authored-by: Cursor --- scripts/deploy_symbol_js_fix.py | 54 +++++++++++++++++++++++++++++++++ static/js/symbol.js | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 scripts/deploy_symbol_js_fix.py diff --git a/scripts/deploy_symbol_js_fix.py b/scripts/deploy_symbol_js_fix.py new file mode 100644 index 0000000..5fe2931 --- /dev/null +++ b/scripts/deploy_symbol_js_fix.py @@ -0,0 +1,54 @@ +"""Deploy symbol.js syntax fix.""" +import paramiko +import sys +from pathlib import Path + +sys.stdout.reconfigure(encoding="utf-8", errors="replace") +root = Path(__file__).resolve().parents[1] + +c = paramiko.SSHClient() +c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) +c.connect("192.168.8.21", username="root", password="woaini88", timeout=15) +sftp = c.open_sftp() +sftp.put(str(root / "static/js/symbol.js"), "/opt/qihuo/static/js/symbol.js") +print("uploaded symbol.js") +sftp.close() + +VERIFY = r""" +import sys, urllib.request, urllib.parse, http.cookiejar, json +sys.path.insert(0, "/opt/qihuo") + +jar = http.cookiejar.CookieJar() +op = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(jar)) +user = pwd = "" +for line in open("/opt/qihuo/.env"): + line = line.strip() + if line.startswith("ADMIN_USERNAME="): + user = line.split("=", 1)[1].strip().strip('"').strip("'") + if line.startswith("ADMIN_PASSWORD="): + pwd = line.split("=", 1)[1].strip().strip('"').strip("'") +op.open(urllib.request.Request( + "http://127.0.0.1:6600/login", + urllib.parse.urlencode({"username": user, "password": pwd}).encode(), +)) +raw = op.open("http://127.0.0.1:6600/api/symbols/recommended").read().decode() +groups = json.loads(raw) +items = sum(len(g.get("items") or []) for g in groups) +print("recommended groups", len(groups), "items", items) +js = open("/opt/qihuo/static/js/symbol.js", encoding="utf-8").read() +if "if item.near_expiry)" in js: + print("FAIL syntax still broken") +elif items <= 0: + print("WARN no recommended items") +else: + print("VERIFY PASS") +""" + +sftp = c.open_sftp() +with sftp.open("/tmp/verify_symbol_js.py", "w") as f: + f.write(VERIFY) +sftp.close() +_, o, e = c.exec_command("cd /opt/qihuo && /opt/qihuo/venv/bin/python /tmp/verify_symbol_js.py") +print(o.read().decode("utf-8", errors="replace")) +print(e.read().decode("utf-8", errors="replace")) +c.close() diff --git a/static/js/symbol.js b/static/js/symbol.js index 42cdd30..9d21857 100644 --- a/static/js/symbol.js +++ b/static/js/symbol.js @@ -106,7 +106,7 @@ div.classList.add('near-expiry'); } var label = item.display || (item.name + ' ' + item.ths_code); - if item.near_expiry) { + if (item.near_expiry) { label += ' 临期'; } if (item.has_night_session) {