fix: use devUrl when dev (#556)
This commit is contained in:
@@ -21,8 +21,17 @@ pub fn run() {
|
|||||||
.plugin(tauri_plugin_localhost::Builder::new(port).build())
|
.plugin(tauri_plugin_localhost::Builder::new(port).build())
|
||||||
.plugin(tauri_plugin_window_state::Builder::default().build())
|
.plugin(tauri_plugin_window_state::Builder::default().build())
|
||||||
.setup(move |app| {
|
.setup(move |app| {
|
||||||
let url = format!("http://localhost:{}", port).parse().unwrap();
|
// Dev: use devUrl from tauri.conf.json (http://localhost:8080) to support HMR
|
||||||
let window_url = WebviewUrl::External(url);
|
#[cfg(debug_assertions)]
|
||||||
|
let window_url = WebviewUrl::App(Default::default());
|
||||||
|
|
||||||
|
// Release: tauri-plugin-localhost serves bundled frontend assets on this port
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
let window_url = {
|
||||||
|
let url = format!("http://localhost:{}", port).parse().unwrap();
|
||||||
|
WebviewUrl::External(url)
|
||||||
|
};
|
||||||
|
|
||||||
WebviewWindowBuilder::new(app, "main".to_string(), window_url)
|
WebviewWindowBuilder::new(app, "main".to_string(), window_url)
|
||||||
.title("Cinny")
|
.title("Cinny")
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|||||||
Reference in New Issue
Block a user