feat: 优化任务状态与进度体验
This commit is contained in:
@@ -28,6 +28,20 @@ def from_json_filter(value: str | None) -> list:
|
||||
return parsed if isinstance(parsed, list) else []
|
||||
|
||||
|
||||
def progress_percent(processed_count: int, total_count: int) -> int:
|
||||
if total_count <= 0:
|
||||
return 0
|
||||
return min(100, max(0, round((processed_count / total_count) * 100)))
|
||||
|
||||
|
||||
def rate_percent(rate: float | None) -> int:
|
||||
if rate is None:
|
||||
return 0
|
||||
return min(100, max(0, round(rate * 100)))
|
||||
|
||||
|
||||
templates.env.globals["status_badge_config"] = status_badge_config
|
||||
templates.env.globals["progress_percent"] = progress_percent
|
||||
templates.env.globals["rate_percent"] = rate_percent
|
||||
templates.env.filters["platform_label"] = platform_label
|
||||
templates.env.filters["from_json"] = from_json_filter
|
||||
|
||||
Reference in New Issue
Block a user