Repository navigation
Expand file tree
/
Copy pathmain.go
More file actions
66 lines (60 loc) · 1.63 KB
/
Copy pathmain.go
File metadata and controls
66 lines (60 loc) · 1.63 KB
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
package main
import (
"context"
"embed"
"log"
"os"
"strings"
"github.com/VaderChen/FastFileViewer/internal/app"
"github.com/VaderChen/FastFileViewer/internal/updater"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/wailsapp/wails/v2/pkg/options/mac"
)
//go:embed all:frontend/dist
var assets embed.FS
func main() {
if handled, err := updater.RunInstaller(os.Args[1:]); handled {
if err != nil {
log.Print(err)
}
return
}
services := app.New()
// 直接由 Finder/`open` 傳入檔案時,macOS 會將路徑放在 argv;
// 先排入佇列可讓前端完成第一幀後立即開啟,不必等待 OnFileOpen Apple Event。
for _, argument := range updater.FileArguments(os.Args[1:]) {
if strings.TrimSpace(argument) == "" || strings.HasPrefix(argument, "-") {
continue
}
services.Library.QueueOpenFile(argument)
}
err := wails.Run(&options.App{
Title: "FastFileViewer",
Width: 1440,
Height: 920,
MinWidth: 960,
MinHeight: 560,
AssetServer: &assetserver.Options{Assets: assets, Middleware: app.NewMediaMiddleware(services.Media)},
DragAndDrop: &options.DragAndDrop{EnableFileDrop: true},
Mac: &mac.Options{
OnFileOpen: services.Library.QueueOpenFile,
},
BackgroundColour: &options.RGBA{R: 242, G: 244, B: 241, A: 1},
OnStartup: services.Startup,
OnShutdown: func(context.Context) {
services.Shutdown()
},
Bind: []interface{}{
services.Library,
services.Media,
services.Download,
services.File,
services.Update,
},
})
if err != nil {
log.Fatal(err)
}
}