LG WebOS无法运行在模拟器上需要HTTP服务器的Web应用程序

发布于 2025-01-29 01:22:25 字数 2620 浏览 2 评论 0原文

我有一个想法可以在WebOS上运行Flutter应用程序。我已经下载了最新的WebOS SDK和一个模拟器(因为他们已经弃用了模拟器) 我创建了一个简单的Hello World应用程序,它只是使用HTML,并且在模拟器上运行良好。然后,我决定添加一个用于运行Flutter应用程序的逻辑。所以现在编译的应用结构就是这样

index.html的内容如下

<!DOCTYPE html>
<html>

<head>
  <base href="/">

  <meta charset="UTF-8">
  <meta content="IE=Edge" http-equiv="X-UA-Compatible">
  <meta name="description" content="A new Flutter project.">

  <!-- iOS meta tags & icons -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="flutter_iz_tube_tv">
  <link rel="apple-touch-icon" href="icons/Icon-192.png">

  <!-- Favicon -->
  <link rel="icon" type="image/png" href="favicon.png" />

  <title>IZ Tube TV</title>
  <link rel="manifest" href="manifest.json">

  <script>
    // The value below is injected by flutter build, do not touch.
    var serviceWorkerVersion = '3924677883';
  </script>
  <script src="flutter.js" defer></script>
  <script src="webOSTVjs-1.2.4/webOSTV.js" charset="utf-8"></script>
  <script src="webOSTVjs-1.2.4/webOSTV-dev.js" charset="utf-8"></script>
</head>

<body>
  <script>
    window.addEventListener('load', function (ev) {
      // Download main.dart.js
      _flutter.loader.loadEntrypoint({
        serviceWorker: {
          serviceWorkerVersion: serviceWorkerVersion,
        }
      }).then(function (engineInitializer) {
        return engineInitializer.initializeEngine();
      }).then(function (appRunner) {
        return appRunner.runApp();
      });
    });
  </script>
</body>

</html>

,这是appinfo.json的内容,

{
  "id": "com.example",
  "version": "0.0.1",
  "vendor": "Test TV",
  "type": "web",
  "main": "index.html",
  "title": "tv_app",
  "icon": "icon.png",
  "largeIcon": "largeIcon.png"
}

如果我使用Web服务器,此应用程序在浏览器中运行良好。 但是,当我使用RCU上的应用按钮将其加载到WebOS模拟器上时,问题就开始了。

我只是无法运行。显然,问题是因为它使用了一个简单的文件:协议而不是运行HTTP服务器。 我已经搜索了很多,但还没有找到解决方案。 有人知道如何在模拟器中运行这样的应用吗?

I've got an idea to run Flutter app on WebOS. I've downloaded the latest WebOS sdk and a Simulator (as they already deprecated the Emulator)
I've created a simple Hello World app that simply uses HTML and it ran just fine on the Simulator. Then I decided to add a logic for running Flutter app to it. So now the compiled app structure is like this
enter image description here

The content of the index.html is as follows

<!DOCTYPE html>
<html>

<head>
  <base href="/">

  <meta charset="UTF-8">
  <meta content="IE=Edge" http-equiv="X-UA-Compatible">
  <meta name="description" content="A new Flutter project.">

  <!-- iOS meta tags & icons -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="flutter_iz_tube_tv">
  <link rel="apple-touch-icon" href="icons/Icon-192.png">

  <!-- Favicon -->
  <link rel="icon" type="image/png" href="favicon.png" />

  <title>IZ Tube TV</title>
  <link rel="manifest" href="manifest.json">

  <script>
    // The value below is injected by flutter build, do not touch.
    var serviceWorkerVersion = '3924677883';
  </script>
  <script src="flutter.js" defer></script>
  <script src="webOSTVjs-1.2.4/webOSTV.js" charset="utf-8"></script>
  <script src="webOSTVjs-1.2.4/webOSTV-dev.js" charset="utf-8"></script>
</head>

<body>
  <script>
    window.addEventListener('load', function (ev) {
      // Download main.dart.js
      _flutter.loader.loadEntrypoint({
        serviceWorker: {
          serviceWorkerVersion: serviceWorkerVersion,
        }
      }).then(function (engineInitializer) {
        return engineInitializer.initializeEngine();
      }).then(function (appRunner) {
        return appRunner.runApp();
      });
    });
  </script>
</body>

</html>

And here is the content of appinfo.json

{
  "id": "com.example",
  "version": "0.0.1",
  "vendor": "Test TV",
  "type": "web",
  "main": "index.html",
  "title": "tv_app",
  "icon": "icon.png",
  "largeIcon": "largeIcon.png"
}

This app runs fine in browser if I use a web server.
But the problem starts when I load it on a WebOS Simulator using App button on RCU.

