diff --git a/services/kdocs_uploader.py b/services/kdocs_uploader.py index 6c87a02..02b6440 100644 --- a/services/kdocs_uploader.py +++ b/services/kdocs_uploader.py @@ -804,6 +804,16 @@ class KDocsUploader: status_tracked = False try: + try: + account = safe_get_account(user_id, account_id) + if account and self._should_mark_upload(account): + prev_status = getattr(account, "status", None) + account.status = "上传截图" + self._emit_account_update(user_id, account) + status_tracked = True + except Exception: + prev_status = None + if not self._ensure_playwright(): self._notify_admin(unit, name, image_path, self._last_error or "浏览器不可用") return @@ -824,16 +834,6 @@ class KDocsUploader: self._login_required = False self._last_login_ok = True - try: - account = safe_get_account(user_id, account_id) - if account and not getattr(account, "is_running", False): - prev_status = getattr(account, "status", None) - account.status = "上传截图" - self._emit_account_update(user_id, account) - status_tracked = True - except Exception: - prev_status = None - sheet_name = (cfg.get("kdocs_sheet_name") or "").strip() sheet_index = int(cfg.get("kdocs_sheet_index") or 0) unit_col = (cfg.get("kdocs_unit_column") or "A").strip().upper() @@ -1010,6 +1010,15 @@ class KDocsUploader: return True return False + def _should_mark_upload(self, account: Any) -> bool: + if not account: + return False + status_text = str(getattr(account, "status", "") or "") + if status_text: + if "运行" in status_text or "排队" in status_text: + return False + return True + def _search_person(self, name: str) -> None: self._page.keyboard.press("Control+f") time.sleep(0.3) @@ -1108,6 +1117,7 @@ class KDocsUploader: self._page.keyboard.press("Control+f") time.sleep(0.2) self._find_next() + self._close_search() return -1 def _upload_image_to_cell(self, row_num: int, image_path: str, image_col: str) -> bool: