From 40c631166a79efec40ec6d5d9fedc95ddce5a672 Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Sun, 12 Jul 2026 18:18:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E5=BC=8F=E5=8F=98=E9=87=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hiwifi-b70.sh | 21 ++++++++++++++++++++- newifi3_d2.sh | 22 +++++++++++++++++++++- r2s.sh | 24 ++++++++++++++++++++++-- x86-64.sh | 24 ++++++++++++++++++++++-- 4 files changed, 85 insertions(+), 6 deletions(-) diff --git a/hiwifi-b70.sh b/hiwifi-b70.sh index 576d5f2..5d6ce00 100644 --- a/hiwifi-b70.sh +++ b/hiwifi-b70.sh @@ -141,12 +141,31 @@ build() { echo -e "固件输出: ${PROJECT_OUTPUT_DIR}" } +# ============================================================= +# 交互输入函数 +# 参数1: 提示信息 +# 参数2: 默认值 +# 返回: 用户输入值,直接回车返回默认值 +# ============================================================= +ask_input() { + local prompt="$1" + local default="$2" + + read -p "${prompt} [默认: ${default}]: " value + + if [ -z "$value" ]; then + echo "$default" + else + echo "$value" + fi +} project_dir="$(cd "$(dirname "$0")" && pwd)" cd "$project_dir" # 要构建的 ImmortalWrt 版本 -version="25.12.1" +default_version="25.12.1" +version=$(ask_input "请输入 ImmortalWrt 版本" "$default_version") install_dependencies diff --git a/newifi3_d2.sh b/newifi3_d2.sh index 72929c2..2dfebeb 100644 --- a/newifi3_d2.sh +++ b/newifi3_d2.sh @@ -32,6 +32,25 @@ download_imagebuilder() { echo "$(pwd)/$folder" } +# ============================================================= +# 交互输入函数 +# 参数1: 提示信息 +# 参数2: 默认值 +# 返回: 用户输入值,直接回车返回默认值 +# ============================================================= +ask_input() { + local prompt="$1" + local default="$2" + + read -p "${prompt} [默认: ${default}]: " value + + if [ -z "$value" ]; then + echo "$default" + else + echo "$value" + fi +} + build() { # ============================================================= # 设备 Profile(必须与 ImageBuilder 支持的设备一致) @@ -146,7 +165,8 @@ project_dir="$(cd "$(dirname "$0")" && pwd)" cd "$project_dir" # 要构建的 ImmortalWrt 版本, 可以在 https://github.com/immortalwrt/immortalwrt 查询版本号 -version="25.12.1" +default_version="25.12.1" +version=$(ask_input "请输入 ImmortalWrt 版本" "$default_version") # 安装依赖 install_dependencies diff --git a/r2s.sh b/r2s.sh index ecb4bb9..95e13d6 100644 --- a/r2s.sh +++ b/r2s.sh @@ -188,16 +188,36 @@ build(){ fi } +# ============================================================= +# 交互输入函数 +# 参数1: 提示信息 +# 参数2: 默认值 +# 返回: 用户输入值,直接回车返回默认值 +# ============================================================= +ask_input() { + local prompt="$1" + local default="$2" + + read -p "${prompt} [默认: ${default}]: " value + + if [ -z "$value" ]; then + echo "$default" + else + echo "$value" + fi +} # 项目根目录,保证从任意位置执行 r2s.sh 都能找到其他资源 project_dir="$(cd "$(dirname "$0")" && pwd)" cd "$project_dir" # 要构建的 ImmortalWrt 版本 -version="25.12.1" +default_version="25.12.1" +version=$(ask_input "请输入 ImmortalWrt 版本" "$default_version") # 根分区大小(单位: MB) -rootfs_partsize=600 +default_rootfs_partsize="600" +rootfs_partsize=$(ask_input "请输入根分区大小(MB)" "$default_rootfs_partsize") install_dependencies diff --git a/x86-64.sh b/x86-64.sh index 1d364db..827d9b7 100644 --- a/x86-64.sh +++ b/x86-64.sh @@ -214,16 +214,36 @@ build(){ } +# ============================================================= +# 交互输入函数 +# 参数1: 提示信息 +# 参数2: 默认值 +# 返回: 用户输入值,直接回车返回默认值 +# ============================================================= +ask_input() { + local prompt="$1" + local default="$2" + + read -p "${prompt} [默认: ${default}]: " value + + if [ -z "$value" ]; then + echo "$default" + else + echo "$value" + fi +} # 项目根目录,用来保证从任意位置执行 main.sh 都能找到其他脚本 project_dir="$(cd "$(dirname "$0")" && pwd)" cd "$project_dir" # 要构建的 ImmortalWrt 版本, 可以在 https://github.com/immortalwrt/immortalwrt 查询版本号 -version="25.12.1" +default_version="25.12.1" +version=$(ask_input "请输入 ImmortalWrt 版本" "$default_version") # 根分区大小(单位: MB) -rootfs_partsize=600 +default_rootfs_partsize="600" +rootfs_partsize=$(ask_input "请输入根分区大小(MB)" "$default_rootfs_partsize") # 安装依赖 install_dependencies