chore: integrate with umami
This commit is contained in:
parent
4032c80add
commit
b361e9b0be
|
@ -3,6 +3,7 @@ package services
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||||
|
runtime2 "runtime"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"tinyrdm/backend/consts"
|
"tinyrdm/backend/consts"
|
||||||
|
@ -12,6 +13,7 @@ import (
|
||||||
|
|
||||||
type systemService struct {
|
type systemService struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
|
appVersion string
|
||||||
}
|
}
|
||||||
|
|
||||||
var system *systemService
|
var system *systemService
|
||||||
|
@ -20,15 +22,18 @@ var onceSystem sync.Once
|
||||||
func System() *systemService {
|
func System() *systemService {
|
||||||
if system == nil {
|
if system == nil {
|
||||||
onceSystem.Do(func() {
|
onceSystem.Do(func() {
|
||||||
system = &systemService{}
|
system = &systemService{
|
||||||
|
appVersion: "0.0.0",
|
||||||
|
}
|
||||||
go system.loopWindowEvent()
|
go system.loopWindowEvent()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return system
|
return system
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *systemService) Start(ctx context.Context) {
|
func (s *systemService) Start(ctx context.Context, version string) {
|
||||||
s.ctx = ctx
|
s.ctx = ctx
|
||||||
|
s.appVersion = version
|
||||||
|
|
||||||
// maximize the window if screen size is lower than the minimum window size
|
// maximize the window if screen size is lower than the minimum window size
|
||||||
if screen, err := runtime.ScreenGetAll(ctx); err == nil && len(screen) > 0 {
|
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
|
// SelectFile open file dialog to select a file
|
||||||
func (s *systemService) SelectFile(title string, extensions []string) (resp types.JSResp) {
|
func (s *systemService) SelectFile(title string, extensions []string) (resp types.JSResp) {
|
||||||
filters := sliceutil.Map(extensions, func(i int) runtime.FileFilter {
|
filters := sliceutil.Map(extensions, func(i int) runtime.FileFilter {
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang='en'>
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset='UTF-8' />
|
<meta charset="UTF-8" />
|
||||||
<meta content='width=device-width, initial-scale=1.0' name='viewport' />
|
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
||||||
<title>Tiny RDM</title>
|
<title>Tiny RDM</title>
|
||||||
<!-- <link href="./src/styles/style.scss" rel="stylesheet">-->
|
<!-- <link href="./src/styles/style.scss" rel="stylesheet">-->
|
||||||
</head>
|
</head>
|
||||||
<body spellcheck="false">
|
<body spellcheck="false">
|
||||||
<div id='app'></div>
|
<div id="app"></div>
|
||||||
<script src='./src/main.js' type='module'></script>
|
<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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import AboutDialog from '@/components/dialogs/AboutDialog.vue'
|
||||||
import FlushDbDialog from '@/components/dialogs/FlushDbDialog.vue'
|
import FlushDbDialog from '@/components/dialogs/FlushDbDialog.vue'
|
||||||
import ExportKeyDialog from '@/components/dialogs/ExportKeyDialog.vue'
|
import ExportKeyDialog from '@/components/dialogs/ExportKeyDialog.vue'
|
||||||
import ImportKeyDialog from '@/components/dialogs/ImportKeyDialog.vue'
|
import ImportKeyDialog from '@/components/dialogs/ImportKeyDialog.vue'
|
||||||
|
import { Info } from 'wailsjs/go/services/systemService.js'
|
||||||
|
|
||||||
const prefStore = usePreferencesStore()
|
const prefStore = usePreferencesStore()
|
||||||
const connectionStore = useConnectionStore()
|
const connectionStore = useConnectionStore()
|
||||||
|
@ -33,6 +34,10 @@ onMounted(async () => {
|
||||||
if (prefStore.autoCheckUpdate) {
|
if (prefStore.autoCheckUpdate) {
|
||||||
prefStore.checkForUpdate()
|
prefStore.checkForUpdate()
|
||||||
}
|
}
|
||||||
|
Info().then(({ data }) => {
|
||||||
|
// const {os, arch, version} = data
|
||||||
|
umami && umami.track('startup', data)
|
||||||
|
})
|
||||||
} finally {
|
} finally {
|
||||||
initializing.value = false
|
initializing.value = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,11 +109,18 @@ const onSelectPreferenceMenu = (key) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const openWechatOfficial = () => {
|
||||||
|
umami && umami.track('open', { target: 'wechat_official' })
|
||||||
|
showWechat.value = true
|
||||||
|
}
|
||||||
|
|
||||||
const openX = () => {
|
const openX = () => {
|
||||||
|
umami && umami.track('open', { target: 'x' })
|
||||||
BrowserOpenURL('https://twitter.com/LykinHuang')
|
BrowserOpenURL('https://twitter.com/LykinHuang')
|
||||||
}
|
}
|
||||||
|
|
||||||
const openGithub = () => {
|
const openGithub = () => {
|
||||||
|
umami && umami.track('open', { target: 'github' })
|
||||||
BrowserOpenURL('https://github.com/tiny-craft/tiny-rdm')
|
BrowserOpenURL('https://github.com/tiny-craft/tiny-rdm')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +170,7 @@ const exThemeVars = computed(() => {
|
||||||
:size="iconSize"
|
:size="iconSize"
|
||||||
class="nav-menu-button"
|
class="nav-menu-button"
|
||||||
t-tooltip="ribbon.wechat_official"
|
t-tooltip="ribbon.wechat_official"
|
||||||
@click="showWechat = true" />
|
@click="openWechatOfficial" />
|
||||||
<icon-button
|
<icon-button
|
||||||
v-else
|
v-else
|
||||||
:border="false"
|
:border="false"
|
||||||
|
|
2
main.go
2
main.go
|
@ -66,7 +66,7 @@ func main() {
|
||||||
BackgroundColour: options.NewRGBA(27, 38, 54, 0),
|
BackgroundColour: options.NewRGBA(27, 38, 54, 0),
|
||||||
StartHidden: true,
|
StartHidden: true,
|
||||||
OnStartup: func(ctx context.Context) {
|
OnStartup: func(ctx context.Context) {
|
||||||
sysSvc.Start(ctx)
|
sysSvc.Start(ctx, version)
|
||||||
connSvc.Start(ctx)
|
connSvc.Start(ctx)
|
||||||
browserSvc.Start(ctx)
|
browserSvc.Start(ctx)
|
||||||
cliSvc.Start(ctx)
|
cliSvc.Start(ctx)
|
||||||
|
|
Loading…
Reference in New Issue