Optimize cloud drive upload flow
This commit is contained in:
65
gui.py
65
gui.py
@@ -962,6 +962,8 @@ class YidaimaGUI:
|
||||
upload_frame.pack(fill=tk.X)
|
||||
|
||||
ttk.Button(upload_frame, text="整理项目", command=self._ps_organize_project, width=15).pack(side=tk.LEFT, padx=(0, 5))
|
||||
ttk.Button(upload_frame, text="整理并上传夸克", command=self._ps_organize_upload_cloud, width=18).pack(side=tk.LEFT, padx=(5, 5))
|
||||
ttk.Button(upload_frame, text="整理并上传百度", command=self._ps_organize_upload_baidu, width=18).pack(side=tk.LEFT, padx=(5, 5))
|
||||
ttk.Button(upload_frame, text="上传夸克网盘", command=self._ps_upload_quark, width=15).pack(side=tk.LEFT, padx=(5, 5))
|
||||
ttk.Button(upload_frame, text="上传百度网盘", command=self._ps_upload_baidu, width=15).pack(side=tk.LEFT, padx=(5, 0))
|
||||
|
||||
@@ -1577,6 +1579,69 @@ class YidaimaGUI:
|
||||
|
||||
threading.Thread(target=run, daemon=True).start()
|
||||
|
||||
def _ps_organize_upload_baidu(self):
|
||||
"""整理项目并上传到百度网盘"""
|
||||
def run():
|
||||
try:
|
||||
self._ps_set_running(True)
|
||||
self._ps_log("=" * 50)
|
||||
self._ps_log("开始整理项目并打包...")
|
||||
config = self._get_ps_config()
|
||||
automation = ProjectScreenshotAutomation(config, log_callback=self._ps_log)
|
||||
|
||||
project_name = self.ps_project_name_var.get().strip()
|
||||
if not project_name:
|
||||
project_name = None
|
||||
else:
|
||||
self._ps_log(f"使用项目名称: {project_name}")
|
||||
|
||||
zip_file = automation.organize_and_zip_project(override_name=project_name)
|
||||
|
||||
if zip_file:
|
||||
self._ps_log("=" * 50)
|
||||
self._ps_log(f"项目整理完成!压缩包已生成:{zip_file}")
|
||||
self._ps_log("\n开始准备上传到百度网盘...")
|
||||
|
||||
chrome_path = self.config.get("chrome.path", "")
|
||||
baidu_cookies_dir = self.config.get("baidu.cookies_dir", os.path.join(os.getcwd(), "data", "baidu_cookies"))
|
||||
baidu_root_path = self.config.get("baidu.root_path", "精品项目整理")
|
||||
|
||||
if not project_name:
|
||||
project_name = os.path.basename(zip_file).replace(".zip", "")
|
||||
|
||||
uploader = BaiduUploader(
|
||||
chrome_path=chrome_path,
|
||||
cookies_dir=baidu_cookies_dir,
|
||||
log_callback=self._ps_log
|
||||
)
|
||||
|
||||
success = uploader.upload_file(
|
||||
file_path=zip_file,
|
||||
target_folder_name=project_name,
|
||||
root_path=baidu_root_path
|
||||
)
|
||||
|
||||
if success:
|
||||
self._ps_log("=" * 50)
|
||||
self._ps_log("项目已成功整理并上传到百度网盘!")
|
||||
self.root.after(0, lambda: messagebox.showinfo("成功", "项目整理并上传百度网盘成功!"))
|
||||
else:
|
||||
self._ps_log("=" * 50)
|
||||
self._ps_log("上传百度网盘失败,请检查日志。")
|
||||
self.root.after(0, lambda: messagebox.showerror("错误", "上传百度网盘失败,请检查日志。"))
|
||||
else:
|
||||
self._ps_log("=" * 50)
|
||||
self._ps_log("项目整理失败,请检查日志。")
|
||||
self.root.after(0, lambda: messagebox.showerror("错误", "项目整理并打包失败,请检查日志。"))
|
||||
|
||||
except Exception as e:
|
||||
self._ps_log(f"错误: {str(e)}")
|
||||
self.root.after(0, lambda: messagebox.showerror("错误", f"执行异常: {str(e)}"))
|
||||
finally:
|
||||
self._ps_set_running(False)
|
||||
|
||||
threading.Thread(target=run, daemon=True).start()
|
||||
|
||||
def _ps_organize_upload_cloud(self):
|
||||
"""整理项目并上传网盘"""
|
||||
def run():
|
||||
|
||||
Reference in New Issue
Block a user