Fix Add Server menu does not recognize servers not using HTTPS or using the :8096 port. #74

This commit is contained in:
prayag17 committed 2023-05-13 22:18:42 +05:30
1 parent 027cf93492
commit 9f4c2f990a
5 files changed
+87 -125

No files matched your search

+3 -1
View File
@@ -17,8 +17,10 @@ tauri-build = { version = "1.2.1", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2.2", features = ["process-exit", "process-relaunch", "shell-all", "window-set-fullscreen"] }
tauri = { version = "1.2.2", features = ["api-all", "devtools"] }
tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" }
tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
portpicker = "0.1" # used in the example to pick a random free port
[features]
# by default Tauri runs in production mode
+34 -2
View File
@@ -2,6 +2,8 @@
use tauri::Manager;
use tauri::{utils::config::AppUrl, WindowUrl};
// Create the command:
// This command must be async so that it doesn't run on the main thread.
#[tauri::command]
@@ -14,10 +16,40 @@ async fn close_splashscreen(window: tauri::Window) {
window.get_window("main").unwrap().show().unwrap();
}
// Tauri by default uses HTTPS, so use the localhost plugin to downgrade back to
// HTTP. However, when running tauri dev, we already have a localhost server
// provided by vite, so don't enable it
#[cfg(debug_assertions)]
const USE_LOCALHOST_SERVER: bool = false;
#[cfg(not(debug_assertions))]
const USE_LOCALHOST_SERVER: bool = true;
fn main() {
tauri::Builder::default()
let port = portpicker::pick_unused_port().expect("failed to find unused port");
let window_url = if USE_LOCALHOST_SERVER {
WindowUrl::External(format!("http://localhost:{}", port).parse().unwrap())
} else {
WindowUrl::App("index.html".into())
};
let mut context = tauri::generate_context!();
let mut builder = tauri::Builder::default();
if USE_LOCALHOST_SERVER {
// rewrite the config so the IPC is enabled on this URL
context.config_mut().build.dist_dir = AppUrl::Url(window_url.clone());
context.config_mut().build.dev_path = AppUrl::Url(window_url.clone());
builder = builder.plugin(tauri_plugin_localhost::Builder::new(port).build());
}
builder
.invoke_handler(tauri::generate_handler![close_splashscreen])
.plugin(tauri_plugin_store::Builder::default().build())
.run(tauri::generate_context!())
.run(context)
.expect("error while running tauri application");
// tauri::Builder::default()
// .run(tauri::generate_context!())
// .expect("error while running tauri application");
}
+3 -1
View File
@@ -12,7 +12,6 @@
},
"tauri": {
"allowlist": {
"all": false,
"process": {
"all": false,
"exit": true,
@@ -24,6 +23,9 @@
},
"shell": {
"all": true
},
"http": {
"all": true
}
},
"bundle": {