From e726dfce11d52ebb39ef79196d9ed0bf6cf89c5c Mon Sep 17 00:00:00 2001 From: Vixalie Date: Sun, 29 Mar 2026 22:19:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E9=80=89=E9=A1=B9=E5=88=97=E8=A1=A8=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E6=94=AF=E6=8C=81=20HTTP=20=E5=92=8C=20SOCKS?= =?UTF-8?q?5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/commands.rs | 30 +++++++++++++++++++++++++++++- src-tauri/src/lib.rs | 3 ++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index c74913f..9e97da1 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -1,7 +1,14 @@ -use crate::config::{AppConfig, AppConfigState}; +use crate::config::{AppConfig, AppConfigState, ProxyKind}; use tauri::State; use tauri::{AppHandle, WebviewWindow}; +#[derive(serde::Serialize)] +#[serde(rename_all = "camelCase")] +pub struct SelectOption { + pub label: String, + pub value: String, +} + #[tauri::command] pub fn set_window_title( app_handle: AppHandle, @@ -33,3 +40,24 @@ pub fn save_app_config( .set(config) .map_err(|e| format!("更新应用配置状态失败: {e}")) } + +#[tauri::command] +pub fn list_proxy_kind_options() -> Vec { + vec![ + SelectOption { + label: "HTTP".to_string(), + value: proxy_kind_value(&ProxyKind::Http).to_string(), + }, + SelectOption { + label: "SOCKS5".to_string(), + value: proxy_kind_value(&ProxyKind::Socks5).to_string(), + }, + ] +} + +fn proxy_kind_value(kind: &ProxyKind) -> &'static str { + match kind { + ProxyKind::Http => "Http", + ProxyKind::Socks5 => "Socks5", + } +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 8407c05..66c95a5 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -18,7 +18,8 @@ pub fn run() { .invoke_handler(tauri::generate_handler![ commands::set_window_title, commands::load_app_config, - commands::save_app_config + commands::save_app_config, + commands::list_proxy_kind_options ]) .run(tauri::generate_context!()) .expect("error while running tauri application");