windows的run.bat,修复动画路径
This commit is contained in:
parent
0a1abebe24
commit
79e21d572d
18
project/project_manager.py
Executable file → Normal file
18
project/project_manager.py
Executable file → Normal file
@ -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:
|
||||
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:
|
||||
f.write("#!/bin/bash\n")
|
||||
f.write("python3 main.py \"$@\"\n")
|
||||
|
||||
# 添加执行权限
|
||||
import stat
|
||||
# 为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")
|
||||
|
||||
@ -9203,14 +9203,18 @@ class PropertyPanelManager:
|
||||
# 尝试多种修复策略
|
||||
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 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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user