Compare commits

...

2 Commits

Author SHA1 Message Date
Rumio
552ed80304
Merge c36c161b0e into c839b44256 2025-11-13 09:28:25 +00:00
webjoin111
c36c161b0e feat(renderer): 支持组件变体样式收集 2025-11-13 17:28:07 +08:00

View File

@ -239,27 +239,36 @@ class RendererService:
) )
style_paths_to_load = [] style_paths_to_load = []
if manifest and "styles" in manifest: if manifest and manifest.get("styles"):
styles = ( styles = manifest["styles"]
[manifest["styles"]] styles = [styles] if isinstance(styles, str) else styles
if isinstance(manifest["styles"], str)
else manifest["styles"] resolution_base_path = Path(component_path_base)
) if variant:
for style_path in styles: skin_manifest_path = str(Path(component_path_base) / "skins" / variant)
full_style_path = str(Path(component_path_base) / style_path).replace( skin_manifest = await context.theme_manager._load_single_manifest(
"\\", "/" skin_manifest_path
) )
style_paths_to_load.append(full_style_path) if skin_manifest and "styles" in skin_manifest:
resolution_base_path = Path(skin_manifest_path)
style_paths_to_load.extend(
str(resolution_base_path / style).replace("\\", "/") for style in styles
)
else: else:
resolved_template_name = ( base_template_path = (
await context.theme_manager._resolve_component_template( await context.theme_manager._resolve_component_template(
component, context component, context
) )
) )
conventional_style_path = str( base_style_path = str(
Path(resolved_template_name).with_name("style.css") Path(base_template_path).with_name("style.css")
).replace("\\", "/") ).replace("\\", "/")
style_paths_to_load.append(conventional_style_path) style_paths_to_load.append(base_style_path)
if variant:
skin_style_path = f"{component_path_base}/skins/{variant}/style.css"
style_paths_to_load.append(skin_style_path)
for css_template_path in style_paths_to_load: for css_template_path in style_paths_to_load:
try: try: