fix: use devUrl when dev (#556)

This commit is contained in:
Shenwei Wang
2026-03-17 21:29:22 +08:00
committed by GitHub
parent a396a54f90
commit 89804c83ac

View File

@@ -21,8 +21,17 @@ pub fn run() {
.plugin(tauri_plugin_localhost::Builder::new(port).build())
.plugin(tauri_plugin_window_state::Builder::default().build())
.setup(move |app| {
let url = format!("http://localhost:{}", port).parse().unwrap();
let window_url = WebviewUrl::External(url);
// Dev: use devUrl from tauri.conf.json (http://localhost:8080) to support HMR
#[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)
.title("Cinny")
.build()?;