mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
feat(frontend): 添加窗口移动功能并优化错误处理
- 在 App.vue 中添加移动窗口功能 - 优化全屏切换逻辑 - 在 stock_data_api.go 中改进错误处理 - 移除 app.go 中的冗余日志
This commit is contained in:
parent
9dc8fa97df
commit
1fd149bbd5
1
app.go
1
app.go
@ -147,7 +147,6 @@ func getStockInfo(follow data.FollowedStock) *data.StockInfo {
|
|||||||
stockCode := follow.StockCode
|
stockCode := follow.StockCode
|
||||||
stockDatas, err := data.NewStockDataApi().GetStockCodeRealTimeData(stockCode)
|
stockDatas, err := data.NewStockDataApi().GetStockCodeRealTimeData(stockCode)
|
||||||
if err != nil || len(*stockDatas) == 0 {
|
if err != nil || len(*stockDatas) == 0 {
|
||||||
logger.SugaredLogger.Errorf("get stock code real time data error:%s", err.Error())
|
|
||||||
return &data.StockInfo{}
|
return &data.StockInfo{}
|
||||||
}
|
}
|
||||||
stockData := (*stockDatas)[0]
|
stockData := (*stockDatas)[0]
|
||||||
|
@ -281,7 +281,7 @@ func (receiver StockDataApi) GetStockCodeRealTimeData(StockCodes ...string) (*[]
|
|||||||
Get(fmt.Sprintf(sina_stook_url, time.Now().Unix(), slice.Join(StockCodes, ",")))
|
Get(fmt.Sprintf(sina_stook_url, time.Now().Unix(), slice.Join(StockCodes, ",")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.SugaredLogger.Error(err.Error())
|
logger.SugaredLogger.Error(err.Error())
|
||||||
return &[]StockInfo{}, nil
|
return &[]StockInfo{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
stockInfos := make([]StockInfo, 0)
|
stockInfos := make([]StockInfo, 0)
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
import stockInfo from './components/stock.vue'
|
import stockInfo from './components/stock.vue'
|
||||||
import {
|
import {
|
||||||
Quit,
|
Quit,
|
||||||
WindowFullscreen,
|
WindowFullscreen, WindowGetPosition,
|
||||||
WindowHide,
|
WindowHide,
|
||||||
WindowIsFullscreen,
|
WindowIsFullscreen, WindowSetPosition,
|
||||||
WindowUnfullscreen
|
WindowUnfullscreen
|
||||||
} from '../wailsjs/runtime'
|
} from '../wailsjs/runtime'
|
||||||
import {h, ref} from "vue";
|
import {h, ref} from "vue";
|
||||||
@ -14,7 +14,7 @@ import {
|
|||||||
SettingsOutline,
|
SettingsOutline,
|
||||||
ReorderTwoOutline,
|
ReorderTwoOutline,
|
||||||
ExpandOutline,
|
ExpandOutline,
|
||||||
RefreshOutline, PowerOutline, BarChartOutline,
|
RefreshOutline, PowerOutline, BarChartOutline, MoveOutline,
|
||||||
} from '@vicons/ionicons5'
|
} from '@vicons/ionicons5'
|
||||||
|
|
||||||
const content = ref('数据来源于网络,仅供参考\n投资有风险,入市需谨慎')
|
const content = ref('数据来源于网络,仅供参考\n投资有风险,入市需谨慎')
|
||||||
@ -71,7 +71,15 @@ const menuOptions = ref([
|
|||||||
}, { default: () => '隐藏到托盘区' }),
|
}, { default: () => '隐藏到托盘区' }),
|
||||||
key: 'hide',
|
key: 'hide',
|
||||||
icon: renderIcon(ReorderTwoOutline),
|
icon: renderIcon(ReorderTwoOutline),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: ()=> h("a", {
|
||||||
|
href: 'javascript:void(0)',
|
||||||
|
style: 'cursor: move;',
|
||||||
|
onClick: toggleStartMoveWindow,
|
||||||
|
}, { default: () => '移动' }),
|
||||||
|
key: 'move',
|
||||||
|
icon: renderIcon(MoveOutline),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: ()=> h("a", {
|
label: ()=> h("a", {
|
||||||
@ -87,18 +95,31 @@ function renderIcon(icon) {
|
|||||||
}
|
}
|
||||||
function toggleFullscreen(e) {
|
function toggleFullscreen(e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
WindowIsFullscreen().then((isFull) => {
|
isFullscreen.value=!isFullscreen.value
|
||||||
isFullscreen.value = isFull
|
if (isFullscreen.value) {
|
||||||
if (isFull) {
|
|
||||||
WindowUnfullscreen()
|
WindowUnfullscreen()
|
||||||
e.target.innerHTML = '全屏'
|
e.target.innerHTML = '全屏'
|
||||||
} else {
|
} else {
|
||||||
WindowFullscreen()
|
WindowFullscreen()
|
||||||
e.target.innerHTML = '取消全屏'
|
e.target.innerHTML = '取消全屏'
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
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)
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user