feat(ai-studio): add prompt template storage

This commit is contained in:
chengma
2026-07-11 12:35:42 +08:00
parent 1267e0a727
commit 3ebefab91e
6 changed files with 81 additions and 4 deletions
+4
View File
@@ -253,6 +253,10 @@ def cover_prompts_dir(config=None) -> str:
return data_path("prompts", "cover", config=config)
def image_studio_prompts_dir(config=None) -> str:
return data_path("prompts", "image_studio", config=config)
def diagnostic_log_dir(config=None) -> str:
return data_path("logs", config=config)
+31
View File
@@ -10,6 +10,7 @@ from . import appconfig
TITLE_PROMPT_PATH = appconfig.title_prompt_path()
TITLE_TEMPLATES_DIR = appconfig.title_templates_dir()
COVER_PROMPTS_DIR = appconfig.cover_prompts_dir()
IMAGE_STUDIO_PROMPTS_DIR = appconfig.image_studio_prompts_dir()
TEMPLATE_EXT = ".txt"
INVALID_NAME_CHARS = set('\\/:*?"<>|')
DEFAULT_PROMPTS_PACKAGE = "app.default_prompts"
@@ -151,6 +152,36 @@ def delete_title_template(name, directory=TITLE_TEMPLATES_DIR) -> None:
delete_template(name, directory)
def list_image_studio_templates(directory=IMAGE_STUDIO_PROMPTS_DIR):
"""Return AI studio prompt template names sorted by display name."""
return list_templates(directory)
def load_image_studio_template(name, directory=IMAGE_STUDIO_PROMPTS_DIR) -> str:
"""Load one AI studio prompt template as raw text."""
return load_template(name, directory)
def save_image_studio_template(name, text, directory=IMAGE_STUDIO_PROMPTS_DIR) -> None:
"""Save one AI studio prompt template as raw UTF-8 text."""
save_template(name, text, directory)
def rename_image_studio_template(old, new, directory=IMAGE_STUDIO_PROMPTS_DIR) -> None:
"""Rename an AI studio prompt template with duplicate-name protection."""
rename_template(old, new, directory)
def delete_image_studio_template(name, directory=IMAGE_STUDIO_PROMPTS_DIR) -> None:
"""Delete one AI studio prompt template."""
delete_template(name, directory)
def list_cover_templates(directory=COVER_PROMPTS_DIR):
"""Return cover template names sorted by display name."""