Skip to content

Commit 0c04272

Browse files
author
spark
committed
样式修改,新增菜单工具栏
1 parent cf7e841 commit 0c04272

File tree

6 files changed

+77
-14
lines changed

6 files changed

+77
-14
lines changed

build/bin/go-stock.exe

-2 MB
Binary file not shown.

frontend/package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
12+
"@vicons/ionicons5": "^0.13.0",
1213
"vue": "^3.2.25"
1314
},
1415
"devDependencies": {

frontend/package.json.md5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9ce62efac1fed08499bbf20c8a5fd1b2
1+
bd20b6837e5729f2325cbbbaa79cbf1e

frontend/src/components/stock.vue

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import {onBeforeMount, onBeforeUnmount, onMounted, reactive, ref} from 'vue'
33
import {Greet, Follow, UnFollow, GetFollowList, GetStockList, SetCostPriceAndVolume} from '../../wailsjs/go/main/App'
44
import {NButton, NFlex, NForm, NFormItem, NInputNumber, NText, useMessage, useModal} from 'naive-ui'
5-
import { WindowFullscreen,WindowUnfullscreen } from '../../wailsjs/runtime'
6-
5+
import { WindowFullscreen,WindowUnfullscreen,EventsOn } from '../../wailsjs/runtime'
6+
import {Add, StarOutline} from '@vicons/ionicons5'
77
88
const message = useMessage()
99
const modal = useModal()
@@ -17,6 +17,7 @@ const options=ref([])
1717
const modalShow = ref(false)
1818
const modalShow2 = ref(false)
1919
const modalShow3 = ref(false)
20+
const addBTN = ref(true)
2021
const formModel = ref({
2122
name: "",
2223
code: "",
@@ -73,6 +74,28 @@ onBeforeUnmount(() => {
7374
clearInterval(ticker.value)
7475
})
7576
77+
EventsOn("refresh",(data)=>{
78+
message.success(data)
79+
})
80+
81+
EventsOn("showSearch",(data)=>{
82+
addBTN.value = data === 1;
83+
})
84+
85+
86+
EventsOn("refreshFollowList",(data)=>{
87+
message.loading("refresh...")
88+
GetFollowList().then(result => {
89+
followList.value = result
90+
for (const followedStock of result) {
91+
if (!stocks.value.includes(followedStock.StockCode)) {
92+
stocks.value.push(followedStock.StockCode)
93+
}
94+
}
95+
monitor()
96+
message.destroyAll
97+
})
98+
})
7699
77100
//判断是否是A股交易时间
78101
function isTradingTime() {
@@ -272,21 +295,25 @@ function fullscreen(){
272295
</n-card >
273296
</n-gi>
274297
</n-grid>
298+
<n-affix :trigger-bottom="60" v-if="addBTN">
299+
<!-- <n-card :bordered="false">-->
300+
<n-input-group>
275301

276-
<n-card :bordered="false" :closable="false">
277-
<n-button-group>
278-
<n-auto-complete v-model:value="data.name" type="text"
302+
<n-button type="info" @click="addBTN=false" >隐藏</n-button>
303+
<n-auto-complete v-model:value="data.name"
279304
:input-props="{
280305
autocomplete: 'disabled',
281306
}"
282307
:options="options"
283-
placeholder="输入股票名称或者代码"
284-
clearable class="input" @input="getStockList" :on-select="onSelect"/>
285-
<n-button type="info" @click="AddStock">添加 </n-button>&nbsp;&nbsp;
286-
<n-button type="warning" @click="fullscreen"> {{data.fullscreen?'退出全屏':'全屏'}} </n-button>
287-
</n-button-group>
288-
</n-card>
289-
308+
placeholder="请输入股票名称或者代码"
309+
clearable @input="getStockList" :on-select="onSelect"/>
310+
<n-button type="primary" @click="AddStock">
311+
<n-icon :component="Add"/> &nbsp;关注该股票
312+
</n-button>
313+
</n-input-group>
314+
<!-- </n-card>-->
315+
316+
</n-affix>
290317
<n-modal transform-origin="center" size="small" v-model:show="modalShow" :title="formModel.name" style="width: 400px" :preset="'card'">
291318
<n-form :model="formModel" :rules="{ costPrice: { required: true, message: '请输入成本'}, volume: { required: true, message: '请输入数量'} }" label-placement="left" label-width="80px">
292319
<n-form-item label="成本(元)" path="costPrice">

main.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ import (
66
"github.com/duke-git/lancet/v2/convertor"
77
"github.com/wailsapp/wails/v2"
88
"github.com/wailsapp/wails/v2/pkg/logger"
9+
"github.com/wailsapp/wails/v2/pkg/menu"
10+
"github.com/wailsapp/wails/v2/pkg/menu/keys"
911
"github.com/wailsapp/wails/v2/pkg/options"
1012
"github.com/wailsapp/wails/v2/pkg/options/mac"
1113
"github.com/wailsapp/wails/v2/pkg/options/windows"
14+
"github.com/wailsapp/wails/v2/pkg/runtime"
1215
"go-stock/backend/data"
1316
"go-stock/backend/db"
1417
"log"
1518
"os"
19+
"time"
1620
)
1721

1822
//go:embed frontend/dist
@@ -40,6 +44,31 @@ func main() {
4044
// Create an instance of the app structure
4145
app := NewApp()
4246
// Create application with options
47+
48+
AppMenu := menu.NewMenu()
49+
FileMenu := AppMenu.AddSubmenu("设置")
50+
FileMenu.AddText("显示搜索框", keys.CmdOrCtrl("s"), func(callbackData *menu.CallbackData) {
51+
runtime.EventsEmit(app.ctx, "showSearch", 1)
52+
})
53+
FileMenu.AddText("隐藏搜索框", keys.CmdOrCtrl("d"), func(callbackData *menu.CallbackData) {
54+
runtime.EventsEmit(app.ctx, "showSearch", 0)
55+
})
56+
FileMenu.AddText("刷新数据", keys.CmdOrCtrl("r"), func(callbackData *menu.CallbackData) {
57+
//runtime.EventsEmit(app.ctx, "refresh", "setting-"+time.Now().Format("2006-01-02 15:04:05"))
58+
runtime.EventsEmit(app.ctx, "refreshFollowList", "refresh-"+time.Now().Format("2006-01-02 15:04:05"))
59+
})
60+
FileMenu.AddSeparator()
61+
FileMenu.AddText("窗口全屏", keys.CmdOrCtrl("f"), func(callback *menu.CallbackData) {
62+
runtime.WindowFullscreen(app.ctx)
63+
callback.MenuItem.Hide()
64+
})
65+
FileMenu.AddText("窗口还原", keys.Key("Esc"), func(callback *menu.CallbackData) {
66+
runtime.WindowUnfullscreen(app.ctx)
67+
})
68+
FileMenu.AddText("退出", keys.CmdOrCtrl("q"), func(_ *menu.CallbackData) {
69+
runtime.Quit(app.ctx)
70+
})
71+
4372
err := wails.Run(&options.App{
4473
Title: "go-stock",
4574
Width: 1366,
@@ -55,7 +84,7 @@ func main() {
5584
HideWindowOnClose: false,
5685
BackgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 255},
5786
Assets: assets,
58-
Menu: nil,
87+
Menu: AppMenu,
5988
Logger: nil,
6089
LogLevel: logger.DEBUG,
6190
OnStartup: app.startup,

0 commit comments

Comments
 (0)