xland / QuickUI

A GUI framework based on QuickJs and WebUI
MIT License
18 stars 3 forks source link

Improuvments #1

Open AlbertShown opened 1 month ago

AlbertShown commented 1 month ago

I wonder if it will be better to use const instead of numbers.

Change win.showBrowser("index.html", 2) to win.showBrowser("index.html", webui.Chrome).

webui.NoBrowser,  // 0. No web browser
webui.AnyBrowser, // 1. Default recommended web browser
webui.Chrome, // 2. Google Chrome
webui.Firefox, // 3. Mozilla Firefox
webui.Edge, // 4. Microsoft Edge
webui.Safari, // 5. Apple Safari
webui.Chromium, // 6. The Chromium Project
webui.Opera, // 7. Opera Browser
webui.Brave, // 8. The Brave Browser
webui.Vivaldi, // 9. The Vivaldi Browser
webui.Epic, // 10. The Epic Browser
webui.Yandex, // 11. The Yandex Browser
webui.ChromiumBased, // 12. Any Chromium based browser
AlbertShown commented 1 month ago

Also, I guess this will be good to have:

if (e.eventType == webui.WindowConnection) { ... }

webui.WindowDisconnection // 0: Window disconnection event
webui.WindowConnection // 1: Window connection event
webui.MouseClick // 2: Mouse click event
webui.WindowNavigation // 3: Window navigation event
webui.FunctionCall // 4: Function call event
xland commented 1 month ago

Thank you for your suggestion.

I know what you mean. I also considered the solution you suggested,when I was writing this part of the code.

If I provide such a const type or enum type to the user(TypeScript Developer). The user must import the definition files of these types, when they using these types. This will complicate my distribution package.

Maybe you have a better way to solve this problem. PR is welcome.