Merge pull request #239 from wnlen/dev

Dev
This commit is contained in:
Arvin
2026-04-29 17:07:16 +08:00
committed by GitHub
3 changed files with 18 additions and 12 deletions
-1
View File
@@ -258,7 +258,6 @@ _clash_alias_auto_restore_proxy() {
_clash_alias_persist_enabled || return 0
_clash_alias_export_proxy || return 0
echo "♻️ 已恢复当前 shell 代理环境(来自持久化状态)"
return 0
}
+15 -4
View File
@@ -195,20 +195,32 @@ cmd_on() {
local relay_switch
local relay_switch_file relay_err_file relay_rc
local system_proxy_rc system_proxy_degraded="false"
local already_on="false"
trap 'rc=$?; ui_error "开启代理失败:cmd_on 在第 ${LINENO} 行执行失败:${BASH_COMMAND}(返回码:${rc})"; ui_next "clashctl logs service"; exit "$rc"' ERR
prepare
ensure_on_path_ready
# fast path 1:代理已经完整开启
if status_is_running 2>/dev/null \
&& proxy_controller_reachable 2>/dev/null \
&& [ "$(system_proxy_status 2>/dev/null || echo off)" = "on" ] \
&& system_proxy_matches_runtime 2>/dev/null; then
already_on="true"
print_on_feedback
trap - ERR
return 0
fi
# fast path 2:runtime 已运行,只是系统代理被关了
if status_is_running 2>/dev/null \
&& proxy_controller_reachable 2>/dev/null; then
system_proxy_enable || true
print_on_feedback
trap - ERR
return 0
fi
ensure_on_path_ready
if status_is_running 2>/dev/null && ! proxy_controller_reachable 2>/dev/null; then
ui_warn "检测到内核已运行但控制器不可访问,正在重启以加载当前配置"
service_restart || die_state "控制器启动失败:内核重启未完成" "clashctl logs mihomo"
@@ -285,7 +297,6 @@ cmd_off() {
local system_proxy_rc
prepare
service_stop
if system_proxy_disable; then
:
+3 -7
View File
@@ -21,29 +21,25 @@ for arg in "$@"; do
esac
done
# shellcheck source=scripts/core/common.sh
source "$PROJECT_DIR/scripts/core/common.sh"
# shellcheck source=scripts/core/runtime.sh
source "$PROJECT_DIR/scripts/core/runtime.sh"
# shellcheck source=scripts/core/config.sh
source "$PROJECT_DIR/scripts/core/config.sh"
# shellcheck source=scripts/init/systemd.sh
source "$PROJECT_DIR/scripts/core/proxy.sh"
source "$PROJECT_DIR/scripts/init/systemd.sh"
# shellcheck source=scripts/init/systemd-user.sh
source "$PROJECT_DIR/scripts/init/systemd-user.sh"
# shellcheck source=scripts/init/script.sh
source "$PROJECT_DIR/scripts/init/script.sh"
init_project_context "$PROJECT_DIR"
load_env_if_exists
detect_install_scope auto
system_proxy_disable || true
clear_shell_proxy_persist_state || true
service_stop || true
remove_runtime_entry || true
remove_clashctl_entry || true
remove_clashctl_completion || true
remove_shell_alias_entry || true
clear_shell_proxy_persist_state || true
if [ "$PURGE_RUNTIME" = "true" ]; then
rm -rf "$RUNTIME_DIR"