enter image description here

I just cannot run. And the problem is, obviously, because it uses a simple file: protocol instead of running an http server.
I've googled a lot and haven't found a solution to this.
Does anyone know how to run an app like this in simulator?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一笔一画续写前缘 2025-02-05 01:22:25

我发现在模拟器中不可能做。但是有解决方法。我们可以在这样的index.html文件的“头”部分添加一个重定向“ rel =“ nofollow noreferrer”> https://webostv.developer.lge.com/develop/app-developer-guide/hosted-web-app/ ):

<meta http-equiv="refresh" content="0;url=http://0.0.0.0:8080/index.html">

因此有效地将其重定向到远程应用程序。和WebOS可以显示flutter应用程序

I've found out it's impossible to do in a Simulator. But there is a workaround. We can add a redirection to the "head" part of index.html file like this (https://webostv.developer.lge.com/develop/app-developer-guide/hosted-web-app/):

<meta http-equiv="refresh" content="0;url=http://0.0.0.0:8080/index.html">

Thus effectively redirecting it to the remote app. And WebOS can display a Flutter app

零崎曲识 2025-02-05 01:22:25

因此,似乎有了Flutter,由于Flutter Web需要使用Web服务,因此需要Web服务器才能正常工作。 与此。因此,在WebOS上运行Flutter Web应用程序时有两个选择:

远程Web托管
让您的Web应用程序(在 /build /Web)托管在某个地方的Web服务器上,一种快速简便的方法是使用Apache托管您的构建。
现在,有两种方法可以启动此托管Web应用程序:

  1. 进入设置 - &GT; SI服务器设置 - &GT;申请启动模式 - &GT;偏僻的。然后,要么输入您完全合格的域名或SI Server IP和端口。
    重新启动LG WebOS系统,启动后,您应该运行扑朔迷离的应用程序。
  2. 将重定向添加到Web应用程序的URL。 ,如下所示
<!DOCTYPE html>
<html>
  <head> </head>
  <body>
    <script>
      window.location.href = "https://webostv.developer.lge.com/";
    </script>
  </body>
</html>

自我网络托管
让WebOS系统托管Web服务器本身,这样,WebOS IPK不需要远程服务器即可查看Web应用程序。这样做的方法是一个杂乱的方法,但效果很好:
在WebOS中,有 js services 运行nodejs。在 /媒体 /内部下载并存储您的Flutter Web构建,这是可以共享应用程序和JS服务数据的地方。然后,创建一个将运行Express并在 /Media /Internal中启动HTTP服务器的JS服务。在WebOS应用程序的index.html文件中,您可以将重定向设置为Localhost(服务托管弹奏应用程序),与上述相同的方式相同:

<!DOCTYPE html>
<html>
  <head> </head>
  <body>
    <script>
      window.location.href = "http://0.0.0.0:12345/";
    </script>
  </body>
</html>

So, it seems that with Flutter, it requires a web server for it to work properly, due to the fact that flutter web needs to use web services. Related to this. So, there are two options when it comes to running a flutter web application on webOS:

Remote Web Hosting
Have your web application (in /build/web) being hosted on a web server somewhere, a quick and easy way is to host your build using Apache.
Now, there are two ways to launch this hosted web application:

  1. Go into settings -> SI Server Settings -> Application Launch Mode -> Remote. Then, either enter your Fully Qualified Domain Name, or the SI Server IP and port.
    Restart your LG WebOS System, upon bootup, you should have the flutter application running.
  2. Add a redirection to the URL of the web application. As shown here.
<!DOCTYPE html>
<html>
  <head> </head>
  <body>
    <script>
      window.location.href = "https://webostv.developer.lge.com/";
    </script>
  </body>
</html>

Self Web Hosting
Have the webOS system host the web server itself, that way, the webOS IPK doesn’t need a remote server to view the web application. The method of doing this is a scrappy but it works just fine:
In webOS, there are JS Services that run NodeJS. Download and store your flutter web build in /media/internal, that is where application and JS Service data can be shared. Then, create a JS Service that will run express and start a http server in /media/internal. In the index.html file of your webOS application, you can set a redirect to your localhost, where the service is hosting the flutter application, the same way as above:

<!DOCTYPE html>
<html>
  <head> </head>
  <body>
    <script>
      window.location.href = "http://0.0.0.0:12345/";
    </script>
  </body>
</html>
围归者 2025-02-05 01:22:25

我找到了一种解决方案,该解决方案也可以在模拟器上测试该应用程序。 在index.html文件中添加以下行

<base href="./">

只需

<base href="/">

I have found a solution that works and have tested the app on the simulator as well. Just add the following line in the index.html file

<base href="./">

instead of

<base href="/">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文