# -*- coding: utf-8 -*- import subprocess import os ROOT = os.path.dirname(os.path.dirname(__file__)) OUT = os.path.join(ROOT, "ruoyi-ui", "src", "views", "basic", "waybill", "components", "WaybillDetail.vue") raw = open(OUT, "rb").read() try: text = raw.decode("utf-8") except UnicodeDecodeError: text = raw.decode("gbk") # Syntax: missing closing paren on msgSuccess text = text.replace("+ phone;", "+ phone);") text = text.replace('+ phone;', '+ phone);') open(OUT, "w", encoding="utf-8", newline="\n").write(text) subprocess.run([__import__("sys").executable, os.path.join(ROOT, "tools", "fix_waybill_detail_zh.py")], check=True) subprocess.run([__import__("sys").executable, os.path.join(ROOT, "tools", "fix_phase.py")], check=True) text = open(OUT, encoding="utf-8").read() if "+ phone);" not in text and "phone);" not in text: raise SystemExit("parenthesis fix failed") if "_\u6e29\u5ea6\u8bb0\u5f55.pdf" not in text: # fix duplicate attachment via unicode lines = text.splitlines() for i, line in enumerate(lines): if 'attachments()' in line or (i > 244 and i < 252 and '.pdf' in line): pass text = text.replace( ' { name: no + "_\u53d1\u8fd0\u5355.pdf", time: base }\n ];', ' { name: no + "_\u53d1\u8fd0\u5355.pdf", time: base },\n { name: no + "_\u7b7e\u6536\u5355.pdf", time: base },\n { name: no + "_\u6e29\u5ea6\u8bb0\u5f55.pdf", time: base }\n ];', 1 ) # simpler: replace third attachment line import re pdf_lines = [m.start() for m in re.finditer(r'name: no \+ "_[^"]+\.pdf"', text)] if len(pdf_lines) >= 3: pass final = open(OUT, encoding="utf-8").read() # fix download message final = final.replace( 'downloadFile(file) {\n this.$modal.msgInfo("\u9884\u89c8\uff1a" + file.name);', 'downloadFile(file) {\n this.$modal.msgInfo("\u4e0b\u8f7d\uff1a" + file.name);', ) open(OUT, "w", encoding="utf-8", newline="\n").write(final) print("fixed syntax and encoding")