diff --git a/app.go b/app.go
index ac8d785..87655a1 100644
--- a/app.go
+++ b/app.go
@@ -14,6 +14,8 @@ import (
"github.com/duke-git/lancet/v2/strutil"
"github.com/getlantern/systray"
"github.com/go-resty/resty/v2"
+ "github.com/go-toast/toast"
+ "github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/runtime"
"go-stock/backend/data"
"go-stock/backend/db"
@@ -118,18 +120,18 @@ func (a *App) domReady(ctx context.Context) {
}
}()
- go func() {
- ticker := time.NewTicker(time.Second * time.Duration(60))
- defer ticker.Stop()
- for range ticker.C {
- telegraph := refreshTelegraphList()
- if telegraph != nil && config.EnableNews {
- go runtime.EventsEmit(a.ctx, "telegraph", telegraph)
- }
- }
-
- }()
if config.EnableNews {
+ go func() {
+ ticker := time.NewTicker(time.Second * time.Duration(60))
+ defer ticker.Stop()
+ for range ticker.C {
+ telegraph := refreshTelegraphList()
+ if telegraph != nil {
+ go runtime.EventsEmit(a.ctx, "telegraph", telegraph)
+ }
+ }
+
+ }()
go runtime.EventsEmit(a.ctx, "telegraph", refreshTelegraphList())
}
go MonitorStockPrices(a)
@@ -479,6 +481,7 @@ func (a *App) shutdown(ctx context.Context) {
defer PanicHandler()
// Perform your teardown here
systray.Quit()
+ os.Exit(0)
}
// Greet returns a greeting for the given name
@@ -673,6 +676,7 @@ func getMsgTypeName(msgType int) string {
func onExit(a *App) {
// 清理操作
logger.SugaredLogger.Infof("onExit")
+ systray.Quit()
runtime.Quit(a.ctx)
}
@@ -696,15 +700,12 @@ func onReady(a *App) {
case <-mQuitOrig.ClickedCh:
logger.SugaredLogger.Infof("退出应用程序")
runtime.Quit(a.ctx)
- //systray.Quit()
case <-show.ClickedCh:
logger.SugaredLogger.Infof("显示应用程序")
runtime.WindowShow(a.ctx)
- //runtime.WindowShow(a.ctx)
case <-hide.ClickedCh:
logger.SugaredLogger.Infof("隐藏应用程序")
runtime.WindowHide(a.ctx)
-
}
}
}()
@@ -780,3 +781,19 @@ func (a *App) FollowFund(fundCode string) string {
func (a *App) UnFollowFund(fundCode string) string {
return data.NewFundApi().UnFollowFund(fundCode)
}
+
+func OnSecondInstanceLaunch(secondInstanceData options.SecondInstanceData) {
+ notification := toast.Notification{
+ AppID: "go-stock",
+ Title: "go-stock",
+ Message: "程序已经在运行了",
+ Icon: "",
+ Duration: "short",
+ Audio: toast.Default,
+ }
+ err := notification.Push()
+ if err != nil {
+ logger.SugaredLogger.Error(err)
+ }
+ time.Sleep(time.Second * 3)
+}
diff --git a/frontend/index.html b/frontend/index.html
index f27a275..db29dec 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -6,7 +6,7 @@
go-stock:AI赋能股票分析
-
+
diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index 1e241d7..ea8bffa 100644
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -129,15 +129,15 @@ const menuOptions = ref([
key: 'hide',
icon: renderIcon(ReorderTwoOutline),
},
- {
- label: ()=> h("a", {
- href: 'javascript:void(0)',
- style: 'cursor: move;',
- onClick: toggleStartMoveWindow,
- }, { default: () => '移动' }),
- key: 'move',
- icon: renderIcon(MoveOutline),
- },
+ // {
+ // label: ()=> h("a", {
+ // href: 'javascript:void(0)',
+ // style: 'cursor: move;',
+ // onClick: toggleStartMoveWindow,
+ // }, { default: () => '移动' }),
+ // key: 'move',
+ // icon: renderIcon(MoveOutline),
+ // },
{
label: ()=> h("a", {
href: '#',
@@ -161,22 +161,22 @@ function toggleFullscreen(e) {
}
isFullscreen.value=!isFullscreen.value
}
-const drag = ref(false)
-const lastPos= ref({x:0,y:0})
-function toggleStartMoveWindow(e) {
- drag.value=!drag.value
- lastPos.value={x:e.clientX,y:e.clientY}
-}
-function dragstart(e) {
- if (drag.value) {
- let x=e.clientX-lastPos.value.x
- let y=e.clientY-lastPos.value.y
- WindowGetPosition().then((pos) => {
- WindowSetPosition(pos.x+x,pos.y+y)
- })
- }
-}
-window.addEventListener('mousemove', dragstart)
+// const drag = ref(false)
+// const lastPos= ref({x:0,y:0})
+// function toggleStartMoveWindow(e) {
+// drag.value=!drag.value
+// lastPos.value={x:e.clientX,y:e.clientY}
+// }
+// function dragstart(e) {
+// if (drag.value) {
+// let x=e.clientX-lastPos.value.x
+// let y=e.clientY-lastPos.value.y
+// WindowGetPosition().then((pos) => {
+// WindowSetPosition(pos.x+x,pos.y+y)
+// })
+// }
+// }
+// window.addEventListener('mousemove', dragstart)
EventsOn("realtime_profit",(data)=>{
realtimeProfit.value=data
diff --git a/main.go b/main.go
index ff8eb86..bd3f951 100644
--- a/main.go
+++ b/main.go
@@ -17,7 +17,6 @@ import (
"go-stock/backend/db"
log "go-stock/backend/logger"
"go-stock/backend/models"
-
"os"
goruntime "runtime"
"runtime/debug"
@@ -126,7 +125,7 @@ func main() {
width, height, err = getScreenResolution()
if err != nil {
log.SugaredLogger.Error("get screen resolution error")
- width = 1366
+ width = 1456
height = 768
}
@@ -135,7 +134,7 @@ func main() {
Title: "go-stock",
Width: width * 4 / 5,
Height: height * 4 / 5,
- MinWidth: 1024,
+ MinWidth: 1456,
MinHeight: 768,
MaxWidth: width,
MaxHeight: height,
@@ -156,6 +155,10 @@ func main() {
OnBeforeClose: app.beforeClose,
OnShutdown: app.shutdown,
WindowStartState: options.Normal,
+ SingleInstanceLock: &options.SingleInstanceLock{
+ UniqueId: "go-stock",
+ OnSecondInstanceLaunch: OnSecondInstanceLaunch,
+ },
Bind: []interface{}{
app,
},