feat: improve UI/UX

This commit is contained in:
sofia-riese
2026-01-31 13:40:16 +08:00
parent 01174fa6d4
commit 07920b35ce
5 changed files with 441 additions and 373 deletions

View File

@@ -218,7 +218,7 @@ setrules() {
fi
;;
3)
comp_box "是否确认清空全部自定义规则"
comp_box "是否确认清空全部自定义规则"
btm_box "1) 是" \
"0) 否,返回上级菜单"
read -r -p "$COMMON_INPUT> " res
@@ -233,9 +233,10 @@ setrules() {
4)
if [ "$proxies_bypass" = "OFF" ]; then
comp_box "\033[33m本功能会自动将当前配置文件中的节点域名或IP设置为直连规则以防止出现双重流量\033[0m" \
"\033[33m请确保下游设备使用的节点与ShellCrash中使用的节点相同否则无法生效\033[0m"
btm_box "是否启用节点绕过?" \
"\033[33m请确保下游设备使用的节点与ShellCrash中使用的节点相同否则无法生效\033[0m" \
"" \
"是否启用节点绕过?"
btm_box
"1) 是" \
"0) 否,返回上级菜单"
read -r -p "$COMMON_INPUT> " res
@@ -503,10 +504,10 @@ setproxies() {
4)
if [ "$proxies_bypass" = "OFF" ]; then
comp_box "\033[33m本功能会自动将当前配置文件中的节点域名或IP设置为直连规则以防止出现双重流量\033[0m" \
"\033[33m请确保下游设备使用的节点与ShellCrash中使用的节点相同否则无法生效\033[0m"
btm_box "是否确定启用节点绕过:" \
"\033[33m请确保下游设备使用的节点与ShellCrash中使用的节点相同否则无法生效\033[0m" \
"" \
"1) 是" \
"是否确定启用节点绕过:"
btm_box "1) 是" \
"0) 否,返回上级菜单"
read -r -p "$COMMON_INPUT> " res
if [ "$res" = "1" ]; then

View File

