forked from A-SunsetMkt-Forks/EasyClash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
95 lines (84 loc) · 2.14 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
package main
import (
"embed"
"fmt"
"log"
"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/mac"
"github.com/wailsapp/wails/v2/pkg/options/windows"
"easyclash/app"
"easyclash/pkg/notify"
"easyclash/pkg/stdpath"
"easyclash/pkg/utils"
)
//go:embed build/appicon.png
var icon []byte
//go:embed frontend/dist
var ui embed.FS
//go:embed easy_clash
var ruleSet embed.FS
var appName = "EasyClash"
func main() {
path, _ := stdpath.AppDataLocation(appName)
err := utils.SaveDir(ruleSet, path, false)
if err != nil {
_ = notify.Notification("EasyClash", "", "init conf dir error", "")
log.Fatal(fmt.Errorf("AppDataLocation dir %s init err %v", path, err))
return
}
_app := app.NewApp(path)
opt := appOptions()
opt.OnStartup = _app.Startup
opt.OnDomReady = _app.DomReady
opt.OnShutdown = _app.Shutdown
opt.OnBeforeClose = _app.OnBeforeClose
opt.Bind = []interface{}{
_app,
}
err = wails.Run(opt)
if err != nil {
log.Fatal(err)
}
}
func appOptions() *options.App {
return &options.App{
Title: appName,
Width: 1024,
Height: 768,
MinWidth: 985,
MinHeight: 768,
DisableResize: false,
Fullscreen: false,
Frameless: false,
StartHidden: false,
HideWindowOnClose: true,
RGBA: &options.RGBA{R: 255, G: 255, B: 255, A: 255},
Assets: ui,
LogLevel: logger.DEBUG,
Windows: &windows.Options{
WebviewIsTransparent: false,
WindowIsTranslucent: false,
DisableWindowIcon: false,
},
Mac: &mac.Options{
TitleBar: &mac.TitleBar{
TitlebarAppearsTransparent: true,
HideTitle: true,
HideTitleBar: false,
FullSizeContent: false,
UseToolbar: false,
HideToolbarSeparator: true,
},
Appearance: mac.NSAppearanceNameVibrantLight,
WebviewIsTransparent: true,
WindowIsTranslucent: true,
About: &mac.AboutInfo{
Title: appName,
Message: "clash config manager",
Icon: icon,
},
},
}
}