Add close and refresh keybinds

This commit is contained in:
2024-08-19 11:02:15 +02:00
parent c17e25c358
commit 9cbaf7880b
5 changed files with 25 additions and 0 deletions

2
.gitignore vendored
View File

@@ -3,3 +3,5 @@ frontend/dist
build build
bills.db bills.db
main.log main.log
bills.db-shm
bills.db-wal

5
app.go
View File

@@ -3,6 +3,8 @@ package main
import ( import (
"context" "context"
"time" "time"
"github.com/wailsapp/wails/v2/pkg/runtime"
) )
// App struct // App struct
@@ -20,6 +22,9 @@ func NewApp() *App {
func (a *App) startup(ctx context.Context) { func (a *App) startup(ctx context.Context) {
a.ctx = ctx a.ctx = ctx
} }
func (a *App) Close() {
runtime.Quit(a.ctx)
}
func (a *App) GetBills() WailsBills { func (a *App) GetBills() WailsBills {
res := WailsBills{} res := WailsBills{}

View File

@@ -1,8 +1,20 @@
<script lang="ts"> <script lang="ts">
import { Toaster } from "svelte-sonner";
import Header from "$lib/components/Header.svelte"; import Header from "$lib/components/Header.svelte";
import Router from "$lib/router/Router.svelte"; import Router from "$lib/router/Router.svelte";
import { Close } from '$wails/main/App'
function keyDown(event: KeyboardEvent) {
if (event.ctrlKey && event.key == "r") {
window.location.reload();
}
if (event.ctrlKey && event.key == "w") {
Close();
}
}
</script> </script>
<svelte:window on:keydown={keyDown} />
<Toaster theme="dark" expand visibleToasts={9} />
<template> <template>
<Header /> <Header />
<main class="flex-1"> <main class="flex-1">

View File

@@ -3,6 +3,8 @@
import {main} from '../models'; import {main} from '../models';
import {time} from '../models'; import {time} from '../models';
export function Close():Promise<void>;
export function EmptyBill():Promise<main.Bill>; export function EmptyBill():Promise<main.Bill>;
export function EmptyPayment():Promise<main.Payment>; export function EmptyPayment():Promise<main.Payment>;

View File

@@ -2,6 +2,10 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL // Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT // This file is automatically generated. DO NOT EDIT
export function Close() {
return window['go']['main']['App']['Close']();
}
export function EmptyBill() { export function EmptyBill() {
return window['go']['main']['App']['EmptyBill'](); return window['go']['main']['App']['EmptyBill']();
} }