@@ -14,77 +14,89 @@ providers() {
while true; do
# 获取模版名称
if [ -z "$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg)" ]; then
provider_temp_des=$(sed -n "1 p" "$CRASHDIR"/configs/${CORE_TYPE}_providers.list | awk '{print $1}')
provider_temp_des=$(sed -n "1 p" "$CRASHDIR"/configs/"${CORE_TYPE}"_providers.list | awk '{print $1}')
else
provider_temp_file=$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg | awk -F '=' '{print $2}')
provider_temp_des=$(grep "$provider_temp_file" "$CRASHDIR"/configs/${CORE_TYPE}_providers.list | awk '{print $1}')
provider_temp_des=$(grep "$provider_temp_file" "$CRASHDIR"/configs/"${CORE_TYPE}"_providers.list | awk '{print $1}')
[ -z "$provider_temp_des" ] && provider_temp_des=$provider_temp_file
fi
separator_line "-"
content_line "1) \033[32m生成\033[0m包含全部提供者的配置文件"
content_line "2) 选择\033[33m规则模版\033[0m \033[32m$provider_temp_des\033[0m"
content_line "3) \033[33m清理\033[0mproviders目录文件"
separator_line "-"
top_box "1) \033[32m生成\033[0m包含全部提供者的配置文件" \
"2) 选择\033[33m规则模版\033[0m \033[32m$provider_temp_des\033[0m" \
"3) \033[33m清理\033[0mproviders目录文件" \
""
common_back
read -p "请输入对应字母或数字 > " num
read -r -p "请输入对应字母或数字> " num
case "$num" in
"" | 0)
break
;;
1)
separator_line "-"
if [ -s "$CRASHDIR"/configs/providers.cfg ] || [ -s "$CRASHDIR"/configs/providers_uri.cfg ]; then
. "$CRASHDIR/menus/providers_$CORE_TYPE.sh"
gen_providers
else
content_line "\033[31m你还未添加链接或本地配置文件请先添加\033[0m"
sleep 1
msg_alert "\033[31m你还未添加链接或本地配置文件请先添加\033[0m"
fi
;;
2)
list=$(cat "$CRASHDIR/configs/${CORE_TYPE}_providers.list" | awk '{print $1}')
separator_line "-"
content_line "当前规则模版为:\033[32m$provider_temp_des\033[0m"
content_line "\033[33m请选择在线模版\033[0m"
separator_line "-"
comp_box "当前规则模版为:\033[32m$provider_temp_des\033[0m" \
"\033[33m请选择在线模版\033[0m"
list_box "$list"
separator_line "-"
content_line ""
content_line "a) 使用\033[36m本地模版\033[0m"
content_line ""
common_back
read -p "请输入对应字母或数字 > " num
read -r -p "请输入对应字母或数字> " num
case "$num" in
"" | 0) ;;
a)
read -p "请输入模版的路径(绝对路径) > " dir
if [ -s $dir ]; then
echo ""
read -r -p "请输入模版的路径(绝对路径)> " dir
if [ -s "$dir" ]; then
provider_temp_file=$dir
setconfig provider_temp_"$CORE_TYPE" "$provider_temp_file"
content_line "\033[32m设置成功\033[0m"
if setconfig provider_temp_"$CORE_TYPE" "$provider_temp_file"; then
common_success
else
content_line "\033[31m输入错误找不到对应模版文件\033[0m"
common_failed
fi
else
msg_alert "\033[31m输入错误找不到对应模版文件\033[0m"
fi
sleep 1
;;
*)
provider_temp_file=$(sed -n "$num p" "$CRASHDIR"/configs/${CORE_TYPE}_providers.list 2>/dev/null | awk '{print $2}')
provider_temp_file=$(sed -n "$num p" "$CRASHDIR"/configs/"${CORE_TYPE}"_providers.list 2>/dev/null | awk '{print $2}')
if [ -z "$provider_temp_file" ]; then
errornum
sleep 1
else
setconfig provider_temp_"$CORE_TYPE" "$provider_temp_file"
if setconfig provider_temp_"$CORE_TYPE" "$provider_temp_file"; then
common_success
else
common_failed
fi
fi
;;
esac
;;
3)
content_line "\033[33m将清空 $CRASHDIR/providers 目录下所有内容\033[0m"
read -p "是否继续?(1/0) > " res
[ "$res" = "1" ] && rm -rf "$CRASHDIR"/providers && common_success
comp_box "\033[33m将清空 $CRASHDIR/providers 目录下所有内容\033[0m" \
"" \
"是否继续?"
btm_box "1) 是" \
"0) 否"
read -r -p "$COMMON_INPUT> " res
if [ "$res" = "1" ]; then
if rm -rf "$CRASHDIR"/providers; then
common_success
else
common_failed
fi
fi
;;
*)
errornum
sleep 1
break
;;
esac
done

View File

