windows的run.bat,修复动画路径

This commit is contained in:
Hector 2025-12-12 14:23:59 +08:00
parent 0a1abebe24
commit 79e21d572d
2 changed files with 29 additions and 19 deletions

18
project/project_manager.py Executable file → Normal file
View File

@ -469,20 +469,26 @@ class ProjectManager:
success = self._executeStandardBuild(build_dir, parent_window) success = self._executeStandardBuild(build_dir, parent_window)
if success: if success:
# 创建run.sh文件 # 根据操作系统创建对应的启动脚本文件
run_sh_path = os.path.join(build_dir, "run.sh")
try: try:
import stat
# 检查操作系统类型
if os.name == 'nt': # Windows系统
run_bat_path = os.path.join(build_dir, "run.bat")
with open(run_bat_path, "w") as f:
f.write("@echo off\n")
f.write("python main.py %*\n")
else: # Unix-like系统 (Linux, macOS等)
run_sh_path = os.path.join(build_dir, "run.sh")
with open(run_sh_path, "w") as f: with open(run_sh_path, "w") as f:
f.write("#!/bin/bash\n") f.write("#!/bin/bash\n")
f.write("python3 main.py \"$@\"\n") f.write("python3 main.py \"$@\"\n")
# 添加执行权限 # 为Unix-like系统添加执行权限
import stat
st = os.stat(run_sh_path) st = os.stat(run_sh_path)
os.chmod(run_sh_path, st.st_mode | stat.S_IEXEC) os.chmod(run_sh_path, st.st_mode | stat.S_IEXEC)
except Exception as e: except Exception as e:
print(f"创建run.sh文件失败: {str(e)}") print(f"创建启动脚本文件失败: {str(e)}")
QMessageBox.information(parent_window, "成功", QMessageBox.information(parent_window, "成功",
"打包完成!\n可执行文件在 build 目录中。\n") "打包完成!\n可执行文件在 build 目录中。\n")

View File

@ -9203,14 +9203,18 @@ class PropertyPanelManager:
# 尝试多种修复策略 # 尝试多种修复策略
fixed = False fixed = False
import platform
# 策略1: 处理Linux风格路径在Windows上的问题 # 策略1: 处理Linux风格路径在Windows上的问题
if filepath.startswith('/') and ':' not in filepath: if platform.system() == "Windows" and filepath.startswith('/') and ':' not in filepath:
# 提取文件名并尝试在当前目录查找 path_parts = filepath.split('/')
filename = os.path.basename(filepath) if len(path_parts) > 2 and len(path_parts[1]) == 1:
potential_path = os.path.join(os.getcwd(), filename) drive_letter = path_parts[1].upper() + ':'
remaining_path = '\\'.join(path_parts[2:]) if len(path_parts) > 2 else ''
potential_path = os.path.join(drive_letter, remaining_path)
if os.path.exists(potential_path): if os.path.exists(potential_path):
filepath = potential_path filepath = potential_path
fixed = True fixed = True
print(f"[路径转换] {original_filepath} -> {filepath}")
# 策略2: 处理路径分隔符问题 # 策略2: 处理路径分隔符问题
if not fixed: if not fixed: