-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
117 lines (108 loc) · 3.11 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
109
110
111
112
113
114
115
116
117
package main
import (
"bytes"
"embed"
"github.com/Esword618/MoocDownload/app"
"github.com/Esword618/MoocDownload/app/utils"
"github.com/Esword618/MoocDownload/config"
"github.com/spf13/viper"
"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/assetserver"
"github.com/wailsapp/wails/v2/pkg/options/linux"
"github.com/wailsapp/wails/v2/pkg/options/mac"
"github.com/wailsapp/wails/v2/pkg/options/windows"
)
//go:embed frontend/dist
var assets embed.FS
//go:embed build/appicon.png
var icon []byte
func main() {
// Create an instance of the app structure
// 创建一个App结构体实例
application := app.NewApplication()
// Create application with options
// 使用选项创建应用
err := wails.Run(&options.App{
Title: "MoocDownload",
Width: 1000,
Height: 790,
//MinWidth: 1000,
//MinHeight: 780,
//MaxWidth: 1200,
//MaxHeight: 780,
DisableResize: false,
Fullscreen: false,
Frameless: true,
StartHidden: false,
HideWindowOnClose: false,
BackgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 0},
Menu: nil,
Logger: nil,
LogLevel: logger.DEBUG,
OnStartup: application.Startup,
OnDomReady: application.DomReady,
OnBeforeClose: application.BeforeClose,
OnShutdown: application.Shutdown,
WindowStartState: options.Normal,
AssetServer: &assetserver.Options{
Assets: assets,
Handler: nil,
Middleware: nil,
},
Bind: []interface{}{
application,
},
// Windows platform specific options
// Windows平台特定选项
Windows: &windows.Options{
WebviewIsTransparent: true,
WindowIsTranslucent: false,
DisableWindowIcon: false,
DisableFramelessWindowDecorations: false,
WebviewUserDataPath: "",
WebviewBrowserPath: "",
Theme: windows.SystemDefault,
WebviewGpuIsDisabled: false,
},
// Mac platform specific options
// Mac平台特定选项
Mac: &mac.Options{
TitleBar: &mac.TitleBar{
TitlebarAppearsTransparent: true,
HideTitle: true,
HideTitleBar: false,
FullSizeContent: true,
UseToolbar: false,
HideToolbarSeparator: false,
},
Appearance: mac.NSAppearanceNameDarkAqua,
WebviewIsTransparent: true,
WindowIsTranslucent: true,
About: &mac.AboutInfo{
Title: "Wails Template Vue",
Message: "A Wails template based on Vue and Vue-Router",
Icon: icon,
},
},
Linux: &linux.Options{
Icon: icon,
},
})
if err != nil {
log.Fatal(err)
}
}
func init() {
// 配置文件
viper.SetConfigFile(config.ConfigPath)
b, _ := utils.PathExist(config.ConfigPath)
if !b {
viper.ReadConfig(bytes.NewBuffer([]byte(config.DefaultYaml)))
viper.WriteConfig()
}
viper.ReadInConfig()
}
//https://www.icourse163.org/learn/kaopei-1003292002?tid=1003524008#/learn/announce