Skip to content

Commit 9650d21

Browse files
zhanglinclaude
andcommitted
chore: fix biome lint and cargo fmt issues
- Remove useless fragments in SwitcherMode.tsx - Add biome-ignore for valid useEffect dependency - Apply biome and cargo fmt formatting across codebase 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 530d7db commit 9650d21

47 files changed

Lines changed: 1122 additions & 1068 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

aumate-app/src-tauri/src/commands/clipboard.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ pub async fn write_clipboard_image(
8585
log::info!("API: write_clipboard_image called, size={}x{}", width, height);
8686

8787
// 直接调用 ClipboardAdapter 的 write_image_rgba 方法
88-
state.clipboard.write_image_rgba(data, width as usize, height as usize).await.map_err(|e| {
89-
format!("Failed to write image to clipboard: {}", e)
90-
})
88+
state
89+
.clipboard
90+
.write_image_rgba(data, width as usize, height as usize)
91+
.await
92+
.map_err(|e| format!("Failed to write image to clipboard: {}", e))
9193
}
9294

9395
/// 从 PNG base64 写入图像到剪贴板 (优化版)
@@ -102,14 +104,12 @@ pub async fn write_clipboard_image_png(
102104
use image::GenericImageView;
103105

104106
// Decode base64 to PNG bytes
105-
let png_data = STANDARD.decode(&png_base64).map_err(|e| {
106-
format!("Failed to decode base64: {}", e)
107-
})?;
107+
let png_data =
108+
STANDARD.decode(&png_base64).map_err(|e| format!("Failed to decode base64: {}", e))?;
108109

109110
// Decode PNG to get RGBA pixels
110-
let img = image::load_from_memory(&png_data).map_err(|e| {
111-
format!("Failed to decode PNG: {}", e)
112-
})?;
111+
let img =
112+
image::load_from_memory(&png_data).map_err(|e| format!("Failed to decode PNG: {}", e))?;
113113

114114
let (width, height) = img.dimensions();
115115
let rgba = img.to_rgba8();
@@ -118,7 +118,9 @@ pub async fn write_clipboard_image_png(
118118
log::info!("API: Decoded PNG to {}x{} RGBA image", width, height);
119119

120120
// 直接调用 ClipboardAdapter 的 write_image_rgba 方法(绕过不支持图像的通用 write 方法)
121-
state.clipboard.write_image_rgba(data, width as usize, height as usize).await.map_err(|e| {
122-
format!("Failed to write image to clipboard: {}", e)
123-
})
121+
state
122+
.clipboard
123+
.write_image_rgba(data, width as usize, height as usize)
124+
.await
125+
.map_err(|e| format!("Failed to write image to clipboard: {}", e))
124126
}

aumate-app/src-tauri/src/commands/draw.rs

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ pub async fn create_draw_window(app: AppHandle) -> Result<(), String> {
1111
log::info!("Draw window exists, showing it");
1212
let _ = window.show();
1313
let _ = window.set_focus();
14-
14+
1515
// 重新设置窗口层级以覆盖菜单栏和 Dock
1616
#[cfg(target_os = "macos")]
1717
set_window_above_menubar(&window)?;
18-
18+
1919
let _ = window.emit("start-screenshot", ());
2020
return Ok(());
2121
}
@@ -45,25 +45,21 @@ pub async fn create_draw_window(app: AppHandle) -> Result<(), String> {
4545
);
4646

4747
// 创建新窗口
48-
let window = WebviewWindowBuilder::new(
49-
&app,
50-
"draw",
51-
WebviewUrl::App("pages/draw.html".into()),
52-
)
53-
.title("Screenshot Editor")
54-
.position(logical_x, logical_y)
55-
.inner_size(logical_width, logical_height)
56-
.decorations(false)
57-
.transparent(true)
58-
.resizable(false)
59-
.maximizable(false)
60-
.minimizable(false)
61-
.shadow(false)
62-
.skip_taskbar(true)
63-
.always_on_top(true)
64-
.focused(true)
65-
.build()
66-
.map_err(|e| format!("Failed to create window: {}", e))?;
48+
let window = WebviewWindowBuilder::new(&app, "draw", WebviewUrl::App("pages/draw.html".into()))
49+
.title("Screenshot Editor")
50+
.position(logical_x, logical_y)
51+
.inner_size(logical_width, logical_height)
52+
.decorations(false)
53+
.transparent(true)
54+
.resizable(false)
55+
.maximizable(false)
56+
.minimizable(false)
57+
.shadow(false)
58+
.skip_taskbar(true)
59+
.always_on_top(true)
60+
.focused(true)
61+
.build()
62+
.map_err(|e| format!("Failed to create window: {}", e))?;
6763

6864
// macOS: 设置窗口层级以覆盖菜单栏和 Dock
6965
#[cfg(target_os = "macos")]
@@ -80,25 +76,27 @@ pub async fn create_draw_window(app: AppHandle) -> Result<(), String> {
8076
fn set_window_above_menubar(window: &tauri::WebviewWindow) -> Result<(), String> {
8177
use cocoa::appkit::{NSMainMenuWindowLevel, NSWindow, NSWindowCollectionBehavior};
8278
use cocoa::base::id;
83-
79+
8480
// 获取 NSWindow 指针,转换为 usize 以便在线程间传递
85-
let ns_window_ptr = window.ns_window()
86-
.map_err(|e| format!("Failed to get NSWindow: {:?}", e))? as usize;
87-
88-
window.run_on_main_thread(move || unsafe {
89-
let ns_window = ns_window_ptr as id;
90-
91-
// 设置窗口层级高于菜单栏
92-
// NSMainMenuWindowLevel = 24, 我们使用 25 确保覆盖所有
93-
ns_window.setLevel_((NSMainMenuWindowLevel + 1) as i64);
94-
95-
// 设置窗口行为:可以出现在所有空间、静止、全屏辅助
96-
let behavior = NSWindowCollectionBehavior::NSWindowCollectionBehaviorCanJoinAllSpaces
97-
| NSWindowCollectionBehavior::NSWindowCollectionBehaviorStationary
98-
| NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary;
99-
100-
ns_window.setCollectionBehavior_(behavior);
101-
}).map_err(|e| format!("Failed to set window level: {:?}", e))
81+
let ns_window_ptr =
82+
window.ns_window().map_err(|e| format!("Failed to get NSWindow: {:?}", e))? as usize;
83+
84+
window
85+
.run_on_main_thread(move || unsafe {
86+
let ns_window = ns_window_ptr as id;
87+
88+
// 设置窗口层级高于菜单栏
89+
// NSMainMenuWindowLevel = 24, 我们使用 25 确保覆盖所有
90+
ns_window.setLevel_((NSMainMenuWindowLevel + 1) as i64);
91+
92+
// 设置窗口行为:可以出现在所有空间、静止、全屏辅助
93+
let behavior = NSWindowCollectionBehavior::NSWindowCollectionBehaviorCanJoinAllSpaces
94+
| NSWindowCollectionBehavior::NSWindowCollectionBehaviorStationary
95+
| NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary;
96+
97+
ns_window.setCollectionBehavior_(behavior);
98+
})
99+
.map_err(|e| format!("Failed to set window level: {:?}", e))
102100
}
103101

104102
/// 关闭截图窗口
@@ -107,11 +105,8 @@ pub async fn close_draw_window(app: AppHandle) -> Result<(), String> {
107105
log::info!("API: close_draw_window called");
108106

109107
if let Some(window) = app.get_webview_window("draw") {
110-
window
111-
.destroy()
112-
.map_err(|e| format!("Failed to destroy window: {}", e))?;
108+
window.destroy().map_err(|e| format!("Failed to destroy window: {}", e))?;
113109
}
114110

115111
Ok(())
116112
}
117-

aumate-app/src-tauri/src/commands/element_scanner.rs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@ pub async fn scan_screen_elements(
1010
) -> Result<Vec<ScannableElementDto>, String> {
1111
log::info!("API: scan_screen_elements called");
1212

13-
state
14-
.scan_elements_use_case
15-
.execute()
16-
.await
17-
.map_err(|e| {
18-
let api_error: ApiError = e.into();
19-
api_error.to_string()
20-
})
13+
state.scan_elements_use_case.execute().await.map_err(|e| {
14+
let api_error: ApiError = e.into();
15+
api_error.to_string()
16+
})
2117
}
2218

2319
/// 触发元素操作(点击或聚焦)
@@ -34,20 +30,15 @@ pub async fn trigger_element_action(
3430
);
3531

3632
// 解析操作类型(参数验证)
37-
let action = aumate_application::use_cases::ElementActionType::from_str(&action_type)
38-
.map_err(|e| {
33+
let action =
34+
aumate_application::use_cases::ElementActionType::from_str(&action_type).map_err(|e| {
3935
let api_error: ApiError = e.into();
4036
api_error.to_string()
4137
})?;
4238

4339
// 调用统一的业务逻辑用例
44-
state
45-
.trigger_element_action_use_case
46-
.execute(&element_id, action)
47-
.await
48-
.map_err(|e| {
49-
let api_error: ApiError = e.into();
50-
api_error.to_string()
51-
})
40+
state.trigger_element_action_use_case.execute(&element_id, action).await.map_err(|e| {
41+
let api_error: ApiError = e.into();
42+
api_error.to_string()
43+
})
5244
}
53-

aumate-app/src-tauri/src/commands/hotkey.rs

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@ pub async fn register_global_shortcut(
1111
) -> Result<(), String> {
1212
log::info!("API: register_global_shortcut called - shortcut: {}", shortcut);
1313

14-
state
15-
.register_global_shortcut
16-
.execute(shortcut)
17-
.await
18-
.map_err(|e| {
19-
let api_error: ApiError = e.into();
20-
api_error.to_string()
21-
})
14+
state.register_global_shortcut.execute(shortcut).await.map_err(|e| {
15+
let api_error: ApiError = e.into();
16+
api_error.to_string()
17+
})
2218
}
2319

2420
/// 注销全局快捷键
@@ -29,14 +25,10 @@ pub async fn unregister_global_shortcut(
2925
) -> Result<(), String> {
3026
log::info!("API: unregister_global_shortcut called - shortcut: {}", shortcut);
3127

32-
state
33-
.unregister_global_shortcut
34-
.execute(shortcut)
35-
.await
36-
.map_err(|e| {
37-
let api_error: ApiError = e.into();
38-
api_error.to_string()
39-
})
28+
state.unregister_global_shortcut.execute(shortcut).await.map_err(|e| {
29+
let api_error: ApiError = e.into();
30+
api_error.to_string()
31+
})
4032
}
4133

4234
/// 检查全局快捷键是否可用
@@ -47,12 +39,8 @@ pub async fn check_global_shortcut_availability(
4739
) -> Result<bool, String> {
4840
log::info!("API: check_global_shortcut_availability called - shortcut: {}", shortcut);
4941

50-
state
51-
.check_global_shortcut_availability
52-
.execute(shortcut)
53-
.await
54-
.map_err(|e| {
55-
let api_error: ApiError = e.into();
56-
api_error.to_string()
57-
})
42+
state.check_global_shortcut_availability.execute(shortcut).await.map_err(|e| {
43+
let api_error: ApiError = e.into();
44+
api_error.to_string()
45+
})
5846
}

aumate-app/src-tauri/src/commands/permissions.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,3 @@ fn check_microphone_permission() -> bool {
145145
true
146146
}
147147
}
148-

0 commit comments

Comments
 (0)