Skip to content

Commit

Permalink
perf: 手动刷新live管理器防止闪屏
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnserf-Seed committed Nov 27, 2024
1 parent 70739fd commit 2e9c394
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
7 changes: 5 additions & 2 deletions f2/apps/douyin/dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,15 @@ async def create_download_tasks(
# 使用 Rich 的 Live 管理器
with Live(
console=RichConsoleManager().rich_console,
# auto_refresh=True,
refresh_per_second=2,
auto_refresh=False,
# refresh_per_second=2,
vertical_overflow="visible",
) as live:
for aweme_data in aweme_datas_list:
await self.handler_download(kwargs, aweme_data, user_path)
# 手动刷新防止过快闪屏
live.refresh()

# 延时更新,避免过快刷新导致界面错乱
await asyncio.sleep(0.1)
# 动态更新规则输出
Expand Down
7 changes: 5 additions & 2 deletions f2/apps/tiktok/dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,15 @@ async def create_download_tasks(
# 使用 Rich 的 Live 管理器
with Live(
console=RichConsoleManager().rich_console,
# auto_refresh=True,
refresh_per_second=2,
auto_refresh=False,
# refresh_per_second=2,
vertical_overflow="visible",
) as live:
for aweme_data in aweme_datas_list:
await self.handler_download(kwargs, aweme_data, user_path)
# 手动刷新防止过快闪屏
live.refresh()

# 延时更新,避免过快刷新导致界面错乱
await asyncio.sleep(0.1)
# 动态更新规则输出
Expand Down
7 changes: 5 additions & 2 deletions f2/apps/twitter/dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,15 @@ async def create_download_tasks(
# 使用 Rich 的 Live 管理器
with Live(
console=RichConsoleManager().rich_console,
# auto_refresh=True,
refresh_per_second=2,
auto_refresh=False,
# refresh_per_second=2,
vertical_overflow="visible",
) as live:
for tweet_data in tweet_datas_list:
await self.handler_download(kwargs, tweet_data, user_path)
# 手动刷新防止过快闪屏
live.refresh()

# 延时更新,避免过快刷新导致界面错乱
await asyncio.sleep(0.1)
# 动态更新规则输出
Expand Down
7 changes: 5 additions & 2 deletions f2/apps/weibo/dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ async def create_download_tasks(
# 使用 Rich 的 Live 管理器
with Live(
console=RichConsoleManager().rich_console,
# auto_refresh=True,
refresh_per_second=2,
auto_refresh=False,
# refresh_per_second=2,
vertical_overflow="visible",
) as live:
for weibo_data in weibo_datas_list:
await self.handler_download(kwargs, weibo_data, user_path)
# 手动刷新防止过快闪屏
live.refresh()

# 延时更新,避免过快刷新导致界面错乱
await asyncio.sleep(0.1)
# 动态更新规则输出
Expand Down

0 comments on commit 2e9c394

Please sign in to comment.