115 lines
4.6 KiB
Python
115 lines
4.6 KiB
Python
from utils.generate_utils import (
|
||
generate_template,
|
||
generate_comment_all,
|
||
generate_report,
|
||
batch_convert_folder,
|
||
generate_zodiac,
|
||
)
|
||
from utils.file_utils import export_templates_folder, initialize_project, export_data
|
||
|
||
|
||
def application():
|
||
from rich.console import Console
|
||
from rich.panel import Panel
|
||
from rich.prompt import Prompt
|
||
from rich.table import Table
|
||
from rich.align import Align
|
||
from rich import box
|
||
import sys
|
||
|
||
console = Console()
|
||
|
||
while True:
|
||
console.clear()
|
||
|
||
# 1. 创建一个表格,不显示表头,使用圆角边框
|
||
table = Table(box=None, show_header=False, padding=(0, 2))
|
||
|
||
# 2. 添加两列:序号列(居右),内容列(居左)
|
||
table.add_column(justify="right", style="cyan bold")
|
||
table.add_column(justify="left")
|
||
|
||
# 3. 添加行内容
|
||
table.add_row("1.", "📁 生成图片路径(每一个幼儿一个图片文件夹)")
|
||
table.add_row("2.", "🤖 生成评语(根据姓名、学段、性别)")
|
||
table.add_row("3.", "📊 生成报告(根据表格生成)")
|
||
table.add_row("4.", "📑 格式转换(PPT转PDF)")
|
||
table.add_row("5.", "📑 生肖转化(根据生日)")
|
||
table.add_row("6.", "📦 导出数据模板(Zip)")
|
||
table.add_row("7.", "📦 初始化系统")
|
||
table.add_row("8.", "📤 导出数据")
|
||
table.add_row("9.", "🚪 退出系统")
|
||
|
||
# 4. 将表格放入面板,并居中显示
|
||
panel = Panel(
|
||
Align.center(table),
|
||
title="[bold green]🌱 幼儿园成长报告助手",
|
||
subtitle="[dim]By 寒寒",
|
||
width=60,
|
||
border_style="bright_blue",
|
||
box=box.ROUNDED, # 圆角边框更柔和
|
||
)
|
||
|
||
# 使用 Align.center 让整个菜单在屏幕中间显示
|
||
console.print(Align.center(panel, vertical="middle"))
|
||
console.print("\n") # 留点空隙
|
||
|
||
choice = Prompt.ask(
|
||
"👉 请输入序号执行",
|
||
choices=["1", "2", "3", "4", "5", "6", "7","8","9"],
|
||
default="1",
|
||
)
|
||
|
||
try:
|
||
if choice == "1":
|
||
console.rule("[bold cyan]正在执行: 生成模板[/]")
|
||
with console.status(
|
||
"[bold green]正在创建文件夹结构...[/]", spinner="dots"
|
||
):
|
||
generate_template()
|
||
elif choice == "2":
|
||
console.rule("[bold yellow]正在执行: AI 生成评语[/]")
|
||
# 这里的 generate_comment_all 最好内部有进度条,或者简单的 print
|
||
generate_comment_all()
|
||
elif choice == "3":
|
||
console.rule("[bold blue]正在执行: PPT 合成[/]")
|
||
with console.status(
|
||
"[bold blue]正在处理图片和文字...[/]", spinner="earth"
|
||
):
|
||
generate_report()
|
||
elif choice == "4":
|
||
console.rule("[bold magenta]正在执行: PDF 批量转换[/]")
|
||
# 调用上面的批量转换函数,传入你的 output 文件夹路径
|
||
batch_convert_folder(config["output_folder"])
|
||
elif choice == "5":
|
||
console.rule("[bold magenta]正在执行: 生肖转化[/]")
|
||
# 调用上面的批量转换函数,传入你的 output 文件夹路径
|
||
generate_zodiac()
|
||
elif choice == "6":
|
||
console.rule("[bold magenta]正在执行: 导出数据模板[/]")
|
||
# 调用上面的批量转换函数,传入你的 output 文件夹路径
|
||
export_templates_folder()
|
||
elif choice == "7":
|
||
console.rule("[bold magenta]正在执行: 初始化系统[/]")
|
||
# 调用上面的批量转换函数,传入你的 output 文件夹路径
|
||
initialize_project()
|
||
elif choice == "8":
|
||
console.rule("[bold magenta]正在执行: 导出数据[/]")
|
||
# 调用上面的批量转换函数,传入你的 output 文件夹路径
|
||
export_data()
|
||
elif choice == "9":
|
||
console.print("[bold red]👋 再见![/]")
|
||
sys.exit()
|
||
Prompt.ask("按 [bold]Enter[/] 键返回主菜单...")
|
||
except Exception as e:
|
||
console.print(
|
||
Panel(
|
||
f"[bold red]❌ 发生错误:[/]\n{e}", title="Error", border_style="red"
|
||
)
|
||
)
|
||
Prompt.ask("按 Enter 键继续...")
|
||
|
||
|
||
if __name__ == "__main__":
|
||
application()
|