Merge pull request #103 from lwmacct/dev/260111-1931

fix: 消除跨平台编译警告
This commit is contained in:
coso
2026-01-11 21:09:42 +08:00
committed by GitHub
6 changed files with 36 additions and 14 deletions
+3
View File
@@ -5,6 +5,9 @@
use std::sync::Arc;
use tauri::Manager;
#[cfg(target_os = "macos")]
use tauri::{Emitter, Listener};
use crate::commands;
use crate::tray::{TrayIconStatus, TrayManager, TrayStateSnapshot};
+5 -1
View File
@@ -2934,7 +2934,11 @@ pub struct PlaywrightStatus {
/// 获取系统 Chrome 可执行文件路径
fn get_system_chrome_path() -> Option<String> {
let _home = dirs::home_dir().unwrap_or_else(|| PathBuf::from("."));
#[cfg_attr(
not(any(target_os = "macos", target_os = "windows")),
allow(unused_variables)
)]
let home = dirs::home_dir().unwrap_or_else(|| PathBuf::from("."));
#[cfg(target_os = "macos")]
{
+4
View File
@@ -2,6 +2,10 @@
//!
//! 这是一个 Tauri 应用,提供 AI API 的代理和管理功能。
// 抑制 objc crate 宏内部的 unexpected_cfgs 警告
// 该警告来自 cocoa/objc 依赖的 msg_send! 宏,是已知的 issue
#![allow(unexpected_cfgs)]
// 核心模块
pub mod agent;
pub mod app;
+3
View File
@@ -6,6 +6,9 @@ use std::path::PathBuf;
use tauri::AppHandle;
use tracing::{debug, error, info};
#[cfg(target_os = "macos")]
use tracing::warn;
/// 截图错误类型
#[derive(Debug, thiserror::Error)]
pub enum CaptureError {
+16 -12
View File
@@ -8,8 +8,10 @@ use tauri::{AppHandle, Manager, WebviewUrl, WebviewWindowBuilder};
use tracing::{debug, info};
#[cfg(target_os = "macos")]
#[allow(deprecated)]
use cocoa::appkit::{NSColor, NSWindow};
#[cfg(target_os = "macos")]
#[allow(deprecated)]
use cocoa::base::{id, nil};
/// 窗口错误类型
@@ -164,6 +166,7 @@ pub fn open_floating_window(app: &AppHandle, image_path: &Path) -> Result<(), Wi
{
use objc::{msg_send, sel, sel_impl};
if let Ok(ns_win) = window.ns_window() {
#[allow(deprecated, unexpected_cfgs)]
unsafe {
let ns_window = ns_win as id;
// 设置窗口背景透明
@@ -202,24 +205,25 @@ pub fn open_floating_window(app: &AppHandle, image_path: &Path) -> Result<(), Wi
let (x, y) = calculate_window_position(app);
// 创建悬浮窗口(启用透明)
let _window =
WebviewWindowBuilder::new(app, FLOATING_WINDOW_LABEL, WebviewUrl::App(url.into()))
.inner_size(WINDOW_WIDTH, WINDOW_HEIGHT)
.position(x, y)
.decorations(false)
.always_on_top(true)
.skip_taskbar(true)
.visible(true)
.focused(true)
.transparent(true)
.build()
.map_err(|e| WindowError::CreateFailed(format!("{}", e)))?;
#[cfg_attr(not(target_os = "macos"), allow(unused_variables))]
let window = WebviewWindowBuilder::new(app, FLOATING_WINDOW_LABEL, WebviewUrl::App(url.into()))
.inner_size(WINDOW_WIDTH, WINDOW_HEIGHT)
.position(x, y)
.decorations(false)
.always_on_top(true)
.skip_taskbar(true)
.visible(true)
.focused(true)
.transparent(true)
.build()
.map_err(|e| WindowError::CreateFailed(format!("{}", e)))?;
// macOS: 设置窗口和 webview 背景透明
#[cfg(target_os = "macos")]
{
use objc::{msg_send, sel, sel_impl};
if let Ok(ns_win) = window.ns_window() {
#[allow(deprecated, unexpected_cfgs)]
unsafe {
let ns_window = ns_win as id;
// 设置窗口背景透明
+5 -1
View File
@@ -12,8 +12,10 @@ use tauri::{AppHandle, Manager, WebviewUrl, WebviewWindowBuilder};
use tracing::{debug, info};
#[cfg(target_os = "macos")]
#[allow(deprecated)]
use cocoa::appkit::{NSColor, NSWindow};
#[cfg(target_os = "macos")]
#[allow(deprecated)]
use cocoa::base::{id, nil};
use super::update_check_service::UpdateInfo;
@@ -164,7 +166,8 @@ pub fn open_update_window(
let (x, y) = calculate_window_position(app);
let _window = WebviewWindowBuilder::new(app, UPDATE_WINDOW_LABEL, WebviewUrl::App(url.into()))
#[cfg_attr(not(target_os = "macos"), allow(unused_variables))]
let window = WebviewWindowBuilder::new(app, UPDATE_WINDOW_LABEL, WebviewUrl::App(url.into()))
.inner_size(WINDOW_WIDTH, WINDOW_HEIGHT)
.position(x, y)
.decorations(false)
@@ -182,6 +185,7 @@ pub fn open_update_window(
{
use objc::{msg_send, sel, sel_impl};
if let Ok(ns_win) = window.ns_window() {
#[allow(deprecated, unexpected_cfgs)]
unsafe {
let ns_window = ns_win as id;
let clear_color = NSColor::clearColor(nil);