From f2a53acc9de4e6756ab57317e36fdbad68a67430 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Tue, 31 Mar 2026 13:11:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF=E8=AD=A6?= =?UTF-8?q?=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/chat_channel/backends/telegram.rs | 6 +++--- .../src/chat_channel/command_handlers.rs | 10 +++++----- src-tauri/src/chat_channel/manager.rs | 6 ++++++ src-tauri/src/commands/chat_channel.rs | 2 ++ src-tauri/src/commands/folders.rs | 2 +- .../src/db/service/chat_channel_service.rs | 1 + .../settings/add-chat-channel-dialog.tsx | 19 +++++-------------- src/lib/api.ts | 10 ++++------ 8 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src-tauri/src/chat_channel/backends/telegram.rs b/src-tauri/src/chat_channel/backends/telegram.rs index f1a3b97..9daea81 100644 --- a/src-tauri/src/chat_channel/backends/telegram.rs +++ b/src-tauri/src/chat_channel/backends/telegram.rs @@ -50,7 +50,7 @@ impl TelegramBackend { let resp = self .client - .post(&self.api_url("sendMessage")) + .post(self.api_url("sendMessage")) .json(&body) .send() .await @@ -94,7 +94,7 @@ impl ChatChannelBackend for TelegramBackend { // Verify bot token by calling getMe let resp = self .client - .get(&self.api_url("getMe")) + .get(self.api_url("getMe")) .send() .await .map_err(|e| ChatChannelError::ConnectionFailed(e.to_string()))?; @@ -217,7 +217,7 @@ impl ChatChannelBackend for TelegramBackend { async fn test_connection(&self) -> Result<(), ChatChannelError> { let resp = self .client - .get(&self.api_url("getMe")) + .get(self.api_url("getMe")) .send() .await .map_err(|e| ChatChannelError::ConnectionFailed(e.to_string()))?; diff --git a/src-tauri/src/chat_channel/command_handlers.rs b/src-tauri/src/chat_channel/command_handlers.rs index 5cb269c..69dadc0 100644 --- a/src-tauri/src/chat_channel/command_handlers.rs +++ b/src-tauri/src/chat_channel/command_handlers.rs @@ -88,7 +88,7 @@ pub async fn handle_search(db: &DatabaseConnection, keyword: &str) -> RichMessag } RichMessage::info(body.trim_end()) - .with_title(&format!("搜索 \"{}\" - {} 条结果", keyword, matched.len())) + .with_title(format!("搜索 \"{}\" - {} 条结果", keyword, matched.len())) } pub async fn handle_detail(db: &DatabaseConnection, conversation_id: i32) -> RichMessage { @@ -114,11 +114,11 @@ pub async fn handle_detail(db: &DatabaseConnection, conversation_id: i32) -> Ric let title = conv.title.as_deref().unwrap_or("(无标题)"); RichMessage::info(title) - .with_title(&format!("会话详情 #{}", conv.id)) + .with_title(format!("会话详情 #{}", conv.id)) .with_field("代理", &conv.agent_type) .with_field("状态", format!("{:?}", conv.status)) - .with_field("消息数", &conv.message_count.to_string()) - .with_field("创建时间", &conv.created_at.format("%Y-%m-%d %H:%M").to_string()) + .with_field("消息数", conv.message_count.to_string()) + .with_field("创建时间", conv.created_at.format("%Y-%m-%d %H:%M").to_string()) } pub async fn handle_today(db: &DatabaseConnection) -> RichMessage { @@ -176,7 +176,7 @@ pub async fn handle_today(db: &DatabaseConnection) -> RichMessage { } } - RichMessage::info(body).with_title(&format!( + RichMessage::info(body).with_title(format!( "今日活动 ({})", now.format("%Y-%m-%d") )) diff --git a/src-tauri/src/chat_channel/manager.rs b/src-tauri/src/chat_channel/manager.rs index c0b56ef..85630b6 100644 --- a/src-tauri/src/chat_channel/manager.rs +++ b/src-tauri/src/chat_channel/manager.rs @@ -27,6 +27,12 @@ pub struct ChatChannelManager { inner: Arc, } +impl Default for ChatChannelManager { + fn default() -> Self { + Self::new() + } +} + impl ChatChannelManager { pub fn new() -> Self { let (command_tx, command_rx) = mpsc::channel(256); diff --git a/src-tauri/src/commands/chat_channel.rs b/src-tauri/src/commands/chat_channel.rs index a1db81c..9684666 100644 --- a/src-tauri/src/commands/chat_channel.rs +++ b/src-tauri/src/commands/chat_channel.rs @@ -50,6 +50,7 @@ pub async fn create_chat_channel_core( Ok(ChatChannelInfo::from(model)) } +#[allow(clippy::too_many_arguments)] pub async fn update_chat_channel_core( db: &AppDatabase, id: i32, @@ -369,6 +370,7 @@ pub async fn create_chat_channel( create_chat_channel_core(&db, name, channel_type, config_json, enabled, daily_report_enabled, daily_report_time).await } +#[allow(clippy::too_many_arguments)] #[cfg(feature = "tauri-runtime")] #[tauri::command] pub async fn update_chat_channel( diff --git a/src-tauri/src/commands/folders.rs b/src-tauri/src/commands/folders.rs index 71979b2..d532957 100644 --- a/src-tauri/src/commands/folders.rs +++ b/src-tauri/src/commands/folders.rs @@ -2997,7 +2997,7 @@ pub async fn list_directory_entries( .filter_map(|e| e.ok()) .any(|e| { let ft = e.file_type().ok(); - let is_sub_dir = ft.map_or(false, |ft| { + let is_sub_dir = ft.is_some_and(|ft| { if ft.is_symlink() { e.path().is_dir() } else { diff --git a/src-tauri/src/db/service/chat_channel_service.rs b/src-tauri/src/db/service/chat_channel_service.rs index db6bffc..55a3640 100644 --- a/src-tauri/src/db/service/chat_channel_service.rs +++ b/src-tauri/src/db/service/chat_channel_service.rs @@ -32,6 +32,7 @@ pub async fn create( Ok(active.insert(conn).await?) } +#[allow(clippy::too_many_arguments)] pub async fn update( conn: &DatabaseConnection, id: i32, diff --git a/src/components/settings/add-chat-channel-dialog.tsx b/src/components/settings/add-chat-channel-dialog.tsx index 9632136..d4504e1 100644 --- a/src/components/settings/add-chat-channel-dialog.tsx +++ b/src/components/settings/add-chat-channel-dialog.tsx @@ -21,10 +21,7 @@ import { SelectValue, } from "@/components/ui/select" import { Switch } from "@/components/ui/switch" -import { - createChatChannel, - saveChatChannelToken, -} from "@/lib/api" +import { createChatChannel, saveChatChannelToken } from "@/lib/api" import type { ChannelType } from "@/lib/types" interface AddChatChannelDialogProps { @@ -66,7 +63,7 @@ export function AddChatChannelDialog({ if (!nextOpen) resetForm() onOpenChange(nextOpen) }, - [onOpenChange, resetForm], + [onOpenChange, resetForm] ) const handleSubmit = useCallback(async () => { @@ -151,9 +148,7 @@ export function AddChatChannelDialog({ Telegram - - {t("lark")} - + {t("lark")} @@ -178,9 +173,7 @@ export function AddChatChannelDialog({ value={token} onChange={(e) => setToken(e.target.value)} placeholder={ - channelType === "telegram" - ? "123456:ABC-DEF..." - : "xxxxx" + channelType === "telegram" ? "123456:ABC-DEF..." : "xxxxx" } /> @@ -197,9 +190,7 @@ export function AddChatChannelDialog({
- + { export async function saveChatChannelToken( channelId: number, - token: string, + token: string ): Promise { return getTransport().call("save_chat_channel_token", { channelId, token }) } export async function getChatChannelHasToken( - channelId: number, + channelId: number ): Promise { return getTransport().call("get_chat_channel_has_token", { channelId }) } -export async function deleteChatChannelToken( - channelId: number, -): Promise { +export async function deleteChatChannelToken(channelId: number): Promise { return getTransport().call("delete_chat_channel_token", { channelId }) } @@ -1416,7 +1414,7 @@ export async function getChatEventFilter(): Promise { } export async function setChatEventFilter( - filter: string[] | null, + filter: string[] | null ): Promise { return getTransport().call("set_chat_event_filter", { filter }) }