38 lines
956 B
Svelte
38 lines
956 B
Svelte
<script>
|
|
import { emit, listen } from '@tauri-apps/api/event';
|
|
import queue from './lib/queue.js';
|
|
|
|
const VIEWS = import.meta.glob('./views/*.svelte', {eager: true});
|
|
|
|
window.emit = emit;
|
|
window.queue = queue;
|
|
|
|
var appState = {
|
|
currentRequest: null,
|
|
pendingRequests: queue(),
|
|
credentialStatus: 'locked',
|
|
}
|
|
window.appState = appState;
|
|
|
|
|
|
import { invoke } from '@tauri-apps/api/tauri';
|
|
window.invoke = invoke;
|
|
|
|
|
|
var currentView = VIEWS['./views/Home.svelte'].default;
|
|
window.currentView = currentView;
|
|
window.VIEWS = VIEWS;
|
|
function navigate(svelteEvent) {
|
|
const moduleName = `./views/${svelteEvent.detail.target}.svelte`;
|
|
currentView = VIEWS[moduleName].default;
|
|
}
|
|
window.navigate = navigate;
|
|
|
|
listen('credentials-request', (tauriEvent) => {
|
|
appState.pendingRequests.put(tauriEvent.payload);
|
|
console.log('Received request.');
|
|
});
|
|
</script>
|
|
|
|
<svelte:component this={currentView} on:navigate={navigate} bind:appState={appState} />
|