-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
87 lines (76 loc) · 1.74 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
//go:build linux || windows
package main
import (
"os"
"fmt"
"embed"
"context"
"runtime"
"github.com/wailsapp/wails/v2"
wailsruntime "github.com/wailsapp/wails/v2/pkg/runtime"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
)
var (
sodium uintptr
//go:embed all:frontend/dist
assets embed.FS
)
func getSodiumLibrary() string {
switch runtime.GOOS {
case "linux":
return "libsodium.so.26"
case "windows":
return "libsodium.dll"
default:
panic(fmt.Errorf("GOOS=%s is not supported", runtime.GOOS))
}
}
func main() {
s, err := openLibrary(getSodiumLibrary())
if err != nil {
panic(err)
}
sodium = s
// Create an instance of the app structure
app := NewApp()
// Create application with options
err = wails.Run(&options.App{
Title: "Krypto",
Width: 1024, //1024
Height: 768, // 768
AssetServer: &assetserver.Options{
Assets: assets,
},
EnableDefaultContextMenu: false,
OnStartup: app.startup,
Bind: []interface{}{
app,
},
DragAndDrop: &options.DragAndDrop{
EnableFileDrop: true,
DisableWebViewDrop: false,
CSSDropProperty: "--wails-drop-target",
CSSDropValue: "drop",
},
OnDomReady: func(ctx context.Context) {
wailsruntime.OnFileDrop(ctx, func(x, y int, paths []string) {
if len(paths) > 0 {
info, err := os.Stat(paths[0])
if err != nil {
wailsruntime.EventsEmit(ctx, "log", "Invalid file")
return
}
if !info.IsDir() {
wailsruntime.EventsEmit(ctx, "filedrop", paths[0])
} else {
wailsruntime.EventsEmit(ctx, "log", "Invalid file")
}
}
})
},
})
if err != nil {
println("Error:", err.Error())
}
}