mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-04-02 18:31:50 -04:00
refactor: add gpauth
This commit is contained in:
parent
77fda0f527
commit
ec0bff1e36
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -1089,6 +1089,14 @@ dependencies = [
|
|||||||
"system-deps 6.0.3",
|
"system-deps 6.0.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gpauth"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"webkit2gtk",
|
||||||
|
"wry",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpclient"
|
name = "gpclient"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -4,6 +4,7 @@ members = [
|
|||||||
"common",
|
"common",
|
||||||
"gpclient",
|
"gpclient",
|
||||||
"gpservice",
|
"gpservice",
|
||||||
|
"gpauth",
|
||||||
"gpgui/src-tauri"
|
"gpgui/src-tauri"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
10
gpauth/Cargo.toml
Normal file
10
gpauth/Cargo.toml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[package]
|
||||||
|
name = "gpauth"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
wry = "0.24.3"
|
||||||
|
webkit2gtk = "0.18.2"
|
14
gpauth/src/lib.rs
Normal file
14
gpauth/src/lib.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
pub fn add(left: usize, right: usize) -> usize {
|
||||||
|
left + right
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn it_works() {
|
||||||
|
let result = add(2, 2);
|
||||||
|
assert_eq!(result, 4);
|
||||||
|
}
|
||||||
|
}
|
45
gpauth/src/main.rs
Normal file
45
gpauth/src/main.rs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
use webkit2gtk::LoadEvent;
|
||||||
|
use webkit2gtk::URIResponseExt;
|
||||||
|
use webkit2gtk::WebResourceExt;
|
||||||
|
use webkit2gtk::WebViewExt;
|
||||||
|
use wry::application::event::Event;
|
||||||
|
use wry::application::event::StartCause;
|
||||||
|
use wry::application::event::WindowEvent;
|
||||||
|
use wry::application::event_loop::ControlFlow;
|
||||||
|
use wry::application::event_loop::EventLoop;
|
||||||
|
use wry::application::window::WindowBuilder;
|
||||||
|
use wry::webview::WebViewBuilder;
|
||||||
|
use wry::webview::WebviewExtUnix;
|
||||||
|
|
||||||
|
fn main() -> wry::Result<()> {
|
||||||
|
let event_loop = EventLoop::new();
|
||||||
|
let window = WindowBuilder::new()
|
||||||
|
.with_title("Hello World")
|
||||||
|
.build(&event_loop)?;
|
||||||
|
let _webview = WebViewBuilder::new(window)?
|
||||||
|
.with_url("https://tauri.studio")?
|
||||||
|
.build()?;
|
||||||
|
|
||||||
|
let wv = _webview.webview();
|
||||||
|
wv.connect_load_changed(|wv, load_event| {
|
||||||
|
if load_event == LoadEvent::Finished {
|
||||||
|
let response = wv.main_resource().unwrap().response().unwrap();
|
||||||
|
response.http_headers().unwrap().foreach(|k, v| {
|
||||||
|
println!("{}: {}", k, v);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
event_loop.run(move |event, _, control_flow| {
|
||||||
|
*control_flow = ControlFlow::Wait;
|
||||||
|
|
||||||
|
match event {
|
||||||
|
Event::NewEvents(StartCause::Init) => println!("Wry has started!"),
|
||||||
|
Event::WindowEvent {
|
||||||
|
event: WindowEvent::CloseRequested,
|
||||||
|
..
|
||||||
|
} => *control_flow = ControlFlow::Exit,
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user