Parcourir la source

feat: 队列/标题库状态5秒自动刷新

- 发布中→完成的状态跳变实时可见,不再需要手动点刷新
- 标题库自动刷新保留当前多选(不打断批量操作)
wubinggen il y a 3 mois
Parent
commit
a407252129
1 fichiers modifiés avec 20 ajouts et 0 suppressions
  1. 20 0
      白盒重建/kuaishou_tool/ui.py

+ 20 - 0
白盒重建/kuaishou_tool/ui.py

@@ -281,6 +281,7 @@ class App(tk.Tk):
         self.refresh_all()
         self.refresh_all()
         self.protocol('WM_DELETE_WINDOW', self._on_close)
         self.protocol('WM_DELETE_WINDOW', self._on_close)
         self.after(200, self._drain)
         self.after(200, self._drain)
+        self.after(5000, self._auto_refresh)   # 队列/标题库状态自动刷新
 
 
     # ---------------- 布局 ----------------
     # ---------------- 布局 ----------------
 
 
@@ -465,6 +466,25 @@ class App(tk.Tk):
             self._tree_biaoti.selection_set(kids)
             self._tree_biaoti.selection_set(kids)
             self._set_status(f'已全选 {len(kids)} 行')
             self._set_status(f'已全选 {len(kids)} 行')
 
 
+    def _auto_refresh(self):
+        """5秒轮询:发布队列与标题库状态列自动更新(发布中→完成自动跳变,
+        不再需要手动点刷新);标题库刷新保留当前多选。"""
+        try:
+            self.refresh_queue()
+            self._refresh_biaoti_keep_sel()
+        except Exception:
+            pass
+        self.after(5000, self._auto_refresh)
+
+    def _refresh_biaoti_keep_sel(self):
+        sel = {self._tree_biaoti.item(s, 'values')[0]
+               for s in self._tree_biaoti.selection()}
+        self._refresh_biaoti()
+        if sel:
+            kids = [(k, self._tree_biaoti.item(k, 'values')[0])
+                    for k in self._tree_biaoti.get_children()]
+            self._tree_biaoti.selection_set([k for k, v in kids if v in sel])
+
     def _refresh_biaoti(self):
     def _refresh_biaoti(self):
         self._fill(self._tree_biaoti, biaoti_rows(self.cfg),
         self._fill(self._tree_biaoti, biaoti_rows(self.cfg),
                    ('biaoti1', 'biaoti2', 'panduan', 'has_mat', 'goodsId'))
                    ('biaoti1', 'biaoti2', 'panduan', 'has_mat', 'goodsId'))