chore: unify code formatting and remove unused code
- Apply cargo fmt to Rust code with multiline error handling - Apply Prettier formatting to TypeScript code with trailing commas - Unify #[allow(non_snake_case)] attribute formatting - Remove unused ProviderNotFound error variant from error.rs - Add vitest-report.json to .gitignore to exclude test artifacts - Optimize readability of error handling chains with vertical alignment All tests passing: 22 Rust tests + 126 frontend tests
This commit is contained in:
@@ -73,8 +73,7 @@ pub async fn open_config_folder(handle: AppHandle, app: String) -> Result<bool,
|
||||
#[tauri::command]
|
||||
pub async fn pick_directory(
|
||||
app: AppHandle,
|
||||
#[allow(non_snake_case)]
|
||||
defaultPath: Option<String>,
|
||||
#[allow(non_snake_case)] defaultPath: Option<String>,
|
||||
) -> Result<Option<String>, String> {
|
||||
let initial = defaultPath
|
||||
.map(|p| p.trim().to_string())
|
||||
|
||||
@@ -12,8 +12,7 @@ use crate::store::AppState;
|
||||
/// 导出配置文件
|
||||
#[tauri::command]
|
||||
pub async fn export_config_to_file(
|
||||
#[allow(non_snake_case)]
|
||||
filePath: String
|
||||
#[allow(non_snake_case)] filePath: String,
|
||||
) -> Result<Value, String> {
|
||||
tauri::async_runtime::spawn_blocking(move || {
|
||||
let target_path = PathBuf::from(&filePath);
|
||||
@@ -32,8 +31,7 @@ pub async fn export_config_to_file(
|
||||
/// 从文件导入配置
|
||||
#[tauri::command]
|
||||
pub async fn import_config_from_file(
|
||||
#[allow(non_snake_case)]
|
||||
filePath: String,
|
||||
#[allow(non_snake_case)] filePath: String,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<Value, String> {
|
||||
let (new_config, backup_id) = tauri::async_runtime::spawn_blocking(move || {
|
||||
@@ -81,8 +79,7 @@ pub async fn sync_current_providers_live(state: State<'_, AppState>) -> Result<V
|
||||
#[tauri::command]
|
||||
pub async fn save_file_dialog<R: tauri::Runtime>(
|
||||
app: tauri::AppHandle<R>,
|
||||
#[allow(non_snake_case)]
|
||||
defaultName: String,
|
||||
#[allow(non_snake_case)] defaultName: String,
|
||||
) -> Result<Option<String>, String> {
|
||||
let dialog = app.dialog();
|
||||
let result = dialog
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use crate::init_status::InitErrorPayload;
|
||||
use tauri::AppHandle;
|
||||
use tauri_plugin_opener::OpenerExt;
|
||||
use crate::init_status::InitErrorPayload;
|
||||
|
||||
/// 打开外部链接
|
||||
#[tauri::command]
|
||||
|
||||
@@ -112,8 +112,7 @@ pub fn import_default_config(state: State<'_, AppState>, app: String) -> Result<
|
||||
#[tauri::command]
|
||||
pub async fn queryProviderUsage(
|
||||
state: State<'_, AppState>,
|
||||
#[allow(non_snake_case)]
|
||||
providerId: String, // 使用 camelCase 匹配前端
|
||||
#[allow(non_snake_case)] providerId: String, // 使用 camelCase 匹配前端
|
||||
app: String,
|
||||
) -> Result<crate::provider::UsageResult, String> {
|
||||
let app_type = AppType::from_str(&app).map_err(|e| e.to_string())?;
|
||||
@@ -127,16 +126,12 @@ pub async fn queryProviderUsage(
|
||||
#[tauri::command]
|
||||
pub async fn testUsageScript(
|
||||
state: State<'_, AppState>,
|
||||
#[allow(non_snake_case)]
|
||||
providerId: String,
|
||||
#[allow(non_snake_case)] providerId: String,
|
||||
app: String,
|
||||
#[allow(non_snake_case)]
|
||||
scriptCode: String,
|
||||
#[allow(non_snake_case)] scriptCode: String,
|
||||
timeout: Option<u64>,
|
||||
#[allow(non_snake_case)]
|
||||
accessToken: Option<String>,
|
||||
#[allow(non_snake_case)]
|
||||
userId: Option<String>,
|
||||
#[allow(non_snake_case)] accessToken: Option<String>,
|
||||
#[allow(non_snake_case)] userId: Option<String>,
|
||||
) -> Result<crate::provider::UsageResult, String> {
|
||||
let app_type = AppType::from_str(&app).map_err(|e| e.to_string())?;
|
||||
ProviderService::test_usage_script(
|
||||
@@ -163,8 +158,7 @@ pub fn read_live_provider_settings(app: String) -> Result<serde_json::Value, Str
|
||||
#[tauri::command]
|
||||
pub async fn test_api_endpoints(
|
||||
urls: Vec<String>,
|
||||
#[allow(non_snake_case)]
|
||||
timeoutSecs: Option<u64>,
|
||||
#[allow(non_snake_case)] timeoutSecs: Option<u64>,
|
||||
) -> Result<Vec<EndpointLatency>, String> {
|
||||
SpeedtestService::test_endpoints(urls, timeoutSecs)
|
||||
.await
|
||||
@@ -176,8 +170,7 @@ pub async fn test_api_endpoints(
|
||||
pub fn get_custom_endpoints(
|
||||
state: State<'_, AppState>,
|
||||
app: String,
|
||||
#[allow(non_snake_case)]
|
||||
providerId: String,
|
||||
#[allow(non_snake_case)] providerId: String,
|
||||
) -> Result<Vec<crate::settings::CustomEndpoint>, String> {
|
||||
let app_type = AppType::from_str(&app).map_err(|e| e.to_string())?;
|
||||
ProviderService::get_custom_endpoints(state.inner(), app_type, &providerId)
|
||||
@@ -189,8 +182,7 @@ pub fn get_custom_endpoints(
|
||||
pub fn add_custom_endpoint(
|
||||
state: State<'_, AppState>,
|
||||
app: String,
|
||||
#[allow(non_snake_case)]
|
||||
providerId: String,
|
||||
#[allow(non_snake_case)] providerId: String,
|
||||
url: String,
|
||||
) -> Result<(), String> {
|
||||
let app_type = AppType::from_str(&app).map_err(|e| e.to_string())?;
|
||||
@@ -203,8 +195,7 @@ pub fn add_custom_endpoint(
|
||||
pub fn remove_custom_endpoint(
|
||||
state: State<'_, AppState>,
|
||||
app: String,
|
||||
#[allow(non_snake_case)]
|
||||
providerId: String,
|
||||
#[allow(non_snake_case)] providerId: String,
|
||||
url: String,
|
||||
) -> Result<(), String> {
|
||||
let app_type = AppType::from_str(&app).map_err(|e| e.to_string())?;
|
||||
@@ -217,8 +208,7 @@ pub fn remove_custom_endpoint(
|
||||
pub fn update_endpoint_last_used(
|
||||
state: State<'_, AppState>,
|
||||
app: String,
|
||||
#[allow(non_snake_case)]
|
||||
providerId: String,
|
||||
#[allow(non_snake_case)] providerId: String,
|
||||
url: String,
|
||||
) -> Result<(), String> {
|
||||
let app_type = AppType::from_str(&app).map_err(|e| e.to_string())?;
|
||||
|
||||
Reference in New Issue
Block a user