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
# start local-app
cd local-app/
yarn dev
yarn dev:local-app
# start electron app
LOCAL_APP_URL=http://localhost:3000 yarn dev
# or create an executable by running:
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>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Security-Policy" content="script-src 'self';">
<title>WorkAdventure Desktop</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Security-Policy" content="script-src 'self';" />
<title>WorkAdventure Desktop</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body, #app {
height: 100%;
width: 100%;
}
html,
body,
#app {
height: 100%;
width: 100%;
}
#app {
display: flex;
}
</style>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
#app {
display: flex;
}
</style>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</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",
"preview": "vite preview",
"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}'"
},
"devDependencies": {

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

View File

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

View File

@ -7,8 +7,9 @@
"license": "SEE LICENSE IN LICENSE.txt",
"scripts": {
"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",
"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",
"release": "yarn bundle",
"typecheck": "tsc --noEmit",