This commit is contained in:
Anton Bracke 2022-02-20 21:06:27 +01:00
parent 05d7f64d1d
commit 4337264157
No known key found for this signature in database
GPG Key ID: B1222603899C6B25
8 changed files with 64 additions and 55 deletions

View File

@ -11,12 +11,36 @@ The desktop component is an electron app. It uses a hybrid setup based of two ma
```bash ```bash
# start local-app # start local-app
cd local-app/ yarn dev:local-app
yarn dev
# start electron app # start electron app
LOCAL_APP_URL=http://localhost:3000 yarn dev LOCAL_APP_URL=http://localhost:3000 yarn dev
# or create an executable by running: # or create an executable by running:
yarn bundle yarn bundle
```
## 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");
``` ```

View File

@ -1,29 +1,31 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Security-Policy" content="script-src 'self';"> <meta http-equiv="Content-Security-Policy" content="script-src 'self';" />
<title>WorkAdventure Desktop</title> <title>WorkAdventure Desktop</title>
<style> <style>
* { * {
margin: 0; margin: 0;
padding: 0; padding: 0;
box-sizing: border-box; box-sizing: border-box;
} }
html, body, #app { html,
height: 100%; body,
width: 100%; #app {
} height: 100%;
width: 100%;
}
#app { #app {
display: flex; display: flex;
} }
</style> </style>
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>
<script type="module" src="/src/main.ts"></script> <script type="module" src="/src/main.ts"></script>
</body> </body>
</html> </html>

View File

@ -1,20 +0,0 @@
// let muted = false;
document.getElementById("btn-reload").onclick = () => {
location.reload();
};
// window?.WorkAdventureDesktopApi?.onMutedKeyPress((event) => {
// if (muted) {
// document.getElementById("demo").innerHTML =
// "Ready to speak! Press ctrl-alt-m to mute.";
// } else {
// document.getElementById("demo").innerHTML =
// "Muted! Press ctrl-alt-m to unmute again.";
// }
// muted = !muted;
// });
// document.getElementById("btn-api").onclick = () => {
// window.WorkAdventureDesktopApi.notify("Hello from website");
// };

View File

@ -8,7 +8,7 @@
"build": "vite build", "build": "vite build",
"preview": "vite preview", "preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json", "check": "svelte-check --tsconfig ./tsconfig.json",
"pretty": "yarn prettier --write 'src/**/*.{ts,tsx}'", "pretty": "yarn prettier --write 'src/**/*.{ts,tsx,svelte}'",
"pretty-check": "yarn prettier --check 'src/**/*.{ts,tsx}'" "pretty-check": "yarn prettier --check 'src/**/*.{ts,tsx}'"
}, },
"devDependencies": { "devDependencies": {

View File

@ -34,6 +34,15 @@
} }
main { main {
/* TODO */
background-color: #30343d; background-color: #30343d;
/* background-color: #2b2f37; */
/* color: #62727c;
border: 1px solid #62727c; */
/* border-color: #e1e4e8;
color: #e1e4e8; */
} }
</style> </style>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -38,12 +38,5 @@
<style> <style>
aside { aside {
width: 70px; width: 70px;
/* background-color: #2b2f37; */
/* color: #62727c;
border: 1px solid #62727c; */
/* border-color: #e1e4e8;
color: #e1e4e8; */
} }
</style> </style>

View File

@ -7,8 +7,9 @@
"license": "SEE LICENSE IN LICENSE.txt", "license": "SEE LICENSE IN LICENSE.txt",
"scripts": { "scripts": {
"build": "tsup-node ./src/main.ts ./src/preload-local-app/preload.ts ./src/preload-app/preload.ts", "build": "tsup-node ./src/main.ts ./src/preload-local-app/preload.ts ./src/preload-app/preload.ts",
"dev": "yarn build --watch --onSuccess 'yarn electron dist/main.js'",
"build:local-app": "cd local-app && yarn && yarn build", "build:local-app": "cd local-app && yarn && yarn build",
"dev": "yarn build --watch --onSuccess 'yarn electron dist/main.js'",
"dev:local-app": "cd local-app && yarn && yarn dev",
"bundle": "yarn build:local-app && yarn build && electron-builder install-app-deps && electron-builder", "bundle": "yarn build:local-app && yarn build && electron-builder install-app-deps && electron-builder",
"release": "yarn bundle", "release": "yarn bundle",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",