-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathapp.go
43 lines (37 loc) · 926 Bytes
/
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
package main
import (
"context"
"fmt"
wruntime "github.com/wailsapp/wails/v2/pkg/runtime"
"os"
)
// App struct
type App struct {
ctx context.Context
}
// NewApp creates a new App application struct
func NewApp() *App {
return &App{}
}
// startup is called when the app starts. The context is saved
// so we can call the runtime methods
func (app *App) startup(ctx context.Context) {
app.ctx = ctx
if app.ReadSetting().RememberLastPage {
wruntime.WindowExecJS(app.ctx, "window.location.href='"+app.ReadSetting().LastPage+"';")
} else {
wruntime.WindowExecJS(app.ctx, "window.location.href='https://chatbot.theb.ai/';")
}
app.updateDialog(false)
}
func (app *App) WriteHome(url string) {
filePath := ConfigPath("home.txt")
data := []byte(url)
err := os.WriteFile(filePath, data, 0644)
if err != nil {
fmt.Println("Error writing file", err)
}
}
func (app *App) GetVersion() string {
return Version
}