-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.go
108 lines (94 loc) · 2.37 KB
/
main.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package main
import (
"embed"
"log"
"os"
"path/filepath"
"github.com/masahide/OmniSSHAgent/pkg/filelog"
"github.com/masahide/OmniSSHAgent/pkg/pageant"
"github.com/masahide/OmniSSHAgent/pkg/store"
"github.com/masahide/OmniSSHAgent/pkg/store/local"
"github.com/wailsapp/wails/v2/pkg/options/mac"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/logger"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/windows"
)
const (
AppName = "OmniSSHAgent"
)
//go:embed all:frontend/dist
var assets embed.FS
//go:embed build/appicon.png
var iconData []byte
func getExeName() string {
return filepath.Base(os.Args[0])
}
func checkAlreadyRunning() {
b, err := pageant.AlreadyRunning()
if err != nil {
return
}
//respLen := binary.BigEndian.Uint32(b[:4])
if string(b[4:]) == AppName {
os.Exit(0)
}
}
var Logger *filelog.FileLog
func main() {
Logger = filelog.New(AppName, 1)
log.SetFlags(log.LstdFlags | log.Lshortfile)
log.SetOutput(Logger)
// Create an instance of the app structure
checkAlreadyRunning()
app := NewApp()
app.settings = store.NewSettings(getExeName(), local.NewLocalCred(AppName))
if err := app.settings.Load(); err != nil {
log.Fatal(err.Error())
}
// Create application with options
err := wails.Run(&options.App{
Title: AppName,
Width: 900,
Height: 900,
MinWidth: 720,
MinHeight: 570,
MaxWidth: 1280,
MaxHeight: 900,
DisableResize: false,
Fullscreen: false,
Frameless: false,
StartHidden: app.settings.StartHidden,
HideWindowOnClose: true,
// RGBA: &options.RGBA{R: 33, G: 37, B: 43, A: 255},
Assets: assets,
LogLevel: logger.DEBUG,
OnStartup: app.startup,
OnDomReady: app.domReady,
OnShutdown: app.shutdown,
Bind: []interface{}{
app,
},
// Windows platform specific options
Windows: &windows.Options{
WebviewIsTransparent: false,
WindowIsTranslucent: false,
DisableWindowIcon: false,
},
Mac: &mac.Options{
TitleBar: mac.TitleBarHiddenInset(),
Appearance: mac.NSAppearanceNameDarkAqua,
WebviewIsTransparent: true,
WindowIsTranslucent: true,
About: &mac.AboutInfo{
Title: "My Application",
Message: "",
Icon: iconData,
},
},
})
if err != nil {
log.Print(err)
app.Quit()
}
}