From 7b2f2f63da896fcef023afb9271a58166d798631 Mon Sep 17 00:00:00 2001 From: lxb <1580622474@qq.com> Date: Sun, 11 Jan 2026 19:05:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=A4=9A=E4=B8=AA=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E7=9A=84=E6=97=B6=E5=80=99=E5=8F=AF=E9=80=89=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E9=93=BE=E6=8E=A5=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index cd73364..38988a5 100644 --- a/app.py +++ b/app.py @@ -14,7 +14,7 @@ import tkinter.font as tkfont # ----------------------- CONFIG ----------------------- # region 配置 -VERSION = "v1.0.5" +VERSION = "v1.0.6" DB_PATH = "tasks.db" # 数据库文件路径 TEMPLATES_PATH = "templates.json" # 检索模板文件路径 @@ -1059,8 +1059,56 @@ class TaskManagerApp(ctk.CTk): tid = self.displayed_sids[r] row = self.db.get_task(tid) links = json.loads(row.get("links") or "[]") - if not links: messagebox.showinfo("No links", "No links found"); return - for u in links: webbrowser.open(u) + if not links: + messagebox.showinfo("No links", "No links found") + return + # Single link: open immediately (preserve original behaviour) + if len(links) == 1: + try: + webbrowser.open(links[0]) + except Exception: + messagebox.showerror("Error", "Failed to open link") + return + + # Multiple links: show a small window listing them; user selects one to open + win = ctk.CTkToplevel(self) + win.title("Open Link") + win.geometry("640x320") + # header + try: + ctk.CTkLabel(win, text=f"Links for task {tid}").pack(anchor="w", padx=8, pady=(8,0)) + except Exception: + tk.Label(win, text=f"Links for task {tid}").pack(anchor="w", padx=8, pady=(8,0)) + + lb = tk.Listbox(win, height=10) + lb.pack(fill="both", expand=True, padx=8, pady=8) + for u in links: + lb.insert("end", u) + + def _open_selected(): + sel = lb.curselection() + if not sel: + messagebox.showinfo("Info", "Select a link") + return + url = lb.get(sel[0]) + try: + webbrowser.open(url) + except Exception: + messagebox.showerror("Error", "Failed to open link") + win.destroy() + + def _open_all(): + for u in links: + try: webbrowser.open(u) + except Exception: pass + win.destroy() + + lb.bind("", lambda e: _open_selected()) + + btn_row = ctk.CTkFrame(win) + btn_row.pack(fill="x", padx=8, pady=8) + ctk.CTkButton(btn_row, text="Open All", command=_open_all).pack(side="left", padx=6) + ctk.CTkButton(btn_row, text="Close", fg_color="#888", hover_color="#666", command=win.destroy).pack(side="right", padx=6) def mark_selected_processed_today(self): r = self._get_first_selected_row_index()