diff --git a/routes/lora_routes.py b/routes/lora_routes.py index 344c7af4..c5efb131 100644 --- a/routes/lora_routes.py +++ b/routes/lora_routes.py @@ -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, diff --git a/static/css/style.css b/static/css/style.css index c51049ab..06672f39 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -841,4 +841,38 @@ body.modal-open .toast-info { .trigger-word-tag:active { transform: scale(0.98); +} + +.initialization-notice { + display: flex; + justify-content: center; + align-items: center; + min-height: 200px; + margin: var(--space-3) 0; + padding: var(--space-3); + background: var(--lora-surface); + border: 1px solid var(--lora-border); + border-radius: var(--border-radius-base); + text-align: center; +} + +.notice-content { + max-width: 400px; +} + +.notice-content h2 { + color: var(--text-color); + margin: var(--space-2) 0; + font-size: 1.5em; +} + +.notice-content p { + color: var(--text-color); + opacity: 0.8; + margin: var(--space-1) 0; +} + +/* 使用已有的loading-spinner样式 */ +.initialization-notice .loading-spinner { + margin-bottom: var(--space-2); } \ No newline at end of file diff --git a/templates/loras.html b/templates/loras.html index 646d03e0..4b5e422c 100644 --- a/templates/loras.html +++ b/templates/loras.html @@ -42,14 +42,46 @@ {% include 'components/loading.html' %}
- {% include 'components/controls.html' %} - - -
- + {% if is_initializing %} +
+
+
+

Initializing LoRA Manager

+

Scanning and building LoRA cache. This may take a few minutes...

+
+ {% else %} + {% include 'components/controls.html' %} + +
+ +
+ {% endif %}
+ \ No newline at end of file