mirror of
				https://github.com/yuezk/GlobalProtect-openconnect.git
				synced 2025-05-20 07:26:58 -04:00 
			
		
		
		
	refactor: upgrade tauri 2.0
This commit is contained in:
		@@ -14,8 +14,7 @@ openssl.workspace = true
 | 
			
		||||
pem.workspace = true
 | 
			
		||||
roxmltree.workspace = true
 | 
			
		||||
serde.workspace = true
 | 
			
		||||
specta.workspace = true
 | 
			
		||||
specta-macros.workspace = true
 | 
			
		||||
specta = { workspace = true, features = ["derive"] }
 | 
			
		||||
urlencoding.workspace = true
 | 
			
		||||
tokio.workspace = true
 | 
			
		||||
serde_json.workspace = true
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@ use std::collections::HashMap;
 | 
			
		||||
 | 
			
		||||
use anyhow::bail;
 | 
			
		||||
use serde::{Deserialize, Serialize};
 | 
			
		||||
use specta_macros::Type;
 | 
			
		||||
use specta::Type;
 | 
			
		||||
 | 
			
		||||
use crate::auth::{SamlAuthData, SamlAuthResult};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@ pub use login::*;
 | 
			
		||||
pub(crate) use parse_gateways::*;
 | 
			
		||||
 | 
			
		||||
use serde::{Deserialize, Serialize};
 | 
			
		||||
use specta_macros::Type;
 | 
			
		||||
use specta::Type;
 | 
			
		||||
 | 
			
		||||
use std::fmt::Display;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@ use std::collections::HashMap;
 | 
			
		||||
use log::info;
 | 
			
		||||
use reqwest::Client;
 | 
			
		||||
use serde::{Deserialize, Serialize};
 | 
			
		||||
use specta_macros::Type;
 | 
			
		||||
use specta::Type;
 | 
			
		||||
 | 
			
		||||
use crate::{utils::request::create_identity, GP_USER_AGENT};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@ use log::{debug, info, warn};
 | 
			
		||||
use reqwest::{Client, StatusCode};
 | 
			
		||||
use roxmltree::{Document, Node};
 | 
			
		||||
use serde::Serialize;
 | 
			
		||||
use specta_macros::Type;
 | 
			
		||||
use specta::Type;
 | 
			
		||||
 | 
			
		||||
use crate::{
 | 
			
		||||
  credential::{AuthCookieCredential, Credential},
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@ use log::{info, warn};
 | 
			
		||||
use reqwest::{Client, StatusCode};
 | 
			
		||||
use roxmltree::Document;
 | 
			
		||||
use serde::Serialize;
 | 
			
		||||
use specta_macros::Type;
 | 
			
		||||
use specta::Type;
 | 
			
		||||
 | 
			
		||||
use crate::{
 | 
			
		||||
  error::PortalError,
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
use std::collections::HashMap;
 | 
			
		||||
 | 
			
		||||
use serde::{Deserialize, Serialize};
 | 
			
		||||
use specta_macros::Type;
 | 
			
		||||
use specta::Type;
 | 
			
		||||
 | 
			
		||||
use crate::{gateway::Gateway, gp_params::ClientOs};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
use serde::{Deserialize, Serialize};
 | 
			
		||||
use specta_macros::Type;
 | 
			
		||||
use specta::Type;
 | 
			
		||||
 | 
			
		||||
use crate::gateway::Gateway;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ use std::env;
 | 
			
		||||
use std::io::Write;
 | 
			
		||||
use std::path::Path;
 | 
			
		||||
 | 
			
		||||
use log::info;
 | 
			
		||||
use tempfile::NamedTempFile;
 | 
			
		||||
 | 
			
		||||
pub fn persist_env_vars(extra: Option<HashMap<String, String>>) -> anyhow::Result<NamedTempFile> {
 | 
			
		||||
@@ -35,3 +36,20 @@ pub fn load_env_vars<T: AsRef<Path>>(env_file: T) -> anyhow::Result<HashMap<Stri
 | 
			
		||||
 | 
			
		||||
  Ok(env_vars)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn patch_gui_runtime_env(hidpi: bool) {
 | 
			
		||||
  // This is to avoid blank screen on some systems
 | 
			
		||||
  std::env::set_var("WEBKIT_DISABLE_COMPOSITING_MODE", "1");
 | 
			
		||||
 | 
			
		||||
  // Workaround for https://github.com/tauri-apps/tao/issues/929
 | 
			
		||||
  let desktop = env::var("XDG_CURRENT_DESKTOP").unwrap_or_default().to_lowercase();
 | 
			
		||||
  if desktop.contains("gnome") {
 | 
			
		||||
    env::set_var("GDK_BACKEND", "x11");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if hidpi {
 | 
			
		||||
    info!("Setting GDK_SCALE=2 and GDK_DPI_SCALE=0.5");
 | 
			
		||||
    std::env::set_var("GDK_SCALE", "2");
 | 
			
		||||
    std::env::set_var("GDK_DPI_SCALE", "0.5");
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -4,7 +4,7 @@ pub mod base64;
 | 
			
		||||
pub mod checksum;
 | 
			
		||||
pub mod crypto;
 | 
			
		||||
pub mod endpoint;
 | 
			
		||||
pub mod env_file;
 | 
			
		||||
pub mod env_utils;
 | 
			
		||||
pub mod lock_file;
 | 
			
		||||
pub mod openssl;
 | 
			
		||||
pub mod redact;
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@ use std::{process::ExitStatus, time::Duration};
 | 
			
		||||
 | 
			
		||||
use anyhow::bail;
 | 
			
		||||
use log::info;
 | 
			
		||||
use tauri::Window;
 | 
			
		||||
use tauri::WebviewWindow;
 | 
			
		||||
use tokio::process::Command;
 | 
			
		||||
 | 
			
		||||
pub trait WindowExt {
 | 
			
		||||
@@ -10,7 +10,7 @@ pub trait WindowExt {
 | 
			
		||||
  fn hide_menu(&self);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl WindowExt for Window {
 | 
			
		||||
impl WindowExt for WebviewWindow {
 | 
			
		||||
  fn raise(&self) -> anyhow::Result<()> {
 | 
			
		||||
    raise_window(self)
 | 
			
		||||
  }
 | 
			
		||||
@@ -20,7 +20,7 @@ impl WindowExt for Window {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn raise_window(win: &Window) -> anyhow::Result<()> {
 | 
			
		||||
pub fn raise_window(win: &WebviewWindow) -> anyhow::Result<()> {
 | 
			
		||||
  let is_wayland = std::env::var("XDG_SESSION_TYPE").unwrap_or_default() == "wayland";
 | 
			
		||||
 | 
			
		||||
  if is_wayland {
 | 
			
		||||
@@ -77,7 +77,7 @@ async fn wmctrl_try_raise_window(title: &str) -> anyhow::Result<ExitStatus> {
 | 
			
		||||
  Ok(exit_status)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn hide_menu(win: &Window) {
 | 
			
		||||
fn hide_menu(win: &WebviewWindow) {
 | 
			
		||||
  // let menu_handle = win.menu_handle();
 | 
			
		||||
 | 
			
		||||
  // tokio::spawn(async move {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user