format: format code
This commit is contained in:
@@ -52,7 +52,7 @@ pub struct PakeConfig {
|
||||
pub user_agent: UserAgent,
|
||||
pub system_tray: FunctionON,
|
||||
pub system_tray_path: String,
|
||||
pub proxy_url: String
|
||||
pub proxy_url: String,
|
||||
}
|
||||
|
||||
impl PakeConfig {
|
||||
|
||||
@@ -29,9 +29,10 @@ pub async fn download_file(app: AppHandle, params: DownloadFileParams) -> Result
|
||||
let client = ClientBuilder::new().build().unwrap();
|
||||
|
||||
let response = client
|
||||
.execute(
|
||||
Request::new(Method::GET, Url::from_str(¶ms.url).unwrap())
|
||||
)
|
||||
.execute(Request::new(
|
||||
Method::GET,
|
||||
Url::from_str(¶ms.url).unwrap(),
|
||||
))
|
||||
.await;
|
||||
|
||||
match response {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
use tauri::{
|
||||
image::Image, include_image, menu::{ContextMenu, MenuBuilder, MenuItemBuilder}, tray::{MouseButton, MouseButtonState, TrayIcon, TrayIconBuilder, TrayIconEvent}, AppHandle, Config, Manager
|
||||
image::Image,
|
||||
menu::{MenuBuilder, MenuItemBuilder},
|
||||
tray::{MouseButtonState, TrayIconBuilder, TrayIconEvent, MouseButton},
|
||||
AppHandle, Manager,
|
||||
};
|
||||
use tauri_plugin_window_state::{AppHandleExt, StateFlags};
|
||||
|
||||
@@ -9,22 +12,24 @@ pub fn set_system_tray(app: &AppHandle, pake_config: &PakeConfig) -> tauri::Resu
|
||||
let hide_app = MenuItemBuilder::with_id("hide_app", "Hide").build(app)?;
|
||||
let show_app = MenuItemBuilder::with_id("show_app", "Show").build(app)?;
|
||||
let quit = MenuItemBuilder::with_id("quit", "Quit").build(app)?;
|
||||
let menu = MenuBuilder::new(app).items(&[&hide_app, &show_app, &quit]).build()?;
|
||||
let menu = MenuBuilder::new(app)
|
||||
.items(&[&hide_app, &show_app, &quit])
|
||||
.build()?;
|
||||
app.app_handle().remove_tray_by_id("pake-tray");
|
||||
let tray = TrayIconBuilder::new()
|
||||
.icon(Image::from_path(pake_config.system_tray_path.as_str())?)
|
||||
.menu(&menu)
|
||||
.on_tray_icon_event(move |tray, event| {
|
||||
if let TrayIconEvent::Click {
|
||||
button: MouseButton::Left,
|
||||
button_state: MouseButtonState::Up,
|
||||
..
|
||||
} = event {
|
||||
button: MouseButton::Left,
|
||||
button_state: MouseButtonState::Up,
|
||||
..
|
||||
} = event
|
||||
{
|
||||
println!("click");
|
||||
|
||||
let app = tray.app_handle();
|
||||
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
if let Some(webview_window) = app.get_webview_window("pake") {
|
||||
@@ -37,7 +42,6 @@ pub fn set_system_tray(app: &AppHandle, pake_config: &PakeConfig) -> tauri::Resu
|
||||
tauri::AppHandle::show(&app.app_handle()).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
.on_menu_event(move |app, event| match event.id().as_ref() {
|
||||
"hide_app" => {
|
||||
|
||||
@@ -42,7 +42,8 @@ pub fn get_window(app: &mut App, config: &PakeConfig, _data_dir: PathBuf) -> Web
|
||||
|
||||
if config.proxy_url != "" {
|
||||
println!("{}", &config.proxy_url);
|
||||
window_builder = window_builder.proxy_url(Url::from_str(&config.proxy_url.as_str()).unwrap());
|
||||
window_builder =
|
||||
window_builder.proxy_url(Url::from_str(&config.proxy_url.as_str()).unwrap());
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
|
||||
@@ -7,8 +7,8 @@ use std::str::FromStr;
|
||||
use app::{invoke, menu::set_system_tray, window};
|
||||
use invoke::{download_file, download_file_by_binary};
|
||||
use tauri::Manager;
|
||||
use tauri_plugin_window_state::Builder as windowStatePlugin;
|
||||
use tauri_plugin_global_shortcut::{GlobalShortcutExt, Shortcut};
|
||||
use tauri_plugin_window_state::Builder as windowStatePlugin;
|
||||
use util::{get_data_dir, get_pake_config};
|
||||
use window::get_window;
|
||||
|
||||
@@ -51,7 +51,6 @@ pub fn run_app() {
|
||||
.plugin(
|
||||
tauri_plugin_global_shortcut::Builder::new()
|
||||
.with_handler(move |app, event, _shortcut| {
|
||||
|
||||
if shortcut_hotkey.eq(event) {
|
||||
let window = app.get_webview_window("pake").unwrap();
|
||||
match window.is_visible().unwrap() {
|
||||
@@ -62,8 +61,9 @@ pub fn run_app() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
).build())
|
||||
})
|
||||
.build(),
|
||||
)
|
||||
.expect("Error registering global evoke shortcuts!");
|
||||
|
||||
app.global_shortcut().register(shortcut_hotkey)?;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use crate::app::config::PakeConfig;
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use tauri::{App, AppHandle, Config, Manager, WebviewWindow};
|
||||
|
||||
use tauri::{AppHandle, Config, Manager, WebviewWindow};
|
||||
|
||||
pub fn get_pake_config() -> (PakeConfig, Config) {
|
||||
#[cfg(feature = "cli-build")]
|
||||
@@ -24,10 +23,12 @@ pub fn get_pake_config() -> (PakeConfig, Config) {
|
||||
(pake_config, tauri_config)
|
||||
}
|
||||
|
||||
pub fn get_data_dir(app: &AppHandle, _tauri_config: Config, ) -> PathBuf {
|
||||
pub fn get_data_dir(app: &AppHandle, _tauri_config: Config) -> PathBuf {
|
||||
{
|
||||
let package_name = _tauri_config.product_name.unwrap();
|
||||
let data_dir = app.path().config_dir()
|
||||
let data_dir = app
|
||||
.path()
|
||||
.config_dir()
|
||||
.expect("Failed to get data dirname")
|
||||
.join(package_name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user