2022-02-20 20:30:53 +01:00
|
|
|
# Desktop app
|
2022-02-17 18:09:57 +01:00
|
|
|
|
2022-02-22 12:02:56 +01:00
|
|
|
The desktop component is an electron app inside `./electron/`. It uses a hybrid setup based of two main components:
|
|
|
|
- A `local-app` bundled into the electron app with two main parts:
|
2022-02-20 20:30:53 +01:00
|
|
|
- A sidebar to show the server list, with the currently selected server
|
2022-02-22 12:02:56 +01:00
|
|
|
- A main page which is used to manage servers and to show other "local" pages like the desktop-app settings
|
2022-02-20 20:30:53 +01:00
|
|
|
- A BrowserView (often called `appView` or `app`) showing the actual frontend of an external WorkAdventure deployment.
|
2022-02-22 12:02:56 +01:00
|
|
|
If a server is selected the BrowserView / `appView` is overlaying the whole main part right to the sidebar.
|
2022-02-20 20:30:53 +01:00
|
|
|
|
|
|
|
## Development
|
|
|
|
|
|
|
|
```bash
|
2022-02-22 12:02:56 +01:00
|
|
|
# start local-app in watch mode
|
|
|
|
cd local-app && yarn dev
|
2022-02-20 20:30:53 +01:00
|
|
|
|
2022-02-22 12:02:56 +01:00
|
|
|
# start electron app in watch mode
|
|
|
|
cd electron && LOCAL_APP_URL=http://localhost:3000 yarn dev
|
2022-02-20 20:30:53 +01:00
|
|
|
|
|
|
|
# or create an executable by running:
|
2022-02-22 12:02:56 +01:00
|
|
|
cd electron && yarn bundle
|
2022-02-20 21:06:27 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
## API for front
|
|
|
|
|
|
|
|
TODO:
|
|
|
|
|
|
|
|
```ts
|
|
|
|
if (window?.WorkAdventureDesktopApi?.desktop) {
|
|
|
|
alert('Yeah you are using the desktop app ;)');
|
|
|
|
}
|
|
|
|
|
|
|
|
let muted = false;
|
|
|
|
|
|
|
|
window?.WorkAdventureDesktopApi?.onMutedKeyPress((event) => {
|
|
|
|
if (muted) {
|
|
|
|
document.getElementById("info-box").innerHTML =
|
|
|
|
"Ready to speak! Press ctrl-alt-m to mute.";
|
|
|
|
} else {
|
|
|
|
document.getElementById("info-box").innerHTML =
|
|
|
|
"Muted! Press ctrl-alt-m to unmute again.";
|
|
|
|
}
|
|
|
|
muted = !muted;
|
|
|
|
});
|
|
|
|
|
|
|
|
window.WorkAdventureDesktopApi.notify("Hello from front");
|
2022-02-20 20:30:53 +01:00
|
|
|
```
|