From b361e9b0be74a6b0f93dae8b071a5f58161aa3c4 Mon Sep 17 00:00:00 2001 From: Lykin <137850705+tiny-craft@users.noreply.github.com> Date: Fri, 26 Jan 2024 00:07:25 +0800 Subject: [PATCH] chore: integrate with umami --- backend/services/system_service.go | 25 +++++++++++++++++++--- frontend/index.html | 12 ++++++----- frontend/src/App.vue | 5 +++++ frontend/src/components/sidebar/Ribbon.vue | 9 +++++++- main.go | 2 +- 5 files changed, 43 insertions(+), 10 deletions(-) diff --git a/backend/services/system_service.go b/backend/services/system_service.go index aa33cc7..a46e83f 100644 --- a/backend/services/system_service.go +++ b/backend/services/system_service.go @@ -3,6 +3,7 @@ package services import ( "context" "github.com/wailsapp/wails/v2/pkg/runtime" + runtime2 "runtime" "sync" "time" "tinyrdm/backend/consts" @@ -11,7 +12,8 @@ import ( ) type systemService struct { - ctx context.Context + ctx context.Context + appVersion string } var system *systemService @@ -20,15 +22,18 @@ var onceSystem sync.Once func System() *systemService { if system == nil { onceSystem.Do(func() { - system = &systemService{} + system = &systemService{ + appVersion: "0.0.0", + } go system.loopWindowEvent() }) } return system } -func (s *systemService) Start(ctx context.Context) { +func (s *systemService) Start(ctx context.Context, version string) { s.ctx = ctx + s.appVersion = version // maximize the window if screen size is lower than the minimum window size if screen, err := runtime.ScreenGetAll(ctx); err == nil && len(screen) > 0 { @@ -43,6 +48,20 @@ func (s *systemService) Start(ctx context.Context) { } } +func (s *systemService) Info() (resp types.JSResp) { + resp.Success = true + resp.Data = struct { + OS string `json:"os"` + Arch string `json:"arch"` + Version string `json:"version"` + }{ + OS: runtime2.GOOS, + Arch: runtime2.GOARCH, + Version: s.appVersion, + } + return +} + // SelectFile open file dialog to select a file func (s *systemService) SelectFile(title string, extensions []string) (resp types.JSResp) { filters := sliceutil.Map(extensions, func(i int) runtime.FileFilter { diff --git a/frontend/index.html b/frontend/index.html index 6e4720f..b53c808 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -1,14 +1,16 @@ - +
- - + +