@@ -61,7 +61,7 @@ async def set_aspect_ratio(self, aspect_ratio: str, check_client_disconnected: C
6161 return
6262 if not await safe_click (dropdown , '宽高比下拉框' , self .req_id ):
6363 continue
64- await asyncio .sleep (0.3 )
64+ await asyncio .sleep (0.15 )
6565 option = self .page .locator (f'mat-option:has-text("{ aspect_ratio } ")' )
6666 if await option .count () > 0 :
6767 if await safe_click (option .first , f'宽高比选项 { aspect_ratio } ' , self .req_id ):
@@ -76,7 +76,7 @@ async def set_aspect_ratio(self, aspect_ratio: str, check_client_disconnected: C
7676 raise
7777 self .logger .warning (f'[{ self .req_id } ] 设置宽高比失败 (尝试 { attempt } ): { e } ' )
7878 if attempt < max_retries :
79- await asyncio .sleep (0.3 )
79+ await asyncio .sleep (0.15 )
8080 self .logger .warning (f'[{ self .req_id } ] 宽高比设置失败,使用默认值' )
8181
8282 async def upload_image (self , image_bytes : bytes , mime_type : str , check_client_disconnected : Callable ):
@@ -92,7 +92,7 @@ async def upload_image(self, image_bytes: bytes, mime_type: str, check_client_di
9292 if attempt < max_retries :
9393 continue
9494 return
95- await asyncio .sleep (0.5 )
95+ await asyncio .sleep (0.25 )
9696 await self ._check_disconnect (check_client_disconnected , '插入菜单展开后' )
9797
9898 ext = 'png' if 'png' in mime_type else 'jpg'
@@ -102,29 +102,29 @@ async def upload_image(self, image_bytes: bytes, mime_type: str, check_client_di
102102 'mimeType' : mime_type ,
103103 'buffer' : image_bytes
104104 })
105- await asyncio .sleep (1.5 )
105+ await asyncio .sleep (0.8 )
106106 await self .page .keyboard .press ('Escape' )
107- await asyncio .sleep (0.5 )
107+ await asyncio .sleep (0.25 )
108108 self .logger .info (f'[{ self .req_id } ] ✅ 图片已上传' )
109109 return
110110 except Exception as e :
111111 if isinstance (e , ClientDisconnectedError ):
112112 raise
113113 self .logger .warning (f'[{ self .req_id } ] 上传图片失败 (尝试 { attempt } ): { e } ' )
114114 if attempt < max_retries :
115- await asyncio .sleep (0.5 )
115+ await asyncio .sleep (0.25 )
116116
117117 async def fill_prompt (self , prompt : str , check_client_disconnected : Callable ):
118118 self .logger .info (f'[{ self .req_id } ] 填充提示词 ({ len (prompt )} chars)' )
119119 max_retries = 3
120120 for attempt in range (1 , max_retries + 1 ):
121121 try :
122122 await self .page .keyboard .press ('Escape' )
123- await asyncio .sleep (0.3 )
123+ await asyncio .sleep (0.15 )
124124 text_input = self .page .locator (PROMPT_TEXTAREA_SELECTOR )
125125 await safe_click (text_input , '输入框' , self .req_id )
126126 await text_input .fill (prompt )
127- await asyncio .sleep (0.2 )
127+ await asyncio .sleep (0.1 )
128128 actual = await text_input .input_value ()
129129 if prompt in actual or actual in prompt :
130130 self .logger .info (f'[{ self .req_id } ] ✅ 提示词已填充' )
@@ -135,7 +135,7 @@ async def fill_prompt(self, prompt: str, check_client_disconnected: Callable):
135135 raise
136136 self .logger .warning (f'[{ self .req_id } ] 填充提示词失败 (尝试 { attempt } ): { e } ' )
137137 if attempt < max_retries :
138- await asyncio .sleep (0.3 )
138+ await asyncio .sleep (0.15 )
139139 raise Exception ('填充提示词失败' )
140140
141141 async def run_generation (self , check_client_disconnected : Callable ):
@@ -144,7 +144,7 @@ async def run_generation(self, check_client_disconnected: Callable):
144144 for attempt in range (1 , max_retries + 1 ):
145145 try :
146146 await self .page .keyboard .press ('Escape' )
147- await asyncio .sleep (0.3 )
147+ await asyncio .sleep (0.15 )
148148 run_btn = self .page .locator (SUBMIT_BUTTON_SELECTOR )
149149 await expect_async (run_btn ).to_be_visible (timeout = 5000 )
150150 await expect_async (run_btn ).to_be_enabled (timeout = 5000 )
@@ -160,7 +160,7 @@ async def run_generation(self, check_client_disconnected: Callable):
160160 raise
161161 self .logger .warning (f'[{ self .req_id } ] 点击 Run 失败 (尝试 { attempt } ): { e } ' )
162162 if attempt < max_retries :
163- await asyncio .sleep (0.3 )
163+ await asyncio .sleep (0.15 )
164164 raise Exception ('点击 Run 按钮失败' )
165165
166166 async def wait_for_content (self , check_client_disconnected : Callable , timeout_seconds : int = 120 ) -> GeneratedContent :
@@ -229,7 +229,7 @@ async def wait_for_content(self, check_client_disconnected: Callable, timeout_se
229229 except Exception as e :
230230 self .logger .warning (f'[{ self .req_id } ] 检查内容时出错: { e } ' )
231231
232- await asyncio .sleep (0.5 )
232+ await asyncio .sleep (0.25 )
233233
234234 async def _extract_images_via_download (self , count : int ) -> List [GeneratedImage ]:
235235 import tempfile
@@ -244,9 +244,9 @@ async def _extract_images_via_download(self, count: int) -> List[GeneratedImage]
244244 img = chunk .locator ('img' )
245245 if await img .count () > 0 :
246246 await img .first .hover ()
247- await asyncio .sleep (0.5 )
247+ await asyncio .sleep (0.25 )
248248 await chunk .evaluate ('el => el.dispatchEvent(new MouseEvent("mouseenter", {bubbles: true}))' )
249- await asyncio .sleep (0.3 )
249+ await asyncio .sleep (0.15 )
250250
251251 download_btn = chunk .locator ('button[aria-label="Download"]' )
252252 if await download_btn .count () == 0 :
0 commit comments