From ad81575546939039f3da33bafc9eef034b5a9e36 Mon Sep 17 00:00:00 2001 From: g1879 Date: Mon, 12 Aug 2024 23:04:15 +0800 Subject: [PATCH] =?UTF-8?q?Tab=E7=9A=84close()=E6=96=B9=E6=B3=95=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0others=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/_pages/tabs.py | 18 ++++++++++++------ DrissionPage/_units/downloader.py | 8 +------- DrissionPage/_units/downloader.pyi | 2 -- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/DrissionPage/_pages/tabs.py b/DrissionPage/_pages/tabs.py index 38188a2..7c6930f 100644 --- a/DrissionPage/_pages/tabs.py +++ b/DrissionPage/_pages/tabs.py @@ -58,9 +58,12 @@ class ChromiumTab(ChromiumBase): self._load_mode = self.browser._load_mode self._download_path = self.browser.download_path - def close(self): - """关闭当前标签页""" - self.browser.close_tabs(self.tab_id) + def close(self, others=False): + """关闭当前标签页 + :param others: 是否关闭其它,保留自己 + :return: None + """ + self.browser.close_tabs(self.tab_id, others=others) @property def set(self): @@ -361,9 +364,12 @@ class MixTab(SessionPage, ChromiumTab, BasePage): elif self._mode == 'd': return super(SessionPage, self).cookies(all_domains, all_info) - def close(self): - """关闭当前标签页""" - self.browser.close_tabs(self.tab_id) + def close(self, others=False): + """关闭当前标签页 + :param others: 是否关闭其它,保留自己 + :return: None + """ + self.browser.close_tabs(self.tab_id, others=others) self._session.close() if self._response is not None: self._response.close() diff --git a/DrissionPage/_units/downloader.py b/DrissionPage/_units/downloader.py index 48a5095..d220f3c 100644 --- a/DrissionPage/_units/downloader.py +++ b/DrissionPage/_units/downloader.py @@ -20,9 +20,6 @@ class DownloadManager(object): :param browser: Browser对象 """ self._browser = browser - # self._page = browser.page - # self._when_download_file_exists = 'rename' - # self._save_path = None t = TabDownloadSettings('browser') t.path = self._browser.download_path @@ -34,9 +31,6 @@ class DownloadManager(object): self._tab_missions = {} # {tab_id: DownloadMission} self._flags = {} # {tab_id: [bool, DownloadMission]} - # if self._page.download_path: - # self.set_path(self._page, self._page.download_path) - self._running = False @property @@ -196,7 +190,7 @@ class DownloadManager(object): elif skip: self.skip(m) else: - self._tab_missions.setdefault(tab_id, []).append(guid) + self._tab_missions.setdefault(tab_id, []).append(m) if self.get_flag(tab_id) is not None: self._flags[tab_id] = m diff --git a/DrissionPage/_units/downloader.pyi b/DrissionPage/_units/downloader.pyi index d9768c4..955611c 100644 --- a/DrissionPage/_units/downloader.pyi +++ b/DrissionPage/_units/downloader.pyi @@ -14,12 +14,10 @@ FILE_EXISTS = Literal['skip', 'rename', 'overwrite', 's', 'r', 'o'] class DownloadManager(object): _browser: Chromium = ... - # _page: ChromiumPage = ... _missions: Dict[str, DownloadMission] = ... _tab_missions: dict = ... _flags: dict = ... _running: bool = ... - # _save_path: Optional[str] = ... def __init__(self, browser: Chromium): ...