chore: update clash_verge_service_ipc to version 2.0.24 , improve service prompts and improve service need reinstall process

This commit is contained in:
Tunglies
2025-12-04 23:04:03 +08:00
parent 7aeaab6e5c
commit f2ad62e446
7 changed files with 27 additions and 22 deletions

4
Cargo.lock generated
View File

@@ -1315,8 +1315,8 @@ dependencies = [
[[package]]
name = "clash_verge_service_ipc"
version = "2.0.23"
source = "git+https://github.com/clash-verge-rev/clash-verge-service-ipc#957fdfa7d26ba7afa1a64efef925c99163fdc598"
version = "2.0.24"
source = "git+https://github.com/clash-verge-rev/clash-verge-service-ipc#c5a557d5a9f15264697a8ac70d42946a881598d7"
dependencies = [
"anyhow",
"compact_str",

View File

@@ -24,6 +24,7 @@
- 修复创建窗口时在非简体中文环境或深色主题下的短暂闪烁
- 修复更新时加载进度条异常
- 升级内核失败导致内核不可用问题
- 修复 macOS 在安装和卸载服务时提示与操作不匹配
<details>
<summary><strong> ✨ 新增功能 </strong></summary>
@@ -57,6 +58,7 @@
- 优化流量采样和数据处理
- 优化应用重启/退出时的资源清理性能, 大幅缩短执行时间
- 优化 WebSocket 连接机制
- 改进旧版 Service 需要重新安装检测流程
</details>

View File

@@ -93,7 +93,7 @@ tauri-plugin-devtools = { version = "2.0.1" }
tauri-plugin-mihomo = { git = "https://github.com/clash-verge-rev/tauri-plugin-mihomo" }
clash_verge_logger = { git = "https://github.com/clash-verge-rev/clash-verge-logger" }
async-trait = "0.1.89"
clash_verge_service_ipc = { version = "2.0.23", features = [
clash_verge_service_ipc = { version = "2.0.24", features = [
"client",
], git = "https://github.com/clash-verge-rev/clash-verge-service-ipc" }
arc-swap = "1.7.1"

View File

@@ -25,7 +25,9 @@ notifications:
title: Application Hidden
body: Clash Verge is running in the background.
service:
adminPrompt: Installing the service requires administrator privileges.
adminInstallPrompt: Installing the service requires administrator privileges.
adminUninstallPrompt: Uninstalling the service requires administrator privileges.
tray:
dashboard: Dashboard
ruleMode: Rule Mode

View File

@@ -25,7 +25,8 @@ notifications:
title: 应用已隐藏
body: Clash Verge 正在后台运行。
service:
adminPrompt: 安装服务需要管理员权限
adminInstallPrompt: 安装服务需要管理员权限
adminUninstallPrompt: 写在服务需要管理员权限
tray:
dashboard: 仪表板
ruleMode: 规则模式

View File

@@ -25,7 +25,8 @@ notifications:
title: 應用已隱藏
body: Clash Verge 正在背景執行。
service:
adminPrompt: 安裝服務需要管理員權限
adminInstallPrompt: 安裝服務需要管理員權限
adminUninstallPrompt: 卸载服務需要管理員權限
tray:
dashboard: 儀表板
ruleMode: 規則模式

View File

@@ -275,7 +275,7 @@ async fn uninstall_service() -> Result<()> {
crate::utils::i18n::sync_locale().await;
let prompt = rust_i18n::t!("service.adminPrompt").to_string();
let prompt = rust_i18n::t!("service.adminUninstallPrompt").to_string();
let command = format!(
r#"do shell script "sudo '{uninstall_shell}'" with administrator privileges with prompt "{prompt}""#
);
@@ -311,13 +311,11 @@ async fn install_service() -> Result<()> {
crate::utils::i18n::sync_locale().await;
let prompt = rust_i18n::t!("service.adminPrompt").to_string();
let prompt = rust_i18n::t!("service.adminInstallPrompt").to_string();
let command = format!(
r#"do shell script "sudo '{install_shell}'" with administrator privileges with prompt "{prompt}""#
);
// logging!(debug, Type::Service, "install command: {}", command);
let status = StdCommand::new("osascript")
.args(vec!["-e", &command])
.status()?;
@@ -351,7 +349,7 @@ async fn reinstall_service() -> Result<()> {
}
/// 强制重装服务UI修复按钮
pub async fn force_reinstall_service() -> Result<()> {
async fn force_reinstall_service() -> Result<()> {
logging!(info, Type::Service, "用户请求强制重装服务");
reinstall_service().await.map_err(|err| {
logging!(error, Type::Service, "强制重装服务失败: {}", err);
@@ -383,10 +381,10 @@ async fn check_service_version() -> Result<String> {
}
/// 检查服务是否需要重装
pub async fn check_service_needs_reinstall() -> bool {
pub async fn check_service_needs_reinstall() -> Result<bool> {
match check_service_version().await {
Ok(version) => version != clash_verge_service_ipc::VERSION,
Err(_) => false,
Ok(version) => Ok(version != clash_verge_service_ipc::VERSION),
Err(e) => Err(e),
}
}
@@ -429,9 +427,10 @@ pub(super) async fn start_with_existing_service(config_file: &PathBuf) -> Result
pub(super) async fn run_core_by_service(config_file: &PathBuf) -> Result<()> {
logging!(info, Type::Service, "正在尝试通过服务启动核心");
if check_service_needs_reinstall().await {
reinstall_service().await?;
}
let mut manager = SERVICE_MANAGER.lock().await;
let status = manager.check_service_comprehensive().await;
manager.handle_service_status(&status).await?;
drop(manager);
logging!(info, Type::Service, "服务已运行且版本匹配,直接使用");
start_with_existing_service(config_file).await
@@ -521,11 +520,11 @@ impl ServiceManager {
/// 综合服务状态检查(一次性完成所有检查)
pub async fn check_service_comprehensive(&self) -> ServiceStatus {
match is_service_available().await {
Ok(_) => {
logging!(info, Type::Service, "服务当前可用,检查是否需要重装");
if check_service_needs_reinstall().await {
logging!(info, Type::Service, "服务需要重装且允许重装");
match check_service_needs_reinstall().await {
Ok(need) => {
logging!(debug, Type::Service, "服务当前可用,检查是否需要重装");
if need {
logging!(debug, Type::Service, "服务需要重装且需要重装");
ServiceStatus::NeedsReinstall
} else {
ServiceStatus::Ready