File tree Expand file tree Collapse file tree 3 files changed +47
-7
lines changed
Expand file tree Collapse file tree 3 files changed +47
-7
lines changed Original file line number Diff line number Diff line change 88)
99
1010type AppConfig struct {
11- BaseRoot string `json:"base_root"`
11+ BaseRoot string `json:"base_root"`
12+ WindowWidth int `json:"window_width"`
13+ WindowHeight int `json:"window_height"`
1214}
1315
1416func localAppData () string {
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import (
1616 "github.com/liteldev/LeviLauncher/internal/vcruntime"
1717
1818 "github.com/wailsapp/wails/v3/pkg/application"
19+ "github.com/wailsapp/wails/v3/pkg/events"
1920)
2021
2122//go:embed all:frontend/dist
@@ -56,7 +57,7 @@ func init() {
5657}
5758
5859func main () {
59- _ , _ = config .Load ()
60+ c , _ : = config .Load ()
6061 extractor .Init ()
6162 update .Init ()
6263 mc := Minecraft {}
@@ -80,10 +81,31 @@ func main() {
8081 }
8182 }
8283
83- app .Window .NewWithOptions (application.WebviewWindowOptions {
84+ w := 1024
85+ h := 640
86+ if c .WindowWidth > 0 {
87+ if c .WindowWidth < 960 {
88+ w = 960
89+ } else {
90+ w = c .WindowWidth
91+ }
92+ }
93+ if c .WindowHeight > 0 {
94+ if c .WindowHeight < 600 {
95+ h = 600
96+ } else {
97+ h = c .WindowHeight
98+ }
99+ }
100+ if c .WindowWidth == 0 || c .WindowHeight == 0 {
101+ c .WindowWidth = w
102+ c .WindowHeight = h
103+ _ = config .Save (c )
104+ }
105+ windows := app .Window .NewWithOptions (application.WebviewWindowOptions {
84106 Title : "LeviLauncher" ,
85- Width : 1024 ,
86- Height : 640 ,
107+ Width : w ,
108+ Height : h ,
87109 MinWidth : 960 ,
88110 MinHeight : 600 ,
89111 Mac : application.MacWindow {},
@@ -100,6 +122,17 @@ func main() {
100122 URL : initialURL ,
101123 })
102124
125+ windows .RegisterHook (events .Common .WindowClosing , func (event * application.WindowEvent ) {
126+ w := windows .Width ()
127+ h := windows .Height ()
128+
129+ c , _ := config .Load ()
130+ if w > 0 && h > 0 {
131+ c .WindowWidth = w
132+ c .WindowHeight = h
133+ _ = config .Save (c )
134+ }
135+ })
103136 err := app .Run ()
104137
105138 if err != nil {
Original file line number Diff line number Diff line change @@ -1920,15 +1920,20 @@ func (a *Minecraft) SetBaseRoot(root string) string {
19201920 if err := os .MkdirAll (r , 0o755 ); err != nil {
19211921 return "ERR_CREATE_TARGET_DIR"
19221922 }
1923- if err := config .Save (config.AppConfig {BaseRoot : r }); err != nil {
1923+ c , _ := config .Load ()
1924+ c .BaseRoot = r
1925+ if err := config .Save (c ); err != nil {
19241926 return "ERR_WRITE_FILE"
19251927 }
19261928 return ""
19271929}
19281930func (a * Minecraft ) ResetBaseRoot () string {
1929- if err := config .Save (config.AppConfig {BaseRoot : "" }); err != nil {
1931+ c , _ := config .Load ()
1932+ c .BaseRoot = ""
1933+ if err := config .Save (c ); err != nil {
19301934 return "ERR_WRITE_FILE"
19311935 }
19321936 return ""
19331937}
1938+
19341939func (a * Minecraft ) CanWriteToDir (path string ) bool { return utils .CanWriteDir (path ) }
You can’t perform that action at this time.
0 commit comments