Revision: Open Browser With Localhost (#3776)
* revision: open browser in localhost * revision: use displayed address
This commit is contained in:
1 parent
9c5f9882d9
commit
b91d374479
4 files changed
+14
-3
No files matched your search
@@ -25,14 +25,16 @@ impl RunArgs {
|
|||||||
|
|
||||||
let devserver_ip = "127.0.0.1:8081".parse().unwrap();
|
let devserver_ip = "127.0.0.1:8081".parse().unwrap();
|
||||||
let fullstack_ip = "127.0.0.1:8080".parse().unwrap();
|
let fullstack_ip = "127.0.0.1:8080".parse().unwrap();
|
||||||
|
let mut open_address = None;
|
||||||
|
|
||||||
if self.build_args.platform() == Platform::Web || self.build_args.fullstack {
|
if self.build_args.platform() == Platform::Web || self.build_args.fullstack {
|
||||||
|
open_address = Some(fullstack_ip);
|
||||||
tracing::info!("Serving at: {}", fullstack_ip);
|
tracing::info!("Serving at: {}", fullstack_ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut runner = crate::serve::AppRunner::start(&krate);
|
let mut runner = crate::serve::AppRunner::start(&krate);
|
||||||
runner
|
runner
|
||||||
.open(bundle, devserver_ip, Some(fullstack_ip), true)
|
.open(bundle, devserver_ip, open_address, Some(fullstack_ip), true)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Run the app, but mostly ignore all the other messages
|
// Run the app, but mostly ignore all the other messages
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ impl AppHandle {
|
|||||||
pub(crate) async fn open(
|
pub(crate) async fn open(
|
||||||
&mut self,
|
&mut self,
|
||||||
devserver_ip: SocketAddr,
|
devserver_ip: SocketAddr,
|
||||||
|
open_address: Option<SocketAddr>,
|
||||||
start_fullstack_on_address: Option<SocketAddr>,
|
start_fullstack_on_address: Option<SocketAddr>,
|
||||||
open_browser: bool,
|
open_browser: bool,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
@@ -139,7 +140,7 @@ impl AppHandle {
|
|||||||
Platform::Web => {
|
Platform::Web => {
|
||||||
// Only the first build we open the web app, after that the user knows it's running
|
// Only the first build we open the web app, after that the user knows it's running
|
||||||
if open_browser {
|
if open_browser {
|
||||||
self.open_web(devserver_ip);
|
self.open_web(open_address.unwrap_or(devserver_ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ pub(crate) async fn serve_all(mut args: ServeArgs) -> Result<()> {
|
|||||||
.open(
|
.open(
|
||||||
bundle,
|
bundle,
|
||||||
devserver.devserver_address(),
|
devserver.devserver_address(),
|
||||||
|
devserver.displayed_address(),
|
||||||
devserver.proxied_server_address(),
|
devserver.proxied_server_address(),
|
||||||
args.open.unwrap_or(false),
|
args.open.unwrap_or(false),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ impl AppRunner {
|
|||||||
&mut self,
|
&mut self,
|
||||||
app: AppBundle,
|
app: AppBundle,
|
||||||
devserver_ip: SocketAddr,
|
devserver_ip: SocketAddr,
|
||||||
|
open_address: Option<SocketAddr>,
|
||||||
fullstack_address: Option<SocketAddr>,
|
fullstack_address: Option<SocketAddr>,
|
||||||
should_open_web: bool,
|
should_open_web: bool,
|
||||||
) -> Result<&AppHandle> {
|
) -> Result<&AppHandle> {
|
||||||
@@ -119,6 +120,7 @@ impl AppRunner {
|
|||||||
handle
|
handle
|
||||||
.open(
|
.open(
|
||||||
devserver_ip,
|
devserver_ip,
|
||||||
|
open_address,
|
||||||
fullstack_address,
|
fullstack_address,
|
||||||
self.builds_opened == 0 && should_open_web,
|
self.builds_opened == 0 && should_open_web,
|
||||||
)
|
)
|
||||||
@@ -137,7 +139,12 @@ impl AppRunner {
|
|||||||
if let Some(runner) = self.running.as_mut() {
|
if let Some(runner) = self.running.as_mut() {
|
||||||
runner.soft_kill().await;
|
runner.soft_kill().await;
|
||||||
runner
|
runner
|
||||||
.open(devserver.devserver_address(), fullstack_address, true)
|
.open(
|
||||||
|
devserver.devserver_address(),
|
||||||
|
devserver.displayed_address(),
|
||||||
|
fullstack_address,
|
||||||
|
true,
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user