mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 22:52:12 -03:00
Add initialization handling for LoRA page with loading state
- Implement dynamic initialization detection in lora_routes - Add initialization notice template with loading spinner - Create CSS styles for initialization notice - Add client-side script to auto-refresh page when initialization completes
This commit is contained in:
@@ -49,12 +49,27 @@ class LoraRoutes:
|
||||
async def handle_loras_page(self, request: web.Request) -> web.Response:
|
||||
"""Handle GET /loras request"""
|
||||
try:
|
||||
# Get cached data for folders only
|
||||
cache = await self.scanner.get_cached_data()
|
||||
|
||||
# Render template with folders only
|
||||
template = self.template_env.get_template('loras.html')
|
||||
rendered = template.render(folders=cache.folders)
|
||||
# 不等待缓存数据,直接检查缓存状态
|
||||
is_initializing = (
|
||||
self.scanner._cache is None or
|
||||
(hasattr(self.scanner, '_cache') and len(self.scanner._cache.raw_data) == 0)
|
||||
)
|
||||
|
||||
if is_initializing:
|
||||
# 如果正在初始化,返回一个只包含加载提示的页面
|
||||
template = self.template_env.get_template('loras.html')
|
||||
rendered = template.render(
|
||||
folders=[], # 空文件夹列表
|
||||
is_initializing=True # 新增标志
|
||||
)
|
||||
else:
|
||||
# 正常流程
|
||||
cache = await self.scanner.get_cached_data()
|
||||
template = self.template_env.get_template('loras.html')
|
||||
rendered = template.render(
|
||||
folders=cache.folders,
|
||||
is_initializing=False
|
||||
)
|
||||
|
||||
return web.Response(
|
||||
text=rendered,
|
||||
|
||||
Reference in New Issue
Block a user