修复错误警告

This commit is contained in:
xintaofei
2026-03-31 13:11:08 +08:00
parent 007b52c183
commit f2a53acc9d
8 changed files with 27 additions and 29 deletions

View File

@@ -50,7 +50,7 @@ impl TelegramBackend {
let resp = self let resp = self
.client .client
.post(&self.api_url("sendMessage")) .post(self.api_url("sendMessage"))
.json(&body) .json(&body)
.send() .send()
.await .await
@@ -94,7 +94,7 @@ impl ChatChannelBackend for TelegramBackend {
// Verify bot token by calling getMe // Verify bot token by calling getMe
let resp = self let resp = self
.client .client
.get(&self.api_url("getMe")) .get(self.api_url("getMe"))
.send() .send()
.await .await
.map_err(|e| ChatChannelError::ConnectionFailed(e.to_string()))?; .map_err(|e| ChatChannelError::ConnectionFailed(e.to_string()))?;
@@ -217,7 +217,7 @@ impl ChatChannelBackend for TelegramBackend {
async fn test_connection(&self) -> Result<(), ChatChannelError> { async fn test_connection(&self) -> Result<(), ChatChannelError> {
let resp = self let resp = self
.client .client
.get(&self.api_url("getMe")) .get(self.api_url("getMe"))
.send() .send()
.await .await
.map_err(|e| ChatChannelError::ConnectionFailed(e.to_string()))?; .map_err(|e| ChatChannelError::ConnectionFailed(e.to_string()))?;

View File

@@ -88,7 +88,7 @@ pub async fn handle_search(db: &DatabaseConnection, keyword: &str) -> RichMessag
} }
RichMessage::info(body.trim_end()) 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 { 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("(无标题)"); let title = conv.title.as_deref().unwrap_or("(无标题)");
RichMessage::info(title) RichMessage::info(title)
.with_title(&format!("会话详情 #{}", conv.id)) .with_title(format!("会话详情 #{}", conv.id))
.with_field("代理", &conv.agent_type) .with_field("代理", &conv.agent_type)
.with_field("状态", format!("{:?}", conv.status)) .with_field("状态", format!("{:?}", conv.status))
.with_field("消息数", &conv.message_count.to_string()) .with_field("消息数", conv.message_count.to_string())
.with_field("创建时间", &conv.created_at.format("%Y-%m-%d %H:%M").to_string()) .with_field("创建时间", conv.created_at.format("%Y-%m-%d %H:%M").to_string())
} }
pub async fn handle_today(db: &DatabaseConnection) -> RichMessage { 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") now.format("%Y-%m-%d")
)) ))

View File

