-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.go
56 lines (46 loc) · 1.31 KB
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"context"
"fmt"
"os"
"github.com/wailsapp/wails/v2/pkg/runtime"
)
// App struct
type App struct {
ctx context.Context
}
// NewApp creates a new App application struct
func NewApp() *App {
return &App{}
}
func (a *App) LogInfo(message string) {
runtime.LogInfo(a.ctx, message)
}
// startup is called when the app starts. The context is saved
// so we can call the runtime methods
func (a *App) startup(ctx context.Context) {
a.ctx = ctx
}
// domReady is called after the front-end dom has been loaded
func (a *App) domReady(ctx context.Context) {
// Add startup tasks here
}
// beforeClose is called when the application is about to quit,
// either by clicking the window close button or calling runtime.Quit.
// Returning true will cause the application to continue, false will continue shutdown as normal.
func (a *App) beforeClose(ctx context.Context) (prevent bool) {
return false
}
// shutdown is called at application termination
func (a *App) shutdown(ctx context.Context) {
// Perform cleanup tasks here
}
// getCurrentDirectory returns the current working directory
func (a *App) getCurrentDirectory() string {
dir, err := os.Getwd()
if err != nil {
runtime.LogError(a.ctx, fmt.Sprintf("Error getting current directory: %v", err))
return "Error getting current directory"
}
return dir
}