feat: add "app" system

This commit is contained in:
hippoz 2021-10-27 03:15:29 +03:00
parent 4702e1b279
commit eab9bc5805
Signed by: hippoz
GPG key ID: 7C52899193467641
9 changed files with 61 additions and 28 deletions

View file

@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset='utf-8'>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'">
<meta name='viewport' content='width=device-width,initial-scale=1'>
<title>app</title>

View file

@ -0,0 +1,11 @@
import { spawnBrowser } from "../appruntime";
const app = {
name: "duckduckgo",
component: null,
async open() {
await spawnBrowser("https://duckduckgo.com/");
}
};
export default app;

View file

@ -0,0 +1,12 @@
import env from '../env';
const { spawn } = require('child_process');
export function spawnBrowser(url, params=[]) {
return new Promise((resolve, reject) => {
const browserProcess = spawn(env.browserLaunch.browserBinary, [...env.browserLaunch.params, ...params, url]);
browserProcess.on("spawn", () => resolve(browserProcess));
browserProcess.on("error", e => reject(e));
});
}

View file

@ -0,0 +1,9 @@
import duckduckgo from "./applications/duckduckgo";
const provider = {
repository: [
duckduckgo
]
};
export default provider;

View file

@ -1,9 +1,13 @@
<script>
export let name;
export let app;
const open = async () => {
return await app.open();
};
</script>
<button class="app-tile">
{ name }
<button on:click={ open } class="app-tile">
{ app.name }
</button>
<style>
@ -15,10 +19,11 @@
min-width: 5rem;
min-height: 5rem;
border: none;
font-size: 2.5em;
font-size: 2.7em;
user-select: none;
box-sizing: border-box;
transition-duration: 0.256s;
transition-duration: 0.252s;
transition-timing-function: cubic-bezier(0.65, 0.05, 0.36, 1);
}
.app-tile:hover {

View file

@ -7,7 +7,7 @@
<div class="app-grid">
{#each applicationRepository as app}
<AppTile name={app.name} />
<AppTile app={app} />
{/each}
</div>
@ -25,5 +25,6 @@
height: 100%;
margin: auto;
margin-top: 5%;
padding: 2.5em;
}
</style>

8
src/env.js Normal file
View file

@ -0,0 +1,8 @@
const env = {
browserLaunch: {
browserBinary: "chromium",
params: ["-kiosk"]
}
};
export default env;

View file

@ -1,14 +1,18 @@
const { app, BrowserWindow } = require('electron');
const { session } = require('electron')
const path = require('path');
const createWindow = () => {
const mainWindow = new BrowserWindow({
width: 800,
height: 600
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
}
});
mainWindow.setMenuBarVisibility(false);
mainWindow.loadFile(path.join(__dirname, '../public/index.html'));
mainWindow.webContents.openDevTools();
};

View file

@ -1,28 +1,10 @@
import App from './App.svelte';
import provider from './appmanager/provider';
const app = new App({
target: document.body,
props: {
applicationRepository: [
{
name: "Rodent App"
},
{
name: "Ratly"
},
{
name: "deadmau5"
},
{
name: "deadmau5"
},
{
name: "deadmau5"
},
{
name: "deadmau5"
}
]
applicationRepository: provider.repository
}
});