webui-dev / webui

Use any web browser or WebView as GUI, with your preferred language in the backend and HTML5 in the frontend, all in a lightweight portable lib.
https://webui.me
MIT License
2.36k stars 144 forks source link

When h5 website is run, a white screen appears randomly and the program exits automatically #352

Open zhuewizz opened 2 months ago

zhuewizz commented 2 months ago

I've tried several times, on the same website, comparing webui-go with webview-go using a package generated by npm run buider: h5, and it looks like this: webui-go: Click for a period of time, a white screen appears randomly, and the error is that js cannot be called dynamically Automatic program exit webview-go is absent I don't quite understand why? Calling from the website: https://tmui.design/h5 i test at window and ubuntu

AlbertShown commented 2 months ago

Hey, did you add <script src="webui.js"></script> to your UI?

zhuewizz commented 2 months ago

i not add ,i will try aigan!!,thanks

zhuewizz commented 2 months ago

I try add webui.js,still not fine
I use vue and npm run build webui.show web.w.ShowBrowser i all try

AlbertShown commented 2 months ago

To know what exactly causing this we need the webui's logs, please follow those instructions.

To get webui logs please follow this:

  1. Download the latest nightly build or stable release
  2. Copy debug version of webui dynamic library webui-xx-xx-xx/debug/webui.so (or .dll, .dynlib... depend on your OS)
  3. Past and replace your installed Go packages with this debug version : a. Can be in $GOPATH or $HOME/go
  4. Run your app again in the terminal, you will get webui's log as well
  5. Copy logs and share it here
AlbertShown commented 2 months ago

Another thing, please share part of code where you use webui. Also, I still don't see webui.js in https://tmui.design/h5, it's not updated yet?

zhuewizz commented 2 months ago

https://tmui.design/h5, It's using vue UI framework, I didn't develop it, I'm testing it locally, my code looks like this: //ui.SetRootFolder("ui") //w.Show("https://tmui.design/h5") w.Show("https://vant-ui.github.io/vant/mobile.html#/zh-CN") // Prepare the second window. ui.Wait() When I was developing locally, I added webui.js The message appeared in the interface. When I did the route in the spa program, it would appear: Resource not available. I ran it directly in the browser, and there was no such phenomenon on every page This situation is random, and the program exits

AlbertShown commented 2 months ago

I see, as I said, it won't work if you can't add webui.js to the UI. webui will run the window for you, and load the URL for you, but if your UI (HTML) does not include webui.js then there is no connection between your window and backend.

Solution is to add <script src="webui.js"></script> to https://tmui.design/h5.

AlbertShown commented 2 months ago

If you still have any issue, please run it locally, add webui.js, then share the webui's logs here.

zhuewizz commented 2 months ago

I'll get around to testing it,thks https://tmui.design/h5.is Other people do demo sites, I can't change I added it locally, but the right click in the application can't open it, I see in the browser: webui.js not found What does webui.js do?

AlbertShown commented 2 months ago

I will explain, webview embed the whole HTML/JS engine in your project, and it need WebView runtime libraries to be installed in your OS, but the result is you can for example get events from an external website, like https://tmui.design.

WebUI does it in another faster way, simply it run the installed web browser, and connect the web browser with your backend using WebSocket trough webui.js, you don't need any runtime... but, WebUI can not give you event of an external web site if you can not add webui.js.

AlbertShown commented 2 months ago

More info: https://github.com/webui-dev/webui?tab=readme-ov-file#how-does-it-work

zhuewizz commented 1 month ago

i use python-webui show the same uri,not add webui.js ,but run and work fine!! why use go-weiui is not fine ?

AlbertShown commented 1 month ago

not add webui.js

Impossible!

work fine!!

Yes, python-webui will run the UI, but you won't receive any click events or anything without webui.js.