diff --git a/src-tauri/src/core/service.rs b/src-tauri/src/core/service.rs index 2426c081..154bd4e0 100644 --- a/src-tauri/src/core/service.rs +++ b/src-tauri/src/core/service.rs @@ -154,8 +154,21 @@ pub async fn reinstall_service() -> Result<()> { let install_shell: String = install_path.to_string_lossy().into_owned(); let uninstall_shell: String = uninstall_path.to_string_lossy().into_owned(); + + // 获取提示文本,如果 i18n 失败则使用硬编码默认值 + let prompt = crate::utils::i18n::t("Service Administrator Prompt"); + let prompt = if prompt == "Service Administrator Prompt" { + if Config::verge().latest().language.as_deref() == Some("zh") || Config::verge().latest().language.is_none() { + "Clash Verge 需要使用管理员权限来重新安装系统服务" + } else { + "Clash Verge needs administrator privileges to reinstall the system service" + } + } else { + &prompt + }; + let command = format!( - r#"do shell script "sudo '{uninstall_shell}' && sudo '{install_shell}'" with administrator privileges"# + r#"do shell script "sudo '{uninstall_shell}' && sudo '{install_shell}'" with administrator privileges with prompt "{prompt}""# ); log::debug!(target: "app", "command: {}", command); diff --git a/src/locales/en.json b/src/locales/en.json index a9ef4532..4fdea74f 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -470,5 +470,6 @@ "Validate YAML File": "Validate YAML File", "Validate Merge File": "Validate Merge File", "Validation Success": "Validation Success", - "Validation Failed": "Validation Failed" + "Validation Failed": "Validation Failed", + "Service Administrator Prompt": "Clash Verge needs administrator privileges to reinstall the system service" } diff --git a/src/locales/zh.json b/src/locales/zh.json index 288b5df6..20d099f2 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -462,5 +462,6 @@ "Validation Success": "验证成功", "Validation Failed": "验证失败", "Verge Basic Setting": "Verge 基础设置", - "Verge Advanced Setting": "Verge 高级设置" + "Verge Advanced Setting": "Verge 高级设置", + "Service Administrator Prompt": "Clash Verge 需要使用管理员权限来重新安装系统服务" }