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 @@ - + - - + + Tiny RDM -
- +
+ + diff --git a/frontend/src/App.vue b/frontend/src/App.vue index e02b1b2..de981ce 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -20,6 +20,7 @@ import AboutDialog from '@/components/dialogs/AboutDialog.vue' import FlushDbDialog from '@/components/dialogs/FlushDbDialog.vue' import ExportKeyDialog from '@/components/dialogs/ExportKeyDialog.vue' import ImportKeyDialog from '@/components/dialogs/ImportKeyDialog.vue' +import { Info } from 'wailsjs/go/services/systemService.js' const prefStore = usePreferencesStore() const connectionStore = useConnectionStore() @@ -33,6 +34,10 @@ onMounted(async () => { if (prefStore.autoCheckUpdate) { prefStore.checkForUpdate() } + Info().then(({ data }) => { + // const {os, arch, version} = data + umami && umami.track('startup', data) + }) } finally { initializing.value = false } diff --git a/frontend/src/components/sidebar/Ribbon.vue b/frontend/src/components/sidebar/Ribbon.vue index 0b112bd..ded693b 100644 --- a/frontend/src/components/sidebar/Ribbon.vue +++ b/frontend/src/components/sidebar/Ribbon.vue @@ -109,11 +109,18 @@ const onSelectPreferenceMenu = (key) => { } } +const openWechatOfficial = () => { + umami && umami.track('open', { target: 'wechat_official' }) + showWechat.value = true +} + const openX = () => { + umami && umami.track('open', { target: 'x' }) BrowserOpenURL('https://twitter.com/LykinHuang') } const openGithub = () => { + umami && umami.track('open', { target: 'github' }) BrowserOpenURL('https://github.com/tiny-craft/tiny-rdm') } @@ -163,7 +170,7 @@ const exThemeVars = computed(() => { :size="iconSize" class="nav-menu-button" t-tooltip="ribbon.wechat_official" - @click="showWechat = true" /> + @click="openWechatOfficial" />