11<script setup>
22import {onBeforeMount , onBeforeUnmount , onMounted , reactive , ref } from ' vue'
3- import {Greet , Follow , UnFollow , GetFollowList , GetStockList , SetCostPriceAndVolume } from ' ../../wailsjs/go/main/App'
3+ import {
4+ Greet ,
5+ Follow ,
6+ UnFollow ,
7+ GetFollowList ,
8+ GetStockList ,
9+ SetCostPriceAndVolume ,
10+ SendDingDingMessage , SetAlarmChangePercent
11+ } from ' ../../wailsjs/go/main/App'
412import {NButton , NFlex , NForm , NFormItem , NInputNumber , NText , useMessage , useModal } from ' naive-ui'
513import { WindowFullscreen ,WindowUnfullscreen ,EventsOn } from ' ../../wailsjs/runtime'
614import {Add , StarOutline } from ' @vicons/ionicons5'
@@ -22,7 +30,8 @@ const formModel = ref({
2230 name: " " ,
2331 code: " " ,
2432 costPrice: 0.000 ,
25- volume: 0
33+ volume: 0 ,
34+ alarm: 0 ,
2635})
2736
2837const data = reactive ({
@@ -171,7 +180,6 @@ async function monitor() {
171180 result .highRate = ((result[" 今日最高价" ]- result[" 今日开盘价" ])* 100 / result[" 今日开盘价" ]).toFixed (2 )+ " %"
172181 result .lowRate = ((result[" 今日最低价" ]- result[" 今日开盘价" ])* 100 / result[" 今日开盘价" ]).toFixed (2 )+ " %"
173182
174-
175183 if (roundedNum> 0 ) {
176184 result .type = " error"
177185 result .color = " #E88080"
@@ -195,6 +203,9 @@ async function monitor() {
195203 }else if (result .profitAmount < 0 ){
196204 result .profitType = " success"
197205 }
206+ if (Math .abs (res[0 ].AlarmChangePercent )> 0 && roundedNum> res[0 ].AlarmChangePercent ){
207+ SendMessage (result)
208+ }
198209 }
199210 results .value [result[" 股票名称" ]]= result
200211 })
@@ -224,6 +235,7 @@ function setStock(code,name){
224235 formModel .value .code = code
225236 formModel .value .volume = res[0 ].Volume
226237 formModel .value .costPrice = res[0 ].CostPrice
238+ formModel .value .alarm = res[0 ].AlarmChangePercent
227239 modalShow .value = true
228240}
229241
@@ -241,8 +253,13 @@ function showK(code,name){
241253}
242254
243255
244- function updateCostPriceAndVolumeNew (code ,price ,volume ){
256+ function updateCostPriceAndVolumeNew (code ,price ,volume , alarm ){
245257 console .log (code,price,volume)
258+ if (alarm){
259+ SetAlarmChangePercent (alarm,code).then (result => {
260+ // message.success(result)
261+ })
262+ }
246263 SetCostPriceAndVolume (code,price,volume).then (result => {
247264 modalShow .value = false
248265 message .success (result)
@@ -267,6 +284,33 @@ function fullscreen(){
267284 }
268285 data .fullscreen = ! data .fullscreen
269286}
287+
288+ function SendMessage (result ){
289+ let img= ' http://image.sinajs.cn/newchart/min/n/' + result[" 股票代码" ]+ ' .gif' + " ?t=" + Date .now ()
290+ let markdown= " ### go-stock市场行情\n\n " +
291+ " ### " + result[" 股票名称" ]+ " (" + result[" 股票代码" ]+ " )\n " +
292+ " - 当前价格: " + result[" 当前价格" ]+ " " + result .s + " \n " +
293+ " - 最高价: " + result[" 今日最高价" ]+ " " + result .highRate + " \n " +
294+ " - 最低价: " + result[" 今日最低价" ]+ " " + result .lowRate + " \n " +
295+ " - 昨收价: " + result[" 昨日收盘价" ]+ " \n " +
296+ " - 今开价: " + result[" 今日开盘价" ]+ " \n " +
297+ " - 成本价: " + result .costPrice + " " + result .profit + " % " + result .profitAmount + " ¥\n " +
298+ " - 成本数量: " + result .volume + " 股\n " +
299+ " - 日期: " + result[" 日期" ]+ " " + result[" 时间" ]+ " \n\n " +
300+ " \n "
301+ let msg= ' {' +
302+ ' "msgtype": "markdown",' +
303+ ' "markdown": {' +
304+ ' "title":"' + result[" 股票名称" ]+ " (" + result[" 股票代码" ]+ " ) " + result[" 当前价格" ]+ " " + result .s + ' ",' +
305+ ' "text": "' + markdown+ ' "' +
306+ ' },' +
307+ ' "at": {' +
308+ ' "isAtAll": true' +
309+ ' }' +
310+ ' }'
311+ SendDingDingMessage (msg,result[" 股票代码" ])
312+ }
313+
270314 </script >
271315
272316<template >
@@ -309,7 +353,7 @@ function fullscreen(){
309353 <n-button size =" tiny" type =" success" @click =" showFenshi(result['股票代码'],result['股票名称'])" > 分时 </n-button >
310354 <n-button size =" tiny" type =" error" @click =" showK(result['股票代码'],result['股票名称'])" > 日K </n-button >
311355 <n-button size =" tiny" type =" warning" @click =" search(result['股票代码'],result['股票名称'])" > 详情 </n-button >
312-
356+ <!-- <n-button size="tiny" type="info" @click="SendMessage(result)"> 钉钉 </n-button> -->
313357 </n-flex >
314358 </template >
315359 </n-card >
@@ -342,9 +386,12 @@ function fullscreen(){
342386 <n-form-item label =" 数量(股)" path =" volume" >
343387 <n-input-number v-model:value =" formModel.volume" min =" 0" placeholder =" 请输入股票数量" />
344388 </n-form-item >
389+ <n-form-item label =" 涨跌报警值(%)" path =" alarm" >
390+ <n-input-number v-model:value =" formModel.alarm" min =" 0" placeholder =" 请输入涨跌报警值(%)" />
391+ </n-form-item >
345392 </n-form >
346393 <template #footer >
347- <n-button type =" primary" @click =" updateCostPriceAndVolumeNew(formModel.code,formModel.costPrice,formModel.volume)" >保存</n-button >
394+ <n-button type =" primary" @click =" updateCostPriceAndVolumeNew(formModel.code,formModel.costPrice,formModel.volume,formModel.alarm )" >保存</n-button >
348395 </template >
349396 </n-modal >
350397
0 commit comments