mirror of
https://github.com/juewuy/ShellCrash.git
synced 2026-03-12 00:11:31 +00:00
style: improve and unify the user interface
This commit is contained in:
@@ -8,6 +8,54 @@ __IS_MODULE_9_UPGRADE_LOADED=1
|
|||||||
. "$CRASHDIR"/libs/check_cpucore.sh
|
. "$CRASHDIR"/libs/check_cpucore.sh
|
||||||
. "$CRASHDIR"/libs/web_get_bin.sh
|
. "$CRASHDIR"/libs/web_get_bin.sh
|
||||||
|
|
||||||
|
|
||||||
|
# ============================== menu formatter tools ==============================
|
||||||
|
# Set the total width of the menu
|
||||||
|
# (Adjusting this number will automatically change the entire menu, including the separator lines)
|
||||||
|
# Note: The number represents the number of columns that appear when the "||" appears on the right.
|
||||||
|
TABLE_WIDTH=60
|
||||||
|
|
||||||
|
# Define two extra-long template strings in advance
|
||||||
|
# (the length should be greater than the expected TABLE_WIDTH)
|
||||||
|
FULL_EQ="===================================================================================================="
|
||||||
|
FULL_DASH="- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
|
||||||
|
|
||||||
|
# Function to print content lines
|
||||||
|
# (using cursor jump)
|
||||||
|
print_content_line() {
|
||||||
|
echo -e "${1}\033[${TABLE_WIDTH}G||"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Increase the spacing between the front and back forms to improve readability
|
||||||
|
double_line_break() {
|
||||||
|
printf "\n\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to print separators
|
||||||
|
# (using string slicing)
|
||||||
|
# Parameter $1: Pass in "=" or "-"
|
||||||
|
print_separator_line() {
|
||||||
|
local separator_type="$1"
|
||||||
|
local output_line=""
|
||||||
|
|
||||||
|
# Calculate the length to be cut: width minus 1
|
||||||
|
# (because || occupies space, and it starts from the TABLE_WIDTH cell)
|
||||||
|
local len=$((TABLE_WIDTH - 1))
|
||||||
|
|
||||||
|
if [ "$separator_type" == "=" ]; then
|
||||||
|
# Extract characters from FULL_EQ up to output_line
|
||||||
|
output_line="${FULL_EQ:0:$len}"
|
||||||
|
else
|
||||||
|
# Extract from FULL_DASH
|
||||||
|
output_line="${FULL_DASH:0:$len}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Print out the truncated line + the ending ||
|
||||||
|
echo "${output_line}||"
|
||||||
|
}
|
||||||
|
# ============================================================
|
||||||
|
|
||||||
|
|
||||||
error_down(){
|
error_down(){
|
||||||
echo -e "\033[33m请尝试切换至其他安装源后重新下载!\033[0m"
|
echo -e "\033[33m请尝试切换至其他安装源后重新下载!\033[0m"
|
||||||
echo -e "或者参考 \033[32;4mhttps://juewuy.github.io/bdaz\033[0m 进行本地安装!"
|
echo -e "或者参考 \033[32;4mhttps://juewuy.github.io/bdaz\033[0m 进行本地安装!"
|
||||||
@@ -16,37 +64,41 @@ error_down(){
|
|||||||
|
|
||||||
# 更新/卸载功能菜单
|
# 更新/卸载功能菜单
|
||||||
upgrade() {
|
upgrade() {
|
||||||
|
double_line_break
|
||||||
while true; do
|
while true; do
|
||||||
echo "-----------------------------------------------"
|
|
||||||
[ -z "$version_new" ] && checkupdate
|
[ -z "$version_new" ] && checkupdate
|
||||||
[ -z "$core_v" ] && core_v=$crashcore
|
[ -z "$core_v" ] && core_v=$crashcore
|
||||||
core_v_new=$(eval echo \$"$crashcore"_v)
|
core_v_new=$(eval echo \$"$crashcore"_v)
|
||||||
echo -e "\033[30;47m欢迎使用更新功能:\033[0m"
|
|
||||||
echo "-----------------------------------------------"
|
# Automatically generate '====' lines
|
||||||
echo -e "当前目录(\033[32m$CRASHDIR\033[0m)剩余空间:\033[36m$(dir_avail "$CRASHDIR" -h)\033[0m"
|
print_separator_line "="
|
||||||
|
|
||||||
|
print_content_line " \033[30;47m更新与支持\033[0m"
|
||||||
|
|
||||||
|
# Automatically generate '- - - ' lines
|
||||||
|
print_separator_line "-"
|
||||||
|
|
||||||
|
print_content_line " 当前目录(\033[32m$CRASHDIR\033[0m)剩余空间:\033[36m$(dir_avail "$CRASHDIR" -h)\033[0m"
|
||||||
[ "$(dir_avail "$CRASHDIR")" -le 5120 ] && [ "$CRASHDIR" = "$BINDIR" ] && {
|
[ "$(dir_avail "$CRASHDIR")" -le 5120 ] && [ "$CRASHDIR" = "$BINDIR" ] && {
|
||||||
echo -e "\033[33m当前目录剩余空间较低,建议开启小闪存模式!\033[0m"
|
print_content_line " \033[33m当前目录剩余空间较低,建议开启小闪存模式!\033[0m"
|
||||||
sleep 1
|
|
||||||
}
|
}
|
||||||
echo "-----------------------------------------------"
|
print_separator_line "-"
|
||||||
echo -e " 1 更新\033[36m管理脚本 \033[33m$versionsh_l\033[0m > \033[32m$version_new \033[36m$release_type\033[0m"
|
print_content_line " 1) 更新\033[36m管理脚本 \033[33m$versionsh_l\033[0m > \033[32m$version_new \033[36m$release_type\033[0m"
|
||||||
echo -e " 2 切换\033[33m内核文件 \033[33m$core_v\033[0m > \033[32m$core_v_new\033[0m"
|
print_content_line " 2) 切换\033[33m内核文件 \033[33m$core_v\033[0m > \033[32m$core_v_new\033[0m"
|
||||||
echo -e " 3 更新\033[32m数据库文件\033[0m > \033[32m$GeoIP_v\033[0m"
|
print_content_line " 3) 更新\033[32m数据库文件\033[0m > \033[32m$GeoIP_v\033[0m"
|
||||||
echo -e " 4 安装本地\033[35mDashboard\033[0m面板"
|
print_content_line " 4) 安装本地\033[35mDashboard\033[0m面板"
|
||||||
echo -e " 5 安装/更新本地\033[33m根证书文件\033[0m"
|
print_content_line " 5) 安装/更新本地\033[33m根证书文件\033[0m"
|
||||||
echo -e " 6 查看\033[32mPAC\033[0m自动代理配置"
|
print_content_line " 6) 查看\033[32mPAC\033[0m自动代理配置"
|
||||||
echo "-----------------------------------------------"
|
print_content_line " 7) 切换\033[36m安装源\033[0m及\033[36m安装版本\033[0m"
|
||||||
echo -e " 7 切换\033[36m安装源\033[0m及\033[36m安装版本\033[0m"
|
print_content_line " 8) \033[32m配置自动更新\033[0m"
|
||||||
echo -e " 8 \033[32m配置自动更新\033[0m"
|
print_content_line " 9) \033[31m卸载ShellCrash\033[0m"
|
||||||
echo -e " 9 \033[31m卸载ShellCrash\033[0m"
|
print_content_line " 99) \033[36m鸣谢!\033[0m"
|
||||||
echo "-----------------------------------------------"
|
print_content_line " 0) 返回上级菜单"
|
||||||
echo -e " 99 \033[36m鸣谢!\033[0m"
|
print_separator_line "="
|
||||||
echo "-----------------------------------------------"
|
|
||||||
echo -e " 0 返回上级菜单"
|
read -p "请输入对应数字> " num
|
||||||
echo "-----------------------------------------------"
|
|
||||||
read -p "请输入对应数字 > " num
|
|
||||||
case "$num" in
|
case "$num" in
|
||||||
""|0)
|
"" | 0)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
1)
|
1)
|
||||||
@@ -59,15 +111,18 @@ upgrade() {
|
|||||||
setgeo
|
setgeo
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
|
double_line_break
|
||||||
setdb
|
setdb
|
||||||
|
double_line_break
|
||||||
;;
|
;;
|
||||||
5)
|
5)
|
||||||
setcrt
|
setcrt
|
||||||
;;
|
;;
|
||||||
6)
|
6)
|
||||||
echo "-----------------------------------------------"
|
print_separator_line "="
|
||||||
echo -e "PAC配置链接为:\033[30;47m http://$host:$db_port/ui/pac \033[0m"
|
print_content_line "PAC配置链接为:\033[30;47m http://$host:$db_port/ui/pac \033[0m"
|
||||||
echo -e "PAC的使用教程请参考:\033[4;32mhttps://juewuy.github.io/ehRUeewcv\033[0m"
|
print_content_line "PAC的使用教程请参考:\033[4;32mhttps://juewuy.github.io/ehRUeewcv\033[0m"
|
||||||
|
print_separator_line "="
|
||||||
sleep 2
|
sleep 2
|
||||||
;;
|
;;
|
||||||
7)
|
7)
|
||||||
@@ -80,25 +135,54 @@ upgrade() {
|
|||||||
. "$CRASHDIR"/menus/uninstall.sh && uninstall
|
. "$CRASHDIR"/menus/uninstall.sh && uninstall
|
||||||
;;
|
;;
|
||||||
99)
|
99)
|
||||||
echo "-----------------------------------------------"
|
print_separator_line "="
|
||||||
echo -e "感谢:\033[32mClash项目 \033[0m作者\033[36m Dreamacro\033[0m"
|
print_content_line " 感谢以下项目和作者!"
|
||||||
echo -e "感谢:\033[32msing-box项目 \033[0m作者\033[36m SagerNet\033[0m 项目地址:\033[32mhttps://github.com/SagerNet/sing-box\033[0m"
|
print_separator_line "-"
|
||||||
echo -e "感谢:\033[32mMetaCubeX项目 \033[0m作者\033[36m MetaCubeX\033[0m 项目地址:\033[32mhttps://github.com/MetaCubeX\033[0m"
|
|
||||||
echo -e "感谢:\033[32mYACD面板项目 \033[0m作者\033[36m haishanh\033[0m 项目地址:\033[32mhttps://github.com/haishanh/yacd\033[0m"
|
print_content_line " \033[32mClash项目 \033[0m作者:\033[36mDreamacro\033[0m"
|
||||||
echo -e "感谢:\033[32mzashboard项目 \033[0m作者\033[36m Zephyruso\033[0m 项目地址:\033[32mhttps://github.com/Zephyruso/zashboard\033[0m"
|
print_content_line ""
|
||||||
echo -e "感谢:\033[32mSubconverter \033[0m作者\033[36m tindy2013\033[0m 项目地址:\033[32mhttps://github.com/tindy2013/subconverter\033[0m"
|
|
||||||
echo -e "感谢:\033[32msing-box分支项目 \033[0m作者\033[36m PuerNya\033[0m 项目地址:\033[32mhttps://github.com/PuerNya/sing-box\033[0m"
|
print_content_line " \033[32msing-box项目 \033[0m作者:\033[36mSagerNet\033[0m"
|
||||||
echo -e "感谢:\033[32msing-box分支项目 \033[0m作者\033[36m reF1nd\033[0m 项目地址:\033[32mhttps://github.com/reF1nd/sing-box\033[0m"
|
print_content_line " 项目地址:\033[32mhttps://github.com/SagerNet/sing-box\033[0m"
|
||||||
echo -e "感谢:\033[32mDustinWin相关项目 \033[0m作者\033[36m DustinWin\033[0m 作者地址:\033[32mhttps://github.com/DustinWin\033[0m"
|
print_content_line ""
|
||||||
echo "-----------------------------------------------"
|
|
||||||
echo -e "特别感谢:\033[36m所有帮助及赞助过此项目的同仁们!\033[0m"
|
print_content_line " \033[32mMetaCubeX项目 \033[0m作者:\033[36mMetaCubeX\033[0m"
|
||||||
echo "-----------------------------------------------"
|
print_content_line " 项目地址:\033[32mhttps://github.com/MetaCubeX\033[0m"
|
||||||
|
print_content_line ""
|
||||||
|
|
||||||
|
print_content_line " \033[32mYACD面板项目 \033[0m作者:\033[36mhaishanh\033[0m"
|
||||||
|
print_content_line " 项目地址:\033[32mhttps://github.com/haishanh/yacd\033[0m"
|
||||||
|
print_content_line ""
|
||||||
|
|
||||||
|
print_content_line " \033[32mzashboard项目 \033[0m作者:\033[36mZephyruso\033[0m"
|
||||||
|
print_content_line " 项目地址:\033[32mhttps://github.com/Zephyruso/zashboard\033[0m"
|
||||||
|
print_content_line ""
|
||||||
|
|
||||||
|
print_content_line " \033[32mSubconverter \033[0m作者:\033[36mtindy2013\033[0m"
|
||||||
|
print_content_line " 项目地址:\033[32mhttps://github.com/tindy2013/subconverter\033[0m"
|
||||||
|
print_content_line ""
|
||||||
|
|
||||||
|
print_content_line " \033[32msing-box分支项目 \033[0m作者:\033[36mPuerNya\033[0m"
|
||||||
|
print_content_line " 项目地址:\033[32mhttps://github.com/PuerNya/sing-box\033[0m"
|
||||||
|
print_content_line ""
|
||||||
|
|
||||||
|
print_content_line " \033[32msing-box分支项目 \033[0m作者:\033[36mreF1nd\033[0m"
|
||||||
|
print_content_line " 项目地址:\033[32mhttps://github.com/reF1nd/sing-box\033[0m"
|
||||||
|
print_content_line ""
|
||||||
|
|
||||||
|
print_content_line " \033[32mDustinWin相关项目 \033[0m作者:\033[36mDustinWin\033[0m"
|
||||||
|
print_content_line " 作者地址:\033[32mhttps://github.com/DustinWin\033[0m"
|
||||||
|
print_content_line ""
|
||||||
|
|
||||||
|
print_separator_line "-"
|
||||||
|
print_content_line " 特别感谢:\033[36m所有帮助及赞助过此项目的同仁们!\033[0m"
|
||||||
|
print_separator_line "="
|
||||||
sleep 2
|
sleep 2
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
errornum
|
errornum
|
||||||
sleep 1
|
sleep 1
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -821,22 +905,25 @@ dbdir() {
|
|||||||
|
|
||||||
setdb() {
|
setdb() {
|
||||||
while true; do
|
while true; do
|
||||||
echo "-----------------------------------------------"
|
print_separator_line "="
|
||||||
echo -e "\033[36m安装本地版dashboard管理面板\033[0m"
|
print_content_line " \033[36m安装 dashboard 管理面板到本地\033[0m"
|
||||||
echo -e "\033[32m打开管理面板的速度更快且更稳定\033[0m"
|
print_content_line " \033[32m打开管理面板的速度更快且更稳定\033[0m"
|
||||||
echo "-----------------------------------------------"
|
print_separator_line "-"
|
||||||
echo -e "请选择面板\033[33m安装类型:\033[0m"
|
|
||||||
echo "-----------------维护中------------------------"
|
print_content_line " 请选择面板\033[33m安装类型:\033[0m"
|
||||||
echo -e " 1 安装\033[32mzashboard面板\033[0m(约2.2mb)"
|
print_content_line " - - - - - - -维护中- - - - - - -"
|
||||||
echo -e " 2 安装\033[32mMetaXD面板\033[0m(约1.5mb)"
|
print_content_line " 1) 安装\033[32mzashboard面板\033[0m(约2.2mb)"
|
||||||
echo -e " 3 安装\033[32mYacd-Meta魔改面板\033[0m(约1.7mb)"
|
print_content_line " 2) 安装\033[32mMetaXD面板\033[0m(约1.5mb)"
|
||||||
echo "---------------已停止维护----------------------"
|
print_content_line " 3) 安装\033[32mYacd-Meta魔改面板\033[0m(约1.7mb)"
|
||||||
echo -e " 4 安装\033[32m基础面板\033[0m(约500kb)"
|
print_content_line " - - - - - -已停止维护- - - - - -"
|
||||||
echo -e " 5 安装\033[32mMeta基础面板\033[0m(约800kb)"
|
print_content_line " 4) 安装\033[32m基础面板\033[0m(约500kb)"
|
||||||
echo -e " 6 安装\033[32mYacd面板\033[0m(约1.1mb)"
|
print_content_line " 5) 安装\033[32mMeta基础面板\033[0m(约800kb)"
|
||||||
echo "-----------------------------------------------"
|
print_content_line " 6) 安装\033[32mYacd面板\033[0m(约1.1mb)"
|
||||||
echo -e " 9 卸载\033[33m本地面板\033[0m"
|
print_content_line ""
|
||||||
echo " 0 返回上级菜单"
|
print_content_line " 9) 卸载\033[33m本地面板\033[0m"
|
||||||
|
print_content_line " 0) 返回上级菜单"
|
||||||
|
print_separator_line "="
|
||||||
|
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
case "$num" in
|
case "$num" in
|
||||||
"" | 0)
|
"" | 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user