chore: integrate with umami

This commit is contained in:
Lykin 2024-01-26 00:07:25 +08:00
parent 4032c80add
commit b361e9b0be
5 changed files with 43 additions and 10 deletions

View File

@ -3,6 +3,7 @@ package services
import (
"context"
"github.com/wailsapp/wails/v2/pkg/runtime"
runtime2 "runtime"
"sync"
"time"
"tinyrdm/backend/consts"
@ -12,6 +13,7 @@ import (
type systemService struct {
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 {

View File

@ -1,14 +1,16 @@
<!DOCTYPE html>
<html lang='en'>
<html lang="en">
<head>
<meta charset='UTF-8' />
<meta content='width=device-width, initial-scale=1.0' name='viewport' />
<meta charset="UTF-8" />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<title>Tiny RDM</title>
<!-- <link href="./src/styles/style.scss" rel="stylesheet">-->
</head>
<body spellcheck="false">
<div id='app'></div>
<script src='./src/main.js' type='module'></script>
<div id="app"></div>
<script async data-website-id="ad6de51d-1e27-44a5-958d-319679c56aec"
src="https://analytics.tinycraft.cc/script.js"></script>
<script src="./src/main.js" type="module"></script>
</body>
</html>

View File

@ -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
}

View File

@ -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" />
<icon-button
v-else
:border="false"

View File

@ -66,7 +66,7 @@ func main() {
BackgroundColour: options.NewRGBA(27, 38, 54, 0),
StartHidden: true,
OnStartup: func(ctx context.Context) {
sysSvc.Start(ctx)
sysSvc.Start(ctx, version)
connSvc.Start(ctx)
browserSvc.Start(ctx)
cliSvc.Start(ctx)