修改 server.js 默认端口从 3000 更改为 30006,增强部署脚本的灵活性和可维护性。

This commit is contained in:
2026-02-02 18:35:13 +08:00
parent 2aad5d55fd
commit d74410cfb5
2 changed files with 17 additions and 0 deletions

View File

@@ -217,6 +217,23 @@ def pack_standalone_zip(root):
except Exception:
pass
# 修改 server.js 默认端口3000 → 30006
server_js_path = os.path.join(staging, "server.js")
if os.path.isfile(server_js_path):
try:
with open(server_js_path, "r", encoding="utf-8") as f:
server_js_content = f.read()
# 替换默认端口:|| 3000 → || 30006
if "|| 3000" in server_js_content:
server_js_content = server_js_content.replace("|| 3000", "|| 30006")
with open(server_js_path, "w", encoding="utf-8") as f:
f.write(server_js_content)
print(" [修改] server.js 默认端口已改为 30006")
else:
print(" [提示] server.js 未找到 '|| 3000' 字符串,跳过端口修改")
except Exception as e:
print(" [警告] 修改 server.js 失败:", str(e))
# 打成 zip仅包含顶层内容解压后即 dist2 根目录;排除 ZIP_EXCLUDE_* 配置的目录/文件)
zip_path = os.path.join(tempfile.gettempdir(), "soul_devlop.zip")
excluded_count = [0] # 用列表以便内层可修改