diff --git a/project/project_manager.py b/project/project_manager.py old mode 100755 new mode 100644 index 87a7ec17..adba33e0 --- a/project/project_manager.py +++ b/project/project_manager.py @@ -469,20 +469,26 @@ class ProjectManager: success = self._executeStandardBuild(build_dir, parent_window) if success: - # 创建run.sh文件 - run_sh_path = os.path.join(build_dir, "run.sh") - + # 根据操作系统创建对应的启动脚本文件 try: - with open(run_sh_path, "w") as f: - f.write("#!/bin/bash\n") - f.write("python3 main.py \"$@\"\n") - - # 添加执行权限 import stat - st = os.stat(run_sh_path) - os.chmod(run_sh_path, st.st_mode | stat.S_IEXEC) + # 检查操作系统类型 + 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: + f.write("#!/bin/bash\n") + f.write("python3 main.py \"$@\"\n") + + # 为Unix-like系统添加执行权限 + st = os.stat(run_sh_path) + os.chmod(run_sh_path, st.st_mode | stat.S_IEXEC) except Exception as e: - print(f"创建run.sh文件失败: {str(e)}") + print(f"创建启动脚本文件失败: {str(e)}") QMessageBox.information(parent_window, "成功", "打包完成!\n可执行文件在 build 目录中。\n") diff --git a/ui/property_panel.py b/ui/property_panel.py index e7c64529..9591e401 100644 --- a/ui/property_panel.py +++ b/ui/property_panel.py @@ -9202,15 +9202,19 @@ class PropertyPanelManager: original_filepath = filepath # 尝试多种修复策略 fixed = False - + + import platform # 策略1: 处理Linux风格路径在Windows上的问题 - if filepath.startswith('/') and ':' not in filepath: - # 提取文件名并尝试在当前目录查找 - filename = os.path.basename(filepath) - potential_path = os.path.join(os.getcwd(), filename) - if os.path.exists(potential_path): - filepath = potential_path - fixed = True + if platform.system() == "Windows" and filepath.startswith('/') and ':' not in filepath: + path_parts = filepath.split('/') + if len(path_parts) > 2 and len(path_parts[1]) == 1: + 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): + filepath = potential_path + fixed = True + print(f"[路径转换] {original_filepath} -> {filepath}") # 策略2: 处理路径分隔符问题 if not fixed: