Skip to content

Commit

Permalink
electron 10 und Änderungen am Configstore
Browse files Browse the repository at this point in the history
  • Loading branch information
hmt committed Aug 25, 2020
1 parent 031de6d commit 18fee86
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 54 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"postinstall": "electron-builder install-app-deps"
},
"devDependencies": {
"electron": "^9.2.1",
"electron": "^10.0.0",
"electron-builder": "^22.8.0",
"electron-packager": "^15.1.0",
"electron-wix-msi": "^3.0.0",
Expand Down
41 changes: 22 additions & 19 deletions src/components/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,38 @@
</script>

<script>
import { configData, connected, user } from './../stores.js';
import { VERSION } from './../version.js';
import { configData, connected, user } from "./../stores.js";
import { VERSION } from "./../version.js";
import Main from "./Main.svelte";
import Intro from "./Intro.svelte";
const production = VERSION.production
const production = VERSION.production;
const init = async () => {
try {
await schild.connect($configData.db)
$connected = await schild.testConnection()
await schild.connect($configData.db);
$connected = await schild.testConnection();
} catch (e) {
console.log(e)
throw e
console.log(e);
throw e;
}
}
};
</script>

{#if $configData}
{#await init()}
Verbinde mit der Datenbank …
{:then}
{#if $connected && ($user || !production)}
<Main />
{:else}
<Intro />
{/if}
{:catch}
<Intro />
{/await}
{/if}

<style>
@import "../node_modules/bulma/css/bulma.css";
</style>

{#await init()} Verbinde mit der Datenbank …
{:then}
{#if $connected && ($user || !production)}
<Main />
{:else}
<Intro />
{/if}
{:catch}
<Intro />
{/await}
4 changes: 2 additions & 2 deletions src/components/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
</div>
</section>
{/if}
<div class:show>
<div class:show style="height: -webkit-fill-available;">
{#await schule then schule}
<Dokument {schule} />
<Dokument {schule}/>
{/await}
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { join, normalize } from 'path'
import url from 'url'
import { app, BrowserWindow, shell, protocol } from 'electron'
import { app, BrowserWindow, shell, protocol, ipcMain } from 'electron'
import { is } from 'electron-util'

import configFile from './configstore'
Expand Down Expand Up @@ -81,3 +81,6 @@ app.on('window-all-closed', function () {
app.on('activate', function () {
if (mainWindow === null) createWindow()
})

ipcMain.handle('get_store', (event, key) => configData );
ipcMain.handle('set_store', (event, value) => configFile.set(value))
58 changes: 30 additions & 28 deletions src/stores.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
import { writable } from 'svelte/store';
import configFile from './configstore';
import { writable } from "svelte/store";
import { ipcRenderer } from 'electron';

export const configData = writable(configFile.store);
configData.subscribe(value => {
configFile.set(value)
export const configData = writable();
ipcRenderer.invoke("get_store").then((res) => {
configData.set(res);
configData.subscribe((value) => {
ipcRenderer.invoke("set_store", value);
});
});

export const klasse = writable()
export const schueler = writable()
export const schueler_sortiert = writable()
export const selected = writable()
export const reload = writable(1)
export const abschnitt = writable()
export const jahr = writable()
export const plugin = writable()
export const plugin_entry = writable()
export const dokument = writable()
export const repo = writable()
export const set_mark = writable(true)
export const set_edit = writable()
export const error = writable()
export const kommentar = writable()
export const pdf_name = writable()
export const generic_pdf = writable()
export const user = writable()
export const component = writable()
export const connected = writable()
export const webview = writable()
export const warten = writable()
export const klasse = writable();
export const schueler = writable();
export const schueler_sortiert = writable();
export const selected = writable();
export const reload = writable(1);
export const abschnitt = writable();
export const jahr = writable();
export const plugin = writable();
export const plugin_entry = writable();
export const dokument = writable();
export const repo = writable();
export const set_mark = writable(true);
export const set_edit = writable();
export const error = writable();
export const kommentar = writable();
export const pdf_name = writable();
export const generic_pdf = writable();
export const user = writable();
export const component = writable();
export const connected = writable();
export const webview = writable();
export const warten = writable();

0 comments on commit 18fee86

Please sign in to comment.