@@ -9,18 +9,18 @@ __IS_PROVIDERS_CLASH=1
# 生成clash的providers配置文件
gen_providers() {
if [ -z "$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg)" ]; then
provider_temp_file="$(sed -n "1 p" "$CRASHDIR"/configs/${CORE_TYPE}_providers.list | awk '{print $2}')"
provider_temp_file="$(sed -n "1 p" "$CRASHDIR"/configs/"${CORE_TYPE}"_providers.list | awk '{print $2}')"
else
provider_temp_file=$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg | awk -F '=' '{print $2}')
fi
echo "-----------------------------------------------"
if [ -s "$provider_temp_file" ]; then
ln -sf "$provider_temp_file" "$TMPDIR"/provider_temp_file
else
echo -e "\033[33m正在获取在线模版\033[0m"
msg_alert "\033[33m正在获取在线模版......\033[0m"
get_bin "$TMPDIR"/provider_temp_file "rules/${CORE_TYPE}_providers/$provider_temp_file"
[ -z "$(grep -o 'rules' "$TMPDIR"/provider_temp_file)" ] && {
echo -e "\033[31m下载失败请尝试更换安装源\033[0m"
msg_alert "\033[31m下载失败请尝试更换安装源\033[0m"
. "$CRASHDIR"/menus/9_upgrade.sh && setserver
setproviders
}
@@ -35,13 +35,13 @@ gen_providers(){
rm -rf "$TMPDIR"/provider_temp_file
# 基于单订阅生成providers模块
if [ -n "$1" ]; then
gen_providers_txt $@
gen_providers_txt "$@"
providers_tags=$1
else
# 基于全部订阅/本地文件生成
[ -s "$CRASHDIR"/configs/providers.cfg ] && {
providers_tags=''
while read line;do
while read -r line; do
gen_providers_txt $line
providers_tags=$(echo "$providers_tags, $tag" | sed 's/^, //')
done <"$CRASHDIR"/configs/providers.cfg
@@ -61,10 +61,13 @@ gen_providers(){
# 调用内核测试
. "$CRASHDIR"/starts/check_core.sh && check_core && "$TMPDIR"/CrashCore -t -d "$BINDIR" -f "$TMPDIR"/config.yaml
if [ "$?" = 0 ]; then
echo -e "\033[32m配置文件生成成功\033[0m"
msg_alert "\033[32m配置文件生成成功\033[0m"
mkdir -p "$CRASHDIR"/yamls
mv -f "$TMPDIR"/config.yaml "$CRASHDIR"/yamls/config.yaml
read -p "是否立即启动/重启服务?(1/0) > " res
comp_box "是否立即启动/重启服务?"
btm_box "1) 是" \
"0) 否"
read -r -p "$COMMON_INPUT> " res
[ "$res" = 1 ] && {
start_core && . "$CRASHDIR"/libs/set_cron.sh && cronset '更新订阅'
exit
@@ -72,12 +75,12 @@ gen_providers(){
else
rm -rf "$TMPDIR"/CrashCore
rm -rf "$TMPDIR"/config.yaml
echo -e "\033[31m生成配置文件出错请仔细检查输入\033[0m"
msg_alert "\033[31m生成配置文件出错请仔细检查输入\033[0m"
fi
}
gen_providers_txt() {
if [ -n "$(echo $2|grep -E '^./')" ];then
if [ -n "$(echo "$2" | grep -E '^./')" ]; then
type=file
path=$2
download_url=
@@ -120,4 +123,3 @@ EOF
# 写入提供者
echo ' - {name: '"$tag"', type: url-test, tolerance: 100, lazy: true, use: ['"$tag"']}' >>"$TMPDIR"/providers/proxy-groups.yaml
}

View File

@@ -9,18 +9,17 @@ __IS_PROVIDERS_SINGBOX=1
# 生成singbox的providers配置文件
gen_providers() {
if [ -z "$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg)" ]; then
provider_temp_file="$(sed -n "1 p" "$CRASHDIR"/configs/${CORE_TYPE}_providers.list | awk '{print $2}')"
provider_temp_file="$(sed -n "1 p" "$CRASHDIR"/configs/"${CORE_TYPE}"_providers.list | awk '{print $2}')"
else
provider_temp_file=$(grep "provider_temp_${CORE_TYPE}" "$CRASHDIR"/configs/ShellCrash.cfg | awk -F '=' '{print $2}')
fi
echo "-----------------------------------------------"
if [ -s "$provider_temp_file" ]; then
ln -sf "$provider_temp_file" "$TMPDIR"/provider_temp_file
else
echo -e "\033[33m正在获取在线模版\033[0m"
msg_alert "\033[33m正在获取在线模版......\033[0m"
get_bin "$TMPDIR"/provider_temp_file "rules/${CORE_TYPE}_providers/$provider_temp_file"
[ -z "$(grep -o 'route' "$TMPDIR"/provider_temp_file)" ] && {
echo -e "\033[31m下载失败请尝试更换安装源\033[0m"
msg_alert "\033[31m下载失败请尝试更换安装源\033[0m"
. "$CRASHDIR"/menus/9_upgrade.sh && setserver
setproviders
}
@@ -38,14 +37,14 @@ EOF
EOF
# 基于单订阅生成providers模块
if [ -n "$1" ]; then
gen_providers_txt $@
gen_providers_txt "$@"
providers_tags=\"$1\"
else
# 基于全部订阅/本地文件生成
[ -s "$CRASHDIR"/configs/providers.cfg ] && {
providers_tags=''
while read line;do
gen_providers_txt $line
while read -r line; do
gen_providers_txt "$line"
providers_tags=$(echo "$providers_tags, \"$tag\"" | sed 's/^, //')
done <"$CRASHDIR"/configs/providers.cfg
}
@@ -66,18 +65,21 @@ EOF
# 调用内核测试
. "$CRASHDIR"/starts/check_core.sh && check_core && "$TMPDIR"/CrashCore merge "$TMPDIR"/config.json -C "$TMPDIR"/providers
if [ "$?" = 0 ]; then
echo -e "\033[32m配置文件生成成功如果启动超时建议更新里手动安装Singbox-srs数据库常用包\033[0m"
msg_alert "\033[32m配置文件生成成功如果启动超时建议更新里手动安装Singbox-srs数据库常用包\033[0m"
mkdir -p "$CRASHDIR"/jsons
mv -f "$TMPDIR"/config.json "$CRASHDIR"/jsons/config.json
rm -rf "$TMPDIR"/providers
read -p "是否立即启动/重启服务?(1/0) > " res
rm -rf "$TMPDIR"/providerss
comp_box "是否立即启动/重启服务?"
btm_box "1) 是" \
"0) 否"
read -r -p "$COMMON_INPUT> " res
[ "$res" = 1 ] && {
start_core && . "$CRASHDIR"/libs/set_cron.sh && cronset '更新订阅'
exit
}
else
echo -e "\033[31m生成配置文件出错请仔细检查输入\033[0m"
rm -rf "$TMPDIR"/CrashCore
msg_alert "\033[31m生成配置文件出错请仔细检查输入\033[0m"
# rm -rf "$TMPDIR"/providers
fi
}
@@ -91,7 +93,7 @@ gen_providers_txt(){
include=${7#\#}
[ -n "$exclude" ] && exclude_ele="\"exclude\": \"$exclude\","
[ -n "$include" ] && include_ele="\"include\": \"$include\","
if [ -n "$(echo $2|grep -E '^./')" ];then
if [ -n "$(echo "$2" | grep -E '^./')" ]; then
cat >>"$TMPDIR"/providers/providers.json <<EOF
{
"tag": "$tag",

View File

@@ -10,13 +10,17 @@ __IS_MODULE_SUBCONVERTER=1
# Subconverter在线订阅转换
subconverter() {
while true; do
separator_line "-"
content_line "1) \033[32m生成\033[0m包含全部节点/订阅的配置文件"
[ -z "$exclude" ] && exclude="未设置"
[ -z "$include" ] && include="未设置"
line_break
separator_line "="
content_line "1) \033[32m生成\033[0m包含全部节点订阅的配置文件"
content_line "2) 设置\033[31m排除节点正则\033[0m \033[47;30m$exclude\033[0m"
content_line "3) 设置\033[32m包含节点正则\033[0m \033[47;30m$include\033[0m"
content_line "4) 选择\033[33m在线规则模版\033[0m"
content_line "5) 选择\033[0mSubconverter服务器\033[0m"
content_line "6) 自定义浏览器UA \033[32m$user_agent\033[0m"
content_line ""
common_back
read -r -p "请输入对应数字> " num
case "$num" in
@@ -50,62 +54,78 @@ subconverter() {
;;
*)
errornum
break
;;
esac
done
}
gen_link_flt() { # 排除节点正则
[ -z "$exclude" ] && exclude="未设置"
separator_line "-"
content_line "\033[33m当前过滤关键字\033[47;30m$exclude\033[0m"
separator_line "-"
content_line "\033[33m匹配关键字的节点会在导入时被【屏蔽】\033[0m"
content_line "多个关键字可以用\033[30;47m | \033[0m号分隔"
content_line "\033[32m支持正则表达式\033[0m空格请使用\033[30;47m + \033[0m号替代"
separator_line "-"
content_line " 000 \033[31m删除\033[0m关键字"
content_line " 回车 取消输入并返回上级菜单"
separator_line "-"
read -r -p "请输入关键字 > " exclude
if [ "$exclude" = '000' ]; then
separator_line "-"
# 排除节点正则
gen_link_flt() {
comp_box "\033[33m当前过滤关键字\033[47;30m$exclude\033[0m" \
"" \
"\033[33m匹配关键字的节点会在导入时被【屏蔽】\033[0m" \
"多个关键字可以用\033[30;47m | \033[0m号分隔" \
"\033[32m支持正则表达式\033[0m空格请使用\033[30;47m + \033[0m号替代"
btm_box "\033[36m请直接输入节点过滤关键字\033[0m" \
"或输入 d \033[31m清空\033[0m节点过滤关键字" \
"或输入 0 返回上级菜单"
read -r -p "请输入> " res
case "$res" in
0)
return 0
;;
d)
exclude=''
content_line "\033[31m 已删除节点过滤关键字!!!\033[0m"
;;
*)
exclude="$res"
;;
esac
if setconfig exclude "'$exclude'"; then
common_success
else
common_failed
fi
setconfig exclude "'$exclude'"
}
gen_link_ele() { # 包含节点正则
[ -z "$include" ] && include="未设置"
separator_line "-"
content_line "\033[33m当前筛选关键字\033[47;30m$include\033[0m"
separator_line "-"
content_line "\033[33m仅有匹配关键字的节点才会被【导入】\033[0m"
content_line "多个关键字可以用\033[30;47m | \033[0m号分隔"
content_line "\033[32m支持正则表达式\033[0m空格请使用\033[30;47m + \033[0m号替代"
separator_line "-"
content_line " 000 \033[31m删除\033[0m关键字"
content_line " 回车 取消输入并返回上级菜单"
separator_line "-"
read -r -p "请输入关键字 > " include
if [ "$include" = '000' ]; then
separator_line "-"
include=''
content_line "\033[31m 已删除节点匹配关键字!!!\033[0m"
# 包含节点正则
gen_link_ele() {
comp_box "\033[33m当前筛选关键字\033[47;30m$include\033[0m" \
"" \
"\033[33m仅有匹配关键字的节点才会被【导入】\033[0m" \
"多个关键字可以用\033[30;47m | \033[0m号分隔" \
"\033[32m支持正则表达式\033[0m空格请使用\033[30;47m + \033[0m号替代"
btm_box "\033[36m请直接输入节点匹配关键字\033[0m" \
"或输入 d \033[31m清空\033[0m节点匹配关键字" \
"或输入 0 返回上级菜单"
read -r -p "请输入> " res
case "$res" in
0)
return 0
;;
d)
include=""
;;
*)
include="$res"
;;
esac
if setconfig exclude "'$include'"; then
common_success
else
common_failed
fi
setconfig include "'$include'"
}
gen_link_config() { #选择在线规则模版
# 选择在线规则模版
gen_link_config() {
list=$(grep -aE '^5' "$CRASHDIR"/configs/servers.list | awk '{print $2$4}')
now=$(grep -aE '^5' "$CRASHDIR"/configs/servers.list | sed -n ""$rule_link"p" | awk '{print $2}')
separator_line "-"
content_line "当前使用规则为:\033[33m$now\033[0m"
separator_line "-"
comp_box "当前使用规则为:\033[33m$now\033[0m"
list_box "$list"
separator_line "-"
content_line ""
common_back
read -r -p "请输入对应数字> " num
totalnum=$(grep -acE '^5' "$CRASHDIR"/configs/servers.list)
@@ -116,21 +136,25 @@ gen_link_config() { #选择在线规则模版
elif [ "$num" -le "$totalnum" ]; then
# 将对应标记值写入配置
rule_link=$num
setconfig rule_link $rule_link
separator_line "-"
content_line "\033[32m设置成功返回上级菜单\033[0m"
if setconfig rule_link "$rule_link"; then
msg_alert "\033[32m设置成功返回上级菜单\033[0m"
else
common_failed
fi
fi
}
gen_link_server() { #选择Subconverter服务器
# 选择Subconverter服务器
gen_link_server() {
list=$(grep -aE '^3|^4' "$CRASHDIR"/configs/servers.list | awk '{print $3" "$2}')
now=$(grep -aE '^3|^4' "$CRASHDIR"/configs/servers.list | sed -n ""$server_link"p" | awk '{print $3}')
separator_line "-"
content_line "\033[36m以下为互联网采集的第三方服务器具体安全性请自行斟酌\033[0m"
content_line "\033[32m感谢以下作者的无私奉献\033[0m"
content_line "当前使用后端为:\033[33m$now\033[0m"
separator_line "-"
comp_box "\033[36m以下为互联网采集的第三方服务器具体安全性请自行斟酌\033[0m" \
"\033[32m感谢以下作者的无私奉献\033[0m" \
"" \
"当前使用后端为:\033[33m$now\033[0m"
list_box "$list"
content_line ""
common_back
read -r -p "请输入对应数字> " num
totalnum=$(grep -acE '^3|^4' "$CRASHDIR"/configs/servers.list)
@@ -141,23 +165,30 @@ gen_link_server() { #选择Subconverter服务器
elif [ "$num" -le "$totalnum" ]; then
# 将对应标记值写入配置
server_link=$num
setconfig server_link $server_link
separator_line "-"
if setconfig server_link "$server_link"; then
content_line "\033[32m设置成功返回上级菜单\033[0m"
else
common_failed
fi
fi
}
set_sub_ua() {
separator_line "-"
content_line "\033[36m无法正确获取配置文件时可尝试使用\033[0m"
content_line " 1 使用自动UA(默认)"
content_line " 2 不使用UA"
content_line " 3 使用自定义UA\033[32m$user_agent\033[0m"
separator_line "-"
while true; do
comp_box "\033[36m无法正确获取配置文件时可尝试使用\033[0m" \
"" \
"当前UA$user_agent"
content_line "1) 使用自动UA默认"
content_line "2) 不使用UA"
content_line "3) 使用自定义UA"
content_line "4) 清空UA"
content_line ""
content_line "0) 返回上级菜单"
separator_line "="
read -r -p "请输入对应数字> " num
case "$num" in
0)
user_agent=''
break
;;
1)
user_agent='auto'
@@ -166,12 +197,32 @@ set_sub_ua() {
user_agent='none'
;;
3)
read -r -p "请输入自定义UA(不要包含空格特殊符号!) > " text
[ -n "$text" ] && user_agent="$text"
comp_box "\033[33m注意\n自定义UA不可包含空格特殊符号!\033[0m"
btm_box "\033[36m请直接输入自定义UA\033[0m" \
"或输入 0 返回上级菜单"
read -r -p "请输入> " text
if [ "$text" = 0 ]; then
continue
elif [ -n "$text" ]; then
user_agent="$text"
fi
;;
4)
user_agent=''
;;
*)
errornum
continue
;;
esac
[ "$num" -le 3 ] && setconfig user_agent "$user_agent"
if [ "$num" -ge 1 ] && [ "$num" -le 4 ]; then
if setconfig user_agent "$user_agent"; then
common_success
else
common_failed
fi
fi
break
done
}