利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.
Python ai-video-generatorcontent-creationffmpeginstagram-reelsllmpythonshort-videosubtitlestext-to-speechtiktokvideo-automationvideo-workflowworkflow-automationyoutube-shorts
fix(i18n): translate task preview close action
harry070357f83e06a271
diff --git a/test/services/test_webui_headless_task_actions.py b/test/services/test_webui_headless_task_actions.pynew file mode 100644index 00000000..3cfc6b93--- /dev/null+++ b/test/services/test_webui_headless_task_actions.py@@ -0,0 +1,71 @@+import sys+from pathlib import Path+from unittest.mock import patch++import pytest+from streamlit.testing.v1 import AppTest++from app.config import config+from app.services import state as sm+from app.utils import utils++ROOT_DIR = Path(__file__).parent.parent.parent+WEBUI_MAIN = ROOT_DIR / "webui" / "Main.py"+++def headless_task_app(tmp_path, monkeypatch):+ # 使用独立任务目录避免读取或修改开发者的真实生成记录。测试文件只需要被+ # Streamlit 注册为媒体资源,不参与视频解码,因此无需在单元测试中调用+ # FFmpeg 生成素材,能够稳定覆盖无桌面服务器的 UI 分支。+ tasks_dir = tmp_path / "storage" / "tasks"+ task_dir = tasks_dir / "headless-test"+ task_dir.mkdir(parents=True)+ video_file = task_dir / "final-1.mp4"+ video_file.write_bytes(b"test video payload")++ monkeypatch.setattr(utils, "task_dir", lambda: str(tasks_dir))+ monkeypatch.setattr(sm.state, "get_all_tasks", lambda *_args, **_kwargs: ([], 0))+ monkeypatch.setattr(sys, "platform", "linux")+ monkeypatch.delenv("DISPLAY", raising=False)+ monkeypatch.delenv("WAYLAND_DISPLAY", raising=False)++ # AppTest 会多次重新执行页面脚本;配置保存必须在整个测试生命周期内保持+ # 隔离,防止控件初始化意外写入开发者的 config.toml。+ with patch.object(config, "try_save_config", return_value=True):+ app = AppTest.from_file(str(WEBUI_MAIN), default_timeout=60)+ app.run()+ yield app, video_file+++def _button_by_key_prefix(app, key_prefix):+ return next(button for button in app.button if str(button.key).startswith(key_prefix))+++def test_headless_play_renders_and_closes_browser_preview(headless_task_app):+ app, video_file = headless_task_app++ _button_by_key_prefix(app, "play_task_all_headless-test").click()+ app.run()++ assert not app.exception+ assert app.session_state["task_preview_video_file"] == str(video_file.resolve())+ assert len(app.get("video")) == 1++ _button_by_key_prefix(app, "close_task_video_preview").click()+ app.run()++ assert "task_preview_video_file" not in app.session_state+ assert len(app.get("video")) == 0+++def test_headless_open_folder_shows_host_mapped_path(headless_task_app):+ app, _ = headless_task_app++ _button_by_key_prefix(app, "open_task_all_headless-test").click()+ app.run()++ assert not app.exception+ assert any(+ "./storage/tasks/headless-test" in toast.value for toast in app.get("toast")+ )diff --git a/webui/i18n/de.json b/webui/i18n/de.jsonindex 9e628576..fe813ded 100644--- a/webui/i18n/de.json+++ b/webui/i18n/de.json@@ -62,6 +62,7 @@"Task Actions": "Aktionen","Play Video": "Abspielen","Play": "Abspielen",+ "Close": "Schließen","Open": "Öffnen","Delete": "Löschen","Delete Task": "Aufgabe löschen",diff --git a/webui/i18n/es.json b/webui/i18n/es.jsonindex 28d9088a..e9a1a79b 100644--- a/webui/i18n/es.json+++ b/webui/i18n/es.json@@ -62,6 +62,7 @@"Task Actions": "Acciones","Play Video": "Reproducir","Play": "Reproducir",+ "Close": "Cerrar","Open": "Abrir","Delete": "Eliminar","Delete Task": "Eliminar tarea",diff --git a/webui/i18n/fr.json b/webui/i18n/fr.jsonindex fb996624..3de5acef 100644--- a/webui/i18n/fr.json+++ b/webui/i18n/fr.json@@ -62,6 +62,7 @@"Task Actions": "Actions","Play Video": "Lire","Play": "Lire",+ "Close": "Fermer","Open": "Ouvrir","Delete": "Supprimer","Delete Task": "Supprimer la tâche",diff --git a/webui/i18n/id.json b/webui/i18n/id.jsonindex 118258b1..4d68487a 100644--- a/webui/i18n/id.json+++ b/webui/i18n/id.json@@ -62,6 +62,7 @@"Task Actions": "Tindakan","Play Video": "Putar","Play": "Putar",+ "Close": "Tutup","Open": "Buka","Delete": "Hapus","Delete Task": "Hapus tugas",diff --git a/webui/i18n/it.json b/webui/i18n/it.jsonindex 83a4ff80..eb3165e1 100644--- a/webui/i18n/it.json+++ b/webui/i18n/it.json@@ -62,6 +62,7 @@"Task Actions": "Azioni","Play Video": "Riproduci","Play": "Riproduci",+ "Close": "Chiudi","Open": "Apri","Delete": "Elimina","Delete Task": "Elimina attività",diff --git a/webui/i18n/pt.json b/webui/i18n/pt.jsonindex d4dc8a38..cfb17493 100644--- a/webui/i18n/pt.json+++ b/webui/i18n/pt.json@@ -62,6 +62,7 @@"Task Actions": "Ações","Play Video": "Reproduzir","Play": "Reproduzir",+ "Close": "Fechar","Open": "Abrir","Delete": "Excluir","Delete Task": "Excluir tarefa",diff --git a/webui/i18n/ru.json b/webui/i18n/ru.jsonindex 02e73a8d..171229a8 100644--- a/webui/i18n/ru.json+++ b/webui/i18n/ru.json@@ -62,6 +62,7 @@"Task Actions": "Действия","Play Video": "Воспроизвести","Play": "Воспроизвести",+ "Close": "Закрыть","Open": "Открыть","Delete": "Удалить","Delete Task": "Удалить задачу",diff --git a/webui/i18n/tr.json b/webui/i18n/tr.jsonindex 971d32a4..546319c1 100644--- a/webui/i18n/tr.json+++ b/webui/i18n/tr.json@@ -62,6 +62,7 @@"Task Actions": "İşlemler","Play Video": "Oynat","Play": "Oynat",+ "Close": "Kapat","Open": "Aç","Delete": "Sil","Delete Task": "Görevi sil",diff --git a/webui/i18n/vi.json b/webui/i18n/vi.jsonindex cde6c2b9..5ac75af4 100644--- a/webui/i18n/vi.json+++ b/webui/i18n/vi.json@@ -62,6 +62,7 @@"Task Actions": "Thao tác","Play Video": "Phát","Play": "Phát",+ "Close": "Đóng","Open": "Mở","Delete": "Xóa","Delete Task": "Xóa tác vụ",