generated from dave/wails-template
Add close and refresh keybinds
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -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
5
app.go
@@ -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{}
|
||||||
|
@@ -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">
|
||||||
|
2
frontend/wailsjs/go/main/App.d.ts
vendored
2
frontend/wailsjs/go/main/App.d.ts
vendored
@@ -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>;
|
||||||
|
@@ -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']();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user