webui-dev / webui

Use any web browser or WebView as GUI, with your preferred language in the backend and modern web technologies in the frontend, all in a lightweight portable library.
https://webui.me
MIT License
3.08k stars 186 forks source link

Frontend framework support #109

Closed griffith1deady closed 1 year ago

griffith1deady commented 1 year ago

Hello. I am interested in this question, is there any frontend framework support planned, like in Tauri/Wails 2?

Specifically, I'm interested at least in React support. I tried building react to html with inline styles, but, as one would expect, there is no loading of scripts and other resources like images or fonts, and I don't know how to deal with that.

AlbertShown commented 1 year ago

Did you try the serve_a_folder example? Please give us more details on how your app works so we can better help.

griffith1deady commented 1 year ago

Sorry, but I don't use this: setCurrentDir(currentSourcePath().parentDir() & "\out"). Solved the problem, thanks! (I'm using nim binding). I used to just write the file path as: e.window.show("out/biography.html"), and because of that it didn't load resources. (maybe you should mark somewhere about external directories?)

griffith1deady commented 1 year ago

Sorry, no, the problem was not solved, I jumped to conclusions without checking anything. I don't know if I should send this problem to the nim binding repository?

I use static React code export to HTML with the NextJS framework to display pages on Github Pages, and decided to try it out here. The page style is there, but the resources are not loading. Such as images, or text from files read at compile time. I can provide a test environment with all the resources and code to replicate the errors and display the desired result, the current one, and the errors from the Webview window.

AlbertShown commented 1 year ago

Yes, closing this issue and re-opening it in Nim-WebUI is better.

Just to clarify something, e.window.show("out/biography.html") means the root is "/", so all resources should use the path "out/myFile.css", or add to your HTML <base href="out/" /> then resources path can be "myFile.css".

AlbertShown commented 1 year ago

@hassandraga We should make webui_set_root_folder() a public API, right now it is private and no internal core code is using it.