From 29ceedfe71a8e0f33a324c42d69d5608c9a6beb7 Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Wed, 15 Jul 2026 23:17:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/update_port.sh | 2 +- bin/utils/base.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/update_port.sh b/bin/update_port.sh index 2d1f6ea..f423bd9 100644 --- a/bin/update_port.sh +++ b/bin/update_port.sh @@ -92,6 +92,6 @@ ask_update_port(){ local config_file="$script_dir/../conf/config.json" local current_port=$(jq -r '.inbounds[0].port' "$config_file") - local new_port=$(ask_update "请输入新的端口号" "$current_port") + local new_port=$(ask_input "请输入新的端口号" "$current_port") update_port "$new_port" } \ No newline at end of file diff --git a/bin/utils/base.sh b/bin/utils/base.sh index 187caf4..e008286 100644 --- a/bin/utils/base.sh +++ b/bin/utils/base.sh @@ -77,10 +77,10 @@ check_config(){ } # 通用:展示当前值并询问新值 -# 用法: ask_update "提示语" "当前值(当前配置文件的值)" +# 用法: ask_input "提示语" "当前值(当前配置文件的值)" # 示例: -# new_port=$(ask_update "请输入新的端口号" "$(jq -r '.inbounds[0].port' $config_dir/config.json)") -ask_update() { +# new_port=$(ask_input "请输入新的端口号" "$(jq -r '.inbounds[0].port' $config_dir/config.json)") +ask_input() { local prompt="$1" # 提示语 local current_value="$2" local input @@ -88,4 +88,4 @@ ask_update() { read -p "${prompt} [当前: ${current_value}]: " input # 用户直接回车则保留当前值,否则使用新输入 echo "${input:-$current_value}" -} \ No newline at end of file +}