mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
feat(app):添加谷歌浏览器检查并发送警告消息
- 在应用启动时检查谷歌浏览器是否安装 - 如果未安装,发送警告消息提醒用户 - 新增 checkChromeOnWindows 函数用于检查浏览器 - 在前端添加警告消息的事件监听
This commit is contained in:
parent
2c0e2ec698
commit
908086c0c0
23
app.go
23
app.go
@ -18,6 +18,7 @@ import (
|
|||||||
"go-stock/backend/db"
|
"go-stock/backend/db"
|
||||||
"go-stock/backend/logger"
|
"go-stock/backend/logger"
|
||||||
"go-stock/backend/models"
|
"go-stock/backend/models"
|
||||||
|
"golang.org/x/sys/windows/registry"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -120,6 +121,13 @@ func (a *App) domReady(ctx context.Context) {
|
|||||||
go func() {
|
go func() {
|
||||||
checkUpdate(a)
|
checkUpdate(a)
|
||||||
}()
|
}()
|
||||||
|
//检查谷歌浏览器
|
||||||
|
go func() {
|
||||||
|
f := checkChromeOnWindows()
|
||||||
|
if !f {
|
||||||
|
go runtime.EventsEmit(a.ctx, "warnMsg", "谷歌浏览器未安装,ai分析功能可能无法使用")
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func refreshTelegraphList() *[]string {
|
func refreshTelegraphList() *[]string {
|
||||||
@ -433,6 +441,21 @@ func (a *App) GetVersionInfo() *models.VersionInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// checkChromeOnWindows 在 Windows 系统上检查谷歌浏览器是否安装
|
||||||
|
func checkChromeOnWindows() bool {
|
||||||
|
key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe`, registry.QUERY_VALUE)
|
||||||
|
if err != nil {
|
||||||
|
// 尝试在 WOW6432Node 中查找(适用于 64 位系统上的 32 位程序)
|
||||||
|
key, err = registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe`, registry.QUERY_VALUE)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
defer key.Close()
|
||||||
|
}
|
||||||
|
defer key.Close()
|
||||||
|
_, _, err = key.GetValue("Path", nil)
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
func GetImageBase(bytes []byte) string {
|
func GetImageBase(bytes []byte) string {
|
||||||
return "data:image/jpeg;base64," + base64.StdEncoding.EncodeToString(bytes)
|
return "data:image/jpeg;base64," + base64.StdEncoding.EncodeToString(bytes)
|
||||||
}
|
}
|
||||||
|
@ -215,6 +215,25 @@ EventsOn("updateVersion",async (msg) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
EventsOn("warnMsg",async (msg) => {
|
||||||
|
notify.error({
|
||||||
|
avatar: () =>
|
||||||
|
h(NAvatar, {
|
||||||
|
size: 'small',
|
||||||
|
round: false,
|
||||||
|
src: icon.value
|
||||||
|
}),
|
||||||
|
title: '警告',
|
||||||
|
content: () => {
|
||||||
|
return h('div', {
|
||||||
|
style: {
|
||||||
|
'text-align': 'left',
|
||||||
|
'font-size': '14px',
|
||||||
|
}
|
||||||
|
}, { default: () => msg })
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
//判断是否是A股交易时间
|
//判断是否是A股交易时间
|
||||||
function isTradingTime() {
|
function isTradingTime() {
|
||||||
|
2
go.mod
2
go.mod
@ -15,6 +15,7 @@ require (
|
|||||||
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4
|
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4
|
||||||
github.com/wailsapp/wails/v2 v2.9.2
|
github.com/wailsapp/wails/v2 v2.9.2
|
||||||
go.uber.org/zap v1.27.0
|
go.uber.org/zap v1.27.0
|
||||||
|
golang.org/x/sys v0.28.0
|
||||||
golang.org/x/text v0.21.0
|
golang.org/x/text v0.21.0
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||||
gorm.io/gorm v1.25.12
|
gorm.io/gorm v1.25.12
|
||||||
@ -72,7 +73,6 @@ require (
|
|||||||
golang.org/x/crypto v0.31.0 // indirect
|
golang.org/x/crypto v0.31.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
|
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
|
||||||
golang.org/x/net v0.33.0 // indirect
|
golang.org/x/net v0.33.0 // indirect
|
||||||
golang.org/x/sys v0.28.0 // indirect
|
|
||||||
modernc.org/libc v1.22.5 // indirect
|
modernc.org/libc v1.22.5 // indirect
|
||||||
modernc.org/mathutil v1.5.0 // indirect
|
modernc.org/mathutil v1.5.0 // indirect
|
||||||
modernc.org/memory v1.5.0 // indirect
|
modernc.org/memory v1.5.0 // indirect
|
||||||
|
Loading…
x
Reference in New Issue
Block a user