mirror of
https://github.com/safing/portmaster
synced 2025-09-02 18:49:14 +00:00
[desktop/tauri] Add check if webview is installed
This commit is contained in:
parent
31b99e7647
commit
f07f4e6988
1 changed files with 31 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
||||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use tauri::{AppHandle, Manager, RunEvent, WindowEvent};
|
use tauri::{AppHandle, Manager, RunEvent, WindowEvent};
|
||||||
use tauri_plugin_cli::CliExt;
|
use tauri_plugin_cli::CliExt;
|
||||||
|
|
||||||
|
@ -24,6 +26,8 @@ use window::{close_splash_window, create_main_window};
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
|
const FALLBACK_TO_OLD_UI_EXIT_CODE: i32 = -3;
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize)]
|
#[derive(Clone, serde::Serialize)]
|
||||||
struct Payload {
|
struct Payload {
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
|
@ -82,7 +86,34 @@ impl portmaster::Handler for WsHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn show_webview_not_installed_dialog() -> i32 {
|
||||||
|
use rfd::MessageDialog;
|
||||||
|
|
||||||
|
let result = MessageDialog::new()
|
||||||
|
.set_title("Portmaster")
|
||||||
|
.set_description("Webkit is not installed. Please install it and run portmaster again")
|
||||||
|
.set_buttons(rfd::MessageButtons::OkCancelCustom(
|
||||||
|
"Go to install page".to_owned(),
|
||||||
|
"Use old UI".to_owned(),
|
||||||
|
))
|
||||||
|
.show();
|
||||||
|
println!("{:?}", result);
|
||||||
|
if let rfd::MessageDialogResult::Custom(result) = result {
|
||||||
|
if result.eq("Go to install page") {
|
||||||
|
_ = open::that("https://wiki.safing.io/en/Portmaster/Install/Webview");
|
||||||
|
std::thread::sleep(Duration::from_secs(2));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALLBACK_TO_OLD_UI_EXIT_CODE;
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
if let Err(_) = tauri::webview_version() {
|
||||||
|
std::process::exit(show_webview_not_installed_dialog());
|
||||||
|
}
|
||||||
|
|
||||||
let app = tauri::Builder::default()
|
let app = tauri::Builder::default()
|
||||||
// Shell plugin for open_external support
|
// Shell plugin for open_external support
|
||||||
.plugin(tauri_plugin_shell::init())
|
.plugin(tauri_plugin_shell::init())
|
||||||
|
|
Loading…
Add table
Reference in a new issue