From 447d78fb3e22d7e01b90d2293b00e8606c2f58a6 Mon Sep 17 00:00:00 2001 From: CNlaojing <154053522+CNlaojing@users.noreply.github.com> Date: Sun, 9 Mar 2025 18:34:37 +0800 Subject: [PATCH] Update role_library.py --- ui/role_library.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ui/role_library.py b/ui/role_library.py index 51e13a4..0f53d58 100644 --- a/ui/role_library.py +++ b/ui/role_library.py @@ -350,6 +350,15 @@ class RoleLibrary: try: # 创建临时角色库目录 target_dir = os.path.join(self.save_path, "临时角色库") + # 清空现有临时角色库 + if os.path.exists(target_dir): + for filename in os.listdir(target_dir): + file_path = os.path.join(target_dir, filename) + try: + if os.path.isfile(file_path): + os.unlink(file_path) + except Exception as e: + print(f"删除文件{file_path}时出错: {e}") os.makedirs(target_dir, exist_ok=True) # 调用LLM进行分析