diff --git a/src-tauri/src/commands/mod.rs b/src-tauri/src/commands/mod.rs index 09bb312b3..04bb6da3a 100644 --- a/src-tauri/src/commands/mod.rs +++ b/src-tauri/src/commands/mod.rs @@ -22,10 +22,10 @@ pub mod skill; mod stream_check; mod sync_support; +mod lightweight; mod usage; mod webdav_sync; mod workspace; -mod lightweight; pub use auth::*; pub use config::*; @@ -48,7 +48,7 @@ pub use settings::*; pub use skill::*; pub use stream_check::*; +pub use lightweight::*; pub use usage::*; pub use webdav_sync::*; pub use workspace::*; -pub use lightweight::*; diff --git a/src-tauri/src/lightweight.rs b/src-tauri/src/lightweight.rs index cd0875710..c16af79ef 100644 --- a/src-tauri/src/lightweight.rs +++ b/src-tauri/src/lightweight.rs @@ -87,4 +87,4 @@ pub fn exit_lightweight_mode(app: &tauri::AppHandle) -> Result<(), String> { pub fn is_lightweight_mode() -> bool { LIGHTWEIGHT_MODE.load(Ordering::Acquire) -} \ No newline at end of file +} diff --git a/src-tauri/src/services/provider/live.rs b/src-tauri/src/services/provider/live.rs index cba4daf26..3d459a35f 100644 --- a/src-tauri/src/services/provider/live.rs +++ b/src-tauri/src/services/provider/live.rs @@ -39,11 +39,9 @@ pub(crate) fn provider_exists_in_live_config( ) -> Result { match app_type { AppType::OpenCode => crate::opencode_config::get_providers() - .map(|providers| providers.contains_key(provider_id)) - .map_err(Into::into), + .map(|providers| providers.contains_key(provider_id)), AppType::OpenClaw => crate::openclaw_config::get_providers() - .map(|providers| providers.contains_key(provider_id)) - .map_err(Into::into), + .map(|providers| providers.contains_key(provider_id)), _ => Ok(false), } } diff --git a/src-tauri/src/tray.rs b/src-tauri/src/tray.rs index f5b068157..6ac3d2046 100644 --- a/src-tauri/src/tray.rs +++ b/src-tauri/src/tray.rs @@ -393,11 +393,10 @@ pub fn create_tray_menu( true, crate::lightweight::is_lightweight_mode(), None::<&str>, - ).map_err(|e| AppError::Message(format!("创建轻量模式菜单失败: {e}")))?; + ) + .map_err(|e| AppError::Message(format!("创建轻量模式菜单失败: {e}")))?; - menu_builder = menu_builder - .item(&lightweight_item) - .separator(); + menu_builder = menu_builder.item(&lightweight_item).separator(); // 退出菜单(分隔符已在上面的 section 循环中添加) let quit_item = MenuItem::with_id(app, "quit", tray_texts.quit, true, None::<&str>) @@ -472,10 +471,8 @@ pub fn handle_tray_menu_event(app: &tauri::AppHandle, event_id: &str) { if let Err(e) = crate::lightweight::exit_lightweight_mode(app) { log::error!("退出轻量模式失败: {e}"); } - } else { - if let Err(e) = crate::lightweight::enter_lightweight_mode(app) { - log::error!("进入轻量模式失败: {e}"); - } + } else if let Err(e) = crate::lightweight::enter_lightweight_mode(app) { + log::error!("进入轻量模式失败: {e}"); } } "quit" => { diff --git a/src/components/providers/forms/ProviderForm.tsx b/src/components/providers/forms/ProviderForm.tsx index 41c3f223f..3c8a03b29 100644 --- a/src/components/providers/forms/ProviderForm.tsx +++ b/src/components/providers/forms/ProviderForm.tsx @@ -766,9 +766,7 @@ export function ProviderForm({ } if ( !isProviderKeyLocked && - additiveExistingProviderKeys.includes( - openclawForm.openclawProviderKey, - ) + additiveExistingProviderKeys.includes(openclawForm.openclawProviderKey) ) { toast.error(t("openclaw.providerKeyDuplicate")); return; @@ -1352,7 +1350,9 @@ export function ProviderForm({ ) } placeholder={t("opencode.providerKeyPlaceholder")} - disabled={isProviderKeyLocked || isProviderKeyLockStateLoading} + disabled={ + isProviderKeyLocked || isProviderKeyLockStateLoading + } className={ (additiveExistingProviderKeys.includes( opencodeForm.opencodeProviderKey, @@ -1416,7 +1416,9 @@ export function ProviderForm({ ) } placeholder={t("openclaw.providerKeyPlaceholder")} - disabled={isProviderKeyLocked || isProviderKeyLockStateLoading} + disabled={ + isProviderKeyLocked || isProviderKeyLockStateLoading + } className={ (additiveExistingProviderKeys.includes( openclawForm.openclawProviderKey, diff --git a/src/lib/api/providers.ts b/src/lib/api/providers.ts index d11448dcd..26e7d8fa1 100644 --- a/src/lib/api/providers.ts +++ b/src/lib/api/providers.ts @@ -43,7 +43,11 @@ export const providersApi = { appId: AppId, originalId?: string, ): Promise { - return await invoke("update_provider", { provider, app: appId, originalId }); + return await invoke("update_provider", { + provider, + app: appId, + originalId, + }); }, async delete(id: string, appId: AppId): Promise { diff --git a/src/lib/query/mutations.ts b/src/lib/query/mutations.ts index 3cb334b59..e5ab2815c 100644 --- a/src/lib/query/mutations.ts +++ b/src/lib/query/mutations.ts @@ -39,11 +39,7 @@ export const useAddProviderMutation = (appId: AppId) => { id = generateUUID(); } - const { - providerKey: _providerKey, - addToLive, - ...rest - } = providerInput; + const { providerKey: _providerKey, addToLive, ...rest } = providerInput; const newProvider: Provider = { ...rest,