#微验Shell模板

echo "\n欢迎使用微验网络验证\n微验官网：llua.cn\n加载中...\n"

if ! [ -e "rc4" ]; then
    echo "rc4文件缺失"
    exit 1
fi
chmod 777 rc4

#配置区
w463d5d26ce9bcf2803678cf42c53bd45_wyUrl="http://wy.llua.cn/api/" #API接口(一般不用改)
w463d5d26ce9bcf2803678cf42c53bd45_wyAppid="17325" #APPID(应用ID)
w463d5d26ce9bcf2803678cf42c53bd45_wyAppkey="g24Yl4is25sYIliR" #APPKEY(应用秘钥)
w463d5d26ce9bcf2803678cf42c53bd45_wyRc4key="68gT17wk16r116Ki" #Rc4KEY(Rc4秘钥)

#函数区
parse_json() {
  json=$1
  query=$2
  value=$(echo "$json" | grep -o "\"$query\":[^ }]*" | sed 's/"[^"]*":\([^,}]*\).*/\1/' | head -n 1)
  value="${value#\"}"
  value="${value%\"}"
  echo "$value"
}

#公告区
notice=`curl -s "${w463d5d26ce9bcf2803678cf42c53bd45_wyUrl}?id=notice&app=${w463d5d26ce9bcf2803678cf42c53bd45_wyAppid}"`
deNotice=`./rc4 $notice $w463d5d26ce9bcf2803678cf42c53bd45_wyRc4key "de"`
Notices=`parse_json "$deNotice" "app_gg"`
echo "系统公告:\n${Notices}\n"


#!/system/bin/sh

# 蓝猫助手 - 多文件下载注入工具
# 支持多种配置，便于二次修改

# 颜色定义
RED='\033[1;91m'
GREEN='\033[1;92m'
YELLOW='\033[1;93m'
BLUE='\033[1;94m'
CYAN='\033[1;96m'
WHITE='\033[1;97m'
PURPLE='\033[1;95m'
NC='\033[0m'

# 图标
CHECK='✓'
CROSS='✗'
ARROW='➜'
TRIANGLE='▶'
STAR='★'

# 清屏
clear


cat << "EOF"
                                  
    ██████╗ █████╗ ████████╗      
   ██╔════╝██╔══██╗╚══██╔══╝      
   ██║     ███████║   ██║         
   ██║     ██╔══██║   ██║         
   ╚██████╗██║  ██║   ██║         
    ╚═════╝╚═╝  ╚═╝   ╚═╝         
                                  
EOF
# 简洁标题
echo -e "${CYAN}╭─────────────────────────────────────╮${NC}"
echo -e "${CYAN}│${NC}        ${WHITE}蓝猫助手${NC}         ${WHITE}│   1.0.0${NC}"
echo -e "${CYAN}╰─────────────────────────────────────╯${NC}"
echo ""

# 系统信息
echo -e "${BLUE}${TRIANGLE}${NC} ${WHITE}系统信息${NC}"

# 获取安卓版本
android_version=$(getprop ro.build.version.release 2>/dev/null || echo "未知")
android_sdk=$(getprop ro.build.version.sdk 2>/dev/null || echo "0")
echo -e "  ${ARROW} 安卓版本: ${GREEN}Android ${android_version}${NC}"
echo -e "  ${ARROW} SDK版本:  ${GREEN}${android_sdk}${NC}"

# 获取手机型号
device_model=$(getprop ro.product.model 2>/dev/null || echo "未知")
echo -e "  ${ARROW} 手机型号: ${YELLOW}${device_model}${NC}"

# 获取设备品牌
device_brand=$(getprop ro.product.brand 2>/dev/null || echo "未知")
echo -e "  ${ARROW} 设备品牌: ${CYAN}${device_brand}${NC}"

# 获取内核版本
kernel_version=$(uname -r 2>/dev/null | cut -d'-' -f1)
echo -e "  ${ARROW} 内核版本: ${CYAN}${kernel_version}${NC}"

