From 3afa6236fa2a776b13e081ae620d264e8b4300ff Mon Sep 17 00:00:00 2001 From: g1879 Date: Thu, 26 Jan 2023 23:41:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=94=B9=E5=8F=98=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E7=AA=97=E5=8F=A3=E5=A4=A7=E5=B0=8F=E5=87=BA?= =?UTF-8?q?=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/chromium_page.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/DrissionPage/chromium_page.py b/DrissionPage/chromium_page.py index 25f03e7..16e1d5f 100644 --- a/DrissionPage/chromium_page.py +++ b/DrissionPage/chromium_page.py @@ -505,19 +505,30 @@ class WindowSetter(object): def maximized(self): """窗口最大化""" + s = self._get_info()['bounds']['windowState'] + if s in ('fullscreen', 'minimized'): + self._perform({'windowState': 'normal'}) self._perform({'windowState': 'maximized'}) def minimized(self): """窗口最小化""" + s = self._get_info()['bounds']['windowState'] + if s == 'fullscreen': + self._perform({'windowState': 'normal'}) self._perform({'windowState': 'minimized'}) def fullscreen(self): """设置窗口为全屏""" + s = self._get_info()['bounds']['windowState'] + if s == 'minimized': + self._perform({'windowState': 'normal'}) self._perform({'windowState': 'fullscreen'}) def normal(self): """设置窗口为常规模式""" - self._perform({'windowState': 'normal'}) + s = self._get_info()['bounds']['windowState'] + if s == 'fullscreen': + self._perform({'windowState': 'normal'}) self._perform({'windowState': 'normal'}) def size(self, width=None, height=None): @@ -527,6 +538,9 @@ class WindowSetter(object): :return: None """ if width or height: + s = self._get_info()['bounds']['windowState'] + if s != 'normal': + self._perform({'windowState': 'normal'}) info = self._get_info()['bounds'] width = width or info['width'] height = height or info['height'] @@ -538,11 +552,11 @@ class WindowSetter(object): :param y: 距离左边距离 :return: None """ - if x or y: + if x is not None or y is not None: self.normal() info = self._get_info()['bounds'] - x = x or info['left'] - y = y or info['top'] + x = x if x is not None else info['left'] + y = y if y is not None else info['top'] self._perform({'left': x, 'top': y}) def _get_info(self):