diff --git a/app.go b/app.go index 8f33d7b..082350f 100644 --- a/app.go +++ b/app.go @@ -998,15 +998,6 @@ func (a *App) ExportConfig() string { } return "导出成功:" + file } -func getScreenResolution() (int, int, error) { - //user32 := syscall.NewLazyDLL("user32.dll") - //getSystemMetrics := user32.NewProc("GetSystemMetrics") - // - //width, _, _ := getSystemMetrics.Call(0) - //height, _, _ := getSystemMetrics.Call(1) - - return int(1366), int(768), nil -} func (a *App) ShareAnalysis(stockCode, stockName string) string { //http://go-stock.sparkmemory.top:16688/upload diff --git a/app_darwin.go b/app_darwin.go index 0aa26a6..0839e78 100644 --- a/app_darwin.go +++ b/app_darwin.go @@ -67,9 +67,31 @@ func (a *App) startup(ctx context.Context) { log.Fatalf("系统通知失败: %v", err) } }() + go setUpScreen(a) logger.SugaredLogger.Infof(" application startup Version:%s", Version) } +func setUpScreen(a *App) { + screens, _ := runtime.ScreenGetAll(a.ctx) + if len(screens) == 0 { + return + } + screen := screens[0] + sw, sh := screen.Width, screen.Height + + // macOS 菜单栏 + Dock 留出空间 + topBarHeight := 22 + dockHeight := 56 + verticalMargin := topBarHeight + dockHeight + + // 设置窗口为屏幕 80% 宽 × 可用高度 90% + w := int(float64(sw) * 0.8) + h := int(float64(sh-verticalMargin) * 0.9) + + runtime.WindowSetSize(a.ctx, w, h) + runtime.WindowCenter(a.ctx) +} + // OnSecondInstanceLaunch 处理第二实例启动时的通知 func OnSecondInstanceLaunch(secondInstanceData options.SecondInstanceData) { err := beeep.Notify("go-stock", "程序已经在运行了", "") @@ -166,3 +188,17 @@ func (a *App) beforeClose(ctx context.Context) (prevent bool) { return false // 如果选择了确定,继续关闭应用 } } + +func getFrameless() bool { + return false +} + +func getScreenResolution() (int, int, int, int, error) { + //user32 := syscall.NewLazyDLL("user32.dll") + //getSystemMetrics := user32.NewProc("GetSystemMetrics") + // + //width, _, _ := getSystemMetrics.Call(0) + //height, _, _ := getSystemMetrics.Call(1) + + return int(1200), int(800), 0, 0, nil +} diff --git a/app_windows.go b/app_windows.go index b38c487..4c44546 100644 --- a/app_windows.go +++ b/app_windows.go @@ -199,3 +199,17 @@ func (a *App) beforeClose(ctx context.Context) (prevent bool) { return false } } + +func getFrameless() bool { + return true +} + +func getScreenResolution() (int, int, int, int, error) { + //user32 := syscall.NewLazyDLL("user32.dll") + //getSystemMetrics := user32.NewProc("GetSystemMetrics") + // + //width, _, _ := getSystemMetrics.Call(0) + //height, _, _ := getSystemMetrics.Call(1) + + return int(1366), int(768), 1456, 768, nil +} diff --git a/frontend/package.json.md5 b/frontend/package.json.md5 index fce852e..799119d 100644 --- a/frontend/package.json.md5 +++ b/frontend/package.json.md5 @@ -1 +1 @@ -2d63c3a999d797889c01d6c96451b197 \ No newline at end of file +8d3264f90073dfceb29c3619775d830d \ No newline at end of file diff --git a/main.go b/main.go index 34f5996..4426409 100644 --- a/main.go +++ b/main.go @@ -109,7 +109,7 @@ func main() { //var width, height int //var err error // - width, _, err := getScreenResolution() + width, _, minWidth, minHeight, err := getScreenResolution() if err != nil { log.SugaredLogger.Error("get screen resolution error") width = 1456 @@ -122,18 +122,20 @@ func main() { backgroundColour = &options.RGBA{R: 27, G: 38, B: 54, A: 1} } + frameless := getFrameless() + // Create application with options err = wails.Run(&options.App{ Title: "go-stock", Width: width * 4 / 5, Height: 900, - MinWidth: 1456, - MinHeight: 768, + MinWidth: minWidth, + MinHeight: minHeight, //MaxWidth: width, //MaxHeight: height, DisableResize: false, Fullscreen: false, - Frameless: true, + Frameless: frameless, StartHidden: false, HideWindowOnClose: false, EnableDefaultContextMenu: true, @@ -166,12 +168,11 @@ func main() { // Mac platform specific options Mac: &mac.Options{ TitleBar: &mac.TitleBar{ - TitlebarAppearsTransparent: true, + TitlebarAppearsTransparent: false, HideTitle: false, HideTitleBar: false, FullSizeContent: false, - UseToolbar: false, - HideToolbarSeparator: true, + UseToolbar: true, }, Appearance: mac.NSAppearanceNameDarkAqua, WebviewIsTransparent: true,