# 获取当前时间
current_time=$(date '+%Y-%m-%d %H:%M:%S')
echo -e "  ${ARROW} 当前时间: ${CYAN}${current_time}${NC}"

echo -e "  ${ARROW} 官方频道: ${CYAN}@BlueCatB${NC}"

# 检查you.sh是否存在
YOU_SH="$(dirname "$0")/you.sh"
# 检查是否安卓11以下
if [ "$android_sdk" -lt 30 ]; then
    echo -e "  ${ARROW} 使用环境: ${GREEN}普通Shell (安卓11以下)${NC}"
    USE_YOUSH=false
else
    if [ -f "$YOU_SH" ]; then
        echo -e "  ${ARROW} 使用环境: ${GREEN}Shizuku${NC}"
        USE_YOUSH=true
    else
        echo -e "  ${ARROW} 使用环境: ${YELLOW}普通模式${NC}"
        USE_YOUSH=false
    fi
fi

echo ""

# 分隔线
echo -e "${CYAN}═════════════════════════════════════════${NC}"
echo ""

# ===========================================
# 配置文件区域 - 可以在这里添加更多下载任务
# ===========================================

# 任务列表配置
# 格式: ["任务名称"]="下载链接|目标目录|显示名称"
declare -A TASKS=(
    ["task1"]="https://www.cccimg.com/down.php/8ec5235538b24584aa6892462c6f23f3.zip|/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/Paks/|超广角(14590)"
    ["task2"]="https://www.cccimg.com/down.php/66cb66f6beeb08e2d4162daeb596f34f.zip|/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/Paks/|微加速广角(14590)"
    ["task3"]="https://www.cccimg.com/down.php/8472760fbeed8fefaaba6093885bc3dd.zip|/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/Paks/|实体范围(14590)" 
    ["task4"]="https://www.cccimg.com/down.php/4296373b8f239e29bff247196e988d76.zip|/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/Paks/|全局美化(14590)"
    ["task5"]="https://www.cccimg.com/down.php/168dd86d75f65b4f5143fe6be28c80ae.zip|/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/Paks/|人物天线(14590)"       
    ["task6"]="https://www.cccimg.com/down.php/e4741fe63c942d71b039f2ea2a8137e3.zip|/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/Paks/|原版文件(14590)"            
    ["task7"]="https://www.cccimg.com/down.php/12d6a1e91cca34c08b71f19fb84e7a1f.zip|/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/Paks/|度假岛除草"
    ["task8"]="https://www.cccimg.com/down.php/5c850bd17cc01d0ac7833e88da8eedb2.zip|/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/Paks/|度假岛黑天水泥地"    
    ["task9"]="https://www.cccimg.com/down.php/a85e3cc532344c205e66bc361df3e00e.zip|/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/Config/Android/|辅助瞄准增强(配置文件)"
    ["task10"]="https://www.cccimg.com/down.php/200ff6cc9afaaac05a8dc45e6e5157ec.zip|/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/SaveGames/|动态范围(配置文件)"
    ["task11"]="https://www.cccimg.com/down.php/5c8687ec1c77ea06495b4e155b4c4eff.zip|/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/SaveGames/|静态范围(配置文件)"
    ["task12"]="https://www.cccimg.com/down.php/6fddb869b385a910a6667bed38c7a0d9.zip|/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/Paks/|功能文件一(14515)"
    ["task13"]="https://www.cccimg.com/down.php/a96ec51e660da7bfd95d8b2467a9ae4c.zip|/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/Paks/|功能文件二(14515)"
    ["task14"]="https://www.cccimg.com/down.php/bae924f36a67c4faec77015bcb86128b.zip|/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/Paks/|功能文件三(14515)"
    ["task15"]="https://www.cccimg.com/down.php/fac75527178eede9d420089696786015.zip|/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/Paks/|原版文件(14515)"
)

