🐛 修复mac编译异常

This commit is contained in:
BTMuli
2025-12-02 21:49:59 +08:00
parent b38c3f9fbe
commit cde9149bbd

View File

@@ -77,10 +77,12 @@ pub fn is_in_admin() -> bool {
{
return Err("This function is only supported on Windows.".into());
}
#[cfg(target_os = "windows")]
{
use windows_sys::Win32::Foundation::{CloseHandle, HANDLE};
use windows_sys::Win32::Security::{
AllocateAndInitializeSid, CheckTokenMembership, FreeSid, SID_IDENTIFIER_AUTHORITY, TOKEN_QUERY,
AllocateAndInitializeSid, CheckTokenMembership, FreeSid, SID_IDENTIFIER_AUTHORITY,
TOKEN_QUERY,
};
use windows_sys::Win32::System::SystemServices::{
DOMAIN_ALIAS_RID_ADMINS, SECURITY_BUILTIN_DOMAIN_RID,
@@ -123,6 +125,7 @@ pub fn is_in_admin() -> bool {
result != 0 && is_admin != 0
}
}
}
// 以管理员权限重启应用
@@ -132,7 +135,8 @@ pub fn run_with_admin() -> Result<(), String> {
{
return Err("This function is only supported on Windows.".into());
}
#[cfg(target_os = "windows")]
{
use std::ffi::OsStr;
use std::iter::once;
use std::os::windows::ffi::OsStrExt;
@@ -176,4 +180,5 @@ pub fn run_with_admin() -> Result<(), String> {
Err("Failed to restart as administrator via cmd.".into())
}
}
}
}