From c23402aa9e65f0435767f487a9cbb25cdd213f97 Mon Sep 17 00:00:00 2001 From: yechentide Date: Sun, 14 Aug 2022 12:03:34 +0900 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=95/=E5=A4=9A=E9=80=89?= =?UTF-8?q?=E6=97=B6=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DSTManager.sh | 2 +- lib/utils.lua | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/DSTManager.sh b/DSTManager.sh index 1435b11..3b225f6 100755 --- a/DSTManager.sh +++ b/DSTManager.sh @@ -11,7 +11,7 @@ set -eu # 这个脚本里将会读取其他的全部shell脚本, 所以以下全局常量/变量在其他shell脚本里可用 declare OS='MacOS' -declare -r SCRIPT_VERSION='v1.5.4' +declare -r SCRIPT_VERSION='v1.5.5' declare -r ARCHITECTURE=$(getconf LONG_BIT) declare -r REPO_ROOT_DIR="$HOME/DSTServerManager" # DST服务端文件夹 diff --git a/lib/utils.lua b/lib/utils.lua index 86a2f8c..dc91965 100644 --- a/lib/utils.lua +++ b/lib/utils.lua @@ -103,7 +103,9 @@ function select_one(array, color, message, allow_cancel) local selected = tonumber(io.read()) if selected ~= nil and 1 <= selected and selected <= #array then - return array[selected] + local answer = array[selected] + if allow_cancel then table.remove(array, #array) end + return answer else color_print("error", "请输入正确的数字!", true) end @@ -127,6 +129,7 @@ function multi_select(array, color, message, allow_cancel) local num = tonumber(input) if num ~= nil and 1 <= num and num <= #array then if array[num] == "返回" then + table.remove(array, #array) return "返回" end result[#result+1] = num @@ -138,6 +141,7 @@ function multi_select(array, color, message, allow_cancel) end color_print("info", "你选择的: "..array2string(result), false) count_down(3, true) + if allow_cancel then table.remove(array, #array) end return result end