# 定义任务顺序
TASK_ORDER=("task1" "task2" "task3" "task4" "task5" "task6" "task7" "task8" "task9" "task10" "task11" "task12" "task13" "task14" "task15")

# 下载工具优先级
DOWNLOAD_TOOLS=("wget" "curl")
# 解压工具优先级
EXTRACT_TOOLS=("unzip" "busybox")
# 临时目录
TEMP_DIR="/sdcard/Download"
[ ! -d "$TEMP_DIR" ] && TEMP_DIR="/storage/emulated/0/Download"
[ ! -d "$TEMP_DIR" ] && TEMP_DIR="/data/local/tmp"

# ===========================================
# 函数定义
# ===========================================

# 通过you.sh执行命令（不显示输出）- 安卓11+专用
exec_via_yoush_silent() {
    local command="$1"
    if [ "$USE_YOUSH" = true ] && [ -f "$YOU_SH" ]; then
        echo "$command" | sh "$YOU_SH" > /dev/null 2>&1
        return $?
    else
        eval "$command" > /dev/null 2>&1
        return $?
    fi
}

# 通过you.sh执行命令（有选择地显示输出）- 安卓11+专用
exec_via_yoush() {
    local command="$1"
    if [ "$USE_YOUSH" = true ] && [ -f "$YOU_SH" ]; then
        echo "$command" | sh "$YOU_SH"
        return $?
    else
        eval "$command"
        return $?
    fi
}

# 通用执行命令函数
exec_cmd() {
    local command="$1"
    local silent="$2"
    
    if [ "$USE_YOUSH" = true ] && [ -f "$YOU_SH" ]; then
        if [ "$silent" = "silent" ]; then
            echo "$command" | sh "$YOU_SH" > /dev/null 2>&1
        else
            echo "$command" | sh "$YOU_SH"
        fi
    else
        if [ "$silent" = "silent" ]; then
            eval "$command" > /dev/null 2>&1
        else
            eval "$command"
        fi
    fi
    return $?
}

# 检查命令是否存在
check_command() {
    for cmd in "$@"; do
        if command -v "$cmd" > /dev/null 2>&1; then
            echo "$cmd"
            return 0
        fi
    done
    return 1
}

# 显示菜单
show_menu() {
    echo -e "${BLUE}${TRIANGLE}${NC} ${WHITE}请选择要执行的任务${NC}"
    echo ""
    
    local index=1
    for task_name in "${TASK_ORDER[@]}"; do
        if [ -n "${TASKS[$task_name]}" ]; then
            # 解析任务配置获取显示名称
            local config="${TASKS[$task_name]}"
            IFS='|' read -r url dest display_name <<< "$config"
            [ -z "$display_name" ] && display_name="$task_name"
            
            # 格式化序号，两位对齐
            printf "  ${CYAN}%2d.${NC} ${WHITE}%s${NC}\n" "$index" "$display_name"
            ((index++))
        fi
    done
    
    echo ""
    echo -e "  ${CYAN}a.${NC} ${WHITE}全部执行${NC}"
    echo -e "  ${CYAN}m.${NC} ${WHITE}多选执行 (如: 1 3 5)${NC}"
    echo -e "  ${CYAN}q.${NC} ${WHITE}退出${NC}"
    echo ""
}

# 获取任务列表
get_task_list() {
    echo "${TASK_ORDER[@]}"
}

