import subprocess
import random
# 修正datetime导入方式：从模块中导入datetime类
from datetime import datetime  # 关键修正

# 定义颜色常量
GRAY = "\033[90m"
RESET = "\033[0m"
WHITE = "\033[37m"
# 定义表情字典
EMOJIS = {
    'time': "⏰"
}

# 随机颜色文本生成函数
def random_color_text(text):
    colors = ["\033[31m", "\033[32m", "\033[34m", "\033[35m", "\033[36m"]
    return f"{random.choice(colors)}{text}{RESET}"

# 定义初始选择函数
def yun():
    while True:
        print("\033[33m=\033[0m" * 50)
        print("\033[33m1.进入工具\033[0m")
        print("\033[33m2.退出工具\033[0m")
        print("\033[33m=\033[0m" * 50)
        choice = input("请输入选项数字：")

        if choice == '1':
            yunmeng()
        elif choice == '2':
            print("\033[33m已退出工具\033[0m")
            break
        else:
            print("\033[33m输入无效，请重新选择\033[0m")

# 定义主菜单函数
def yunmeng():
    while True:
        print(f"\n{GRAY}╔═════════════════⋆★⋆══════════════════╗{RESET}")
        print(f"{GRAY}║░░░░░░░░░░ 鬼戮美化工具 V1.0 ░░░░░░░░░░║{RESET}")
        print(f"{GRAY}╚══════════════════════════════════════╝{RESET}")    
        print(f"\n{WHITE}👑作者: 鬼戮{RESET}")
        print(f"{WHITE}📢🐧号3968469760;{RESET}")
        # 修正时间调用方式：使用datetime类的now()方法
        print(f"{WHITE}{EMOJIS['time']}执行时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}{RESET}")  # 已修正
        
        print(f"--------------------------------------------------")    
        menu_items = [
            random_color_text("dat打包解包"), 
            random_color_text("uexp非块解包"),
            random_color_text("uexp非块打包"), 
            random_color_text("自动美化"),
            random_color_text("搭建环境(第一次使用执行)"),
            random_color_text("抓小包"),
            random_color_text("配置功能"),
            random_color_text("自动查找dat和特征码"),
            random_color_text("免root输出代码"),
            random_color_text("退出工具")
        ]
        print(f"""
{GRAY}╭─────────────────────────────────╮{RESET}
{GRAY}│      🎮和平精英美化工具         │{RESET}
{GRAY}│ 1. {menu_items[0]}      2. {menu_items[1]}     │{RESET}
{GRAY}│ 3. {menu_items[2]}      4. {menu_items[3]}     │{RESET}
{GRAY}│ 5. {menu_items[4]}      6. {menu_items[5]}│{RESET}
{GRAY}│ 7. {menu_items[6]}│{RESET}
{GRAY}│ 8. {menu_items[7]}│{RESET}
{GRAY}│ 9. {menu_items[8]}│{RESET}
{GRAY}│ 0. {menu_items[9]}                         │{RESET}
{GRAY}╰─────────────────────────────────╯{RESET}
""")
        choice = input("请输入选项数字：")

        if choice == '1':
            subprocess.call("bash 打包解包.sh", shell=True)
        elif choice == '2':
            subprocess.call("bash 非块.sh", shell=True)
        elif choice == '3':
            subprocess.call("bash 非块打包.sh", shell=True)
        elif choice == '4':
            subprocess.call("python 自动美化.py", shell=True)
        elif choice == '5':
            subprocess.call("bash 搭建环境.sh", shell=True)
        elif choice == '6':
            subprocess.call("python 抓小包.py", shell=True)
        elif choice == '7':
            subprocess.call("python 配置功能.py", shell=True)
        elif choice ==  '8':
            subprocess.call("python 自动提取dat.py", shell=True) 
        elif choice ==  '9':
            subprocess.call("python 免root输出和平美化代码.py", shell=True) 
        elif choice == '0':
            print("\033[33m返回上一级\033[0m")
            break
        else:
            print("\033[33m输入无效，请重新选择\033[0m")

if __name__ == "__main__":
    yun()  # 启动程序
