Implement refresh on ctrl-r and close on ctrl-w
This commit is contained in:
6
app.go
6
app.go
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
)
|
||||
|
||||
// App struct
|
||||
@@ -135,3 +136,8 @@ func (a *App) SetSetting(key string, value int64) WailsGenericAck {
|
||||
}
|
||||
return WailsGenericAck{Success: true}
|
||||
}
|
||||
|
||||
//region other
|
||||
func (a *App) Close() {
|
||||
os.Exit(0)
|
||||
}
|
@@ -1,12 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
||||
<title>calorie-counter</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script src="./src/main.ts" type="module"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
@@ -1,9 +1,22 @@
|
||||
<script lang="ts">
|
||||
import Header from "$lib/components/Header.svelte";
|
||||
import Router from "$lib/router/Router.svelte";
|
||||
import { Toaster } from 'svelte-sonner'
|
||||
import { Close } from "$wails/main/App";
|
||||
import { Toaster } from "svelte-sonner";
|
||||
|
||||
function keyDown(event: KeyboardEvent) {
|
||||
if (event.ctrlKey && event.key == "r") {
|
||||
window.location.reload();
|
||||
}
|
||||
if (event.ctrlKey && event.key == 'w') {
|
||||
console.log("close");
|
||||
Close();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window on:keydown={keyDown} />
|
||||
|
||||
<Toaster />
|
||||
<template>
|
||||
<Header />
|
||||
|
2
frontend/wailsjs/go/main/App.d.ts
vendored
2
frontend/wailsjs/go/main/App.d.ts
vendored
@@ -2,6 +2,8 @@
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
import {main} from '../models';
|
||||
|
||||
export function Close():Promise<void>;
|
||||
|
||||
export function CreateFood(arg1:main.Food):Promise<main.WailsFood1>;
|
||||
|
||||
export function CreateWeight(arg1:main.Weight):Promise<main.WailsWeight1>;
|
||||
|
@@ -2,6 +2,10 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
export function Close() {
|
||||
return window['go']['main']['App']['Close']();
|
||||
}
|
||||
|
||||
export function CreateFood(arg1) {
|
||||
return window['go']['main']['App']['CreateFood'](arg1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user