# 通过索引获取任务名称
get_task_by_index() {
    local index="$1"
    local task_list=($(get_task_list))
    
    if [ $index -ge 1 ] && [ $index -le ${#task_list[@]} ]; then
        echo "${task_list[$((index-1))]}"
        return 0
    else
        return 1
    fi
}

# 解析任务配置
parse_task() {
    local task_name="$1"
    local config="${TASKS[$task_name]}"
    
    if [ -z "$config" ]; then
        echo -e "${RED}错误: 任务 '${task_name}' 配置不存在${NC}"
        return 1
    fi
    
    # 分割配置: 下载链接|目标目录|显示名称
    IFS='|' read -r url dest display_name <<< "$config"
    
    # 如果没有指定显示名称，使用任务名称
    [ -z "$display_name" ] && display_name="$task_name"
    
    # 返回结果
    CURRENT_TASK_NAME="$task_name"
    CURRENT_DISPLAY_NAME="$display_name"
    CURRENT_URL="$url"
    CURRENT_DEST="$dest"
    
    # 创建临时文件名
    local timestamp=$(date +%s)
    local random=$((RANDOM % 1000))
    CURRENT_TEMP_FILE="${TEMP_DIR}/download_${task_name}_${timestamp}_${random}.zip"
    
    return 0
}

# 显示任务信息
show_task_info() {
    echo -e "${BLUE}${TRIANGLE}${NC} ${WHITE}任务信息${NC}"
    echo -e "  ${ARROW} 任务名称: ${YELLOW}${CURRENT_DISPLAY_NAME}${NC}"
    echo -e "  ${ARROW} 目标目录: ${YELLOW}${CURRENT_DEST}${NC}"
    echo ""
}

# 显示进度条
show_progress() {
    local percent="$1"
    local task="$2"
    local width=30
    local bar_length=$((percent * width / 100))
    local bar=""
    
    for ((i=0; i<bar_length; i++)); do
        bar="${bar}█"
    done
    for ((i=bar_length; i<width; i++)); do
        bar="${bar}░"
    done
    
    printf "\r  ${ARROW} ${task}进度: [${GREEN}%s${NC}] ${CYAN}%3d%%${NC}" "$bar" "$percent"
}

# 下载文件
download_file() {
    local url="$1"
    local output_file="$2"
    
    echo -e "  ${ARROW} 正在连接服务器..."
    
    # 检查下载工具
    local download_tool=$(check_command "${DOWNLOAD_TOOLS[@]}")
    if [ -z "$download_tool" ]; then
        echo -e "  ${ARROW} ${RED}✗ 下载失败${NC}"
        return 1
    fi
    
    # 创建临时目录
    exec_cmd "mkdir -p \"$(dirname "$output_file")\"" "silent"
    
    # 开始下载
    if [ "$download_tool" = "wget" ]; then
        wget -q -O "$output_file" "$url" 2>&1 | \
        while IFS= read -r line; do
            if echo "$line" | grep -q "[0-9]*%"; then
                local percent=$(echo "$line" | grep -o "[0-9]*%" | head -n1 | tr -d '%')
                [ -z "$percent" ] && percent=0
                show_progress "$percent" "下载"
            fi
        done
    elif [ "$download_tool" = "curl" ]; then
        curl -L -o "$output_file" "$url" 2>&1 | \
        while IFS= read -r line; do
            if echo "$line" | grep -q "[0-9]*\.[0-9]*%"; then
                local percent=$(echo "$line" | grep -o "[0-9]*\.[0-9]*%" | head -n1 | cut -d. -f1)
                [ -z "$percent" ] && percent=0
                show_progress "$percent" "下载"
            fi
        done
    fi
    
    # 确保显示100%
    show_progress 100 "下载"
    echo ""
    
    # 检查下载结果
    if [ $? -eq 0 ] && [ -f "$output_file" ]; then
        return 0
    else
        echo -e "  ${ARROW} ${RED}✗ 下载失败${NC}"
        return 1
    fi
}

# 解压文件（通过you.sh执行，不显示详细信息）
extract_file_silent() {
    local input_file="$1"
    local output_dir="$2"
    
    # 检查解压工具
    local extract_tool=$(check_command "${EXTRACT_TOOLS[@]}")
    if [ -z "$extract_tool" ]; then
        echo -e "  ${ARROW} ${RED}✗ 解压失败${NC}"
        return 1
    fi
    
    # 创建目标目录
    exec_cmd "mkdir -p \"$output_dir\"" "silent"
    
    # 构建解压命令
    local unzip_cmd=""
    if [ "$extract_tool" = "unzip" ]; then
        unzip_cmd="unzip -oq \"$input_file\" -d \"$output_dir\" 2>/dev/null"
    elif [ "$extract_tool" = "busybox" ]; then
        unzip_cmd="busybox unzip -oq \"$input_file\" -d \"$output_dir\" 2>/dev/null"
    else
        return 1
    fi
    
    # 执行解压命令
    if exec_cmd "$unzip_cmd" "silent"; then
        return 0
    else
        return 1
    fi
}

# 解压文件（带进度显示）
extract_file() {
    local input_file="$1"
    local output_dir="$2"
    
    echo -ne "  ${ARROW} 解压进度: ["
    for ((i=0; i<30; i++)); do
        echo -ne "░"
    done
    echo -ne "] ${CYAN}0%${NC}\r"
    
    # 在后台执行解压
    extract_file_silent "$input_file" "$output_dir" &
    local extract_pid=$!
    
    # 显示进度条动画
    for i in {1..30}; do
        local percent=$((i * 100 / 30))
        local bar_length=$i
        local bar=""
        
        for ((j=0; j<bar_length; j++)); do
            bar="${bar}▓"
        done
        for ((j=bar_length; j<30; j++)); do
            bar="${bar}░"
        done
        
        # 检查解压是否完成
        if ! kill -0 "$extract_pid" 2>/dev/null; then
            break
        fi
        
        printf "  ${ARROW} 解压进度: [${GREEN}%s${NC}] ${CYAN}%3d%%${NC}\r" "$bar" "$percent"
        sleep 0.1
    done
    
    # 等待解压完成
    wait "$extract_pid"
    local result=$?
    
    # 显示完成
    printf "  ${ARROW} 解压进度: [${GREEN}"
    for ((i=0; i<30; i++)); do
        printf "█"
    done
    printf "${NC}] ${CYAN}100%%${NC}\n"
    
    if [ $result -eq 0 ]; then
        return 0
    else
        echo -e "  ${ARROW} ${YELLOW}⚠ 解压过程可能有警告${NC}"
        return 1
    fi
}

# 执行单个任务
execute_task() {
    local task_name="$1"
    
    echo -e "${CYAN}═════════════════════════════════════════${NC}"
    echo -e "${GREEN}${TRIANGLE}${NC} ${WHITE}开始执行任务: ${YELLOW}${CURRENT_DISPLAY_NAME}${NC}"
    
    # 解析任务配置
    if ! parse_task "$task_name"; then
        return 1
    fi
    
    # 显示任务信息
    show_task_info
    
    # 下载文件
    echo -e "  ${ARROW} 开始下载..."
    if ! download_file "$CURRENT_URL" "$CURRENT_TEMP_FILE"; then
        return 1
    fi
    
    # 检查文件大小
    local file_size=0
    if [ -f "$CURRENT_TEMP_FILE" ]; then
        if command -v wc > /dev/null 2>&1; then
            file_size=$(wc -c < "$CURRENT_TEMP_FILE" 2>/dev/null || echo 0)
        elif command -v stat > /dev/null 2>&1; then
            file_size=$(stat -c%s "$CURRENT_TEMP_FILE" 2>/dev/null || stat -f%z "$CURRENT_TEMP_FILE" 2>/dev/null || echo 0)
        fi
    fi
    
    if [ "$file_size" -eq 0 ]; then
        echo -e "  ${ARROW} ${RED}✗ 下载的文件为空${NC}"
        rm -f "$CURRENT_TEMP_FILE" 2>/dev/null
        return 1
    fi
    
    echo -e "  ${ARROW} 文件大小: ${CYAN}$((file_size/1024)) KB${NC}"
    echo ""
    
    # 解压文件
    echo -e "  ${ARROW} 开始解压..."
    if ! extract_file "$CURRENT_TEMP_FILE" "$CURRENT_DEST"; then
        echo -e "  ${ARROW} ${YELLOW}⚠ 解压可能不完整${NC}"
    fi
    
    # 清理临时文件
    rm -f "$CURRENT_TEMP_FILE" 2>/dev/null
    
    echo -e "  ${GREEN}${CHECK}${NC} 任务完成"
    
    return 0
}

# 执行多个任务
execute_multiple_tasks() {
    local task_indices="$1"
    local success_count=0
    local task_array=($task_indices)
    local total_tasks="${#task_array[@]}"
    local current_task=1
    
    echo -e "${BLUE}${TRIANGLE}${NC} ${WHITE}开始执行选中的任务 (共 ${total_tasks} 个)${NC}"
    echo ""
    
    for index in "${task_array[@]}"; do
        if [ $total_tasks -gt 1 ]; then
            echo -e "${WHITE}任务 ${current_task}/${total_tasks} (编号: ${index})${NC}"
        fi
        
        # 获取任务名称
        task_name=$(get_task_by_index "$index")
        if [ -n "$task_name" ]; then
            # 先解析任务获取显示名称
            if parse_task "$task_name"; then
                if execute_task "$task_name"; then
                    ((success_count++))
                fi
            fi
        else
            echo -e "  ${RED}✗ 任务编号 ${index} 无效，跳过${NC}"
        fi
        
        ((current_task++))
        
        # 如果不是最后一个任务，添加间隔
        if [ $current_task -le $total_tasks ]; then
            echo ""
        fi
    done
    
    echo -e "${CYAN}═════════════════════════════════════════${NC}"
    echo ""
    echo -e "${BLUE}${TRIANGLE}${NC} ${WHITE}执行结果${NC}"
    echo -e "  ${ARROW} 总任务数: ${total_tasks}"
    echo -e "  ${ARROW} 成功: ${GREEN}${success_count}${NC}"
    echo -e "  ${ARROW} 失败: ${RED}$((total_tasks - success_count))${NC}"
    echo ""
    
    return $((total_tasks - success_count))
}

# 执行所有任务
execute_all_tasks() {
    local task_list=($(get_task_list))
    local success_count=0
    local total_tasks="${#task_list[@]}"
    local current_task=1
    
    echo -e "${BLUE}${TRIANGLE}${NC} ${WHITE}开始执行所有任务 (共 ${total_tasks} 个)${NC}"
    echo ""
    
    for task_name in "${task_list[@]}"; do
        if [ $total_tasks -gt 1 ]; then
            echo -e "${WHITE}任务 ${current_task}/${total_tasks}${NC}"
        fi
        
        # 先解析任务获取显示名称
        if parse_task "$task_name"; then
            if execute_task "$task_name"; then
                ((success_count++))
            fi
        fi
        
        ((current_task++))
        
        # 如果不是最后一个任务，添加间隔
        if [ $current_task -le $total_tasks ]; then
            echo ""
        fi
    done
    
    echo -e "${CYAN}═════════════════════════════════════════${NC}"
    echo ""
    echo -e "${BLUE}${TRIANGLE}${NC} ${WHITE}执行结果${NC}"
    echo -e "  ${ARROW} 总任务数: ${total_tasks}"
    echo -e "  ${ARROW} 成功: ${GREEN}${success_count}${NC}"
    echo -e "  ${ARROW} 失败: ${RED}$((total_tasks - success_count))${NC}"
    echo ""
    
    return $((total_tasks - success_count))
}

# 检查输入是否为数字
is_number() {
    local num="$1"
    [[ "$num" =~ ^[0-9]+$ ]]
}

# 检查输入是否为多个数字
is_multiple_numbers() {
    local input="$1"
    
    # 如果是空字符串，返回false
    [ -z "$input" ] && return 1
    
    # 检查是否包含空格
    if [[ "$input" =~ [[:space:]] ]]; then
        # 分割输入
        local numbers=($input)
        
        # 检查每个部分是否都是数字
        for num in "${numbers[@]}"; do
            if ! is_number "$num"; then
                return 1
            fi
        done
        return 0
    else
        return 1
    fi
}

# ===========================================
# 主程序
# ===========================================

# 检查任务列表是否为空
if [ ${#TASK_ORDER[@]} -eq 0 ]; then
    echo -e "${RED}错误: 任务列表为空${NC}"
    echo "请在脚本的 TASK_ORDER 数组中添加任务配置"
    echo ""
    exit 1
fi

# 显示菜单
show_menu

# 获取任务总数
task_count=${#TASK_ORDER[@]}

# 读取用户选择
read -p "请输入选择 (1-${task_count}, a, m, q): " choice

# 处理用户选择
if [ -z "$choice" ]; then
    echo -e "${RED}无效的选择${NC}"
    exit 1
elif [[ "$choice" =~ ^[0-9]+$ ]]; then
    # 单个数字输入
    if [ "$choice" -ge 1 ] && [ "$choice" -le "$task_count" ]; then
        # 执行单个任务
        task_name=$(get_task_by_index "$choice")
        if [ -n "$task_name" ]; then
            # 先解析任务获取显示名称
            if parse_task "$task_name"; then
                echo ""
                execute_task "$task_name"
            else
                echo -e "${RED}解析任务失败${NC}"
                exit 1
            fi
        else
            echo -e "${RED}无效的选择${NC}"
            exit 1
        fi
    else
        echo -e "${RED}无效的选择${NC}"
        exit 1
    fi
elif [[ "$choice" =~ ^[0-9]+[[:space:]]+[0-9]+.*$ ]]; then
    # 多个数字输入
    echo ""
    execute_multiple_tasks "$choice"
elif [[ "$choice" =~ ^[Aa]$ ]]; then
    # 执行所有任务
    echo ""
    execute_all_tasks
elif [[ "$choice" =~ ^[Mm]$ ]]; then
    # 多选模式
    echo ""
    echo -e "${BLUE}${TRIANGLE}${NC} ${WHITE}多选模式${NC}"
    echo -e "  ${ARROW} 请输入任务编号，用空格分隔"
    echo -e "  ${ARROW} 例如: 1 3 5 7"
    echo -e "  ${ARROW} 或者: 2 4 6 8 10"
    echo ""
    read -p "请输入任务编号: " multi_choice
    
    if is_multiple_numbers "$multi_choice"; then
        echo ""
        execute_multiple_tasks "$multi_choice"
    else
        echo -e "${RED}错误: 请输入有效的任务编号，用空格分隔${NC}"
        exit 1
    fi
elif [[ "$choice" =~ ^[Qq]$ ]]; then
    # 退出程序
    echo -e "${CYAN}退出程序${NC}"
    exit 0
else
    echo -e "${RED}无效的选择${NC}"
    exit 1
fi

echo -e "${CYAN}═════════════════════════════════════════${NC}"
echo ""
echo -e "${GREEN}${CHECK}${NC} ${WHITE}所有操作已完成！${NC}"
echo ""
echo -e "${BLUE}使用说明:${NC}"
echo -e "  ${CYAN}1.${NC} 为了稳定性除了配置文件都要配端口"
echo -e "  ${CYAN}2.${NC} 没效果自己问题此版本不可能会没效果"
echo -e "  ${CYAN}3.${NC} 全部功能都在桌面前开启遇见资源修复重新开启"
echo ""
echo -e "${YELLOW}注意: 使用改文件有封号风险，请谨慎操作${NC}"
echo ""
echo -e "${CYAN}═════════════════════════════════════════${NC}"
echo -e "${CYAN}蓝猫助手 - 任务执行结束${NC}"
echo ""

