mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-25 13:45:03 +08:00
8a05e7bd3d
* feat(gemini): add Gemini provider integration - Add gemini_config.rs module for .env file parsing - Extend AppType enum to support Gemini - Implement GeminiConfigEditor and GeminiFormFields components - Add GeminiIcon with standardized 1024x1024 viewBox - Add Gemini provider presets configuration - Update i18n translations for Gemini support - Extend ProviderService and McpService for Gemini * fix(gemini): resolve TypeScript errors, add i18n support, and fix MCP logic **Critical Fixes:** - Fix TS2741 errors in tests/msw/state.ts by adding missing Gemini type definitions - Fix ProviderCard.extractApiUrl to support GOOGLE_GEMINI_BASE_URL display - Add missing apps.gemini i18n keys (zh/en) for proper app name display - Fix MCP service Gemini cross-app duplication logic to prevent self-copy **Technical Details:** - tests/msw/state.ts: Add gemini default providers, current ID, and MCP config - ProviderCard.tsx: Check both ANTHROPIC_BASE_URL and GOOGLE_GEMINI_BASE_URL - services/mcp.rs: Skip Gemini in sync_other_side logic with unreachable!() guards - Run pnpm format to auto-fix code style issues **Verification:** - ✅ pnpm typecheck passes - ✅ pnpm format completed * feat(gemini): enhance authentication and config parsing - Add strict and lenient .env parsing modes - Implement PackyCode partner authentication detection - Support Google OAuth official authentication - Auto-configure security.auth.selectedType for PackyCode - Add comprehensive test coverage for all auth types - Update i18n for OAuth hints and Gemini config --------- Co-authored-by: Jason <farion1231@gmail.com>
54 lines
1.5 KiB
Rust
54 lines
1.5 KiB
Rust
#![allow(non_snake_case)]
|
|
|
|
use crate::init_status::InitErrorPayload;
|
|
use tauri::AppHandle;
|
|
use tauri_plugin_opener::OpenerExt;
|
|
|
|
/// 打开外部链接
|
|
#[tauri::command]
|
|
pub async fn open_external(app: AppHandle, url: String) -> Result<bool, String> {
|
|
let url = if url.starts_with("http://") || url.starts_with("https://") {
|
|
url
|
|
} else {
|
|
format!("https://{url}")
|
|
};
|
|
|
|
app.opener()
|
|
.open_url(&url, None::<String>)
|
|
.map_err(|e| format!("打开链接失败: {e}"))?;
|
|
|
|
Ok(true)
|
|
}
|
|
|
|
/// 检查更新
|
|
#[tauri::command]
|
|
pub async fn check_for_updates(handle: AppHandle) -> Result<bool, String> {
|
|
handle
|
|
.opener()
|
|
.open_url(
|
|
"https://github.com/farion1231/cc-switch/releases/latest",
|
|
None::<String>,
|
|
)
|
|
.map_err(|e| format!("打开更新页面失败: {e}"))?;
|
|
|
|
Ok(true)
|
|
}
|
|
|
|
/// 判断是否为便携版(绿色版)运行
|
|
#[tauri::command]
|
|
pub async fn is_portable_mode() -> Result<bool, String> {
|
|
let exe_path = std::env::current_exe().map_err(|e| format!("获取可执行路径失败: {e}"))?;
|
|
if let Some(dir) = exe_path.parent() {
|
|
Ok(dir.join("portable.ini").is_file())
|
|
} else {
|
|
Ok(false)
|
|
}
|
|
}
|
|
|
|
/// 获取应用启动阶段的初始化错误(若有)。
|
|
/// 用于前端在早期主动拉取,避免事件订阅竞态导致的提示缺失。
|
|
#[tauri::command]
|
|
pub async fn get_init_error() -> Result<Option<InitErrorPayload>, String> {
|
|
Ok(crate::init_status::get_init_error())
|
|
}
|