fix:修复模板问题,修复系统操作逻辑,修复系统的一些BUG

This commit is contained in:
2025-12-31 08:28:45 +08:00
parent d3c0121632
commit 54398e2cbe
12 changed files with 342 additions and 172 deletions

View File

@@ -5,6 +5,7 @@ from loguru import logger
import zipfile
import traceback
def export_templates_folder(output_folder, stop_event, progress_callback=None):
"""
将指定文件夹压缩为 zip 包
@@ -121,7 +122,9 @@ def export_data(save_dir, root_dir=".", progress_callback=None):
has_files = True
# 更新进度条
if progress_callback:
progress_callback(processed_count + 1, total_files, "导出数据中...")
progress_callback(
processed_count + 1, total_files, "导出数据中..."
)
if has_files:
# 确保进度条最后能走到 100%
@@ -139,6 +142,7 @@ def export_data(save_dir, root_dir=".", progress_callback=None):
except Exception as e:
logger.error(f"导出过程出错: {str(e)}")
import traceback
logger.error(traceback.format_exc())
return None
@@ -218,6 +222,7 @@ def check_file_exists(file_path):
"""
return file_path and isinstance(file_path, str) and os.path.exists(file_path)
def get_output_pptx_files(output_dir="output"):
"""
获取 output 文件夹下所有的 pptx 文件
@@ -241,3 +246,17 @@ def get_output_pptx_files(output_dir="output"):
except Exception as e:
logger.error(f"发生未知错误: {e}")
logger.error(traceback.format_exc())
def open_folder(folder_path):
"""
打开指定文件夹
:param folder_path: 文件夹路径
"""
try:
if os.path.exists(folder_path):
os.startfile(folder_path)
else:
logger.error(f"文件夹不存在: {folder_path}")
except Exception as e:
logger.error(f"打开文件夹失败: {e}")