@@ -27,6 +27,12 @@ pub struct ChatChannelManager {
inner: Arc<Inner>, inner: Arc<Inner>,
} }
impl Default for ChatChannelManager {
fn default() -> Self {
Self::new()
}
}
impl ChatChannelManager { impl ChatChannelManager {
pub fn new() -> Self { pub fn new() -> Self {
let (command_tx, command_rx) = mpsc::channel(256); let (command_tx, command_rx) = mpsc::channel(256);

View File

@@ -50,6 +50,7 @@ pub async fn create_chat_channel_core(
Ok(ChatChannelInfo::from(model)) Ok(ChatChannelInfo::from(model))
} }
#[allow(clippy::too_many_arguments)]
pub async fn update_chat_channel_core( pub async fn update_chat_channel_core(
db: &AppDatabase, db: &AppDatabase,
id: i32, 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 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")] #[cfg(feature = "tauri-runtime")]
#[tauri::command] #[tauri::command]
pub async fn update_chat_channel( pub async fn update_chat_channel(

View File

@@ -2997,7 +2997,7 @@ pub async fn list_directory_entries(
.filter_map(|e| e.ok()) .filter_map(|e| e.ok())
.any(|e| { .any(|e| {
let ft = e.file_type().ok(); 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() { if ft.is_symlink() {
e.path().is_dir() e.path().is_dir()
} else { } else {

View File

@@ -32,6 +32,7 @@ pub async fn create(
Ok(active.insert(conn).await?) Ok(active.insert(conn).await?)
} }
#[allow(clippy::too_many_arguments)]
pub async fn update( pub async fn update(
conn: &DatabaseConnection, conn: &DatabaseConnection,
id: i32, id: i32,

View File

@@ -21,10 +21,7 @@ import {
SelectValue, SelectValue,
} from "@/components/ui/select" } from "@/components/ui/select"
import { Switch } from "@/components/ui/switch" import { Switch } from "@/components/ui/switch"
import { import { createChatChannel, saveChatChannelToken } from "@/lib/api"
createChatChannel,
saveChatChannelToken,
} from "@/lib/api"
import type { ChannelType } from "@/lib/types" import type { ChannelType } from "@/lib/types"
interface AddChatChannelDialogProps { interface AddChatChannelDialogProps {
@@ -66,7 +63,7 @@ export function AddChatChannelDialog({
if (!nextOpen) resetForm() if (!nextOpen) resetForm()
onOpenChange(nextOpen) onOpenChange(nextOpen)
}, },
[onOpenChange, resetForm], [onOpenChange, resetForm]
) )
const handleSubmit = useCallback(async () => { const handleSubmit = useCallback(async () => {
@@ -151,9 +148,7 @@ export function AddChatChannelDialog({
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
<SelectItem value="telegram">Telegram</SelectItem> <SelectItem value="telegram">Telegram</SelectItem>
<SelectItem value="lark"> <SelectItem value="lark">{t("lark")}</SelectItem>
{t("lark")}
</SelectItem>
</SelectContent> </SelectContent>
</Select> </Select>
</div> </div>
@@ -178,9 +173,7 @@ export function AddChatChannelDialog({
value={token} value={token}
onChange={(e) => setToken(e.target.value)} onChange={(e) => setToken(e.target.value)}
placeholder={ placeholder={
channelType === "telegram" channelType === "telegram" ? "123456:ABC-DEF..." : "xxxxx"
? "123456:ABC-DEF..."
: "xxxxx"
} }
/> />
</div> </div>
@@ -197,9 +190,7 @@ export function AddChatChannelDialog({
</div> </div>
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<label className="text-xs font-medium"> <label className="text-xs font-medium">{t("dailyReport")}</label>
{t("dailyReport")}
</label>
<Switch <Switch
checked={dailyReportEnabled} checked={dailyReportEnabled}
onCheckedChange={setDailyReportEnabled} onCheckedChange={setDailyReportEnabled}

View File

@@ -1358,20 +1358,18 @@ export async function deleteChatChannel(id: number): Promise<void> {
export async function saveChatChannelToken( export async function saveChatChannelToken(
channelId: number, channelId: number,
token: string, token: string
): Promise<void> { ): Promise<void> {
return getTransport().call("save_chat_channel_token", { channelId, token }) return getTransport().call("save_chat_channel_token", { channelId, token })
} }
export async function getChatChannelHasToken( export async function getChatChannelHasToken(
channelId: number, channelId: number
): Promise<boolean> { ): Promise<boolean> {
return getTransport().call("get_chat_channel_has_token", { channelId }) return getTransport().call("get_chat_channel_has_token", { channelId })
} }
export async function deleteChatChannelToken( export async function deleteChatChannelToken(channelId: number): Promise<void> {
channelId: number,
): Promise<void> {
return getTransport().call("delete_chat_channel_token", { channelId }) return getTransport().call("delete_chat_channel_token", { channelId })
} }
@@ -1416,7 +1414,7 @@ export async function getChatEventFilter(): Promise<string[] | null> {
} }
export async function setChatEventFilter( export async function setChatEventFilter(
filter: string[] | null, filter: string[] | null
): Promise<void> { ): Promise<void> {
return getTransport().call("set_chat_event_filter", { filter }) return getTransport().call("set_chat_event_filter", { filter })
} }