mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
Compare commits
1 Commits
v2025.7.12
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
6116e9287a |
10
.github/workflows/main.yml
vendored
10
.github/workflows/main.yml
vendored
@ -5,13 +5,10 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
# Match any new tag
|
# Match any new tag
|
||||||
- '*-release'
|
- '*-release'
|
||||||
- '*-dev'
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# Necessary for most environments as build failure can occur due to OOM issues
|
# Necessary for most environments as build failure can occur due to OOM issues
|
||||||
NODE_OPTIONS: "--max-old-space-size=4096"
|
NODE_OPTIONS: "--max-old-space-size=4096"
|
||||||
OFFICIAL_STATEMENT: ${{ vars.OFFICIAL_STATEMENT }}
|
|
||||||
BUILD_KEY: ${{ vars.BUILD_KEY }}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -26,9 +23,6 @@ jobs:
|
|||||||
# - name: 'go-stock-linux-amd64'
|
# - name: 'go-stock-linux-amd64'
|
||||||
# platform: 'linux/amd64'
|
# platform: 'linux/amd64'
|
||||||
# os: 'ubuntu-latest'
|
# os: 'ubuntu-latest'
|
||||||
- name: 'go-stock-darwin-universal'
|
|
||||||
platform: 'darwin/universal'
|
|
||||||
os: 'macos-latest'
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.build.os }}
|
runs-on: ${{ matrix.build.os }}
|
||||||
steps:
|
steps:
|
||||||
@ -44,7 +38,7 @@ jobs:
|
|||||||
echo "::set-output name=commit_message::$commit_message"
|
echo "::set-output name=commit_message::$commit_message"
|
||||||
|
|
||||||
- name: Build wails x go-stock
|
- name: Build wails x go-stock
|
||||||
uses: ArvinLovegood/wails-build-action@v3.6
|
uses: ArvinLovegood/wails-build-action@v3.4
|
||||||
id: build
|
id: build
|
||||||
with:
|
with:
|
||||||
build-name: ${{ matrix.build.name }}
|
build-name: ${{ matrix.build.name }}
|
||||||
@ -53,6 +47,4 @@ jobs:
|
|||||||
go-version: '1.24'
|
go-version: '1.24'
|
||||||
build-tags: ${{ github.ref_name }}
|
build-tags: ${{ github.ref_name }}
|
||||||
build-commit-message: ${{ steps.get_commit_message.outputs.commit_message }}
|
build-commit-message: ${{ steps.get_commit_message.outputs.commit_message }}
|
||||||
build-statement: ${{ env.OFFICIAL_STATEMENT }}
|
|
||||||
build-key: ${{ env.BUILD_KEY }}
|
|
||||||
node-version: '20.x'
|
node-version: '20.x'
|
||||||
|
17
README.md
17
README.md
@ -23,7 +23,6 @@
|
|||||||
### 📦 立即体验
|
### 📦 立即体验
|
||||||
- 安装版:[go-stock-amd64-installer.exe](https://github.com/ArvinLovegood/go-stock/releases)
|
- 安装版:[go-stock-amd64-installer.exe](https://github.com/ArvinLovegood/go-stock/releases)
|
||||||
- 绿色版:[go-stock-windows-amd64.exe](https://github.com/ArvinLovegood/go-stock/releases)
|
- 绿色版:[go-stock-windows-amd64.exe](https://github.com/ArvinLovegood/go-stock/releases)
|
||||||
- MACOS版:[go-stock-darwin-universal](https://github.com/ArvinLovegood/go-stock/releases)
|
|
||||||
|
|
||||||
|
|
||||||
### 💬 支持大模型/平台
|
### 💬 支持大模型/平台
|
||||||
@ -38,21 +37,13 @@
|
|||||||
|
|
||||||
### <span style="color: #568DF4;">各位亲爱的朋友们,如果您对这个项目感兴趣,请先给我一个<i style="color: #EA2626;">star</i>吧,谢谢!</span>💕
|
### <span style="color: #568DF4;">各位亲爱的朋友们,如果您对这个项目感兴趣,请先给我一个<i style="color: #EA2626;">star</i>吧,谢谢!</span>💕
|
||||||
- 优云智算(by UCloud):万卡规模4090免费用10小时,新人注册另增50万tokens,海量热门源项目镜像一键部署,[注册链接](https://www.compshare.cn/image-community?ytag=GPU_YY-gh_gostock)
|
- 优云智算(by UCloud):万卡规模4090免费用10小时,新人注册另增50万tokens,海量热门源项目镜像一键部署,[注册链接](https://www.compshare.cn/image-community?ytag=GPU_YY-gh_gostock)
|
||||||
- 火山方舟:新用户每个模型注册即送50万tokens,[注册链接](https://www.volcengine.com/experience/ark?utm_term=202502dsinvite&ac=DSASUQY5&rc=IJSE43PZ)
|
- 经测试目前硅基流动(siliconflow)提供的deepSeek api 服务比较稳定,注册即送2000万Tokens,[注册链接](https://cloud.siliconflow.cn/i/foufCerk)
|
||||||
- 硅基流动(siliconflow),注册即送2000万Tokens,[注册链接](https://cloud.siliconflow.cn/i/foufCerk)
|
- 火山方舟:每个模型注册即送50万tokens,[注册链接](https://www.volcengine.com/experience/ark?utm_term=202502dsinvite&ac=DSASUQY5&rc=IJSE43PZ)
|
||||||
- Tushare大数据开放社区,免费提供各类金融数据,助力行业和量化研究(注意:Tushare只需要120积分即可,注册完成个人资料补充即可得120积分!!!),[注册链接](https://tushare.pro/register?reg=701944)
|
- Tushare大数据开放社区,免费提供各类金融数据,助力行业和量化研究(注意:Tushare只需要120积分即可,注册完成个人资料补充即可得120积分!!!),[注册链接](https://tushare.pro/register?reg=701944)
|
||||||
- 软件快速迭代开发中,请大家优先测试和使用最新发布的版本。
|
- 软件快速迭代开发中,请大家优先测试和使用最新发布的版本。
|
||||||
- 欢迎大家提出宝贵的建议,欢迎提issue,PR。当然更欢迎[赞助我](#都划到这了如果我的项目对您有帮助请赞助我吧)。💕
|
- 欢迎大家提出宝贵的建议,欢迎提issue,PR。当然更欢迎[赞助我](#都划到这了如果我的项目对您有帮助请赞助我吧)。💕
|
||||||
|
|
||||||
|
|
||||||
### 支持开源💕计划
|
|
||||||
| 赞助计划 | 赞助等级 | 权益说明 |
|
|
||||||
|:--------------------------------|----------------|:-------------------------------------------------------|
|
|
||||||
| 每月 0 RMB | vip0 | 🌟 全部功能,软件自动更新(从GitHub下载),自行解决github平台网络问题。 |
|
|
||||||
| 每月赞助 18.8 RMB<br>每年赞助 120 RMB | vip1 | 💕 全部功能,软件自动更新(从CDN下载),更新快速便捷。AI配置指导,提示词参考等 |
|
|
||||||
| 每月赞助 28.8 RMB<br>每年赞助 240 RMB | vip2 | 💕 💕 vip1全部功能,赠送硅基流动AI分析服务 |
|
|
||||||
| 每月赞助 X RMB | vipX | 🧩 更多计划,视go-stock开源项目发展情况而定...(承接GitHub项目README广告推广💖) |
|
|
||||||
|
|
||||||
## 🧩 重大功能开发计划
|
## 🧩 重大功能开发计划
|
||||||
| 功能说明 | 状态 | 备注 |
|
| 功能说明 | 状态 | 备注 |
|
||||||
|-----------------|----|----------------------------------------------------------------------------------------------------------|
|
|-----------------|----|----------------------------------------------------------------------------------------------------------|
|
||||||
@ -66,10 +57,6 @@
|
|||||||
| 不再强制依赖Chrome浏览器 | ✅ | 默认使用edge浏览器抓取新闻资讯 |
|
| 不再强制依赖Chrome浏览器 | ✅ | 默认使用edge浏览器抓取新闻资讯 |
|
||||||
|
|
||||||
## 👀 更新日志
|
## 👀 更新日志
|
||||||
### 2025.07.08 实现软件自动更新功能
|
|
||||||
### 2025.07.07 卡片添加迷你分时图
|
|
||||||
### 2025.07.05 MacOs支持
|
|
||||||
### 2025.07.01 AI分析集成工具函数,AI分析将更加智能
|
|
||||||
### 2025.06.30 添加指标选股功能
|
### 2025.06.30 添加指标选股功能
|
||||||
### 2025.06.27 添加财经日历和重大事件时间轴功能
|
### 2025.06.27 添加财经日历和重大事件时间轴功能
|
||||||
### 2025.06.25 添加热门股票、事件和话题功能
|
### 2025.06.25 添加热门股票、事件和话题功能
|
||||||
|
599
app.go
599
app.go
@ -1,20 +1,17 @@
|
|||||||
|
//go:build windows
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/duke-git/lancet/v2/cryptor"
|
|
||||||
"github.com/inconshreveable/go-update"
|
|
||||||
"go-stock/backend/data"
|
"go-stock/backend/data"
|
||||||
"go-stock/backend/db"
|
"go-stock/backend/db"
|
||||||
"go-stock/backend/logger"
|
"go-stock/backend/logger"
|
||||||
"go-stock/backend/models"
|
"go-stock/backend/models"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -24,19 +21,21 @@ import (
|
|||||||
"github.com/duke-git/lancet/v2/mathutil"
|
"github.com/duke-git/lancet/v2/mathutil"
|
||||||
"github.com/duke-git/lancet/v2/slice"
|
"github.com/duke-git/lancet/v2/slice"
|
||||||
"github.com/duke-git/lancet/v2/strutil"
|
"github.com/duke-git/lancet/v2/strutil"
|
||||||
|
"github.com/energye/systray"
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
|
"github.com/go-toast/toast"
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/robfig/cron/v3"
|
||||||
|
"github.com/wailsapp/wails/v2/pkg/options"
|
||||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||||
|
"golang.org/x/sys/windows/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
// App struct
|
// App struct
|
||||||
type App struct {
|
type App struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
cache *freecache.Cache
|
cache *freecache.Cache
|
||||||
cron *cron.Cron
|
cron *cron.Cron
|
||||||
cronEntrys map[string]cron.EntryID
|
cronEntrys map[string]cron.EntryID
|
||||||
AiTools []data.Tool
|
|
||||||
SponsorInfo map[string]any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewApp creates a new App application struct
|
// NewApp creates a new App application struct
|
||||||
@ -45,126 +44,68 @@ func NewApp() *App {
|
|||||||
cache := freecache.NewCache(cacheSize)
|
cache := freecache.NewCache(cacheSize)
|
||||||
c := cron.New(cron.WithSeconds())
|
c := cron.New(cron.WithSeconds())
|
||||||
c.Start()
|
c.Start()
|
||||||
var tools []data.Tool
|
|
||||||
tools = AddTools(tools)
|
|
||||||
return &App{
|
return &App{
|
||||||
cache: cache,
|
cache: cache,
|
||||||
cron: c,
|
cron: c,
|
||||||
cronEntrys: make(map[string]cron.EntryID),
|
cronEntrys: make(map[string]cron.EntryID),
|
||||||
AiTools: tools,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddTools(tools []data.Tool) []data.Tool {
|
// startup is called at application startup
|
||||||
tools = append(tools, data.Tool{
|
func (a *App) startup(ctx context.Context) {
|
||||||
Type: "function",
|
defer PanicHandler()
|
||||||
Function: data.ToolFunction{
|
runtime.EventsOn(ctx, "frontendError", func(optionalData ...interface{}) {
|
||||||
Name: "SearchStockByIndicators",
|
logger.SugaredLogger.Errorf("Frontend error: %v\n", optionalData)
|
||||||
Description: "根据自然语言筛选股票,返回自然语言选股条件要求的股票所有相关数据。输入股票名称可以获取当前股票最新的股价交易数据和基础财务指标信息,多个股票名称使用,分隔。",
|
})
|
||||||
Parameters: data.FunctionParameters{
|
logger.SugaredLogger.Infof("Version:%s", Version)
|
||||||
Type: "object",
|
// Perform your setup here
|
||||||
Properties: map[string]any{
|
a.ctx = ctx
|
||||||
"words": map[string]any{
|
|
||||||
"type": "string",
|
// 创建系统托盘
|
||||||
"description": "选股自然语言。" +
|
//systray.RunWithExternalLoop(func() {
|
||||||
"例1:创新药,半导体;PE<30;净利润增长率>50%。 " +
|
// onReady(a)
|
||||||
"例2:上证指数,科创50。 " +
|
//}, func() {
|
||||||
"例3:长电科技,上海贝岭。" +
|
// onExit(a)
|
||||||
"例4:长电科技,上海贝岭;KDJ,MACD,RSI,BOLL,主力净流入/流出" +
|
//})
|
||||||
"例5:换手率大于3%小于25%.量比1以上. 10日内有过涨停.股价处于峰值的二分之一以下.流通股本<100亿.当日和连续四日净流入;股价在20日均线以上.分时图股价在均线之上.热门板块下涨幅领先的A股. 当日量能20000手以上.沪深个股.近一年市盈率波动小于150%.MACD金叉;不要ST股及不要退市股,非北交所,每股收益>0。" +
|
runtime.EventsOn(ctx, "updateSettings", func(optionalData ...interface{}) {
|
||||||
"例6:沪深主板.流通市值小于100亿.市值大于10亿.60分钟dif大于dea.60分钟skdj指标k值大于d值.skdj指标k值小于90.换手率大于3%.成交额大于1亿元.量比大于2.涨幅大于2%小于7%.股价大于5小于50.创业板.10日均线大于20日均线;不要ST股及不要退市股;不要北交所;不要科创板;不要创业板。" +
|
logger.SugaredLogger.Infof("updateSettings : %v\n", optionalData)
|
||||||
"例7:股价在20日线上,一月之内涨停次数>=1,量比大于1,换手率大于3%,流通市值大于 50亿小于200亿。" +
|
config := &data.Settings{}
|
||||||
"例8:基本条件:前期有爆量,回调到 10 日线,当日是缩量阴线,均线趋势向上。;优选条件:一月之内涨停次数>=1",
|
setMap := optionalData[0].(map[string]interface{})
|
||||||
},
|
|
||||||
},
|
// 将 map 转换为 JSON 字节切片
|
||||||
Required: []string{"words"},
|
jsonData, err := json.Marshal(setMap)
|
||||||
},
|
if err != nil {
|
||||||
},
|
logger.SugaredLogger.Errorf("Marshal error:%s", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 将 JSON 字节切片解析到结构体中
|
||||||
|
err = json.Unmarshal(jsonData, config)
|
||||||
|
if err != nil {
|
||||||
|
logger.SugaredLogger.Errorf("Unmarshal error:%s", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.SugaredLogger.Infof("updateSettings config:%+v", config)
|
||||||
|
if config.DarkTheme {
|
||||||
|
runtime.WindowSetBackgroundColour(ctx, 27, 38, 54, 1)
|
||||||
|
runtime.WindowSetDarkTheme(ctx)
|
||||||
|
} else {
|
||||||
|
runtime.WindowSetBackgroundColour(ctx, 255, 255, 255, 1)
|
||||||
|
runtime.WindowSetLightTheme(ctx)
|
||||||
|
}
|
||||||
|
runtime.WindowReloadApp(ctx)
|
||||||
|
|
||||||
|
})
|
||||||
|
go systray.Run(func() {
|
||||||
|
onReady(a)
|
||||||
|
}, func() {
|
||||||
|
onExit(a)
|
||||||
})
|
})
|
||||||
|
|
||||||
tools = append(tools, data.Tool{
|
logger.SugaredLogger.Infof(" application startup Version:%s", Version)
|
||||||
Type: "function",
|
|
||||||
Function: data.ToolFunction{
|
|
||||||
Name: "GetStockKLine",
|
|
||||||
Description: "获取股票日K线数据。",
|
|
||||||
Parameters: data.FunctionParameters{
|
|
||||||
Type: "object",
|
|
||||||
Properties: map[string]any{
|
|
||||||
"days": map[string]any{
|
|
||||||
"type": "string",
|
|
||||||
"description": "日K数据条数",
|
|
||||||
},
|
|
||||||
"stockCode": map[string]any{
|
|
||||||
"type": "string",
|
|
||||||
"description": "股票代码(A股:sh,sz开头;港股hk开头,美股:us开头)",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Required: []string{"days", "stockCode"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
return tools
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *App) GetSponsorInfo() map[string]any {
|
|
||||||
return a.SponsorInfo
|
|
||||||
}
|
|
||||||
func (a *App) CheckSponsorCode(sponsorCode string) map[string]any {
|
|
||||||
sponsorCode = strutil.Trim(sponsorCode)
|
|
||||||
if sponsorCode != "" {
|
|
||||||
encrypted, err := hex.DecodeString(sponsorCode)
|
|
||||||
if err != nil {
|
|
||||||
return map[string]any{
|
|
||||||
"code": 0,
|
|
||||||
"msg": "赞助码格式错误,请输入正确的赞助码!",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
key, err := hex.DecodeString(BuildKey)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Error(err.Error())
|
|
||||||
return map[string]any{
|
|
||||||
"code": 0,
|
|
||||||
"msg": "版本错误,不支持赞助码!",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
decrypt := cryptor.AesEcbDecrypt(encrypted, key)
|
|
||||||
if decrypt == nil || len(decrypt) == 0 {
|
|
||||||
return map[string]any{
|
|
||||||
"code": 0,
|
|
||||||
"msg": "赞助码错误,请输入正确的赞助码!",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map[string]any{
|
|
||||||
"code": 1,
|
|
||||||
"msg": "赞助码校验成功,感谢您的支持!",
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return map[string]any{"code": 0, "message": "赞助码不能为空,请输入正确的赞助码!"}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) CheckUpdate() {
|
func (a *App) CheckUpdate() {
|
||||||
sponsorCode := strutil.Trim(a.GetConfig().SponsorCode)
|
|
||||||
if sponsorCode != "" {
|
|
||||||
encrypted, err := hex.DecodeString(sponsorCode)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Error(err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
key, err := hex.DecodeString(BuildKey)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Error(err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
decrypt := string(cryptor.AesEcbDecrypt(encrypted, key))
|
|
||||||
err = json.Unmarshal([]byte(decrypt), &a.SponsorInfo)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Error(err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
releaseVersion := &models.GitHubReleaseVersion{}
|
releaseVersion := &models.GitHubReleaseVersion{}
|
||||||
_, err := resty.New().R().
|
_, err := resty.New().R().
|
||||||
SetResult(releaseVersion).
|
SetResult(releaseVersion).
|
||||||
@ -175,7 +116,6 @@ func (a *App) CheckUpdate() {
|
|||||||
}
|
}
|
||||||
logger.SugaredLogger.Infof("releaseVersion:%+v", releaseVersion.TagName)
|
logger.SugaredLogger.Infof("releaseVersion:%+v", releaseVersion.TagName)
|
||||||
if releaseVersion.TagName != Version {
|
if releaseVersion.TagName != Version {
|
||||||
|
|
||||||
tag := &models.Tag{}
|
tag := &models.Tag{}
|
||||||
_, err = resty.New().R().
|
_, err = resty.New().R().
|
||||||
SetResult(tag).
|
SetResult(tag).
|
||||||
@ -183,7 +123,6 @@ func (a *App) CheckUpdate() {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
releaseVersion.Tag = *tag
|
releaseVersion.Tag = *tag
|
||||||
}
|
}
|
||||||
|
|
||||||
commit := &models.Commit{}
|
commit := &models.Commit{}
|
||||||
_, err = resty.New().R().
|
_, err = resty.New().R().
|
||||||
SetResult(commit).
|
SetResult(commit).
|
||||||
@ -192,109 +131,7 @@ func (a *App) CheckUpdate() {
|
|||||||
releaseVersion.Commit = *commit
|
releaseVersion.Commit = *commit
|
||||||
}
|
}
|
||||||
|
|
||||||
if !(IsWindows() || IsMacOS()) {
|
go runtime.EventsEmit(a.ctx, "updateVersion", releaseVersion)
|
||||||
go runtime.EventsEmit(a.ctx, "updateVersion", releaseVersion)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
downloadUrl := fmt.Sprintf("https://github.com/ArvinLovegood/go-stock/releases/download/%s/go-stock-windows-amd64.exe", releaseVersion.TagName)
|
|
||||||
if IsMacOS() {
|
|
||||||
downloadUrl = fmt.Sprintf("https://github.com/ArvinLovegood/go-stock/releases/download/%s/go-stock-darwin-universal", releaseVersion.TagName)
|
|
||||||
}
|
|
||||||
sponsorCode = strutil.Trim(a.GetConfig().SponsorCode)
|
|
||||||
if sponsorCode != "" {
|
|
||||||
encrypted, err := hex.DecodeString(sponsorCode)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Error(err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
key, err := hex.DecodeString(BuildKey)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Error(err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
decrypt := string(cryptor.AesEcbDecrypt(encrypted, key))
|
|
||||||
err = json.Unmarshal([]byte(decrypt), &a.SponsorInfo)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Error(err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
vipStartTime, err := time.ParseInLocation("2006-01-02 15:04:05", a.SponsorInfo["vipStartTime"].(string), time.Local)
|
|
||||||
vipEndTime, err := time.ParseInLocation("2006-01-02 15:04:05", a.SponsorInfo["vipEndTime"].(string), time.Local)
|
|
||||||
vipAuthTime, err := time.ParseInLocation("2006-01-02 15:04:05", a.SponsorInfo["vipAuthTime"].(string), time.Local)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Error(err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
isVip := false
|
|
||||||
|
|
||||||
if time.Now().After(vipAuthTime) && time.Now().After(vipStartTime) && time.Now().Before(vipEndTime) {
|
|
||||||
isVip = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if IsWindows() {
|
|
||||||
if isVip {
|
|
||||||
if a.SponsorInfo["winDownUrl"] == nil {
|
|
||||||
downloadUrl = fmt.Sprintf("https://gitproxy.click/https://github.com/ArvinLovegood/go-stock/releases/download/%s/go-stock-windows-amd64.exe", releaseVersion.TagName)
|
|
||||||
} else {
|
|
||||||
downloadUrl = a.SponsorInfo["winDownUrl"].(string)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
downloadUrl = fmt.Sprintf("https://github.com/ArvinLovegood/go-stock/releases/download/%s/go-stock-windows-amd64.exe", releaseVersion.TagName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if IsMacOS() {
|
|
||||||
if isVip {
|
|
||||||
if a.SponsorInfo["macDownUrl"] == nil {
|
|
||||||
downloadUrl = fmt.Sprintf("https://gitproxy.click/https://github.com/ArvinLovegood/go-stock/releases/download/%s/go-stock-darwin-universal", releaseVersion.TagName)
|
|
||||||
} else {
|
|
||||||
downloadUrl = a.SponsorInfo["macDownUrl"].(string)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
downloadUrl = fmt.Sprintf("https://github.com/ArvinLovegood/go-stock/releases/download/%s/go-stock-darwin-universal", releaseVersion.TagName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
go runtime.EventsEmit(a.ctx, "newsPush", map[string]any{
|
|
||||||
"time": "发现新版本:" + releaseVersion.TagName,
|
|
||||||
"isRed": false,
|
|
||||||
"source": "go-stock",
|
|
||||||
"content": fmt.Sprintf("当前版本:%s, 最新版本:%s,后台开始下载...", Version, releaseVersion.TagName),
|
|
||||||
})
|
|
||||||
resp, err := resty.New().R().Get(downloadUrl)
|
|
||||||
if err != nil {
|
|
||||||
go runtime.EventsEmit(a.ctx, "newsPush", map[string]any{
|
|
||||||
"time": "新版本:" + releaseVersion.TagName,
|
|
||||||
"isRed": true,
|
|
||||||
"source": "go-stock",
|
|
||||||
"content": "新版本下载失败,请稍后重试或请前往 https://github.com/ArvinLovegood/go-stock/releases 手动下载替换文件。",
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
body := resp.Body()
|
|
||||||
|
|
||||||
if len(body) < 1024 {
|
|
||||||
go runtime.EventsEmit(a.ctx, "newsPush", map[string]any{
|
|
||||||
"time": "新版本:" + releaseVersion.TagName,
|
|
||||||
"isRed": true,
|
|
||||||
"source": "go-stock",
|
|
||||||
"content": "新版本下载失败,请稍后重试或请前往 https://github.com/ArvinLovegood/go-stock/releases 手动下载替换文件。",
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
err = update.Apply(bytes.NewReader(body), update.Options{})
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Error("更新失败: ", err.Error())
|
|
||||||
go runtime.EventsEmit(a.ctx, "updateVersion", releaseVersion)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
go runtime.EventsEmit(a.ctx, "newsPush", map[string]any{
|
|
||||||
"time": "新版本:" + releaseVersion.TagName,
|
|
||||||
"isRed": true,
|
|
||||||
"source": "go-stock",
|
|
||||||
"content": "版本更新完成,下次重启软件生效.",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,7 +311,7 @@ func (a *App) AddCronTask(follow data.FollowedStock) func() {
|
|||||||
return func() {
|
return func() {
|
||||||
go runtime.EventsEmit(a.ctx, "warnMsg", "开始自动分析"+follow.Name+"_"+follow.StockCode)
|
go runtime.EventsEmit(a.ctx, "warnMsg", "开始自动分析"+follow.Name+"_"+follow.StockCode)
|
||||||
ai := data.NewDeepSeekOpenAi(a.ctx)
|
ai := data.NewDeepSeekOpenAi(a.ctx)
|
||||||
msgs := ai.NewChatStream(follow.Name, follow.StockCode, "", nil, a.AiTools)
|
msgs := ai.NewChatStream(follow.Name, follow.StockCode, "", nil)
|
||||||
var res strings.Builder
|
var res strings.Builder
|
||||||
|
|
||||||
chatId := ""
|
chatId := ""
|
||||||
@ -632,6 +469,49 @@ func MonitorFundPrices(a *App) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MonitorStockPrices(a *App) {
|
||||||
|
dest := &[]data.FollowedStock{}
|
||||||
|
db.Dao.Model(&data.FollowedStock{}).Find(dest)
|
||||||
|
total := float64(0)
|
||||||
|
//for _, follow := range *dest {
|
||||||
|
// stockData := getStockInfo(follow)
|
||||||
|
// total += stockData.ProfitAmountToday
|
||||||
|
// price, _ := convertor.ToFloat(stockData.Price)
|
||||||
|
// if stockData.PrePrice != price {
|
||||||
|
// go runtime.EventsEmit(a.ctx, "stock_price", stockData)
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
stockInfos := GetStockInfos(*dest...)
|
||||||
|
for _, stockInfo := range *stockInfos {
|
||||||
|
if strutil.HasPrefixAny(stockInfo.Code, []string{"SZ", "SH", "sh", "sz"}) && (!isTradingTime(time.Now())) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if strutil.HasPrefixAny(stockInfo.Code, []string{"hk", "HK"}) && (!IsHKTradingTime(time.Now())) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if strutil.HasPrefixAny(stockInfo.Code, []string{"us", "US", "gb_"}) && (!IsUSTradingTime(time.Now())) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
total += stockInfo.ProfitAmountToday
|
||||||
|
price, _ := convertor.ToFloat(stockInfo.Price)
|
||||||
|
|
||||||
|
if stockInfo.PrePrice != price {
|
||||||
|
//logger.SugaredLogger.Infof("-----------sz------------股票代码: %s, 股票名称: %s, 股票价格: %s,盘前盘后:%s", stockInfo.Code, stockInfo.Name, stockInfo.Price, stockInfo.BA)
|
||||||
|
go runtime.EventsEmit(a.ctx, "stock_price", stockInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if total != 0 {
|
||||||
|
title := "go-stock " + time.Now().Format(time.DateTime) + fmt.Sprintf(" %.2f¥", total)
|
||||||
|
systray.SetTooltip(title)
|
||||||
|
}
|
||||||
|
|
||||||
|
go runtime.EventsEmit(a.ctx, "realtime_profit", fmt.Sprintf(" %.2f", total))
|
||||||
|
//runtime.WindowSetTitle(a.ctx, title)
|
||||||
|
|
||||||
|
}
|
||||||
func GetStockInfos(follows ...data.FollowedStock) *[]data.StockInfo {
|
func GetStockInfos(follows ...data.FollowedStock) *[]data.StockInfo {
|
||||||
stockInfos := make([]data.StockInfo, 0)
|
stockInfos := make([]data.StockInfo, 0)
|
||||||
stockCodes := make([]string, 0)
|
stockCodes := make([]string, 0)
|
||||||
@ -749,6 +629,35 @@ func addStockFollowData(follow data.FollowedStock, stockData *data.StockInfo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// beforeClose is called when the application is about to quit,
|
||||||
|
// either by clicking the window close button or calling runtime.Quit.
|
||||||
|
// Returning true will cause the application to continue, false will continue shutdown as normal.
|
||||||
|
func (a *App) beforeClose(ctx context.Context) (prevent bool) {
|
||||||
|
defer PanicHandler()
|
||||||
|
|
||||||
|
dialog, err := runtime.MessageDialog(ctx, runtime.MessageDialogOptions{
|
||||||
|
Type: runtime.QuestionDialog,
|
||||||
|
Title: "go-stock",
|
||||||
|
Message: "确定关闭吗?",
|
||||||
|
Buttons: []string{"确定"},
|
||||||
|
Icon: icon,
|
||||||
|
CancelButton: "取消",
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logger.SugaredLogger.Errorf("dialog error:%s", err.Error())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
logger.SugaredLogger.Debugf("dialog:%s", dialog)
|
||||||
|
if dialog == "No" {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
systray.Quit()
|
||||||
|
a.cron.Stop()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// shutdown is called at application termination
|
// shutdown is called at application termination
|
||||||
func (a *App) shutdown(ctx context.Context) {
|
func (a *App) shutdown(ctx context.Context) {
|
||||||
defer PanicHandler()
|
defer PanicHandler()
|
||||||
@ -838,13 +747,8 @@ func (a *App) SendDingDingMessageByType(message string, stockCode string, msgTyp
|
|||||||
return data.NewDingDingAPI().SendDingDingMessage(message)
|
return data.NewDingDingAPI().SendDingDingMessage(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) NewChatStream(stock, stockCode, question string, sysPromptId *int, enableTools bool) {
|
func (a *App) NewChatStream(stock, stockCode, question string, sysPromptId *int) {
|
||||||
var msgs <-chan map[string]any
|
msgs := data.NewDeepSeekOpenAi(a.ctx).NewChatStream(stock, stockCode, question, sysPromptId)
|
||||||
if enableTools {
|
|
||||||
msgs = data.NewDeepSeekOpenAi(a.ctx).NewChatStream(stock, stockCode, question, sysPromptId, a.AiTools)
|
|
||||||
} else {
|
|
||||||
msgs = data.NewDeepSeekOpenAi(a.ctx).NewChatStream(stock, stockCode, question, sysPromptId, []data.Tool{})
|
|
||||||
}
|
|
||||||
for msg := range msgs {
|
for msg := range msgs {
|
||||||
runtime.EventsEmit(a.ctx, "newChatStream", msg)
|
runtime.EventsEmit(a.ctx, "newChatStream", msg)
|
||||||
}
|
}
|
||||||
@ -860,50 +764,48 @@ func (a *App) GetAIResponseResult(stock string) *models.AIResponseResult {
|
|||||||
|
|
||||||
func (a *App) GetVersionInfo() *models.VersionInfo {
|
func (a *App) GetVersionInfo() *models.VersionInfo {
|
||||||
return &models.VersionInfo{
|
return &models.VersionInfo{
|
||||||
Version: Version,
|
Version: Version,
|
||||||
Icon: GetImageBase(icon),
|
Icon: GetImageBase(icon),
|
||||||
Alipay: GetImageBase(alipay),
|
Alipay: GetImageBase(alipay),
|
||||||
Wxpay: GetImageBase(wxpay),
|
Wxpay: GetImageBase(wxpay),
|
||||||
Wxgzh: GetImageBase(wxgzh),
|
Content: VersionCommit,
|
||||||
Content: VersionCommit,
|
|
||||||
OfficialStatement: OFFICIAL_STATEMENT,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//// checkChromeOnWindows 在 Windows 系统上检查谷歌浏览器是否安装
|
// checkChromeOnWindows 在 Windows 系统上检查谷歌浏览器是否安装
|
||||||
//func checkChromeOnWindows() bool {
|
func checkChromeOnWindows() bool {
|
||||||
// key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe`, registry.QUERY_VALUE)
|
key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe`, registry.QUERY_VALUE)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// // 尝试在 WOW6432Node 中查找(适用于 64 位系统上的 32 位程序)
|
// 尝试在 WOW6432Node 中查找(适用于 64 位系统上的 32 位程序)
|
||||||
// key, err = registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe`, registry.QUERY_VALUE)
|
key, err = registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe`, registry.QUERY_VALUE)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// return false
|
return false
|
||||||
// }
|
}
|
||||||
// defer key.Close()
|
defer key.Close()
|
||||||
// }
|
}
|
||||||
// defer key.Close()
|
defer key.Close()
|
||||||
// _, _, err = key.GetValue("Path", nil)
|
_, _, err = key.GetValue("Path", nil)
|
||||||
// return err == nil
|
return err == nil
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//// checkEdgeOnWindows 在 Windows 系统上检查Edge浏览器是否安装,并返回安装路径
|
// checkEdgeOnWindows 在 Windows 系统上检查Edge浏览器是否安装,并返回安装路径
|
||||||
//func checkEdgeOnWindows() (string, bool) {
|
func checkEdgeOnWindows() (string, bool) {
|
||||||
// key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe`, registry.QUERY_VALUE)
|
key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe`, registry.QUERY_VALUE)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// // 尝试在 WOW6432Node 中查找(适用于 64 位系统上的 32 位程序)
|
// 尝试在 WOW6432Node 中查找(适用于 64 位系统上的 32 位程序)
|
||||||
// key, err = registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe`, registry.QUERY_VALUE)
|
key, err = registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe`, registry.QUERY_VALUE)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// return "", false
|
return "", false
|
||||||
// }
|
}
|
||||||
// defer key.Close()
|
defer key.Close()
|
||||||
// }
|
}
|
||||||
// defer key.Close()
|
defer key.Close()
|
||||||
// path, _, err := key.GetStringValue("Path")
|
path, _, err := key.GetStringValue("Path")
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// return "", false
|
return "", false
|
||||||
// }
|
}
|
||||||
// return path, true
|
return path, true
|
||||||
//}
|
}
|
||||||
|
|
||||||
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)
|
||||||
@ -960,6 +862,44 @@ func onExit(a *App) {
|
|||||||
//runtime.Quit(a.ctx)
|
//runtime.Quit(a.ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func onReady(a *App) {
|
||||||
|
|
||||||
|
// 初始化操作
|
||||||
|
logger.SugaredLogger.Infof("systray onReady")
|
||||||
|
systray.SetIcon(icon2)
|
||||||
|
systray.SetTitle("go-stock")
|
||||||
|
systray.SetTooltip("go-stock 股票行情实时获取")
|
||||||
|
// 创建菜单项
|
||||||
|
show := systray.AddMenuItem("显示", "显示应用程序")
|
||||||
|
show.Click(func() {
|
||||||
|
//logger.SugaredLogger.Infof("显示应用程序")
|
||||||
|
runtime.WindowShow(a.ctx)
|
||||||
|
})
|
||||||
|
hide := systray.AddMenuItem("隐藏", "隐藏应用程序")
|
||||||
|
hide.Click(func() {
|
||||||
|
//logger.SugaredLogger.Infof("隐藏应用程序")
|
||||||
|
runtime.WindowHide(a.ctx)
|
||||||
|
})
|
||||||
|
systray.AddSeparator()
|
||||||
|
mQuitOrig := systray.AddMenuItem("退出", "退出应用程序")
|
||||||
|
mQuitOrig.Click(func() {
|
||||||
|
//logger.SugaredLogger.Infof("退出应用程序")
|
||||||
|
runtime.Quit(a.ctx)
|
||||||
|
})
|
||||||
|
systray.SetOnRClick(func(menu systray.IMenu) {
|
||||||
|
menu.ShowMenu()
|
||||||
|
//logger.SugaredLogger.Infof("SetOnRClick")
|
||||||
|
})
|
||||||
|
systray.SetOnClick(func(menu systray.IMenu) {
|
||||||
|
//logger.SugaredLogger.Infof("SetOnClick")
|
||||||
|
menu.ShowMenu()
|
||||||
|
})
|
||||||
|
systray.SetOnDClick(func(menu systray.IMenu) {
|
||||||
|
menu.ShowMenu()
|
||||||
|
//logger.SugaredLogger.Infof("SetOnDClick")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) UpdateConfig(settings *data.Settings) string {
|
func (a *App) UpdateConfig(settings *data.Settings) string {
|
||||||
//logger.SugaredLogger.Infof("UpdateConfig:%+v", settings)
|
//logger.SugaredLogger.Infof("UpdateConfig:%+v", settings)
|
||||||
if settings.RefreshInterval > 0 {
|
if settings.RefreshInterval > 0 {
|
||||||
@ -998,6 +938,15 @@ func (a *App) ExportConfig() string {
|
|||||||
}
|
}
|
||||||
return "导出成功:" + file
|
return "导出成功:" + file
|
||||||
}
|
}
|
||||||
|
func getScreenResolution() (int, int, error) {
|
||||||
|
//user32 := syscall.NewLazyDLL("user32.dll")
|
||||||
|
//getSystemMetrics := user32.NewProc("GetSystemMetrics")
|
||||||
|
//
|
||||||
|
//width, _, _ := getSystemMetrics.Call(0)
|
||||||
|
//height, _, _ := getSystemMetrics.Call(1)
|
||||||
|
|
||||||
|
return int(1366), int(768), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) ShareAnalysis(stockCode, stockName string) string {
|
func (a *App) ShareAnalysis(stockCode, stockName string) string {
|
||||||
//http://go-stock.sparkmemory.top:16688/upload
|
//http://go-stock.sparkmemory.top:16688/upload
|
||||||
@ -1085,6 +1034,22 @@ func (a *App) SetStockAICron(cronText, stockCode string) {
|
|||||||
a.cronEntrys[stockCode] = id
|
a.cronEntrys[stockCode] = id
|
||||||
|
|
||||||
}
|
}
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) AddGroup(group data.Group) string {
|
func (a *App) AddGroup(group data.Group) string {
|
||||||
ok := data.NewStockGroupApi(db.Dao).AddGroup(group)
|
ok := data.NewStockGroupApi(db.Dao).AddGroup(group)
|
||||||
if ok {
|
if ok {
|
||||||
@ -1162,14 +1127,8 @@ func (a *App) GlobalStockIndexes() map[string]any {
|
|||||||
return data.NewMarketNewsApi().GlobalStockIndexes(30)
|
return data.NewMarketNewsApi().GlobalStockIndexes(30)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) SummaryStockNews(question string, sysPromptId *int, enableTools bool) {
|
func (a *App) SummaryStockNews(question string, sysPromptId *int) {
|
||||||
var msgs <-chan map[string]any
|
msgs := data.NewDeepSeekOpenAi(a.ctx).NewSummaryStockNewsStream(question, sysPromptId)
|
||||||
if enableTools {
|
|
||||||
msgs = data.NewDeepSeekOpenAi(a.ctx).NewSummaryStockNewsStreamWithTools(question, sysPromptId, a.AiTools)
|
|
||||||
} else {
|
|
||||||
msgs = data.NewDeepSeekOpenAi(a.ctx).NewSummaryStockNewsStream(question, sysPromptId)
|
|
||||||
}
|
|
||||||
|
|
||||||
for msg := range msgs {
|
for msg := range msgs {
|
||||||
runtime.EventsEmit(a.ctx, "summaryStockNews", msg)
|
runtime.EventsEmit(a.ctx, "summaryStockNews", msg)
|
||||||
}
|
}
|
||||||
@ -1193,81 +1152,3 @@ func (a *App) GetStockMoneyTrendByDay(stockCode string, days int) []map[string]a
|
|||||||
slice.Reverse(res)
|
slice.Reverse(res)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenURL
|
|
||||||
//
|
|
||||||
// @Description: 跨平台打开默认浏览器
|
|
||||||
// @receiver a
|
|
||||||
// @param url
|
|
||||||
func (a *App) OpenURL(url string) {
|
|
||||||
runtime.BrowserOpenURL(a.ctx, url)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SaveImage
|
|
||||||
//
|
|
||||||
// @Description: 跨平台保存图片
|
|
||||||
// @receiver a
|
|
||||||
// @param name
|
|
||||||
// @param base64Data
|
|
||||||
// @return error
|
|
||||||
func (a *App) SaveImage(name, base64Data string) string {
|
|
||||||
// 打开保存文件对话框
|
|
||||||
filePath, err := runtime.SaveFileDialog(a.ctx, runtime.SaveDialogOptions{
|
|
||||||
Title: "保存图片",
|
|
||||||
DefaultFilename: name + "AI分析.png",
|
|
||||||
Filters: []runtime.FileFilter{
|
|
||||||
{
|
|
||||||
DisplayName: "PNG 图片",
|
|
||||||
Pattern: "*.png",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if err != nil || filePath == "" {
|
|
||||||
return "文件路径,无法保存。"
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解码并保存
|
|
||||||
decodeString, err := base64.StdEncoding.DecodeString(base64Data)
|
|
||||||
if err != nil {
|
|
||||||
return "文件内容异常,无法保存。"
|
|
||||||
}
|
|
||||||
|
|
||||||
err = os.WriteFile(filepath.Clean(filePath), decodeString, 0777)
|
|
||||||
if err != nil {
|
|
||||||
return "保存结果异常,无法保存。"
|
|
||||||
}
|
|
||||||
return filePath
|
|
||||||
}
|
|
||||||
|
|
||||||
// SaveWordFile
|
|
||||||
//
|
|
||||||
// @Description: // 跨平台保存word
|
|
||||||
// @receiver a
|
|
||||||
// @param filename
|
|
||||||
// @param base64Data
|
|
||||||
// @return error
|
|
||||||
func (a *App) SaveWordFile(filename string, base64Data string) string {
|
|
||||||
// 弹出保存文件对话框
|
|
||||||
filePath, err := runtime.SaveFileDialog(a.ctx, runtime.SaveDialogOptions{
|
|
||||||
Title: "保存 Word 文件",
|
|
||||||
DefaultFilename: filename,
|
|
||||||
Filters: []runtime.FileFilter{
|
|
||||||
{DisplayName: "Word 文件", Pattern: "*.docx"},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if err != nil || filePath == "" {
|
|
||||||
return "文件路径,无法保存。"
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解码 base64 内容
|
|
||||||
decodeString, err := base64.StdEncoding.DecodeString(base64Data)
|
|
||||||
if err != nil {
|
|
||||||
return "文件内容异常,无法保存。"
|
|
||||||
}
|
|
||||||
// 保存为文件
|
|
||||||
err = os.WriteFile(filepath.Clean(filePath), decodeString, 0777)
|
|
||||||
if err != nil {
|
|
||||||
return "保存结果异常,无法保存。"
|
|
||||||
}
|
|
||||||
return filePath
|
|
||||||
}
|
|
||||||
|
@ -57,8 +57,5 @@ func (a App) ClsCalendar() []any {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a App) SearchStock(words string) map[string]any {
|
func (a App) SearchStock(words string) map[string]any {
|
||||||
return data.NewSearchStockApi(words).SearchStock(5000)
|
return data.NewSearchStockApi(words).SearchStock()
|
||||||
}
|
|
||||||
func (a App) GetHotStrategy() map[string]any {
|
|
||||||
return data.NewSearchStockApi("").HotStrategy()
|
|
||||||
}
|
}
|
||||||
|
514
app_darwin.go
514
app_darwin.go
@ -5,171 +5,304 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/duke-git/lancet/v2/convertor"
|
|
||||||
"github.com/duke-git/lancet/v2/strutil"
|
|
||||||
"github.com/gen2brain/beeep"
|
|
||||||
"github.com/wailsapp/wails/v2/pkg/options"
|
|
||||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
|
||||||
"go-stock/backend/data"
|
"go-stock/backend/data"
|
||||||
"go-stock/backend/db"
|
"go-stock/backend/db"
|
||||||
"go-stock/backend/logger"
|
"go-stock/backend/logger"
|
||||||
"log"
|
"go-stock/backend/models"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/PuerkitoBio/goquery"
|
||||||
|
"github.com/coocood/freecache"
|
||||||
|
"github.com/duke-git/lancet/v2/convertor"
|
||||||
|
"github.com/duke-git/lancet/v2/mathutil"
|
||||||
|
"github.com/duke-git/lancet/v2/slice"
|
||||||
|
"github.com/go-resty/resty/v2"
|
||||||
|
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
// startup 在应用程序启动时调用
|
// App struct
|
||||||
|
type App struct {
|
||||||
|
ctx context.Context
|
||||||
|
cache *freecache.Cache
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewApp creates a new App application struct
|
||||||
|
func NewApp() *App {
|
||||||
|
cacheSize := 512 * 1024
|
||||||
|
cache := freecache.NewCache(cacheSize)
|
||||||
|
return &App{
|
||||||
|
cache: cache,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// startup is called at application startup
|
||||||
func (a *App) startup(ctx context.Context) {
|
func (a *App) startup(ctx context.Context) {
|
||||||
defer PanicHandler()
|
|
||||||
runtime.EventsOn(ctx, "frontendError", func(optionalData ...interface{}) {
|
|
||||||
logger.SugaredLogger.Errorf("Frontend error: %v\n", optionalData)
|
|
||||||
})
|
|
||||||
logger.SugaredLogger.Infof("Version:%s", Version)
|
logger.SugaredLogger.Infof("Version:%s", Version)
|
||||||
// Perform your setup here
|
// Perform your setup here
|
||||||
a.ctx = ctx
|
a.ctx = ctx
|
||||||
|
|
||||||
// 监听设置更新事件
|
// TODO 创建系统托盘
|
||||||
runtime.EventsOn(ctx, "updateSettings", func(optionalData ...interface{}) {
|
|
||||||
logger.SugaredLogger.Infof("updateSettings : %v\n", optionalData)
|
|
||||||
config := &data.Settings{}
|
|
||||||
setMap := optionalData[0].(map[string]interface{})
|
|
||||||
|
|
||||||
// 将 map 转换为 JSON 字节切片
|
|
||||||
jsonData, err := json.Marshal(setMap)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Errorf("Marshal error:%s", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 将 JSON 字节切片解析到结构体中
|
|
||||||
err = json.Unmarshal(jsonData, config)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Errorf("Unmarshal error:%s", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.SugaredLogger.Infof("updateSettings config:%+v", config)
|
|
||||||
if config.DarkTheme {
|
|
||||||
runtime.WindowSetBackgroundColour(ctx, 27, 38, 54, 1)
|
|
||||||
runtime.WindowSetDarkTheme(ctx)
|
|
||||||
} else {
|
|
||||||
runtime.WindowSetBackgroundColour(ctx, 255, 255, 255, 1)
|
|
||||||
runtime.WindowSetLightTheme(ctx)
|
|
||||||
}
|
|
||||||
runtime.WindowReloadApp(ctx)
|
|
||||||
})
|
|
||||||
|
|
||||||
// 创建 macOS 托盘
|
|
||||||
go func() {
|
|
||||||
// 使用 Beeep 库替代 Windows 的托盘库
|
|
||||||
err := beeep.Notify("go-stock", "应用程序已启动", "")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("系统通知失败: %v", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
go setUpScreen(a)
|
|
||||||
logger.SugaredLogger.Infof(" application startup Version:%s", Version)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func setUpScreen(a *App) {
|
func checkUpdate(a *App) {
|
||||||
screens, _ := runtime.ScreenGetAll(a.ctx)
|
releaseVersion := &models.GitHubReleaseVersion{}
|
||||||
if len(screens) == 0 {
|
_, err := resty.New().R().
|
||||||
|
SetResult(releaseVersion).
|
||||||
|
Get("https://api.github.com/repos/ArvinLovegood/go-stock/releases/latest")
|
||||||
|
if err != nil {
|
||||||
|
logger.SugaredLogger.Errorf("get github release version error:%s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
screen := screens[0]
|
logger.SugaredLogger.Infof("releaseVersion:%+v", releaseVersion.TagName)
|
||||||
sw, sh := screen.Width, screen.Height
|
if releaseVersion.TagName != Version {
|
||||||
|
go runtime.EventsEmit(a.ctx, "updateVersion", releaseVersion)
|
||||||
// macOS 菜单栏 + Dock 留出空间
|
}
|
||||||
topBarHeight := 22
|
|
||||||
dockHeight := 56
|
|
||||||
verticalMargin := topBarHeight + dockHeight
|
|
||||||
|
|
||||||
// 设置窗口为屏幕 80% 宽 × 可用高度 90%
|
|
||||||
w := int(float64(sw) * 0.8)
|
|
||||||
h := int(float64(sh-verticalMargin) * 0.9)
|
|
||||||
|
|
||||||
runtime.WindowSetSize(a.ctx, w, h)
|
|
||||||
runtime.WindowCenter(a.ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnSecondInstanceLaunch 处理第二实例启动时的通知
|
// domReady is called after front-end resources have been loaded
|
||||||
func OnSecondInstanceLaunch(secondInstanceData options.SecondInstanceData) {
|
func (a *App) domReady(ctx context.Context) {
|
||||||
err := beeep.Notify("go-stock", "程序已经在运行了", "")
|
// Add your action here
|
||||||
|
//定时更新数据
|
||||||
|
go func() {
|
||||||
|
config := data.NewSettingsApi(&data.Settings{}).GetConfig()
|
||||||
|
interval := config.RefreshInterval
|
||||||
|
if interval <= 0 {
|
||||||
|
interval = 1
|
||||||
|
}
|
||||||
|
ticker := time.NewTicker(time.Second * time.Duration(interval))
|
||||||
|
defer ticker.Stop()
|
||||||
|
for range ticker.C {
|
||||||
|
if isTradingTime(time.Now()) {
|
||||||
|
MonitorStockPrices(a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
//检查新版本
|
||||||
|
go func() {
|
||||||
|
checkUpdate(a)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
func refreshTelegraphList() *[]string {
|
||||||
|
url := "https://www.cls.cn/telegraph"
|
||||||
|
response, err := resty.New().R().
|
||||||
|
SetHeader("Referer", "https://www.cls.cn/").
|
||||||
|
SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.60").
|
||||||
|
Get(fmt.Sprintf(url))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.SugaredLogger.Error(err)
|
return &[]string{}
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second * 3)
|
//logger.SugaredLogger.Info(string(response.Body()))
|
||||||
|
document, err := goquery.NewDocumentFromReader(strings.NewReader(string(response.Body())))
|
||||||
|
if err != nil {
|
||||||
|
return &[]string{}
|
||||||
|
}
|
||||||
|
var telegraph []string
|
||||||
|
document.Find("div.telegraph-content-box").Each(func(i int, selection *goquery.Selection) {
|
||||||
|
//logger.SugaredLogger.Info(selection.Text())
|
||||||
|
telegraph = append(telegraph, selection.Text())
|
||||||
|
})
|
||||||
|
return &telegraph
|
||||||
|
}
|
||||||
|
|
||||||
|
// isTradingDay 判断是否是交易日
|
||||||
|
func isTradingDay(date time.Time) bool {
|
||||||
|
weekday := date.Weekday()
|
||||||
|
// 判断是否是周末
|
||||||
|
if weekday == time.Saturday || weekday == time.Sunday {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// 这里可以添加具体的节假日判断逻辑
|
||||||
|
// 例如:判断是否是春节、国庆节等
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// isTradingTime 判断是否是交易时间
|
||||||
|
func isTradingTime(date time.Time) bool {
|
||||||
|
if !isTradingDay(date) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
hour, minute, _ := date.Clock()
|
||||||
|
|
||||||
|
// 判断是否在9:15到11:30之间
|
||||||
|
if (hour == 9 && minute >= 15) || (hour == 10) || (hour == 11 && minute <= 30) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断是否在13:00到15:00之间
|
||||||
|
if (hour == 13) || (hour == 14) || (hour == 15 && minute <= 0) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func MonitorStockPrices(a *App) {
|
func MonitorStockPrices(a *App) {
|
||||||
dest := &[]data.FollowedStock{}
|
dest := &[]data.FollowedStock{}
|
||||||
db.Dao.Model(&data.FollowedStock{}).Find(dest)
|
db.Dao.Model(&data.FollowedStock{}).Find(dest)
|
||||||
total := float64(0)
|
total := float64(0)
|
||||||
|
//for _, follow := range *dest {
|
||||||
|
// stockData := getStockInfo(follow)
|
||||||
|
// total += stockData.ProfitAmountToday
|
||||||
|
// price, _ := convertor.ToFloat(stockData.Price)
|
||||||
|
// if stockData.PrePrice != price {
|
||||||
|
// go runtime.EventsEmit(a.ctx, "stock_price", stockData)
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
// 股票信息处理逻辑
|
|
||||||
stockInfos := GetStockInfos(*dest...)
|
stockInfos := GetStockInfos(*dest...)
|
||||||
for _, stockInfo := range *stockInfos {
|
for _, stockInfo := range *stockInfos {
|
||||||
if strutil.HasPrefixAny(stockInfo.Code, []string{"SZ", "SH", "sh", "sz"}) && (!isTradingTime(time.Now())) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if strutil.HasPrefixAny(stockInfo.Code, []string{"hk", "HK"}) && (!IsHKTradingTime(time.Now())) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if strutil.HasPrefixAny(stockInfo.Code, []string{"us", "US", "gb_"}) && (!IsUSTradingTime(time.Now())) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
total += stockInfo.ProfitAmountToday
|
total += stockInfo.ProfitAmountToday
|
||||||
price, _ := convertor.ToFloat(stockInfo.Price)
|
price, _ := convertor.ToFloat(stockInfo.Price)
|
||||||
|
|
||||||
if stockInfo.PrePrice != price {
|
if stockInfo.PrePrice != price {
|
||||||
go runtime.EventsEmit(a.ctx, "stock_price", stockInfo)
|
go runtime.EventsEmit(a.ctx, "stock_price", stockInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算总收益并更新状态
|
|
||||||
if total != 0 {
|
if total != 0 {
|
||||||
// 使用通知替代 systray 更新 Tooltip
|
// title := "go-stock " + time.Now().Format(time.DateTime) + fmt.Sprintf(" %.2f¥", total)
|
||||||
title := "go-stock " + time.Now().Format(time.DateTime) + fmt.Sprintf(" %.2f¥", total)
|
// systray.SetTooltip(title)
|
||||||
|
}
|
||||||
|
|
||||||
// 发送通知显示实时数据
|
go runtime.EventsEmit(a.ctx, "realtime_profit", fmt.Sprintf(" %.2f", total))
|
||||||
err := beeep.Notify("go-stock", title, "")
|
//runtime.WindowSetTitle(a.ctx, title)
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Errorf("发送通知失败: %v", err)
|
}
|
||||||
|
func GetStockInfos(follows ...data.FollowedStock) *[]data.StockInfo {
|
||||||
|
stockCodes := make([]string, 0)
|
||||||
|
for _, follow := range follows {
|
||||||
|
stockCodes = append(stockCodes, follow.StockCode)
|
||||||
|
}
|
||||||
|
stockData, err := data.NewStockDataApi().GetStockCodeRealTimeData(stockCodes...)
|
||||||
|
if err != nil {
|
||||||
|
logger.SugaredLogger.Errorf("get stock code real time data error:%s", err.Error())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
stockInfos := make([]data.StockInfo, 0)
|
||||||
|
for _, info := range *stockData {
|
||||||
|
v, ok := slice.FindBy(follows, func(idx int, follow data.FollowedStock) bool {
|
||||||
|
return follow.StockCode == info.Code
|
||||||
|
})
|
||||||
|
if ok {
|
||||||
|
addStockFollowData(v, &info)
|
||||||
|
stockInfos = append(stockInfos, info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return &stockInfos
|
||||||
// 触发实时利润事件
|
}
|
||||||
go runtime.EventsEmit(a.ctx, "realtime_profit", fmt.Sprintf(" %.2f", total))
|
func getStockInfo(follow data.FollowedStock) *data.StockInfo {
|
||||||
|
stockCode := follow.StockCode
|
||||||
|
stockDatas, err := data.NewStockDataApi().GetStockCodeRealTimeData(stockCode)
|
||||||
|
if err != nil || len(*stockDatas) == 0 {
|
||||||
|
return &data.StockInfo{}
|
||||||
|
}
|
||||||
|
stockData := (*stockDatas)[0]
|
||||||
|
addStockFollowData(follow, &stockData)
|
||||||
|
return &stockData
|
||||||
}
|
}
|
||||||
|
|
||||||
// onReady 在应用程序准备好时调用
|
func addStockFollowData(follow data.FollowedStock, stockData *data.StockInfo) {
|
||||||
func onReady(a *App) {
|
stockData.PrePrice = follow.Price //上次当前价格
|
||||||
// 初始化操作
|
stockData.Sort = follow.Sort
|
||||||
logger.SugaredLogger.Infof("onReady")
|
stockData.CostPrice = follow.CostPrice //成本价
|
||||||
|
stockData.CostVolume = follow.Volume //成本量
|
||||||
|
stockData.AlarmChangePercent = follow.AlarmChangePercent
|
||||||
|
stockData.AlarmPrice = follow.AlarmPrice
|
||||||
|
|
||||||
// 使用 Beeep 发送通知
|
//当前价格
|
||||||
err := beeep.Notify("go-stock", "应用程序已准备就绪", "")
|
price, _ := convertor.ToFloat(stockData.Price)
|
||||||
if err != nil {
|
//当前价格为0 时 使用卖一价格作为当前价格
|
||||||
log.Fatalf("系统通知失败: %v", err)
|
if price == 0 {
|
||||||
|
price, _ = convertor.ToFloat(stockData.A1P)
|
||||||
|
}
|
||||||
|
//当前价格依然为0 时 使用买一报价作为当前价格
|
||||||
|
if price == 0 {
|
||||||
|
price, _ = convertor.ToFloat(stockData.B1P)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示应用窗口
|
//昨日收盘价
|
||||||
runtime.WindowShow(a.ctx)
|
preClosePrice, _ := convertor.ToFloat(stockData.PreClose)
|
||||||
|
|
||||||
// 在 macOS 上没有系统托盘图标菜单,通常我们通过通知或其他方式提供与用户交互的界面
|
//当前价格依然为0 时 使用昨日收盘价为当前价格
|
||||||
|
if price == 0 {
|
||||||
|
price = preClosePrice
|
||||||
|
}
|
||||||
|
|
||||||
|
//今日最高价
|
||||||
|
highPrice, _ := convertor.ToFloat(stockData.High)
|
||||||
|
if highPrice == 0 {
|
||||||
|
highPrice, _ = convertor.ToFloat(stockData.Open)
|
||||||
|
}
|
||||||
|
|
||||||
|
//今日最低价
|
||||||
|
lowPrice, _ := convertor.ToFloat(stockData.Low)
|
||||||
|
if lowPrice == 0 {
|
||||||
|
lowPrice, _ = convertor.ToFloat(stockData.Open)
|
||||||
|
}
|
||||||
|
//开盘价
|
||||||
|
//openPrice, _ := convertor.ToFloat(stockData.Open)
|
||||||
|
|
||||||
|
if price > 0 {
|
||||||
|
stockData.ChangePrice = mathutil.RoundToFloat(price-preClosePrice, 2)
|
||||||
|
stockData.ChangePercent = mathutil.RoundToFloat(mathutil.Div(price-preClosePrice, preClosePrice)*100, 3)
|
||||||
|
}
|
||||||
|
if highPrice > 0 {
|
||||||
|
stockData.HighRate = mathutil.RoundToFloat(mathutil.Div(highPrice-preClosePrice, preClosePrice)*100, 3)
|
||||||
|
}
|
||||||
|
if lowPrice > 0 {
|
||||||
|
stockData.LowRate = mathutil.RoundToFloat(mathutil.Div(lowPrice-preClosePrice, preClosePrice)*100, 3)
|
||||||
|
}
|
||||||
|
if follow.CostPrice > 0 && follow.Volume > 0 {
|
||||||
|
if price > 0 {
|
||||||
|
stockData.Profit = mathutil.RoundToFloat(mathutil.Div(price-follow.CostPrice, follow.CostPrice)*100, 3)
|
||||||
|
stockData.ProfitAmount = mathutil.RoundToFloat((price-follow.CostPrice)*float64(follow.Volume), 2)
|
||||||
|
stockData.ProfitAmountToday = mathutil.RoundToFloat((price-preClosePrice)*float64(follow.Volume), 2)
|
||||||
|
} else {
|
||||||
|
//未开盘时当前价格为昨日收盘价
|
||||||
|
stockData.Profit = mathutil.RoundToFloat(mathutil.Div(preClosePrice-follow.CostPrice, follow.CostPrice)*100, 3)
|
||||||
|
stockData.ProfitAmount = mathutil.RoundToFloat((preClosePrice-follow.CostPrice)*float64(follow.Volume), 2)
|
||||||
|
// 未开盘时,今日盈亏为 0
|
||||||
|
stockData.ProfitAmountToday = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//logger.SugaredLogger.Debugf("stockData:%+v", stockData)
|
||||||
|
if follow.Price != price && price > 0 {
|
||||||
|
go db.Dao.Model(follow).Where("stock_code = ?", follow.StockCode).Updates(map[string]interface{}{
|
||||||
|
"price": price,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// beforeClose 在应用程序关闭前调用,显示确认对话框
|
// beforeClose is called when the application is about to quit,
|
||||||
|
// either by clicking the window close button or calling runtime.Quit.
|
||||||
|
// Returning true will cause the application to continue, false will continue shutdown as normal.
|
||||||
func (a *App) beforeClose(ctx context.Context) (prevent bool) {
|
func (a *App) beforeClose(ctx context.Context) (prevent bool) {
|
||||||
defer PanicHandler()
|
|
||||||
|
|
||||||
// 在 macOS 上使用 MessageDialog 显示确认窗口
|
|
||||||
dialog, err := runtime.MessageDialog(ctx, runtime.MessageDialogOptions{
|
dialog, err := runtime.MessageDialog(ctx, runtime.MessageDialogOptions{
|
||||||
Type: runtime.QuestionDialog,
|
Type: runtime.QuestionDialog,
|
||||||
Title: "go-stock",
|
Title: "go-stock",
|
||||||
Message: "确定关闭吗?",
|
Message: "确定关闭吗?",
|
||||||
Buttons: []string{"确定", "取消"},
|
Buttons: []string{"确定"},
|
||||||
Icon: icon,
|
Icon: icon,
|
||||||
CancelButton: "取消",
|
CancelButton: "取消",
|
||||||
})
|
})
|
||||||
@ -178,27 +311,150 @@ func (a *App) beforeClose(ctx context.Context) (prevent bool) {
|
|||||||
logger.SugaredLogger.Errorf("dialog error:%s", err.Error())
|
logger.SugaredLogger.Errorf("dialog error:%s", err.Error())
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.SugaredLogger.Debugf("dialog:%s", dialog)
|
logger.SugaredLogger.Debugf("dialog:%s", dialog)
|
||||||
if dialog == "取消" {
|
if dialog == "No" {
|
||||||
return true // 如果选择了取消,不关闭应用
|
return true
|
||||||
} else {
|
|
||||||
// 在 macOS 上应用退出时执行清理工作
|
|
||||||
a.cron.Stop() // 停止定时任务
|
|
||||||
return false // 如果选择了确定,继续关闭应用
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func getFrameless() bool {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func getScreenResolution() (int, int, int, int, error) {
|
// shutdown is called at application termination
|
||||||
//user32 := syscall.NewLazyDLL("user32.dll")
|
func (a *App) shutdown(ctx context.Context) {
|
||||||
//getSystemMetrics := user32.NewProc("GetSystemMetrics")
|
// Perform your teardown here
|
||||||
//
|
// systray.Quit()
|
||||||
//width, _, _ := getSystemMetrics.Call(0)
|
}
|
||||||
//height, _, _ := getSystemMetrics.Call(1)
|
|
||||||
|
// Greet returns a greeting for the given name
|
||||||
return int(1200), int(800), 0, 0, nil
|
func (a *App) Greet(stockCode string) *data.StockInfo {
|
||||||
|
//stockInfo, _ := data.NewStockDataApi().GetStockCodeRealTimeData(stockCode)
|
||||||
|
|
||||||
|
follow := &data.FollowedStock{
|
||||||
|
StockCode: stockCode,
|
||||||
|
}
|
||||||
|
db.Dao.Model(follow).Where("stock_code = ?", stockCode).First(follow)
|
||||||
|
stockInfo := getStockInfo(*follow)
|
||||||
|
return stockInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) Follow(stockCode string) string {
|
||||||
|
return data.NewStockDataApi().Follow(stockCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) UnFollow(stockCode string) string {
|
||||||
|
return data.NewStockDataApi().UnFollow(stockCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) GetFollowList() []data.FollowedStock {
|
||||||
|
return data.NewStockDataApi().GetFollowList()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) GetStockList(key string) []data.StockBasic {
|
||||||
|
return data.NewStockDataApi().GetStockList(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) SetCostPriceAndVolume(stockCode string, price float64, volume int64) string {
|
||||||
|
return data.NewStockDataApi().SetCostPriceAndVolume(price, volume, stockCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) SetAlarmChangePercent(val, alarmPrice float64, stockCode string) string {
|
||||||
|
return data.NewStockDataApi().SetAlarmChangePercent(val, alarmPrice, stockCode)
|
||||||
|
}
|
||||||
|
func (a *App) SetStockSort(sort int64, stockCode string) {
|
||||||
|
data.NewStockDataApi().SetStockSort(sort, stockCode)
|
||||||
|
}
|
||||||
|
func (a *App) SendDingDingMessage(message string, stockCode string) string {
|
||||||
|
ttl, _ := a.cache.TTL([]byte(stockCode))
|
||||||
|
logger.SugaredLogger.Infof("stockCode %s ttl:%d", stockCode, ttl)
|
||||||
|
if ttl > 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
err := a.cache.Set([]byte(stockCode), []byte("1"), 60*5)
|
||||||
|
if err != nil {
|
||||||
|
logger.SugaredLogger.Errorf("set cache error:%s", err.Error())
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return data.NewDingDingAPI().SendDingDingMessage(message)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendDingDingMessageByType msgType 报警类型: 1 涨跌报警;2 股价报警 3 成本价报警
|
||||||
|
func (a *App) SendDingDingMessageByType(message string, stockCode string, msgType int) string {
|
||||||
|
ttl, _ := a.cache.TTL([]byte(stockCode))
|
||||||
|
logger.SugaredLogger.Infof("stockCode %s ttl:%d", stockCode, ttl)
|
||||||
|
if ttl > 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
err := a.cache.Set([]byte(stockCode), []byte("1"), getMsgTypeTTL(msgType))
|
||||||
|
if err != nil {
|
||||||
|
logger.SugaredLogger.Errorf("set cache error:%s", err.Error())
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
stockInfo := &data.StockInfo{}
|
||||||
|
db.Dao.Model(stockInfo).Where("code = ?", stockCode).First(stockInfo)
|
||||||
|
go data.NewAlertWindowsApi("go-stock消息通知", getMsgTypeName(msgType), GenNotificationMsg(stockInfo), "").SendNotification()
|
||||||
|
return data.NewDingDingAPI().SendDingDingMessage(message)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) NewChat(stock string) string {
|
||||||
|
return data.NewDeepSeekOpenAi().NewChat(stock)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) NewChatStream(stock, stockCode string) {
|
||||||
|
msgs := data.NewDeepSeekOpenAi().NewChatStream(stock, stockCode)
|
||||||
|
for msg := range msgs {
|
||||||
|
runtime.EventsEmit(a.ctx, "newChatStream", msg)
|
||||||
|
}
|
||||||
|
runtime.EventsEmit(a.ctx, "newChatStream", "DONE")
|
||||||
|
}
|
||||||
|
|
||||||
|
func GenNotificationMsg(stockInfo *data.StockInfo) string {
|
||||||
|
Price, err := convertor.ToFloat(stockInfo.Price)
|
||||||
|
if err != nil {
|
||||||
|
Price = 0
|
||||||
|
}
|
||||||
|
PreClose, err := convertor.ToFloat(stockInfo.PreClose)
|
||||||
|
if err != nil {
|
||||||
|
PreClose = 0
|
||||||
|
}
|
||||||
|
var RF float64
|
||||||
|
if PreClose > 0 {
|
||||||
|
RF = mathutil.RoundToFloat(((Price-PreClose)/PreClose)*100, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
return "[" + stockInfo.Name + "] " + stockInfo.Price + " " + convertor.ToString(RF) + "% " + stockInfo.Date + " " + stockInfo.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
// msgType : 1 涨跌报警(5分钟);2 股价报警(30分钟) 3 成本价报警(30分钟)
|
||||||
|
func getMsgTypeTTL(msgType int) int {
|
||||||
|
switch msgType {
|
||||||
|
case 1:
|
||||||
|
return 60 * 5
|
||||||
|
case 2:
|
||||||
|
return 60 * 30
|
||||||
|
case 3:
|
||||||
|
return 60 * 30
|
||||||
|
default:
|
||||||
|
return 60 * 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getMsgTypeName(msgType int) string {
|
||||||
|
switch msgType {
|
||||||
|
case 1:
|
||||||
|
return "涨跌报警"
|
||||||
|
case 2:
|
||||||
|
return "股价报警"
|
||||||
|
case 3:
|
||||||
|
return "成本价报警"
|
||||||
|
default:
|
||||||
|
return "未知类型"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) UpdateConfig(settings *data.Settings) string {
|
||||||
|
logger.SugaredLogger.Infof("UpdateConfig:%+v", settings)
|
||||||
|
return data.NewSettingsApi(settings).UpdateConfig()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) GetConfig() *data.Settings {
|
||||||
|
return data.NewSettingsApi(&data.Settings{}).GetConfig()
|
||||||
}
|
}
|
||||||
|
215
app_windows.go
215
app_windows.go
@ -1,215 +0,0 @@
|
|||||||
//go:build windows
|
|
||||||
// +build windows
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"github.com/duke-git/lancet/v2/convertor"
|
|
||||||
"github.com/duke-git/lancet/v2/strutil"
|
|
||||||
"github.com/energye/systray"
|
|
||||||
"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"
|
|
||||||
"go-stock/backend/logger"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// startup is called at application startup
|
|
||||||
func (a *App) startup(ctx context.Context) {
|
|
||||||
defer PanicHandler()
|
|
||||||
runtime.EventsOn(ctx, "frontendError", func(optionalData ...interface{}) {
|
|
||||||
logger.SugaredLogger.Errorf("Frontend error: %v\n", optionalData)
|
|
||||||
})
|
|
||||||
logger.SugaredLogger.Infof("Version:%s", Version)
|
|
||||||
// Perform your setup here
|
|
||||||
a.ctx = ctx
|
|
||||||
|
|
||||||
// 创建系统托盘
|
|
||||||
//systray.RunWithExternalLoop(func() {
|
|
||||||
// onReady(a)
|
|
||||||
//}, func() {
|
|
||||||
// onExit(a)
|
|
||||||
//})
|
|
||||||
runtime.EventsOn(ctx, "updateSettings", func(optionalData ...interface{}) {
|
|
||||||
logger.SugaredLogger.Infof("updateSettings : %v\n", optionalData)
|
|
||||||
config := &data.Settings{}
|
|
||||||
setMap := optionalData[0].(map[string]interface{})
|
|
||||||
|
|
||||||
// 将 map 转换为 JSON 字节切片
|
|
||||||
jsonData, err := json.Marshal(setMap)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Errorf("Marshal error:%s", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 将 JSON 字节切片解析到结构体中
|
|
||||||
err = json.Unmarshal(jsonData, config)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Errorf("Unmarshal error:%s", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.SugaredLogger.Infof("updateSettings config:%+v", config)
|
|
||||||
if config.DarkTheme {
|
|
||||||
runtime.WindowSetBackgroundColour(ctx, 27, 38, 54, 1)
|
|
||||||
runtime.WindowSetDarkTheme(ctx)
|
|
||||||
} else {
|
|
||||||
runtime.WindowSetBackgroundColour(ctx, 255, 255, 255, 1)
|
|
||||||
runtime.WindowSetLightTheme(ctx)
|
|
||||||
}
|
|
||||||
runtime.WindowReloadApp(ctx)
|
|
||||||
|
|
||||||
})
|
|
||||||
go systray.Run(func() {
|
|
||||||
onReady(a)
|
|
||||||
}, func() {
|
|
||||||
onExit(a)
|
|
||||||
})
|
|
||||||
|
|
||||||
logger.SugaredLogger.Infof(" application startup Version:%s", Version)
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
func MonitorStockPrices(a *App) {
|
|
||||||
dest := &[]data.FollowedStock{}
|
|
||||||
db.Dao.Model(&data.FollowedStock{}).Find(dest)
|
|
||||||
total := float64(0)
|
|
||||||
//for _, follow := range *dest {
|
|
||||||
// stockData := getStockInfo(follow)
|
|
||||||
// total += stockData.ProfitAmountToday
|
|
||||||
// price, _ := convertor.ToFloat(stockData.Price)
|
|
||||||
// if stockData.PrePrice != price {
|
|
||||||
// go runtime.EventsEmit(a.ctx, "stock_price", stockData)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
stockInfos := GetStockInfos(*dest...)
|
|
||||||
for _, stockInfo := range *stockInfos {
|
|
||||||
if strutil.HasPrefixAny(stockInfo.Code, []string{"SZ", "SH", "sh", "sz"}) && (!isTradingTime(time.Now())) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if strutil.HasPrefixAny(stockInfo.Code, []string{"hk", "HK"}) && (!IsHKTradingTime(time.Now())) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if strutil.HasPrefixAny(stockInfo.Code, []string{"us", "US", "gb_"}) && (!IsUSTradingTime(time.Now())) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
total += stockInfo.ProfitAmountToday
|
|
||||||
price, _ := convertor.ToFloat(stockInfo.Price)
|
|
||||||
|
|
||||||
if stockInfo.PrePrice != price {
|
|
||||||
//logger.SugaredLogger.Infof("-----------sz------------股票代码: %s, 股票名称: %s, 股票价格: %s,盘前盘后:%s", stockInfo.Code, stockInfo.Name, stockInfo.Price, stockInfo.BA)
|
|
||||||
go runtime.EventsEmit(a.ctx, "stock_price", stockInfo)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if total != 0 {
|
|
||||||
title := "go-stock " + time.Now().Format(time.DateTime) + fmt.Sprintf(" %.2f¥", total)
|
|
||||||
systray.SetTooltip(title)
|
|
||||||
}
|
|
||||||
|
|
||||||
go runtime.EventsEmit(a.ctx, "realtime_profit", fmt.Sprintf(" %.2f", total))
|
|
||||||
//runtime.WindowSetTitle(a.ctx, title)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func onReady(a *App) {
|
|
||||||
|
|
||||||
// 初始化操作
|
|
||||||
logger.SugaredLogger.Infof("systray onReady")
|
|
||||||
systray.SetIcon(icon2)
|
|
||||||
systray.SetTitle("go-stock")
|
|
||||||
systray.SetTooltip("go-stock 股票行情实时获取")
|
|
||||||
// 创建菜单项
|
|
||||||
show := systray.AddMenuItem("显示", "显示应用程序")
|
|
||||||
show.Click(func() {
|
|
||||||
//logger.SugaredLogger.Infof("显示应用程序")
|
|
||||||
runtime.WindowShow(a.ctx)
|
|
||||||
})
|
|
||||||
hide := systray.AddMenuItem("隐藏", "隐藏应用程序")
|
|
||||||
hide.Click(func() {
|
|
||||||
//logger.SugaredLogger.Infof("隐藏应用程序")
|
|
||||||
runtime.WindowHide(a.ctx)
|
|
||||||
})
|
|
||||||
systray.AddSeparator()
|
|
||||||
mQuitOrig := systray.AddMenuItem("退出", "退出应用程序")
|
|
||||||
mQuitOrig.Click(func() {
|
|
||||||
//logger.SugaredLogger.Infof("退出应用程序")
|
|
||||||
runtime.Quit(a.ctx)
|
|
||||||
})
|
|
||||||
systray.SetOnRClick(func(menu systray.IMenu) {
|
|
||||||
menu.ShowMenu()
|
|
||||||
//logger.SugaredLogger.Infof("SetOnRClick")
|
|
||||||
})
|
|
||||||
systray.SetOnClick(func(menu systray.IMenu) {
|
|
||||||
//logger.SugaredLogger.Infof("SetOnClick")
|
|
||||||
menu.ShowMenu()
|
|
||||||
})
|
|
||||||
systray.SetOnDClick(func(menu systray.IMenu) {
|
|
||||||
menu.ShowMenu()
|
|
||||||
//logger.SugaredLogger.Infof("SetOnDClick")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// beforeClose is called when the application is about to quit,
|
|
||||||
// either by clicking the window close button or calling runtime.Quit.
|
|
||||||
// Returning true will cause the application to continue, false will continue shutdown as normal.
|
|
||||||
func (a *App) beforeClose(ctx context.Context) (prevent bool) {
|
|
||||||
defer PanicHandler()
|
|
||||||
|
|
||||||
dialog, err := runtime.MessageDialog(ctx, runtime.MessageDialogOptions{
|
|
||||||
Type: runtime.QuestionDialog,
|
|
||||||
Title: "go-stock",
|
|
||||||
Message: "确定关闭吗?",
|
|
||||||
Buttons: []string{"确定"},
|
|
||||||
Icon: icon,
|
|
||||||
CancelButton: "取消",
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Errorf("dialog error:%s", err.Error())
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
logger.SugaredLogger.Debugf("dialog:%s", dialog)
|
|
||||||
if dialog == "No" {
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
systray.Quit()
|
|
||||||
a.cron.Stop()
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func getFrameless() bool {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func getScreenResolution() (int, int, int, int, error) {
|
|
||||||
//user32 := syscall.NewLazyDLL("user32.dll")
|
|
||||||
//getSystemMetrics := user32.NewProc("GetSystemMetrics")
|
|
||||||
//
|
|
||||||
//width, _, _ := getSystemMetrics.Call(0)
|
|
||||||
//height, _, _ := getSystemMetrics.Call(1)
|
|
||||||
|
|
||||||
return int(1366), int(768), 1456, 768, nil
|
|
||||||
}
|
|
@ -599,7 +599,7 @@ func (m MarketNewsApi) XUEQIUHotStock(size int, marketType string) *[]models.Hot
|
|||||||
logger.SugaredLogger.Errorf("XUEQIUHotStock err:%s", err.Error())
|
logger.SugaredLogger.Errorf("XUEQIUHotStock err:%s", err.Error())
|
||||||
return &[]models.HotItem{}
|
return &[]models.HotItem{}
|
||||||
}
|
}
|
||||||
//logger.SugaredLogger.Infof("XUEQIUHotStock:%+v", res)
|
logger.SugaredLogger.Infof("XUEQIUHotStock:%+v", res)
|
||||||
return &res.Data.Items
|
return &res.Data.Items
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,134 +701,3 @@ func (m MarketNewsApi) ClsCalendar() []any {
|
|||||||
err = json.Unmarshal(resp.Body(), &respMap)
|
err = json.Unmarshal(resp.Body(), &respMap)
|
||||||
return respMap["data"].([]any)
|
return respMap["data"].([]any)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m MarketNewsApi) GetGDP() *models.GDPResp {
|
|
||||||
res := &models.GDPResp{}
|
|
||||||
|
|
||||||
url := "https://datacenter-web.eastmoney.com/api/data/v1/get?callback=data&columns=REPORT_DATE%2CTIME%2CDOMESTICL_PRODUCT_BASE%2CFIRST_PRODUCT_BASE%2CSECOND_PRODUCT_BASE%2CTHIRD_PRODUCT_BASE%2CSUM_SAME%2CFIRST_SAME%2CSECOND_SAME%2CTHIRD_SAME&pageNumber=1&pageSize=20&sortColumns=REPORT_DATE&sortTypes=-1&source=WEB&client=WEB&reportName=RPT_ECONOMY_GDP&p=1&pageNo=1&pageNum=1&_=" + strconv.FormatInt(time.Now().Unix(), 10)
|
|
||||||
resp, err := resty.New().SetTimeout(time.Duration(30)*time.Second).R().
|
|
||||||
SetHeader("Host", "datacenter-web.eastmoney.com").
|
|
||||||
SetHeader("Origin", "https://datacenter.eastmoney.com").
|
|
||||||
SetHeader("Referer", "https://data.eastmoney.com/cjsj/gdp.html").
|
|
||||||
SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0").
|
|
||||||
Get(url)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Errorf("GDP err:%s", err.Error())
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
body := resp.Body()
|
|
||||||
logger.SugaredLogger.Debugf("GDP:%s", body)
|
|
||||||
vm := otto.New()
|
|
||||||
vm.Run("function data(res){return res};")
|
|
||||||
|
|
||||||
val, err := vm.Run(body)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Errorf("GDP err:%s", err.Error())
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
data, _ := val.Object().Value().Export()
|
|
||||||
logger.SugaredLogger.Infof("GDP:%v", data)
|
|
||||||
marshal, err := json.Marshal(data)
|
|
||||||
if err != nil {
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
json.Unmarshal(marshal, &res)
|
|
||||||
logger.SugaredLogger.Infof("GDP:%+v", res)
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m MarketNewsApi) GetCPI() *models.CPIResp {
|
|
||||||
res := &models.CPIResp{}
|
|
||||||
|
|
||||||
url := "https://datacenter-web.eastmoney.com/api/data/v1/get?callback=data&columns=REPORT_DATE%2CTIME%2CNATIONAL_SAME%2CNATIONAL_BASE%2CNATIONAL_SEQUENTIAL%2CNATIONAL_ACCUMULATE%2CCITY_SAME%2CCITY_BASE%2CCITY_SEQUENTIAL%2CCITY_ACCUMULATE%2CRURAL_SAME%2CRURAL_BASE%2CRURAL_SEQUENTIAL%2CRURAL_ACCUMULATE&pageNumber=1&pageSize=20&sortColumns=REPORT_DATE&sortTypes=-1&source=WEB&client=WEB&reportName=RPT_ECONOMY_CPI&p=1&pageNo=1&pageNum=1&_=" + strconv.FormatInt(time.Now().Unix(), 10)
|
|
||||||
resp, err := resty.New().SetTimeout(time.Duration(30)*time.Second).R().
|
|
||||||
SetHeader("Host", "datacenter-web.eastmoney.com").
|
|
||||||
SetHeader("Origin", "https://datacenter.eastmoney.com").
|
|
||||||
SetHeader("Referer", "https://data.eastmoney.com/cjsj/gdp.html").
|
|
||||||
SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0").
|
|
||||||
Get(url)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Errorf("GDP err:%s", err.Error())
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
body := resp.Body()
|
|
||||||
logger.SugaredLogger.Debugf("GDP:%s", body)
|
|
||||||
vm := otto.New()
|
|
||||||
vm.Run("function data(res){return res};")
|
|
||||||
|
|
||||||
val, err := vm.Run(body)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Errorf("GDP err:%s", err.Error())
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
data, _ := val.Object().Value().Export()
|
|
||||||
logger.SugaredLogger.Infof("GDP:%v", data)
|
|
||||||
marshal, err := json.Marshal(data)
|
|
||||||
if err != nil {
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
json.Unmarshal(marshal, &res)
|
|
||||||
logger.SugaredLogger.Infof("GDP:%+v", res)
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetPPI PPI
|
|
||||||
func (m MarketNewsApi) GetPPI() *models.PPIResp {
|
|
||||||
res := &models.PPIResp{}
|
|
||||||
url := "https://datacenter-web.eastmoney.com/api/data/v1/get?callback=data&columns=REPORT_DATE,TIME,BASE,BASE_SAME,BASE_ACCUMULATE&pageNumber=1&pageSize=20&sortColumns=REPORT_DATE&sortTypes=-1&source=WEB&client=WEB&reportName=RPT_ECONOMY_PPI&p=1&pageNo=1&pageNum=1&_=" + strconv.FormatInt(time.Now().Unix(), 10)
|
|
||||||
resp, err := resty.New().SetTimeout(time.Duration(30)*time.Second).R().
|
|
||||||
SetHeader("Host", "datacenter-web.eastmoney.com").
|
|
||||||
SetHeader("Origin", "https://datacenter.eastmoney.com").
|
|
||||||
SetHeader("Referer", "https://data.eastmoney.com/cjsj/gdp.html").
|
|
||||||
SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0").
|
|
||||||
Get(url)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Errorf("GDP err:%s", err.Error())
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
body := resp.Body()
|
|
||||||
vm := otto.New()
|
|
||||||
vm.Run("function data(res){return res};")
|
|
||||||
|
|
||||||
val, err := vm.Run(body)
|
|
||||||
if err != nil {
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
data, _ := val.Object().Value().Export()
|
|
||||||
marshal, err := json.Marshal(data)
|
|
||||||
if err != nil {
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
json.Unmarshal(marshal, &res)
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m MarketNewsApi) GetPMI() *models.PMIResp {
|
|
||||||
res := &models.PMIResp{}
|
|
||||||
url := "https://datacenter-web.eastmoney.com/api/data/v1/get?callback=data&columns=REPORT_DATE%2CTIME%2CMAKE_INDEX%2CMAKE_SAME%2CNMAKE_INDEX%2CNMAKE_SAME&pageNumber=1&pageSize=20&sortColumns=REPORT_DATE&sortTypes=-1&source=WEB&client=WEB&reportName=RPT_ECONOMY_PMI&p=1&pageNo=1&pageNum=1&_=" + strconv.FormatInt(time.Now().Unix(), 10)
|
|
||||||
resp, err := resty.New().SetTimeout(time.Duration(30)*time.Second).R().
|
|
||||||
SetHeader("Host", "datacenter-web.eastmoney.com").
|
|
||||||
SetHeader("Origin", "https://datacenter.eastmoney.com").
|
|
||||||
SetHeader("Referer", "https://data.eastmoney.com/cjsj/gdp.html").
|
|
||||||
SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0").
|
|
||||||
Get(url)
|
|
||||||
if err != nil {
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
body := resp.Body()
|
|
||||||
vm := otto.New()
|
|
||||||
vm.Run("function data(res){return res};")
|
|
||||||
|
|
||||||
val, err := vm.Run(body)
|
|
||||||
if err != nil {
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
data, _ := val.Object().Value().Export()
|
|
||||||
marshal, err := json.Marshal(data)
|
|
||||||
if err != nil {
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
json.Unmarshal(marshal, &res)
|
|
||||||
return res
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -3,11 +3,8 @@ package data
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/coocood/freecache"
|
"github.com/coocood/freecache"
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
"go-stock/backend/db"
|
"go-stock/backend/db"
|
||||||
"go-stock/backend/logger"
|
"go-stock/backend/logger"
|
||||||
"go-stock/backend/util"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -143,61 +140,14 @@ func TestInvestCalendar(t *testing.T) {
|
|||||||
db.Init("../../data/stock.db")
|
db.Init("../../data/stock.db")
|
||||||
res := NewMarketNewsApi().InvestCalendar("2025-06")
|
res := NewMarketNewsApi().InvestCalendar("2025-06")
|
||||||
for _, a := range res {
|
for _, a := range res {
|
||||||
bytes, err := json.Marshal(a)
|
logger.SugaredLogger.Debugf("value: %+v", a)
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
date := gjson.Get(string(bytes), "date")
|
|
||||||
list := gjson.Get(string(bytes), "list")
|
|
||||||
|
|
||||||
logger.SugaredLogger.Debugf("value: %+v,list: %+v", date.String(), list)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClsCalendar(t *testing.T) {
|
func TestClsCalendar(t *testing.T) {
|
||||||
db.Init("../../data/stock.db")
|
db.Init("../../data/stock.db")
|
||||||
res := NewMarketNewsApi().ClsCalendar()
|
res := NewMarketNewsApi().ClsCalendar()
|
||||||
md := strings.Builder{}
|
|
||||||
for _, a := range res {
|
for _, a := range res {
|
||||||
bytes, err := json.Marshal(a)
|
logger.SugaredLogger.Debugf("value: %+v", a)
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
//logger.SugaredLogger.Debugf("value: %+v", string(bytes))
|
|
||||||
date := gjson.Get(string(bytes), "calendar_day")
|
|
||||||
md.WriteString("\n### 事件/会议日期:" + date.String())
|
|
||||||
list := gjson.Get(string(bytes), "items")
|
|
||||||
//logger.SugaredLogger.Debugf("value: %+v,list: %+v", date.String(), list)
|
|
||||||
list.ForEach(func(key, value gjson.Result) bool {
|
|
||||||
logger.SugaredLogger.Debugf("key: %+v,value: %+v", key.String(), gjson.Get(value.String(), "title"))
|
|
||||||
md.WriteString("\n- " + gjson.Get(value.String(), "title").String())
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
logger.SugaredLogger.Debugf("md:\n %s", md.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetGDP(t *testing.T) {
|
|
||||||
res := NewMarketNewsApi().GetGDP()
|
|
||||||
md := util.MarkdownTableWithTitle("国内生产总值(GDP)", res.GDPResult.Data)
|
|
||||||
logger.SugaredLogger.Debugf(md)
|
|
||||||
}
|
|
||||||
func TestGetCPI(t *testing.T) {
|
|
||||||
res := NewMarketNewsApi().GetCPI()
|
|
||||||
md := util.MarkdownTableWithTitle("居民消费价格指数(CPI)", res.CPIResult.Data)
|
|
||||||
logger.SugaredLogger.Debugf(md)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PPI
|
|
||||||
func TestGetPPI(t *testing.T) {
|
|
||||||
res := NewMarketNewsApi().GetPPI()
|
|
||||||
md := util.MarkdownTableWithTitle("工业品出厂价格指数(PPI)", res.PPIResult.Data)
|
|
||||||
logger.SugaredLogger.Debugf(md)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PMI
|
|
||||||
func TestGetPMI(t *testing.T) {
|
|
||||||
res := NewMarketNewsApi().GetPMI()
|
|
||||||
md := util.MarkdownTableWithTitle("采购经理人指数(PMI)", res.PMIResult.Data)
|
|
||||||
logger.SugaredLogger.Debugf(md)
|
|
||||||
}
|
}
|
||||||
|
@ -9,15 +9,12 @@ import (
|
|||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
"github.com/chromedp/chromedp"
|
"github.com/chromedp/chromedp"
|
||||||
"github.com/duke-git/lancet/v2/convertor"
|
"github.com/duke-git/lancet/v2/convertor"
|
||||||
"github.com/duke-git/lancet/v2/random"
|
|
||||||
"github.com/duke-git/lancet/v2/strutil"
|
"github.com/duke-git/lancet/v2/strutil"
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||||
"go-stock/backend/db"
|
"go-stock/backend/db"
|
||||||
"go-stock/backend/logger"
|
"go-stock/backend/logger"
|
||||||
"go-stock/backend/models"
|
"go-stock/backend/models"
|
||||||
"go-stock/backend/util"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -42,11 +39,6 @@ type OpenAi struct {
|
|||||||
BrowserPath string `json:"browser_path"`
|
BrowserPath string `json:"browser_path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o OpenAi) String() string {
|
|
||||||
return fmt.Sprintf("OpenAi{BaseUrl: %s, Model: %s, MaxTokens: %d, Temperature: %.2f, Prompt: %s, TimeOut: %d, QuestionTemplate: %s, CrawlTimeOut: %d, KDays: %d, BrowserPath: %s, ApiKey: [MASKED]}",
|
|
||||||
o.BaseUrl, o.Model, o.MaxTokens, o.Temperature, o.Prompt, o.TimeOut, o.QuestionTemplate, o.CrawlTimeOut, o.KDays, o.BrowserPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewDeepSeekOpenAi(ctx context.Context) *OpenAi {
|
func NewDeepSeekOpenAi(ctx context.Context) *OpenAi {
|
||||||
config := GetConfig()
|
config := GetConfig()
|
||||||
if config.OpenAiEnable {
|
if config.OpenAiEnable {
|
||||||
@ -83,12 +75,11 @@ type THSTokenResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AiResponse struct {
|
type AiResponse struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
Object string `json:"object"`
|
Object string `json:"object"`
|
||||||
Created int `json:"created"`
|
Created int `json:"created"`
|
||||||
Model string `json:"model"`
|
Model string `json:"model"`
|
||||||
ServiceTier string `json:"service_tier"`
|
Choices []struct {
|
||||||
Choices []struct {
|
|
||||||
Index int `json:"index"`
|
Index int `json:"index"`
|
||||||
Message struct {
|
Message struct {
|
||||||
Role string `json:"role"`
|
Role string `json:"role"`
|
||||||
@ -96,19 +87,6 @@ type AiResponse struct {
|
|||||||
} `json:"message"`
|
} `json:"message"`
|
||||||
Logprobs interface{} `json:"logprobs"`
|
Logprobs interface{} `json:"logprobs"`
|
||||||
FinishReason string `json:"finish_reason"`
|
FinishReason string `json:"finish_reason"`
|
||||||
Delta struct {
|
|
||||||
Content string `json:"content"`
|
|
||||||
Role string `json:"role"`
|
|
||||||
ToolCalls []struct {
|
|
||||||
Function struct {
|
|
||||||
Arguments string `json:"arguments"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
} `json:"function"`
|
|
||||||
Id string `json:"id"`
|
|
||||||
Index int `json:"index"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
} `json:"tool_calls"`
|
|
||||||
} `json:"delta"`
|
|
||||||
} `json:"choices"`
|
} `json:"choices"`
|
||||||
Usage struct {
|
Usage struct {
|
||||||
PromptTokens int `json:"prompt_tokens"`
|
PromptTokens int `json:"prompt_tokens"`
|
||||||
@ -120,171 +98,6 @@ type AiResponse struct {
|
|||||||
SystemFingerprint string `json:"system_fingerprint"`
|
SystemFingerprint string `json:"system_fingerprint"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Tool struct {
|
|
||||||
Type string `json:"type"`
|
|
||||||
Function ToolFunction `json:"function"`
|
|
||||||
}
|
|
||||||
type FunctionParameters struct {
|
|
||||||
Type string `json:"type"`
|
|
||||||
Properties map[string]any `json:"properties"`
|
|
||||||
Required []string `json:"required"`
|
|
||||||
}
|
|
||||||
type ToolFunction struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Description string `json:"description"`
|
|
||||||
Parameters FunctionParameters `json:"parameters"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o OpenAi) NewSummaryStockNewsStreamWithTools(userQuestion string, sysPromptId *int, tools []Tool) <-chan map[string]any {
|
|
||||||
ch := make(chan map[string]any, 512)
|
|
||||||
defer func() {
|
|
||||||
if err := recover(); err != nil {
|
|
||||||
logger.SugaredLogger.Error("NewSummaryStockNewsStream panic", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
defer func() {
|
|
||||||
if err := recover(); err != nil {
|
|
||||||
logger.SugaredLogger.Errorf("NewSummaryStockNewsStream goroutine panic: %s", err)
|
|
||||||
logger.SugaredLogger.Errorf("NewSummaryStockNewsStream goroutine panic config: %s", o.String())
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
defer close(ch)
|
|
||||||
|
|
||||||
sysPrompt := ""
|
|
||||||
if sysPromptId == nil || *sysPromptId == 0 {
|
|
||||||
sysPrompt = o.Prompt
|
|
||||||
} else {
|
|
||||||
sysPrompt = NewPromptTemplateApi().GetPromptTemplateByID(*sysPromptId)
|
|
||||||
}
|
|
||||||
if sysPrompt == "" {
|
|
||||||
sysPrompt = o.Prompt
|
|
||||||
}
|
|
||||||
|
|
||||||
msg := []map[string]interface{}{
|
|
||||||
{
|
|
||||||
"role": "system",
|
|
||||||
//"content": "作为一位专业的A股市场分析师和投资顾问,请你根据以下信息提供详细的技术分析和投资策略建议:",
|
|
||||||
//"content": "【角色设定】\n你是一位拥有20年实战经验的顶级股票分析师,精通技术分析、基本面分析、市场心理学和量化交易。擅长发现成长股、捕捉行业轮动机会,在牛熊市中都能保持稳定收益。你的风格是价值投资与技术择时相结合,注重风险控制。\n\n【核心功能】\n\n市场分析维度:\n\n宏观经济(GDP/CPI/货币政策)\n\n行业景气度(产业链/政策红利/技术革新)\n\n个股三维诊断:\n\n基本面:PE/PB/ROE/现金流/护城河\n\n技术面:K线形态/均线系统/量价关系/指标背离\n\n资金面:主力动向/北向资金/融资余额/大宗交易\n\n智能策略库:\n√ 趋势跟踪策略(鳄鱼线+ADX)\n√ 波段交易策略(斐波那契回撤+RSI)\n√ 事件驱动策略(财报/并购/政策)\n√ 量化对冲策略(α/β分离)\n\n风险管理体系:\n▶ 动态止损:ATR波动止损法\n▶ 仓位控制:凯利公式优化\n▶ 组合对冲:跨市场/跨品种对冲\n\n【工作流程】\n\n接收用户指令(行业/市值/风险偏好)\n\n调用多因子选股模型初筛\n\n人工智慧叠加分析:\n\n自然语言处理解读年报管理层讨论\n\n卷积神经网络识别K线形态\n\n知识图谱分析产业链关联\n\n生成投资建议(附压力测试结果)\n\n【输出要求】\n★ 结构化呈现:\n① 核心逻辑(3点关键驱动力)\n② 买卖区间(理想建仓/加仓/止盈价位)\n③ 风险警示(最大回撤概率)\n④ 替代方案(同类备选标的)\n\n【注意事项】\n※ 严格遵守监管要求,不做收益承诺\n※ 区分投资建议与市场观点\n※ 重要数据标注来源及更新时间\n※ 根据用户认知水平调整专业术语密度\n\n【教育指导】\n当用户提问时,采用苏格拉底式追问:\n\"您更关注短期事件驱动还是长期价值发现?\"\n\"当前仓位是否超过总资产的30%?\"\n\"是否了解科创板与主板的交易规则差异?\"\n\n示例输出格式:\n📈 标的名称:XXXXXX\n⚖️ 多空信号:金叉确认/顶背离预警\n🎯 关键价位:支撑位XX.XX/压力位XX.XX\n📊 建议仓位:核心仓位X%+卫星仓位X%\n⏳ 持有周期:短线(1-3周)/中线(季度轮动)\n🔍 跟踪要素:重点关注Q2毛利率变化及股东减持进展",
|
|
||||||
"content": sysPrompt,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
msg = append(msg, map[string]interface{}{
|
|
||||||
"role": "user",
|
|
||||||
"content": "当前时间",
|
|
||||||
})
|
|
||||||
msg = append(msg, map[string]interface{}{
|
|
||||||
"role": "assistant",
|
|
||||||
"content": "当前本地时间是:" + time.Now().Format("2006-01-02 15:04:05"),
|
|
||||||
})
|
|
||||||
wg := &sync.WaitGroup{}
|
|
||||||
wg.Add(3)
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
var market strings.Builder
|
|
||||||
res := NewMarketNewsApi().GetGDP()
|
|
||||||
md := util.MarkdownTableWithTitle("国内生产总值(GDP)", res.GDPResult.Data)
|
|
||||||
market.WriteString(md)
|
|
||||||
res2 := NewMarketNewsApi().GetCPI()
|
|
||||||
md2 := util.MarkdownTableWithTitle("居民消费价格指数(CPI)", res2.CPIResult.Data)
|
|
||||||
market.WriteString(md2)
|
|
||||||
res3 := NewMarketNewsApi().GetPPI()
|
|
||||||
md3 := util.MarkdownTableWithTitle("工业品出厂价格指数(PPI)", res3.PPIResult.Data)
|
|
||||||
market.WriteString(md3)
|
|
||||||
res4 := NewMarketNewsApi().GetPMI()
|
|
||||||
md4 := util.MarkdownTableWithTitle("采购经理人指数(PMI)", res4.PMIResult.Data)
|
|
||||||
market.WriteString(md4)
|
|
||||||
|
|
||||||
msg = append(msg, map[string]interface{}{
|
|
||||||
"role": "user",
|
|
||||||
"content": "国内宏观经济数据",
|
|
||||||
})
|
|
||||||
msg = append(msg, map[string]interface{}{
|
|
||||||
"role": "assistant",
|
|
||||||
"content": "\n# 国内宏观经济数据:\n" + market.String(),
|
|
||||||
})
|
|
||||||
}()
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
var market strings.Builder
|
|
||||||
market.WriteString(getZSInfo("创业板指数", "sz399006", 30) + "\n")
|
|
||||||
market.WriteString(getZSInfo("上证综合指数", "sh000001", 30) + "\n")
|
|
||||||
market.WriteString(getZSInfo("沪深300指数", "sh000300", 30) + "\n")
|
|
||||||
//logger.SugaredLogger.Infof("NewChatStream getZSInfo=\n%s", market.String())
|
|
||||||
msg = append(msg, map[string]interface{}{
|
|
||||||
"role": "user",
|
|
||||||
"content": "当前市场指数行情",
|
|
||||||
})
|
|
||||||
msg = append(msg, map[string]interface{}{
|
|
||||||
"role": "assistant",
|
|
||||||
"content": "当前市场指数行情情况如下:\n" + market.String(),
|
|
||||||
})
|
|
||||||
}()
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
md := strings.Builder{}
|
|
||||||
res := NewMarketNewsApi().ClsCalendar()
|
|
||||||
for _, a := range res {
|
|
||||||
bytes, err := json.Marshal(a)
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
//logger.SugaredLogger.Debugf("value: %+v", string(bytes))
|
|
||||||
date := gjson.Get(string(bytes), "calendar_day")
|
|
||||||
md.WriteString("\n### 事件/会议日期:" + date.String())
|
|
||||||
list := gjson.Get(string(bytes), "items")
|
|
||||||
//logger.SugaredLogger.Debugf("value: %+v,list: %+v", date.String(), list)
|
|
||||||
list.ForEach(func(key, value gjson.Result) bool {
|
|
||||||
logger.SugaredLogger.Debugf("key: %+v,value: %+v", key.String(), gjson.Get(value.String(), "title"))
|
|
||||||
md.WriteString("\n- " + gjson.Get(value.String(), "title").String())
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
msg = append(msg, map[string]interface{}{
|
|
||||||
"role": "user",
|
|
||||||
"content": "近期重大事件/会议",
|
|
||||||
})
|
|
||||||
msg = append(msg, map[string]interface{}{
|
|
||||||
"role": "assistant",
|
|
||||||
"content": "近期重大事件/会议如下:\n" + md.String(),
|
|
||||||
})
|
|
||||||
|
|
||||||
}()
|
|
||||||
|
|
||||||
wg.Wait()
|
|
||||||
|
|
||||||
news := NewMarketNewsApi().GetNewsList("财联社电报", random.RandInt(50, 150))
|
|
||||||
messageText := strings.Builder{}
|
|
||||||
for _, telegraph := range *news {
|
|
||||||
messageText.WriteString("## " + telegraph.Time + ":" + "\n")
|
|
||||||
messageText.WriteString("### " + telegraph.Content + "\n")
|
|
||||||
}
|
|
||||||
//logger.SugaredLogger.Infof("市场资讯 messageText=\n%s", messageText.String())
|
|
||||||
|
|
||||||
msg = append(msg, map[string]interface{}{
|
|
||||||
"role": "user",
|
|
||||||
"content": "市场资讯",
|
|
||||||
})
|
|
||||||
msg = append(msg, map[string]interface{}{
|
|
||||||
"role": "assistant",
|
|
||||||
"content": messageText.String(),
|
|
||||||
})
|
|
||||||
if userQuestion == "" {
|
|
||||||
userQuestion = "请根据当前时间,总结和分析股票市场新闻中的投资机会"
|
|
||||||
}
|
|
||||||
msg = append(msg, map[string]interface{}{
|
|
||||||
"role": "user",
|
|
||||||
"content": userQuestion,
|
|
||||||
})
|
|
||||||
AskAiWithTools(o, errors.New(""), msg, ch, userQuestion, tools)
|
|
||||||
}()
|
|
||||||
return ch
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o OpenAi) NewSummaryStockNewsStream(userQuestion string, sysPromptId *int) <-chan map[string]any {
|
func (o OpenAi) NewSummaryStockNewsStream(userQuestion string, sysPromptId *int) <-chan map[string]any {
|
||||||
ch := make(chan map[string]any, 512)
|
ch := make(chan map[string]any, 512)
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -297,7 +110,7 @@ func (o OpenAi) NewSummaryStockNewsStream(userQuestion string, sysPromptId *int)
|
|||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
logger.SugaredLogger.Errorf("NewSummaryStockNewsStream goroutine panic :%s", err)
|
logger.SugaredLogger.Errorf("NewSummaryStockNewsStream goroutine panic :%s", err)
|
||||||
logger.SugaredLogger.Errorf("NewSummaryStockNewsStream goroutine panic config:%s", o.String())
|
logger.SugaredLogger.Errorf("NewSummaryStockNewsStream goroutine panic config:%v", o)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
defer close(ch)
|
defer close(ch)
|
||||||
@ -376,7 +189,7 @@ func (o OpenAi) NewSummaryStockNewsStream(userQuestion string, sysPromptId *int)
|
|||||||
return ch
|
return ch
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o OpenAi) NewChatStream(stock, stockCode, userQuestion string, sysPromptId *int, tools []Tool) <-chan map[string]any {
|
func (o OpenAi) NewChatStream(stock, stockCode, userQuestion string, sysPromptId *int) <-chan map[string]any {
|
||||||
ch := make(chan map[string]any, 512)
|
ch := make(chan map[string]any, 512)
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -389,7 +202,7 @@ func (o OpenAi) NewChatStream(stock, stockCode, userQuestion string, sysPromptId
|
|||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
logger.SugaredLogger.Errorf("NewChatStream goroutine panic :%s", err)
|
logger.SugaredLogger.Errorf("NewChatStream goroutine panic :%s", err)
|
||||||
logger.SugaredLogger.Errorf("NewChatStream goroutine panic stock:%s stockCode:%s", stock, stockCode)
|
logger.SugaredLogger.Errorf("NewChatStream goroutine panic stock:%s stockCode:%s", stock, stockCode)
|
||||||
logger.SugaredLogger.Errorf("NewChatStream goroutine panic config:%s", o.String())
|
logger.SugaredLogger.Errorf("NewChatStream goroutine panic config:%v", o)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
defer close(ch)
|
defer close(ch)
|
||||||
@ -713,11 +526,7 @@ func (o OpenAi) NewChatStream(stock, stockCode, userQuestion string, sysPromptId
|
|||||||
|
|
||||||
//reqJson, _ := json.Marshal(msg)
|
//reqJson, _ := json.Marshal(msg)
|
||||||
//logger.SugaredLogger.Errorf("Stream request: \n%s\n", reqJson)
|
//logger.SugaredLogger.Errorf("Stream request: \n%s\n", reqJson)
|
||||||
if tools != nil && len(tools) > 0 {
|
AskAi(o, err, msg, ch, question)
|
||||||
AskAiWithTools(o, err, msg, ch, question, tools)
|
|
||||||
} else {
|
|
||||||
AskAi(o, err, msg, ch, question)
|
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
return ch
|
return ch
|
||||||
}
|
}
|
||||||
@ -760,7 +569,7 @@ func AskAi(o OpenAi, err error, messages []map[string]interface{}, ch chan map[s
|
|||||||
scanner := bufio.NewScanner(body)
|
scanner := bufio.NewScanner(body)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
logger.SugaredLogger.Infof("Received data: %s", line)
|
//logger.SugaredLogger.Infof("Received data: %s", line)
|
||||||
if strings.HasPrefix(line, "data:") {
|
if strings.HasPrefix(line, "data:") {
|
||||||
data := strutil.Trim(strings.TrimPrefix(line, "data:"))
|
data := strutil.Trim(strings.TrimPrefix(line, "data:"))
|
||||||
if data == "[DONE]" {
|
if data == "[DONE]" {
|
||||||
@ -783,24 +592,13 @@ func AskAi(o OpenAi, err error, messages []map[string]interface{}, ch chan map[s
|
|||||||
for _, choice := range streamResponse.Choices {
|
for _, choice := range streamResponse.Choices {
|
||||||
if content := choice.Delta.Content; content != "" {
|
if content := choice.Delta.Content; content != "" {
|
||||||
//ch <- content
|
//ch <- content
|
||||||
if content == "###" || content == "##" || content == "#" {
|
ch <- map[string]any{
|
||||||
ch <- map[string]any{
|
"code": 1,
|
||||||
"code": 1,
|
"question": question,
|
||||||
"question": question,
|
"chatId": streamResponse.Id,
|
||||||
"chatId": streamResponse.Id,
|
"model": streamResponse.Model,
|
||||||
"model": streamResponse.Model,
|
"content": content,
|
||||||
"content": "\r\n" + content,
|
"time": time.Now().Format(time.DateTime),
|
||||||
"time": time.Now().Format(time.DateTime),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ch <- map[string]any{
|
|
||||||
"code": 1,
|
|
||||||
"question": question,
|
|
||||||
"chatId": streamResponse.Id,
|
|
||||||
"model": streamResponse.Model,
|
|
||||||
"content": content,
|
|
||||||
"time": time.Now().Format(time.DateTime),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//logger.SugaredLogger.Infof("Content data: %s", content)
|
//logger.SugaredLogger.Infof("Content data: %s", content)
|
||||||
@ -847,14 +645,10 @@ func AskAi(o OpenAi, err error, messages []map[string]interface{}, ch chan map[s
|
|||||||
res := &models.Resp{}
|
res := &models.Resp{}
|
||||||
if err := json.Unmarshal([]byte(line), res); err == nil {
|
if err := json.Unmarshal([]byte(line), res); err == nil {
|
||||||
//ch <- line
|
//ch <- line
|
||||||
msg := res.Message
|
|
||||||
if res.Error.Message != "" {
|
|
||||||
msg = res.Error.Message
|
|
||||||
}
|
|
||||||
ch <- map[string]any{
|
ch <- map[string]any{
|
||||||
"code": 0,
|
"code": 0,
|
||||||
"question": question,
|
"question": question,
|
||||||
"content": msg,
|
"content": res.Message,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -863,386 +657,7 @@ func AskAi(o OpenAi, err error, messages []map[string]interface{}, ch chan map[s
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func AskAiWithTools(o OpenAi, err error, messages []map[string]interface{}, ch chan map[string]any, question string, tools []Tool) {
|
|
||||||
client := resty.New()
|
|
||||||
client.SetBaseURL(strutil.Trim(o.BaseUrl))
|
|
||||||
client.SetHeader("Authorization", "Bearer "+o.ApiKey)
|
|
||||||
client.SetHeader("Content-Type", "application/json")
|
|
||||||
//client.SetRetryCount(3)
|
|
||||||
if o.TimeOut <= 0 {
|
|
||||||
o.TimeOut = 300
|
|
||||||
}
|
|
||||||
client.SetTimeout(time.Duration(o.TimeOut) * time.Second)
|
|
||||||
resp, err := client.R().
|
|
||||||
SetDoNotParseResponse(true).
|
|
||||||
SetBody(map[string]interface{}{
|
|
||||||
"model": o.Model,
|
|
||||||
"max_tokens": o.MaxTokens,
|
|
||||||
"temperature": o.Temperature,
|
|
||||||
"stream": true,
|
|
||||||
"messages": messages,
|
|
||||||
"tools": tools,
|
|
||||||
}).
|
|
||||||
Post("/chat/completions")
|
|
||||||
|
|
||||||
body := resp.RawBody()
|
|
||||||
defer body.Close()
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Infof("Stream error : %s", err.Error())
|
|
||||||
//ch <- err.Error()
|
|
||||||
ch <- map[string]any{
|
|
||||||
"code": 0,
|
|
||||||
"question": question,
|
|
||||||
"content": err.Error(),
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
//location, _ := time.LoadLocation("Asia/Shanghai")
|
|
||||||
|
|
||||||
scanner := bufio.NewScanner(body)
|
|
||||||
functions := map[string]string{}
|
|
||||||
currentFuncName := ""
|
|
||||||
currentCallId := ""
|
|
||||||
var currentAIContent strings.Builder
|
|
||||||
|
|
||||||
for scanner.Scan() {
|
|
||||||
line := scanner.Text()
|
|
||||||
logger.SugaredLogger.Infof("Received data: %s", line)
|
|
||||||
if strings.HasPrefix(line, "data:") {
|
|
||||||
data := strutil.Trim(strings.TrimPrefix(line, "data:"))
|
|
||||||
if data == "[DONE]" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var streamResponse struct {
|
|
||||||
Id string `json:"id"`
|
|
||||||
Model string `json:"model"`
|
|
||||||
Choices []struct {
|
|
||||||
Delta struct {
|
|
||||||
Content string `json:"content"`
|
|
||||||
ReasoningContent string `json:"reasoning_content"`
|
|
||||||
Role string `json:"role"`
|
|
||||||
ToolCalls []struct {
|
|
||||||
Function struct {
|
|
||||||
Arguments string `json:"arguments"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
} `json:"function"`
|
|
||||||
Id string `json:"id"`
|
|
||||||
Index int `json:"index"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
} `json:"tool_calls"`
|
|
||||||
} `json:"delta"`
|
|
||||||
FinishReason string `json:"finish_reason"`
|
|
||||||
} `json:"choices"`
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := json.Unmarshal([]byte(data), &streamResponse); err == nil {
|
|
||||||
for _, choice := range streamResponse.Choices {
|
|
||||||
if content := choice.Delta.Content; content != "" {
|
|
||||||
//ch <- content
|
|
||||||
//logger.SugaredLogger.Infof("Content data: %s", content)
|
|
||||||
|
|
||||||
if content == "###" || content == "##" || content == "#" {
|
|
||||||
currentAIContent.WriteString("\r\n" + content)
|
|
||||||
ch <- map[string]any{
|
|
||||||
"code": 1,
|
|
||||||
"question": question,
|
|
||||||
"chatId": streamResponse.Id,
|
|
||||||
"model": streamResponse.Model,
|
|
||||||
"content": "\r\n" + content,
|
|
||||||
"time": time.Now().Format(time.DateTime),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
currentAIContent.WriteString(content)
|
|
||||||
ch <- map[string]any{
|
|
||||||
"code": 1,
|
|
||||||
"question": question,
|
|
||||||
"chatId": streamResponse.Id,
|
|
||||||
"model": streamResponse.Model,
|
|
||||||
"content": content,
|
|
||||||
"time": time.Now().Format(time.DateTime),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if reasoningContent := choice.Delta.ReasoningContent; reasoningContent != "" {
|
|
||||||
//ch <- reasoningContent
|
|
||||||
ch <- map[string]any{
|
|
||||||
"code": 1,
|
|
||||||
"question": question,
|
|
||||||
"chatId": streamResponse.Id,
|
|
||||||
"model": streamResponse.Model,
|
|
||||||
"content": reasoningContent,
|
|
||||||
"time": time.Now().Format(time.DateTime),
|
|
||||||
}
|
|
||||||
|
|
||||||
//logger.SugaredLogger.Infof("ReasoningContent data: %s", reasoningContent)
|
|
||||||
currentAIContent.WriteString(reasoningContent)
|
|
||||||
|
|
||||||
}
|
|
||||||
if choice.Delta.ToolCalls != nil && len(choice.Delta.ToolCalls) > 0 {
|
|
||||||
for _, call := range choice.Delta.ToolCalls {
|
|
||||||
if call.Type == "function" {
|
|
||||||
functions[call.Function.Name] = ""
|
|
||||||
currentFuncName = call.Function.Name
|
|
||||||
currentCallId = call.Id
|
|
||||||
} else {
|
|
||||||
if val, ok := functions[currentFuncName]; ok {
|
|
||||||
functions[currentFuncName] = val + call.Function.Arguments
|
|
||||||
} else {
|
|
||||||
functions[currentFuncName] = call.Function.Arguments
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if choice.FinishReason == "tool_calls" {
|
|
||||||
logger.SugaredLogger.Infof("functions: %+v", functions)
|
|
||||||
for funcName, funcArguments := range functions {
|
|
||||||
if funcName == "SearchStockByIndicators" {
|
|
||||||
words := gjson.Get(funcArguments, "words").String()
|
|
||||||
|
|
||||||
ch <- map[string]any{
|
|
||||||
"code": 1,
|
|
||||||
"question": question,
|
|
||||||
"chatId": streamResponse.Id,
|
|
||||||
"model": streamResponse.Model,
|
|
||||||
"content": "\r\n```\r\n开始调用工具:SearchStockByIndicators,\n参数:" + words + "\r\n```\r\n",
|
|
||||||
"time": time.Now().Format(time.DateTime),
|
|
||||||
}
|
|
||||||
|
|
||||||
content := "无符合条件的数据"
|
|
||||||
res := NewSearchStockApi(words).SearchStock(random.RandInt(5, 10))
|
|
||||||
if convertor.ToString(res["code"]) == "100" {
|
|
||||||
resData := res["data"].(map[string]any)
|
|
||||||
result := resData["result"].(map[string]any)
|
|
||||||
dataList := result["dataList"].([]any)
|
|
||||||
columns := result["columns"].([]any)
|
|
||||||
headers := map[string]string{}
|
|
||||||
for _, v := range columns {
|
|
||||||
//logger.SugaredLogger.Infof("v:%+v", v)
|
|
||||||
d := v.(map[string]any)
|
|
||||||
//logger.SugaredLogger.Infof("key:%s title:%s dateMsg:%s unit:%s", d["key"], d["title"], d["dateMsg"], d["unit"])
|
|
||||||
title := convertor.ToString(d["title"])
|
|
||||||
if convertor.ToString(d["dateMsg"]) != "" {
|
|
||||||
title = title + "[" + convertor.ToString(d["dateMsg"]) + "]"
|
|
||||||
}
|
|
||||||
if convertor.ToString(d["unit"]) != "" {
|
|
||||||
title = title + "(" + convertor.ToString(d["unit"]) + ")"
|
|
||||||
}
|
|
||||||
headers[d["key"].(string)] = title
|
|
||||||
}
|
|
||||||
table := &[]map[string]any{}
|
|
||||||
for _, v := range dataList {
|
|
||||||
d := v.(map[string]any)
|
|
||||||
tmp := map[string]any{}
|
|
||||||
for key, title := range headers {
|
|
||||||
tmp[title] = convertor.ToString(d[key])
|
|
||||||
}
|
|
||||||
*table = append(*table, tmp)
|
|
||||||
}
|
|
||||||
jsonData, _ := json.Marshal(*table)
|
|
||||||
markdownTable, _ := JSONToMarkdownTable(jsonData)
|
|
||||||
//logger.SugaredLogger.Infof("markdownTable=\n%s", markdownTable)
|
|
||||||
content = "\r\n### 工具筛选出的股票数据:\r\n" + markdownTable + "\r\n"
|
|
||||||
}
|
|
||||||
logger.SugaredLogger.Infof("SearchStockByIndicators:words:%s --> \n%s", words, content)
|
|
||||||
|
|
||||||
messages = append(messages, map[string]interface{}{
|
|
||||||
"role": "assistant",
|
|
||||||
"content": currentAIContent.String(),
|
|
||||||
"tool_calls": []map[string]any{
|
|
||||||
{
|
|
||||||
"id": currentCallId,
|
|
||||||
"tool_call_id": currentCallId,
|
|
||||||
"type": "function",
|
|
||||||
"function": map[string]string{
|
|
||||||
"name": funcName,
|
|
||||||
"arguments": funcArguments,
|
|
||||||
"parameters": funcArguments,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
messages = append(messages, map[string]interface{}{
|
|
||||||
"role": "tool",
|
|
||||||
"content": content,
|
|
||||||
"tool_call_id": currentCallId,
|
|
||||||
})
|
|
||||||
|
|
||||||
//ch <- map[string]any{
|
|
||||||
// "code": 1,
|
|
||||||
// "question": question,
|
|
||||||
// "chatId": streamResponse.Id,
|
|
||||||
// "model": streamResponse.Model,
|
|
||||||
// "content": "\r\n```\r\n调用工具:SearchStockByIndicators,\n结果:" + content + "\r\n```\r\n",
|
|
||||||
// "time": time.Now().Format(time.DateTime),
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if funcName == "GetStockKLine" {
|
|
||||||
stockCode := gjson.Get(funcArguments, "stockCode").String()
|
|
||||||
days := gjson.Get(funcArguments, "days").String()
|
|
||||||
ch <- map[string]any{
|
|
||||||
"code": 1,
|
|
||||||
"question": question,
|
|
||||||
"chatId": streamResponse.Id,
|
|
||||||
"model": streamResponse.Model,
|
|
||||||
"content": "\r\n```\r\n开始调用工具:GetStockKLine,\n参数:" + stockCode + "," + days + "\r\n```\r\n",
|
|
||||||
"time": time.Now().Format(time.DateTime),
|
|
||||||
}
|
|
||||||
toIntDay, err := convertor.ToInt(days)
|
|
||||||
if err != nil {
|
|
||||||
toIntDay = 90
|
|
||||||
}
|
|
||||||
|
|
||||||
if strutil.HasPrefixAny(stockCode, []string{"sz", "sh", "hk", "us", "gb_"}) {
|
|
||||||
K := &[]KLineData{}
|
|
||||||
if strutil.HasPrefixAny(stockCode, []string{"sz", "sh"}) {
|
|
||||||
K = NewStockDataApi().GetKLineData(stockCode, "240", o.KDays)
|
|
||||||
}
|
|
||||||
if strutil.HasPrefixAny(stockCode, []string{"hk", "us", "gb_"}) {
|
|
||||||
K = NewStockDataApi().GetHK_KLineData(stockCode, "day", o.KDays)
|
|
||||||
}
|
|
||||||
Kmap := &[]map[string]any{}
|
|
||||||
for _, kline := range *K {
|
|
||||||
mapk := make(map[string]any, 6)
|
|
||||||
mapk["日期"] = kline.Day
|
|
||||||
mapk["开盘价"] = kline.Open
|
|
||||||
mapk["最高价"] = kline.High
|
|
||||||
mapk["最低价"] = kline.Low
|
|
||||||
mapk["收盘价"] = kline.Close
|
|
||||||
Volume, _ := convertor.ToFloat(kline.Volume)
|
|
||||||
mapk["成交量(万手)"] = Volume / 10000.00 / 100.00
|
|
||||||
*Kmap = append(*Kmap, mapk)
|
|
||||||
}
|
|
||||||
jsonData, _ := json.Marshal(Kmap)
|
|
||||||
markdownTable, _ := JSONToMarkdownTable(jsonData)
|
|
||||||
logger.SugaredLogger.Infof("getKLineData=\n%s", markdownTable)
|
|
||||||
|
|
||||||
messages = append(messages, map[string]interface{}{
|
|
||||||
"role": "assistant",
|
|
||||||
"content": currentAIContent.String(),
|
|
||||||
"tool_calls": []map[string]any{
|
|
||||||
{
|
|
||||||
"id": currentCallId,
|
|
||||||
"tool_call_id": currentCallId,
|
|
||||||
"type": "function",
|
|
||||||
"function": map[string]string{
|
|
||||||
"name": funcName,
|
|
||||||
"arguments": funcArguments,
|
|
||||||
"parameters": funcArguments,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
res := "\r\n ### " + stockCode + convertor.ToString(toIntDay) + "日K线数据:\r\n" + markdownTable + "\r\n"
|
|
||||||
messages = append(messages, map[string]interface{}{
|
|
||||||
"role": "tool",
|
|
||||||
"content": res,
|
|
||||||
"tool_call_id": currentCallId,
|
|
||||||
})
|
|
||||||
logger.SugaredLogger.Infof("GetStockKLine:stockCode:%s days:%s --> \n%s", stockCode, days, res)
|
|
||||||
|
|
||||||
//ch <- map[string]any{
|
|
||||||
// "code": 1,
|
|
||||||
// "question": question,
|
|
||||||
// "chatId": streamResponse.Id,
|
|
||||||
// "model": streamResponse.Model,
|
|
||||||
// "content": "\r\n```\r\n调用工具:GetStockKLine,\n结果:" + res + "\r\n```\r\n",
|
|
||||||
// "time": time.Now().Format(time.DateTime),
|
|
||||||
//}
|
|
||||||
} else {
|
|
||||||
messages = append(messages, map[string]interface{}{
|
|
||||||
"role": "assistant",
|
|
||||||
"content": currentAIContent.String(),
|
|
||||||
"tool_calls": []map[string]any{
|
|
||||||
{
|
|
||||||
"id": currentCallId,
|
|
||||||
"tool_call_id": currentCallId,
|
|
||||||
"type": "function",
|
|
||||||
"function": map[string]string{
|
|
||||||
"name": funcName,
|
|
||||||
"arguments": funcArguments,
|
|
||||||
"parameters": funcArguments,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
messages = append(messages, map[string]interface{}{
|
|
||||||
"role": "tool",
|
|
||||||
"content": "无数据,可能股票代码错误。(A股:sh,sz开头;港股hk开头,美股:us开头)",
|
|
||||||
"tool_call_id": currentCallId,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
AskAiWithTools(o, err, messages, ch, question, tools)
|
|
||||||
}
|
|
||||||
|
|
||||||
if choice.FinishReason == "stop" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Infof("Stream data error : %s", err.Error())
|
|
||||||
//ch <- err.Error()
|
|
||||||
ch <- map[string]any{
|
|
||||||
"code": 0,
|
|
||||||
"question": question,
|
|
||||||
"content": err.Error(),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.SugaredLogger.Infof("Stream data error : %s", data)
|
|
||||||
//ch <- data
|
|
||||||
ch <- map[string]any{
|
|
||||||
"code": 0,
|
|
||||||
"question": question,
|
|
||||||
"content": data,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if strutil.RemoveNonPrintable(line) != "" {
|
|
||||||
logger.SugaredLogger.Infof("Stream data error : %s", line)
|
|
||||||
res := &models.Resp{}
|
|
||||||
if err := json.Unmarshal([]byte(line), res); err == nil {
|
|
||||||
//ch <- line
|
|
||||||
msg := res.Message
|
|
||||||
if res.Error.Message != "" {
|
|
||||||
msg = res.Error.Message
|
|
||||||
}
|
|
||||||
|
|
||||||
if msg == "Function call is not supported for this model." {
|
|
||||||
var newMessages []map[string]any
|
|
||||||
for _, message := range messages {
|
|
||||||
if message["role"] == "tool" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if _, ok := message["tool_calls"]; ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
newMessages = append(newMessages, message)
|
|
||||||
}
|
|
||||||
AskAi(o, err, newMessages, ch, question)
|
|
||||||
} else {
|
|
||||||
ch <- map[string]any{
|
|
||||||
"code": 0,
|
|
||||||
"question": question,
|
|
||||||
"content": msg,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func checkIsIndexBasic(stock string) bool {
|
func checkIsIndexBasic(stock string) bool {
|
||||||
count := int64(0)
|
count := int64(0)
|
||||||
db.Dao.Model(&IndexBasic{}).Where("name = ?", stock).Count(&count)
|
db.Dao.Model(&IndexBasic{}).Where("name = ?", stock).Count(&count)
|
||||||
|
@ -8,39 +8,12 @@ import (
|
|||||||
|
|
||||||
func TestNewDeepSeekOpenAiConfig(t *testing.T) {
|
func TestNewDeepSeekOpenAiConfig(t *testing.T) {
|
||||||
db.Init("../../data/stock.db")
|
db.Init("../../data/stock.db")
|
||||||
|
|
||||||
var tools []Tool
|
|
||||||
tools = append(tools, Tool{
|
|
||||||
Type: "function",
|
|
||||||
Function: ToolFunction{
|
|
||||||
Name: "SearchStockByIndicators",
|
|
||||||
Description: "根据自然语言筛选股票,返回自然语言选股条件要求的股票所有相关数据",
|
|
||||||
Parameters: FunctionParameters{
|
|
||||||
Type: "object",
|
|
||||||
Properties: map[string]any{
|
|
||||||
"words": map[string]any{
|
|
||||||
"type": "string",
|
|
||||||
"description": "选股自然语言,并且条件使用;分隔,或者条件使用,分隔。例如:创新药;PE<30;净利润增长率>50%;",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Required: []string{"words"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
ai := NewDeepSeekOpenAi(context.TODO())
|
ai := NewDeepSeekOpenAi(context.TODO())
|
||||||
//res := ai.NewChatStream("长电科技", "sh600584", "长电科技分析和总结", nil)
|
res := ai.NewChatStream("长电科技", "sh600584", "长电科技分析和总结", nil)
|
||||||
res := ai.NewSummaryStockNewsStreamWithTools("总结市场资讯,发掘潜力标的/行业/板块/概念,控制风险。调用工具函数验证", nil, tools)
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case msg := <-res:
|
case msg := <-res:
|
||||||
if len(msg) > 0 {
|
t.Log(msg)
|
||||||
t.Log(msg)
|
|
||||||
if msg["content"] == "DONE" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ type SearchStockApi struct {
|
|||||||
func NewSearchStockApi(words string) *SearchStockApi {
|
func NewSearchStockApi(words string) *SearchStockApi {
|
||||||
return &SearchStockApi{words: words}
|
return &SearchStockApi{words: words}
|
||||||
}
|
}
|
||||||
func (s SearchStockApi) SearchStock(pageSize int) map[string]any {
|
func (s SearchStockApi) SearchStock() map[string]any {
|
||||||
url := "https://np-tjxg-g.eastmoney.com/api/smart-tag/stock/v3/pw/search-code"
|
url := "https://np-tjxg-g.eastmoney.com/api/smart-tag/stock/v3/pw/search-code"
|
||||||
resp, err := resty.New().SetTimeout(time.Duration(30)*time.Second).R().
|
resp, err := resty.New().SetTimeout(time.Duration(30)*time.Second).R().
|
||||||
SetHeader("Host", "np-tjxg-g.eastmoney.com").
|
SetHeader("Host", "np-tjxg-g.eastmoney.com").
|
||||||
@ -29,7 +29,7 @@ func (s SearchStockApi) SearchStock(pageSize int) map[string]any {
|
|||||||
SetHeader("Content-Type", "application/json").
|
SetHeader("Content-Type", "application/json").
|
||||||
SetBody(fmt.Sprintf(`{
|
SetBody(fmt.Sprintf(`{
|
||||||
"keyWord": "%s",
|
"keyWord": "%s",
|
||||||
"pageSize": %d,
|
"pageSize": 50000,
|
||||||
"pageNo": 1,
|
"pageNo": 1,
|
||||||
"fingerprint": "e38b5faabf9378c8238e57219f0ebc9b",
|
"fingerprint": "e38b5faabf9378c8238e57219f0ebc9b",
|
||||||
"gids": [],
|
"gids": [],
|
||||||
@ -43,7 +43,7 @@ func (s SearchStockApi) SearchStock(pageSize int) map[string]any {
|
|||||||
"ownSelectAll": false,
|
"ownSelectAll": false,
|
||||||
"dxInfo": [],
|
"dxInfo": [],
|
||||||
"extraCondition": ""
|
"extraCondition": ""
|
||||||
}`, s.words, pageSize)).Post(url)
|
}`, s.words)).Post(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.SugaredLogger.Errorf("SearchStock-err:%+v", err)
|
logger.SugaredLogger.Errorf("SearchStock-err:%+v", err)
|
||||||
return map[string]any{}
|
return map[string]any{}
|
||||||
@ -53,20 +53,3 @@ func (s SearchStockApi) SearchStock(pageSize int) map[string]any {
|
|||||||
//logger.SugaredLogger.Infof("resp:%+v", respMap["data"])
|
//logger.SugaredLogger.Infof("resp:%+v", respMap["data"])
|
||||||
return respMap
|
return respMap
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SearchStockApi) HotStrategy() map[string]any {
|
|
||||||
url := fmt.Sprintf("https://np-ipick.eastmoney.com/recommend/stock/heat/ranking?count=20&trace=%d&client=web&biz=web_smart_tag", time.Now().Unix())
|
|
||||||
resp, err := resty.New().SetTimeout(time.Duration(30)*time.Second).R().
|
|
||||||
SetHeader("Host", "np-ipick.eastmoney.com").
|
|
||||||
SetHeader("Origin", "https://xuangu.eastmoney.com").
|
|
||||||
SetHeader("Referer", "https://xuangu.eastmoney.com/").
|
|
||||||
SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0").
|
|
||||||
Get(url)
|
|
||||||
if err != nil {
|
|
||||||
logger.SugaredLogger.Errorf("HotStrategy-err:%+v", err)
|
|
||||||
return map[string]any{}
|
|
||||||
}
|
|
||||||
respMap := map[string]any{}
|
|
||||||
json.Unmarshal(resp.Body(), &respMap)
|
|
||||||
return respMap
|
|
||||||
}
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package data
|
package data
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"github.com/duke-git/lancet/v2/convertor"
|
|
||||||
"go-stock/backend/db"
|
"go-stock/backend/db"
|
||||||
"go-stock/backend/logger"
|
"go-stock/backend/logger"
|
||||||
"testing"
|
"testing"
|
||||||
@ -11,49 +9,17 @@ import (
|
|||||||
func TestSearchStock(t *testing.T) {
|
func TestSearchStock(t *testing.T) {
|
||||||
db.Init("../../data/stock.db")
|
db.Init("../../data/stock.db")
|
||||||
|
|
||||||
res := NewSearchStockApi("算力股;净利润连续3年增长").SearchStock(10)
|
res := NewSearchStockApi("算力股;净利润连续3年增长").SearchStock()
|
||||||
data := res["data"].(map[string]any)
|
data := res["data"].(map[string]any)
|
||||||
result := data["result"].(map[string]any)
|
result := data["result"].(map[string]any)
|
||||||
dataList := result["dataList"].([]any)
|
dataList := result["dataList"].([]any)
|
||||||
columns := result["columns"].([]any)
|
|
||||||
headers := map[string]string{}
|
|
||||||
for _, v := range columns {
|
|
||||||
//logger.SugaredLogger.Infof("v:%+v", v)
|
|
||||||
d := v.(map[string]any)
|
|
||||||
//logger.SugaredLogger.Infof("key:%s title:%s dateMsg:%s unit:%s", d["key"], d["title"], d["dateMsg"], d["unit"])
|
|
||||||
title := convertor.ToString(d["title"])
|
|
||||||
if convertor.ToString(d["dateMsg"]) != "" {
|
|
||||||
title = title + "[" + convertor.ToString(d["dateMsg"]) + "]"
|
|
||||||
}
|
|
||||||
if convertor.ToString(d["unit"]) != "" {
|
|
||||||
title = title + "(" + convertor.ToString(d["unit"]) + ")"
|
|
||||||
}
|
|
||||||
headers[d["key"].(string)] = title
|
|
||||||
}
|
|
||||||
table := &[]map[string]any{}
|
|
||||||
for _, v := range dataList {
|
for _, v := range dataList {
|
||||||
//logger.SugaredLogger.Infof("v:%+v", v)
|
|
||||||
d := v.(map[string]any)
|
d := v.(map[string]any)
|
||||||
tmp := map[string]any{}
|
logger.SugaredLogger.Infof("%s:%s", d["INDUSTRY"], d["SECURITY_SHORT_NAME"])
|
||||||
for key, title := range headers {
|
|
||||||
//logger.SugaredLogger.Infof("%s:%s", title, convertor.ToString(d[key]))
|
|
||||||
tmp[title] = convertor.ToString(d[key])
|
|
||||||
}
|
|
||||||
*table = append(*table, tmp)
|
|
||||||
//logger.SugaredLogger.Infof("--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------")
|
|
||||||
}
|
}
|
||||||
jsonData, _ := json.Marshal(*table)
|
//columns := result["columns"].([]any)
|
||||||
markdownTable, _ := JSONToMarkdownTable(jsonData)
|
//for _, v := range columns {
|
||||||
logger.SugaredLogger.Infof("markdownTable=\n%s", markdownTable)
|
// logger.SugaredLogger.Infof("v:%+v", v)
|
||||||
}
|
//}
|
||||||
|
|
||||||
func TestSearchStockApi_HotStrategy(t *testing.T) {
|
|
||||||
db.Init("../../data/stock.db")
|
|
||||||
res := NewSearchStockApi("").HotStrategy()
|
|
||||||
logger.SugaredLogger.Infof("res:%+v", res)
|
|
||||||
dataList := res["data"].([]any)
|
|
||||||
for _, v := range dataList {
|
|
||||||
d := v.(map[string]any)
|
|
||||||
logger.SugaredLogger.Infof("v:%+v", d)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,6 @@ type Settings struct {
|
|||||||
BrowserPoolSize int `json:"browserPoolSize"`
|
BrowserPoolSize int `json:"browserPoolSize"`
|
||||||
EnableFund bool `json:"enableFund"`
|
EnableFund bool `json:"enableFund"`
|
||||||
EnablePushNews bool `json:"enablePushNews"`
|
EnablePushNews bool `json:"enablePushNews"`
|
||||||
SponsorCode string `json:"sponsorCode"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (receiver Settings) TableName() string {
|
func (receiver Settings) TableName() string {
|
||||||
@ -81,7 +80,6 @@ func (s SettingsApi) UpdateConfig() string {
|
|||||||
"dark_theme": s.Config.DarkTheme,
|
"dark_theme": s.Config.DarkTheme,
|
||||||
"enable_fund": s.Config.EnableFund,
|
"enable_fund": s.Config.EnableFund,
|
||||||
"enable_push_news": s.Config.EnablePushNews,
|
"enable_push_news": s.Config.EnablePushNews,
|
||||||
"sponsor_code": s.Config.SponsorCode,
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
logger.SugaredLogger.Infof("未找到配置,创建默认配置:%+v", s.Config)
|
logger.SugaredLogger.Infof("未找到配置,创建默认配置:%+v", s.Config)
|
||||||
@ -110,7 +108,6 @@ func (s SettingsApi) UpdateConfig() string {
|
|||||||
DarkTheme: s.Config.DarkTheme,
|
DarkTheme: s.Config.DarkTheme,
|
||||||
EnableFund: s.Config.EnableFund,
|
EnableFund: s.Config.EnableFund,
|
||||||
EnablePushNews: s.Config.EnablePushNews,
|
EnablePushNews: s.Config.EnablePushNews,
|
||||||
SponsorCode: s.Config.SponsorCode,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return "保存成功!"
|
return "保存成功!"
|
||||||
@ -131,7 +128,7 @@ func (s SettingsApi) GetConfig() *Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if settings.BrowserPath == "" {
|
if settings.BrowserPath == "" {
|
||||||
settings.BrowserPath, _ = CheckBrowser()
|
settings.BrowserPath, _ = CheckBrowserOnWindows()
|
||||||
}
|
}
|
||||||
if settings.BrowserPoolSize <= 0 {
|
if settings.BrowserPoolSize <= 0 {
|
||||||
settings.BrowserPoolSize = 1
|
settings.BrowserPoolSize = 1
|
||||||
|
@ -20,6 +20,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"
|
||||||
"golang.org/x/text/encoding/simplifiedchinese"
|
"golang.org/x/text/encoding/simplifiedchinese"
|
||||||
"golang.org/x/text/transform"
|
"golang.org/x/text/transform"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
@ -1297,6 +1298,50 @@ func SearchStockInfoByCode(stock string) *[]string {
|
|||||||
return &messages
|
return &messages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// checkChromeOnWindows 在 Windows 系统上检查谷歌浏览器是否安装
|
||||||
|
func checkChromeOnWindows() (string, 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()
|
||||||
|
path, _, err := key.GetStringValue("Path")
|
||||||
|
//logger.SugaredLogger.Infof("Chrome安装路径:%s", path)
|
||||||
|
if err != nil {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
return path + "\\chrome.exe", true
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckBrowserOnWindows 在 Windows 系统上检查Edge浏览器是否安装,并返回安装路径
|
||||||
|
func CheckBrowserOnWindows() (string, bool) {
|
||||||
|
if path, ok := checkChromeOnWindows(); ok {
|
||||||
|
return path, true
|
||||||
|
}
|
||||||
|
|
||||||
|
key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe`, registry.QUERY_VALUE)
|
||||||
|
if err != nil {
|
||||||
|
// 尝试在 WOW6432Node 中查找(适用于 64 位系统上的 32 位程序)
|
||||||
|
key, err = registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe`, registry.QUERY_VALUE)
|
||||||
|
if err != nil {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
defer key.Close()
|
||||||
|
}
|
||||||
|
defer key.Close()
|
||||||
|
path, _, err := key.GetStringValue("Path")
|
||||||
|
//logger.SugaredLogger.Infof("Edge安装路径:%s", path)
|
||||||
|
if err != nil {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
return path + "\\msedge.exe", true
|
||||||
|
}
|
||||||
|
|
||||||
// 分时数据
|
// 分时数据
|
||||||
func (receiver StockDataApi) GetStockMinutePriceData(stockCode string) (*[]MinuteData, string) {
|
func (receiver StockDataApi) GetStockMinutePriceData(stockCode string) (*[]MinuteData, string) {
|
||||||
url := fmt.Sprintf("https://web.ifzq.gtimg.cn/appstock/app/minute/query?code=%s", stockCode)
|
url := fmt.Sprintf("https://web.ifzq.gtimg.cn/appstock/app/minute/query?code=%s", stockCode)
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
//go:build darwin
|
|
||||||
// +build darwin
|
|
||||||
|
|
||||||
package data
|
|
||||||
|
|
||||||
import "os"
|
|
||||||
|
|
||||||
// CheckChrome 检查 macOS 是否安装了 Chrome 浏览器
|
|
||||||
func CheckChrome() (string, bool) {
|
|
||||||
// 检查 /Applications 目录下是否存在 Chrome
|
|
||||||
locations := []string{
|
|
||||||
// Mac
|
|
||||||
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
||||||
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
||||||
}
|
|
||||||
path := ""
|
|
||||||
for _, location := range locations {
|
|
||||||
_, err := os.Stat(location)
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
path = location
|
|
||||||
}
|
|
||||||
if path == "" {
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
|
|
||||||
return path, true
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckBrowser 检查 macOS 是否安装了浏览器,并返回安装路径
|
|
||||||
func CheckBrowser() (string, bool) {
|
|
||||||
if path, ok := CheckChrome(); ok {
|
|
||||||
return path, ok
|
|
||||||
}
|
|
||||||
return "", false
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
//go:build windows
|
|
||||||
// +build windows
|
|
||||||
|
|
||||||
package data
|
|
||||||
|
|
||||||
import "golang.org/x/sys/windows/registry"
|
|
||||||
|
|
||||||
// CheckChrome 在 Windows 系统上检查谷歌浏览器是否安装
|
|
||||||
func CheckChrome() (string, 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()
|
|
||||||
path, _, err := key.GetStringValue("Path")
|
|
||||||
//logger.SugaredLogger.Infof("Chrome安装路径:%s", path)
|
|
||||||
if err != nil {
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
return path + "\\chrome.exe", true
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckBrowser 在 Windows 系统上检查Edge浏览器是否安装,并返回安装路径
|
|
||||||
func CheckBrowser() (string, bool) {
|
|
||||||
if path, ok := CheckChrome(); ok {
|
|
||||||
return path, true
|
|
||||||
}
|
|
||||||
|
|
||||||
key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe`, registry.QUERY_VALUE)
|
|
||||||
if err != nil {
|
|
||||||
// 尝试在 WOW6432Node 中查找(适用于 64 位系统上的 32 位程序)
|
|
||||||
key, err = registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe`, registry.QUERY_VALUE)
|
|
||||||
if err != nil {
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
defer key.Close()
|
|
||||||
}
|
|
||||||
defer key.Close()
|
|
||||||
path, _, err := key.GetStringValue("Path")
|
|
||||||
//logger.SugaredLogger.Infof("Edge安装路径:%s", path)
|
|
||||||
if err != nil {
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
return path + "\\msedge.exe", true
|
|
||||||
}
|
|
@ -150,15 +150,13 @@ func (receiver AIResponseResult) TableName() string {
|
|||||||
|
|
||||||
type VersionInfo struct {
|
type VersionInfo struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
Icon string `json:"icon"`
|
Icon string `json:"icon"`
|
||||||
Alipay string `json:"alipay"`
|
Alipay string `json:"alipay"`
|
||||||
Wxpay string `json:"wxpay"`
|
Wxpay string `json:"wxpay"`
|
||||||
Wxgzh string `json:"wxgzh"`
|
BuildTimeStamp int64 `json:"buildTimeStamp"`
|
||||||
BuildTimeStamp int64 `json:"buildTimeStamp"`
|
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag"`
|
||||||
OfficialStatement string `json:"officialStatement"`
|
|
||||||
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (receiver VersionInfo) TableName() string {
|
func (receiver VersionInfo) TableName() string {
|
||||||
@ -196,12 +194,6 @@ func (receiver StockInfoUS) TableName() string {
|
|||||||
type Resp struct {
|
type Resp struct {
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Error struct {
|
|
||||||
Code string `json:"code"`
|
|
||||||
Message string `json:"message"`
|
|
||||||
Param string `json:"param"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
} `json:"error"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PromptTemplate struct {
|
type PromptTemplate struct {
|
||||||
@ -370,94 +362,3 @@ type HotEvent struct {
|
|||||||
StatusCount int `json:"status_count"`
|
StatusCount int `json:"status_count"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GDP struct {
|
|
||||||
REPORTDATE string `json:"REPORT_DATE" md:"报告时间"`
|
|
||||||
TIME string `json:"TIME" md:"报告期"`
|
|
||||||
DOMESTICLPRODUCTBASE float64 `json:"DOMESTICL_PRODUCT_BASE" md:"国内生产总值(亿元)"`
|
|
||||||
SUMSAME float64 `json:"SUM_SAME" md:"国内生产总值同比增长(%)"`
|
|
||||||
FIRSTPRODUCTBASE float64 `json:"FIRST_PRODUCT_BASE" md:"第一产业(亿元)"`
|
|
||||||
FIRSTSAME int `json:"FIRST_SAME" md:"第一产业同比增长(%)"`
|
|
||||||
SECONDPRODUCTBASE float64 `json:"SECOND_PRODUCT_BASE" md:"第二产业(亿元)"`
|
|
||||||
SECONDSAME float64 `json:"SECOND_SAME" md:"第二产业同比增长(%)"`
|
|
||||||
THIRDPRODUCTBASE float64 `json:"THIRD_PRODUCT_BASE" md:"第三产业(亿元)"`
|
|
||||||
THIRDSAME float64 `json:"THIRD_SAME" md:"第三产业同比增长(%)"`
|
|
||||||
}
|
|
||||||
type CPI struct {
|
|
||||||
REPORTDATE string `json:"REPORT_DATE" md:"报告时间"`
|
|
||||||
TIME string `json:"TIME" md:"报告期"`
|
|
||||||
NATIONALBASE float64 `json:"NATIONAL_BASE" md:"全国当月"`
|
|
||||||
NATIONALSAME float64 `json:"NATIONAL_SAME" md:"全国当月同比增长(%)"`
|
|
||||||
NATIONALSEQUENTIAL float64 `json:"NATIONAL_SEQUENTIAL" md:"全国当月环比增长(%)"`
|
|
||||||
NATIONALACCUMULATE float64 `json:"NATIONAL_ACCUMULATE" md:"全国当月累计"`
|
|
||||||
CITYBASE float64 `json:"CITY_BASE" md:"城市当月"`
|
|
||||||
CITYSAME float64 `json:"CITY_SAME" md:"城市当月同比增长(%)"`
|
|
||||||
CITYSEQUENTIAL float64 `json:"CITY_SEQUENTIAL" md:"城市当月环比增长(%)"`
|
|
||||||
CITYACCUMULATE int `json:"CITY_ACCUMULATE" md:"城市当月累计"`
|
|
||||||
RURALBASE float64 `json:"RURAL_BASE" md:"农村当月"`
|
|
||||||
RURALSAME float64 `json:"RURAL_SAME" md:"农村当月同比增长(%)"`
|
|
||||||
RURALSEQUENTIAL int `json:"RURAL_SEQUENTIAL" md:"农村当月环比增长(%)"`
|
|
||||||
RURALACCUMULATE float64 `json:"RURAL_ACCUMULATE" md:"农村当月累计"`
|
|
||||||
}
|
|
||||||
type PPI struct {
|
|
||||||
REPORTDATE string `json:"REPORT_DATE" md:"报告时间"`
|
|
||||||
TIME string `json:"TIME" md:"报告期"`
|
|
||||||
BASE float64 `json:"BASE" md:"当月"`
|
|
||||||
BASESAME float64 `json:"BASE_SAME" md:"当月同比增长(%)"`
|
|
||||||
BASEACCUMULATE float64 `json:"BASE_ACCUMULATE" md:"累计"`
|
|
||||||
}
|
|
||||||
type PMI struct {
|
|
||||||
REPORTDATE string `md:"报告时间" json:"REPORT_DATE"`
|
|
||||||
TIME string `md:"报告期" json:"TIME"`
|
|
||||||
MAKEINDEX float64 `md:"制造业指数" json:"MAKE_INDEX"`
|
|
||||||
MAKESAME float64 `md:"制造业指数同比增长(%)" json:"MAKE_SAME"`
|
|
||||||
NMAKEINDEX float64 `md:"非制造业" json:"NMAKE_INDEX"`
|
|
||||||
NMAKESAME float64 `md:"非制造业同比增长(%)" json:"NMAKE_SAME"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DCResp struct {
|
|
||||||
Version string `json:"version"`
|
|
||||||
Success bool `json:"success"`
|
|
||||||
Message string `json:"message"`
|
|
||||||
Code int `json:"code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GDPResult struct {
|
|
||||||
Pages int `json:"pages"`
|
|
||||||
Data []GDP `json:"data"`
|
|
||||||
Count int `json:"count"`
|
|
||||||
}
|
|
||||||
type CPIResult struct {
|
|
||||||
Pages int `json:"pages"`
|
|
||||||
Data []CPI `json:"data"`
|
|
||||||
Count int `json:"count"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PPIResult struct {
|
|
||||||
Pages int `json:"pages"`
|
|
||||||
Data []PPI `json:"data"`
|
|
||||||
Count int `json:"count"`
|
|
||||||
}
|
|
||||||
type PMIResult struct {
|
|
||||||
Pages int `json:"pages"`
|
|
||||||
Data []PMI `json:"data"`
|
|
||||||
Count int `json:"count"`
|
|
||||||
}
|
|
||||||
type GDPResp struct {
|
|
||||||
DCResp
|
|
||||||
GDPResult GDPResult `json:"result"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type CPIResp struct {
|
|
||||||
DCResp
|
|
||||||
CPIResult CPIResult `json:"result"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PPIResp struct {
|
|
||||||
DCResp
|
|
||||||
PPIResult PPIResult `json:"result"`
|
|
||||||
}
|
|
||||||
type PMIResp struct {
|
|
||||||
DCResp
|
|
||||||
PMIResult PMIResult `json:"result"`
|
|
||||||
}
|
|
||||||
|
@ -1,284 +0,0 @@
|
|||||||
package util
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"reflect"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
// MarkdownTable 生成结构体或结构体切片的Markdown表格表示
|
|
||||||
func MarkdownTable(v interface{}) string {
|
|
||||||
value := reflect.ValueOf(v)
|
|
||||||
if value.Kind() == reflect.Ptr {
|
|
||||||
value = value.Elem()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理单个结构体
|
|
||||||
if value.Kind() == reflect.Struct {
|
|
||||||
return markdownSingleStruct(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理结构体切片/数组
|
|
||||||
if value.Kind() == reflect.Slice || value.Kind() == reflect.Array {
|
|
||||||
if value.Len() == 0 {
|
|
||||||
return "切片/数组为空"
|
|
||||||
}
|
|
||||||
return markdownStructSlice(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
return "输入必须是结构体、结构体指针、结构体切片或数组"
|
|
||||||
}
|
|
||||||
|
|
||||||
func MarkdownTableWithTitle(title string, v interface{}) string {
|
|
||||||
value := reflect.ValueOf(v)
|
|
||||||
if value.Kind() == reflect.Ptr {
|
|
||||||
value = value.Elem()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理单个结构体
|
|
||||||
if value.Kind() == reflect.Struct {
|
|
||||||
return markdownSingleStruct(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理结构体切片/数组
|
|
||||||
if value.Kind() == reflect.Slice || value.Kind() == reflect.Array {
|
|
||||||
if value.Len() == 0 {
|
|
||||||
return "\n## " + title + "\n" + "无数据" + "\n"
|
|
||||||
}
|
|
||||||
return "\n## " + title + "\n" + markdownStructSlice(value) + "\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
return "\n## " + title + "\n" + "无数据" + "\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理单个结构体
|
|
||||||
func markdownSingleStruct(value reflect.Value) string {
|
|
||||||
t := value.Type()
|
|
||||||
var b strings.Builder
|
|
||||||
|
|
||||||
// 表头
|
|
||||||
b.WriteString("|")
|
|
||||||
for i := 0; i < t.NumField(); i++ {
|
|
||||||
field := t.Field(i)
|
|
||||||
if shouldSkip(field) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
b.WriteString(fmt.Sprintf(" %s |", getFieldName(field)))
|
|
||||||
}
|
|
||||||
b.WriteString("\n")
|
|
||||||
|
|
||||||
// 分隔线
|
|
||||||
b.WriteString("|")
|
|
||||||
for i := 0; i < t.NumField(); i++ {
|
|
||||||
field := t.Field(i)
|
|
||||||
if shouldSkip(field) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
b.WriteString(" --- |")
|
|
||||||
}
|
|
||||||
b.WriteString("\n")
|
|
||||||
|
|
||||||
// 数据行
|
|
||||||
b.WriteString("|")
|
|
||||||
for i := 0; i < t.NumField(); i++ {
|
|
||||||
field := t.Field(i)
|
|
||||||
if shouldSkip(field) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
fieldValue := value.Field(i)
|
|
||||||
b.WriteString(fmt.Sprintf(" %s |", formatValue(fieldValue)))
|
|
||||||
}
|
|
||||||
b.WriteString("\n")
|
|
||||||
|
|
||||||
return b.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理结构体切片/数组
|
|
||||||
func markdownStructSlice(value reflect.Value) string {
|
|
||||||
if value.Len() == 0 {
|
|
||||||
return "切片/数组为空"
|
|
||||||
}
|
|
||||||
|
|
||||||
firstElem := value.Index(0)
|
|
||||||
if firstElem.Kind() == reflect.Ptr {
|
|
||||||
firstElem = firstElem.Elem()
|
|
||||||
}
|
|
||||||
if firstElem.Kind() != reflect.Struct {
|
|
||||||
return "切片/数组元素必须是结构体或结构体指针"
|
|
||||||
}
|
|
||||||
|
|
||||||
t := firstElem.Type()
|
|
||||||
var b strings.Builder
|
|
||||||
|
|
||||||
// 表头
|
|
||||||
b.WriteString("|")
|
|
||||||
for i := 0; i < t.NumField(); i++ {
|
|
||||||
field := t.Field(i)
|
|
||||||
if shouldSkip(field) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
b.WriteString(fmt.Sprintf(" %s |", getFieldName(field)))
|
|
||||||
}
|
|
||||||
b.WriteString("\n")
|
|
||||||
|
|
||||||
// 分隔线
|
|
||||||
b.WriteString("|")
|
|
||||||
for i := 0; i < t.NumField(); i++ {
|
|
||||||
field := t.Field(i)
|
|
||||||
if shouldSkip(field) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
b.WriteString(" --- |")
|
|
||||||
}
|
|
||||||
b.WriteString("\n")
|
|
||||||
|
|
||||||
// 多行数据
|
|
||||||
for i := 0; i < value.Len(); i++ {
|
|
||||||
elem := value.Index(i)
|
|
||||||
if elem.Kind() == reflect.Ptr {
|
|
||||||
elem = elem.Elem()
|
|
||||||
}
|
|
||||||
|
|
||||||
b.WriteString("|")
|
|
||||||
for j := 0; j < t.NumField(); j++ {
|
|
||||||
field := t.Field(j)
|
|
||||||
if shouldSkip(field) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
fieldValue := elem.Field(j)
|
|
||||||
b.WriteString(fmt.Sprintf(" %s |", formatValue(fieldValue)))
|
|
||||||
}
|
|
||||||
b.WriteString("\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
return b.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 判断是否应该跳过该字段
|
|
||||||
func shouldSkip(field reflect.StructField) bool {
|
|
||||||
return field.Tag.Get("md") == "-"
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取字段的Markdown表头名称
|
|
||||||
func getFieldName(field reflect.StructField) string {
|
|
||||||
name := field.Tag.Get("md")
|
|
||||||
if name == "" || name == "-" {
|
|
||||||
return field.Name
|
|
||||||
}
|
|
||||||
return name
|
|
||||||
}
|
|
||||||
|
|
||||||
// 格式化字段值为字符串
|
|
||||||
func formatValue(value reflect.Value) string {
|
|
||||||
if !value.IsValid() {
|
|
||||||
return "n/a"
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理指针
|
|
||||||
if value.Kind() == reflect.Ptr {
|
|
||||||
if value.IsNil() {
|
|
||||||
return "nil"
|
|
||||||
}
|
|
||||||
return formatValue(value.Elem())
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理结构体
|
|
||||||
if value.Kind() == reflect.Struct {
|
|
||||||
var fields []string
|
|
||||||
for i := 0; i < value.NumField(); i++ {
|
|
||||||
field := value.Type().Field(i)
|
|
||||||
if shouldSkip(field) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
fieldValue := value.Field(i)
|
|
||||||
fields = append(fields, fmt.Sprintf("%s: %s", getFieldName(field), formatValue(fieldValue)))
|
|
||||||
}
|
|
||||||
return "{" + strings.Join(fields, ", ") + "}"
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理切片/数组
|
|
||||||
if value.Kind() == reflect.Slice || value.Kind() == reflect.Array {
|
|
||||||
var items []string
|
|
||||||
for i := 0; i < value.Len(); i++ {
|
|
||||||
items = append(items, formatValue(value.Index(i)))
|
|
||||||
}
|
|
||||||
return "[" + strings.Join(items, ", ") + "]"
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理映射
|
|
||||||
if value.Kind() == reflect.Map {
|
|
||||||
var items []string
|
|
||||||
for _, key := range value.MapKeys() {
|
|
||||||
keyStr := formatValue(key)
|
|
||||||
valueStr := formatValue(value.MapIndex(key))
|
|
||||||
items = append(items, fmt.Sprintf("%s: %s", keyStr, valueStr))
|
|
||||||
}
|
|
||||||
return "{" + strings.Join(items, ", ") + "}"
|
|
||||||
}
|
|
||||||
|
|
||||||
// 基本类型
|
|
||||||
return fmt.Sprintf("%v", value.Interface())
|
|
||||||
}
|
|
||||||
|
|
||||||
// 示例结构体
|
|
||||||
type Address struct {
|
|
||||||
City string `md:"城市"`
|
|
||||||
Country string `md:"国家"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type User struct {
|
|
||||||
Name string `md:"姓名"`
|
|
||||||
Age int `md:"年龄"`
|
|
||||||
Email string `md:"邮箱"`
|
|
||||||
Address Address `md:"地址"`
|
|
||||||
Phones []string `md:"电话"`
|
|
||||||
Active bool `md:"活跃状态"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// 示例使用:单个结构体
|
|
||||||
user := User{
|
|
||||||
Name: "张三",
|
|
||||||
Age: 30,
|
|
||||||
Email: "zhangsan@example.com",
|
|
||||||
Address: Address{
|
|
||||||
City: "北京",
|
|
||||||
Country: "中国",
|
|
||||||
},
|
|
||||||
Phones: []string{"13800138000", "13900139000"},
|
|
||||||
Active: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("单个结构体转换:")
|
|
||||||
fmt.Println(MarkdownTable(user))
|
|
||||||
fmt.Println()
|
|
||||||
|
|
||||||
// 示例使用:结构体切片
|
|
||||||
users := []User{
|
|
||||||
{
|
|
||||||
Name: "张三",
|
|
||||||
Age: 30,
|
|
||||||
Email: "zhangsan@example.com",
|
|
||||||
Address: Address{
|
|
||||||
City: "北京",
|
|
||||||
Country: "中国",
|
|
||||||
},
|
|
||||||
Phones: []string{"13800138000"},
|
|
||||||
Active: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "李四",
|
|
||||||
Age: 25,
|
|
||||||
Email: "lisi@example.com",
|
|
||||||
Address: Address{
|
|
||||||
City: "上海",
|
|
||||||
Country: "中国",
|
|
||||||
},
|
|
||||||
Phones: []string{"13900139000", "13700137000"},
|
|
||||||
Active: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("结构体切片转换:")
|
|
||||||
fmt.Println(MarkdownTable(users))
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
package util
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestMd(t *testing.T) {
|
|
||||||
// 示例使用:单个结构体
|
|
||||||
user := User{
|
|
||||||
Name: "张三",
|
|
||||||
Age: 30,
|
|
||||||
Email: "zhangsan@example.com",
|
|
||||||
Address: Address{
|
|
||||||
City: "北京",
|
|
||||||
Country: "中国",
|
|
||||||
},
|
|
||||||
Phones: []string{"13800138000", "13900139000"},
|
|
||||||
Active: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("单个结构体转换:")
|
|
||||||
fmt.Println(MarkdownTable(user))
|
|
||||||
fmt.Println()
|
|
||||||
|
|
||||||
// 示例使用:结构体切片
|
|
||||||
users := []User{
|
|
||||||
{
|
|
||||||
Name: "张三",
|
|
||||||
Age: 30,
|
|
||||||
Email: "zhangsan@example.com",
|
|
||||||
Address: Address{
|
|
||||||
City: "北京",
|
|
||||||
Country: "中国",
|
|
||||||
},
|
|
||||||
Phones: []string{"13800138000"},
|
|
||||||
Active: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "李四",
|
|
||||||
Age: 25,
|
|
||||||
Email: "lisi@example.com",
|
|
||||||
Address: Address{
|
|
||||||
City: "上海",
|
|
||||||
Country: "中国",
|
|
||||||
},
|
|
||||||
Phones: []string{"13900139000", "13700137000"},
|
|
||||||
Active: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("结构体切片转换:")
|
|
||||||
fmt.Println(MarkdownTable(users))
|
|
||||||
}
|
|
@ -27,7 +27,7 @@ import {
|
|||||||
StarOutline,
|
StarOutline,
|
||||||
Wallet, WarningOutline,
|
Wallet, WarningOutline,
|
||||||
} from '@vicons/ionicons5'
|
} from '@vicons/ionicons5'
|
||||||
import {AnalyzeSentiment, GetConfig, GetGroupList,GetVersionInfo} from "../wailsjs/go/main/App";
|
import {AnalyzeSentiment, GetConfig, GetGroupList} from "../wailsjs/go/main/App";
|
||||||
import {Dragon, Fire, Gripfire} from "@vicons/fa";
|
import {Dragon, Fire, Gripfire} from "@vicons/fa";
|
||||||
import {ReportSearch} from "@vicons/tabler";
|
import {ReportSearch} from "@vicons/tabler";
|
||||||
import {LocalFireDepartmentRound} from "@vicons/material";
|
import {LocalFireDepartmentRound} from "@vicons/material";
|
||||||
@ -44,9 +44,9 @@ const enableNews = ref(false)
|
|||||||
const contentStyle = ref("")
|
const contentStyle = ref("")
|
||||||
const enableFund = ref(false)
|
const enableFund = ref(false)
|
||||||
const enableDarkTheme = ref(null)
|
const enableDarkTheme = ref(null)
|
||||||
const content = ref('未经授权,禁止商业目的!\n\n数据来源于网络,仅供参考;投资有风险,入市需谨慎')
|
const content = ref('数据来源于网络,仅供参考;投资有风险,入市需谨慎\n\n未经授权,禁止商业目的!')
|
||||||
const isFullscreen = ref(false)
|
const isFullscreen = ref(false)
|
||||||
const activeKey = ref('stock')
|
const activeKey = ref('')
|
||||||
const containerRef = ref({})
|
const containerRef = ref({})
|
||||||
const realtimeProfit = ref(0)
|
const realtimeProfit = ref(0)
|
||||||
const telegraph = ref([])
|
const telegraph = ref([])
|
||||||
@ -64,10 +64,7 @@ const menuOptions = ref([
|
|||||||
groupId: 0,
|
groupId: 0,
|
||||||
},
|
},
|
||||||
params: {},
|
params: {},
|
||||||
},
|
}
|
||||||
onClick: () => {
|
|
||||||
activeKey.value = 'stock'
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{default: () => '股票自选',}
|
{default: () => '股票自选',}
|
||||||
),
|
),
|
||||||
@ -82,7 +79,6 @@ const menuOptions = ref([
|
|||||||
href: '#',
|
href: '#',
|
||||||
type: 'info',
|
type: 'info',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
activeKey.value = 'stock'
|
|
||||||
//console.log("push",item)
|
//console.log("push",item)
|
||||||
router.push({
|
router.push({
|
||||||
name: 'stock',
|
name: 'stock',
|
||||||
@ -118,7 +114,6 @@ const menuOptions = ref([
|
|||||||
params: {}
|
params: {}
|
||||||
},
|
},
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
activeKey.value = 'market'
|
|
||||||
EventsEmit("changeMarketTab", {ID: 0, name: '市场快讯'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '市场快讯'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -140,7 +135,6 @@ const menuOptions = ref([
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
activeKey.value = 'market'
|
|
||||||
EventsEmit("changeMarketTab", {ID: 0, name: '市场快讯'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '市场快讯'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -162,7 +156,6 @@ const menuOptions = ref([
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
activeKey.value = 'market'
|
|
||||||
EventsEmit("changeMarketTab", {ID: 0, name: '全球股指'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '全球股指'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -184,7 +177,6 @@ const menuOptions = ref([
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
activeKey.value = 'market'
|
|
||||||
EventsEmit("changeMarketTab", {ID: 0, name: '指标行情'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '指标行情'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -206,7 +198,6 @@ const menuOptions = ref([
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
activeKey.value = 'market'
|
|
||||||
EventsEmit("changeMarketTab", {ID: 0, name: '行业排名'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '行业排名'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -228,7 +219,6 @@ const menuOptions = ref([
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
activeKey.value = 'market'
|
|
||||||
EventsEmit("changeMarketTab", {ID: 0, name: '个股资金流向'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '个股资金流向'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -250,7 +240,6 @@ const menuOptions = ref([
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
activeKey.value = 'market'
|
|
||||||
EventsEmit("changeMarketTab", {ID: 0, name: '龙虎榜'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '龙虎榜'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -272,7 +261,6 @@ const menuOptions = ref([
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
activeKey.value = 'market'
|
|
||||||
EventsEmit("changeMarketTab", {ID: 0, name: '个股研报'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '个股研报'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -294,7 +282,6 @@ const menuOptions = ref([
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
activeKey.value = 'market'
|
|
||||||
EventsEmit("changeMarketTab", {ID: 0, name: '公司公告'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '公司公告'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -316,7 +303,6 @@ const menuOptions = ref([
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
activeKey.value = 'market'
|
|
||||||
EventsEmit("changeMarketTab", {ID: 0, name: '行业研究'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '行业研究'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -338,7 +324,6 @@ const menuOptions = ref([
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
activeKey.value = 'market'
|
|
||||||
EventsEmit("changeMarketTab", {ID: 0, name: '当前热门'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '当前热门'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -360,7 +345,6 @@ const menuOptions = ref([
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
activeKey.value = 'market'
|
|
||||||
EventsEmit("changeMarketTab", {ID: 0, name: '指标选股'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '指标选股'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -378,13 +362,8 @@ const menuOptions = ref([
|
|||||||
{
|
{
|
||||||
to: {
|
to: {
|
||||||
name: 'fund',
|
name: 'fund',
|
||||||
query: {
|
params: {},
|
||||||
name: '基金自选',
|
}
|
||||||
},
|
|
||||||
},
|
|
||||||
onClick: () => {
|
|
||||||
activeKey.value = 'fund'
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{default: () => '基金自选',}
|
{default: () => '基金自选',}
|
||||||
),
|
),
|
||||||
@ -407,12 +386,7 @@ const menuOptions = ref([
|
|||||||
{
|
{
|
||||||
to: {
|
to: {
|
||||||
name: 'settings',
|
name: 'settings',
|
||||||
query: {
|
params: {}
|
||||||
name:"设置",
|
|
||||||
},
|
|
||||||
onClick: () => {
|
|
||||||
activeKey.value = 'settings'
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{default: () => '设置'}
|
{default: () => '设置'}
|
||||||
@ -427,13 +401,8 @@ const menuOptions = ref([
|
|||||||
{
|
{
|
||||||
to: {
|
to: {
|
||||||
name: 'about',
|
name: 'about',
|
||||||
query: {
|
params: {}
|
||||||
name:"关于",
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
onClick: () => {
|
|
||||||
activeKey.value = 'about'
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{default: () => '关于'}
|
{default: () => '关于'}
|
||||||
),
|
),
|
||||||
@ -453,7 +422,7 @@ const menuOptions = ref([
|
|||||||
label: () => h("a", {
|
label: () => h("a", {
|
||||||
href: '#',
|
href: '#',
|
||||||
onClick: WindowHide,
|
onClick: WindowHide,
|
||||||
title: '隐藏到托盘区 Ctrl+Z',
|
title: '隐藏到托盘区 Ctrl+H',
|
||||||
}, {default: () => '隐藏到托盘区'}),
|
}, {default: () => '隐藏到托盘区'}),
|
||||||
key: 'hide',
|
key: 'hide',
|
||||||
icon: renderIcon(ReorderTwoOutline),
|
icon: renderIcon(ReorderTwoOutline),
|
||||||
@ -482,7 +451,6 @@ function renderIcon(icon) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggleFullscreen(e) {
|
function toggleFullscreen(e) {
|
||||||
activeKey.value = 'full'
|
|
||||||
//console.log(e)
|
//console.log(e)
|
||||||
if (isFullscreen.value) {
|
if (isFullscreen.value) {
|
||||||
WindowUnfullscreen()
|
WindowUnfullscreen()
|
||||||
@ -550,12 +518,6 @@ window.onerror = function (msg, source, lineno, colno, error) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
GetVersionInfo().then(result => {
|
|
||||||
if(result.officialStatement){
|
|
||||||
content.value = result.officialStatement+"\n\n"+content.value
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
GetGroupList().then(result => {
|
GetGroupList().then(result => {
|
||||||
groupList.value = result
|
groupList.value = result
|
||||||
menuOptions.value.map((item) => {
|
menuOptions.value.map((item) => {
|
||||||
|
@ -1,133 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="embed-container">
|
|
||||||
<h3 v-if="title">{{ title }}</h3>
|
|
||||||
<div class="iframe-wrapper">
|
|
||||||
<iframe
|
|
||||||
:src="url"
|
|
||||||
:title="iframeTitle"
|
|
||||||
frameborder="0"
|
|
||||||
scrolling="auto"
|
|
||||||
class="embedded-iframe"
|
|
||||||
@load="onLoad"
|
|
||||||
@error="onError"
|
|
||||||
:style="iframeStyle"
|
|
||||||
></iframe>
|
|
||||||
</div>
|
|
||||||
<div v-if="loading" class="loading-indicator">
|
|
||||||
<div class="spinner"></div>
|
|
||||||
<p>加载中...</p>
|
|
||||||
</div>
|
|
||||||
<p v-if="error" class="error-message">{{ error }}</p>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { ref, onMounted, watch } from 'vue'
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
url: {
|
|
||||||
type: String,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
title: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
iframeTitle: {
|
|
||||||
type: String,
|
|
||||||
default: '外部内容'
|
|
||||||
},
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '100%'
|
|
||||||
},
|
|
||||||
height: {
|
|
||||||
type: String,
|
|
||||||
default: '100%'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const loading = ref(true)
|
|
||||||
const error = ref(null)
|
|
||||||
|
|
||||||
const onLoad = () => {
|
|
||||||
loading.value = false
|
|
||||||
error.value = null
|
|
||||||
}
|
|
||||||
|
|
||||||
const onError = (event) => {
|
|
||||||
loading.value = false
|
|
||||||
error.value = `加载失败: ${event.message || '无法加载该 URL'}`
|
|
||||||
}
|
|
||||||
|
|
||||||
// 监听 URL 变化,重新加载
|
|
||||||
watch(() => props.url, () => {
|
|
||||||
loading.value = true
|
|
||||||
error.value = null
|
|
||||||
})
|
|
||||||
|
|
||||||
// 设置 iframe 样式
|
|
||||||
const iframeStyle = {
|
|
||||||
width: props.width,
|
|
||||||
height: props.height
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.embed-container {
|
|
||||||
margin: 1rem 0;
|
|
||||||
border: 0 solid #e5e7eb;
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.iframe-wrapper {
|
|
||||||
position: relative;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.embedded-iframe {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
min-height: 400px;
|
|
||||||
transition: opacity 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loading-indicator {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
background-color: rgba(255, 255, 255, 0.8);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
z-index: 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spinner {
|
|
||||||
width: 2rem;
|
|
||||||
height: 2rem;
|
|
||||||
border: 3px solid #f3f4f6;
|
|
||||||
border-radius: 50%;
|
|
||||||
border-top-color: #3b82f6;
|
|
||||||
animation: spin 1s linear infinite;
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes spin {
|
|
||||||
to {
|
|
||||||
transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.error-message {
|
|
||||||
color: #ef4444;
|
|
||||||
padding: 1rem;
|
|
||||||
margin: 0;
|
|
||||||
background-color: #fee2e2;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
@ -1,7 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {onBeforeMount, onUnmounted, ref} from 'vue'
|
import {onBeforeMount, onUnmounted, ref} from 'vue'
|
||||||
import {HotTopic, OpenURL} from "../../wailsjs/go/main/App";
|
import {HotTopic} from "../../wailsjs/go/main/App";
|
||||||
import {Environment} from "../../wailsjs/runtime";
|
|
||||||
const list = ref([])
|
const list = ref([])
|
||||||
const task =ref()
|
const task =ref()
|
||||||
|
|
||||||
@ -19,20 +18,11 @@ function openCenteredWindow(url, width, height) {
|
|||||||
const left = (window.screen.width - width) / 2;
|
const left = (window.screen.width - width) / 2;
|
||||||
const top = (window.screen.height - height) / 2;
|
const top = (window.screen.height - height) / 2;
|
||||||
|
|
||||||
Environment().then(env => {
|
return window.open(
|
||||||
switch (env.platform) {
|
url,
|
||||||
case 'windows':
|
'centeredWindow',
|
||||||
window.open(
|
`width=${width},height=${height},left=${left},top=${top}`
|
||||||
url,
|
);
|
||||||
'centeredWindow',
|
|
||||||
`width=${width},height=${height},left=${left},top=${top}`
|
|
||||||
)
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
OpenURL(url)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
function showPage(htid) {
|
function showPage(htid) {
|
||||||
openCenteredWindow(`https://gubatopic.eastmoney.com/topic_v3.html?htid=${htid}`, 1000, 600)
|
openCenteredWindow(`https://gubatopic.eastmoney.com/topic_v3.html?htid=${htid}`, 1000, 600)
|
||||||
|
@ -378,7 +378,7 @@ function calculateMA(dayCount,values) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div ref="kLineChartRef" style="width: 100%;height: auto;--wails-draggable:no-drag" :style="{height:chartHeight+'px'}" ></div>
|
<div ref="kLineChartRef" style="width: 100%;height: auto;" :style="{height:chartHeight+'px'}"></div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -1,195 +1,99 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {h, onBeforeMount, onMounted, onUnmounted, ref} from 'vue'
|
import {h, onBeforeMount, onMounted, onUnmounted, ref} from 'vue'
|
||||||
import {SearchStock, GetHotStrategy, OpenURL} from "../../wailsjs/go/main/App";
|
import {SearchStock} from "../../wailsjs/go/main/App";
|
||||||
import {useMessage, NText, NTag, NButton} from 'naive-ui'
|
import {useMessage, NText, NTag} from 'naive-ui'
|
||||||
import {Environment} from "../../wailsjs/runtime"
|
|
||||||
import {RefreshCircleSharp} from "@vicons/ionicons5";
|
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const search = ref('')
|
const search = ref('科技股;换手率连续3日大于2')
|
||||||
const columns = ref([])
|
const columns = ref([])
|
||||||
const dataList = ref([])
|
const dataList = ref([])
|
||||||
const hotStrategy = ref([])
|
|
||||||
const traceInfo = ref('')
|
|
||||||
|
|
||||||
function Search() {
|
function Search() {
|
||||||
if (!search.value) {
|
|
||||||
message.warning('请输入选股指标或者要求')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const loading = message.loading("正在获取选股数据...", {duration: 0});
|
const loading = message.loading("正在获取选股数据...", {duration: 0});
|
||||||
SearchStock(search.value).then(res => {
|
SearchStock(search.value).then(res => {
|
||||||
loading.destroy()
|
loading.destroy()
|
||||||
// console.log(res)
|
//console.log(res)
|
||||||
if (res.code == 100) {
|
if(res.code==100){
|
||||||
traceInfo.value = res.data.traceInfo.showText
|
message.success(res.msg)
|
||||||
// message.success(res.msg)
|
columns.value=res.data.result.columns.filter(item=>!item.hiddenNeed&&(item.title!="市场码"&&item.title!="市场简称")).map(item=>{
|
||||||
columns.value = res.data.result.columns.filter(item => !item.hiddenNeed && (item.title != "市场码" && item.title != "市场简称")).map(item => {
|
|
||||||
if (item.children) {
|
if(item.children){
|
||||||
return {
|
return {
|
||||||
title: item.title + (item.unit ? '[' + item.unit + ']' : ''),
|
title:item.title+(item.unit?'['+item.unit+']':''),
|
||||||
key: item.key,
|
key:item.key,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
minWidth: 200,
|
minWidth:200,
|
||||||
ellipsis: {
|
ellipsis: {
|
||||||
tooltip: true
|
tooltip: true
|
||||||
},
|
},
|
||||||
children: item.children.filter(item => !item.hiddenNeed).map(item => {
|
children:item.children.filter(item=>!item.hiddenNeed).map(item=>{
|
||||||
return {
|
return {
|
||||||
title: item.dateMsg,
|
title:item.dateMsg,
|
||||||
key: item.key,
|
key:item.key,
|
||||||
minWidth: 100,
|
minWidth:100,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
ellipsis: {
|
ellipsis: {
|
||||||
tooltip: true
|
tooltip: true
|
||||||
},
|
}
|
||||||
sorter: (row1, row2) => {
|
|
||||||
if (isNumeric(row1[item.key]) && isNumeric(row2[item.key])) {
|
|
||||||
return row1[item.key] - row2[item.key];
|
|
||||||
} else {
|
|
||||||
return 'default'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
}else{
|
||||||
return {
|
return {
|
||||||
title: item.title + (item.unit ? '[' + item.unit + ']' : ''),
|
title:item.title+(item.unit?'['+item.unit+']':''),
|
||||||
key: item.key,
|
key:item.key,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
minWidth: 120,
|
minWidth:100,
|
||||||
ellipsis: {
|
ellipsis: {
|
||||||
tooltip: true
|
tooltip: true
|
||||||
},
|
}
|
||||||
sorter: (row1, row2) => {
|
|
||||||
if (isNumeric(row1[item.key]) && isNumeric(row2[item.key])) {
|
|
||||||
return row1[item.key] - row2[item.key];
|
|
||||||
} else {
|
|
||||||
return 'default'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
dataList.value = res.data.result.dataList
|
dataList.value=res.data.result.dataList
|
||||||
} else {
|
}else {
|
||||||
message.error(res.msg)
|
message.error(res.msg)
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
message.error(err)
|
message.error(err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function isNumeric(value) {
|
function isNumeric(value) {
|
||||||
return !isNaN(parseFloat(value)) && isFinite(value);
|
return !isNaN(parseFloat(value)) && isFinite(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
GetHotStrategy().then(res => {
|
Search()
|
||||||
console.log(res)
|
|
||||||
if (res.code == 1) {
|
|
||||||
hotStrategy.value = res.data
|
|
||||||
search.value = hotStrategy.value[0].question
|
|
||||||
Search()
|
|
||||||
}
|
|
||||||
}).catch(err => {
|
|
||||||
message.error(err)
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function DoSearch(question) {
|
|
||||||
search.value = question
|
|
||||||
Search()
|
|
||||||
}
|
|
||||||
|
|
||||||
function openCenteredWindow(url, width, height) {
|
|
||||||
const left = (window.screen.width - width) / 2;
|
|
||||||
const top = (window.screen.height - height) / 2;
|
|
||||||
|
|
||||||
Environment().then(env => {
|
|
||||||
switch (env.platform) {
|
|
||||||
case 'windows':
|
|
||||||
window.open(
|
|
||||||
url,
|
|
||||||
'centeredWindow',
|
|
||||||
`width=${width},height=${height},left=${left},top=${top},location=no,menubar=no,toolbar=no,display=standalone`
|
|
||||||
)
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
OpenURL(url)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<n-grid :cols="24" style="max-height: calc(100vh - 170px)">
|
<n-flex>
|
||||||
<n-gi :span="4">
|
<n-input-group>
|
||||||
<n-list bordered style="text-align: left;" hoverable clickable>
|
<n-input v-model:value="search" placeholder="请输入选股指标或者要求" />
|
||||||
<n-scrollbar style="max-height: calc(100vh - 170px);">
|
<n-button type="success" @click="Search">搜索A股</n-button>
|
||||||
<n-list-item v-for="item in hotStrategy" :key="item.rank" @click="DoSearch(item.question)">
|
</n-input-group>
|
||||||
<n-ellipsis line-clamp="1" :tooltip="true">
|
</n-flex>
|
||||||
<n-tag size="small" :bordered="false" type="info">#{{ item.rank }}</n-tag>
|
<!-- <n-table striped size="small">-->
|
||||||
<n-text type="warning">{{ item.question }}</n-text>
|
<!-- <n-thead>-->
|
||||||
<template #tooltip>
|
<!-- <n-tr>-->
|
||||||
<div style="text-align: center;max-width: 180px">
|
<!-- <n-th v-for="item in columns">{{item.title}}</n-th>-->
|
||||||
<n-text type="warning">{{ item.question }}</n-text>
|
<!-- </n-tr>-->
|
||||||
</div>
|
<!-- </n-thead>-->
|
||||||
</template>
|
<!-- <n-tbody>-->
|
||||||
</n-ellipsis>
|
<!-- <n-tr v-for="(item,index) in dataList">-->
|
||||||
</n-list-item>
|
<!-- <n-td v-for="d in columns">{{item[d.key]}}</n-td>-->
|
||||||
</n-scrollbar>
|
<!-- </n-tr>-->
|
||||||
</n-list>
|
<!-- </n-tbody>-->
|
||||||
|
<!-- </n-table>-->
|
||||||
<!-- <n-virtual-list :items="hotStrategy" :item-size="hotStrategy.length">-->
|
<n-data-table
|
||||||
<!-- <template #default="{ item, index }">-->
|
:max-height="'calc(100vh - 285px)'"
|
||||||
<!-- <n-card :title="''" size="small">-->
|
size="small"
|
||||||
<!-- <template #header-extra>-->
|
:columns="columns"
|
||||||
<!-- {{item.rank}}-->
|
:data="dataList"
|
||||||
<!-- </template>-->
|
:pagination="false"
|
||||||
<!-- <n-ellipsis expand-trigger="click" line-clamp="3" :tooltip="false" >-->
|
:scroll-x="1800"
|
||||||
<!-- <n-text type="warning">{{item.question }}</n-text>-->
|
:render-cell="(value, rowData, column) => {
|
||||||
<!-- </n-ellipsis>-->
|
|
||||||
<!-- </n-card>-->
|
|
||||||
|
|
||||||
<!-- </template>-->
|
|
||||||
<!-- </n-virtual-list>-->
|
|
||||||
</n-gi>
|
|
||||||
<n-gi :span="20">
|
|
||||||
<n-flex>
|
|
||||||
<n-input-group style="text-align: left">
|
|
||||||
<n-input :rows="1" clearable v-model:value="search" placeholder="请输入选股指标或者要求"/>
|
|
||||||
<n-button type="primary" @click="Search">搜索A股</n-button>
|
|
||||||
</n-input-group>
|
|
||||||
</n-flex>
|
|
||||||
<n-flex justify="start" v-if="traceInfo" style="margin: 5px 0">
|
|
||||||
|
|
||||||
<n-ellipsis line-clamp="1" :tooltip="true">
|
|
||||||
<n-text type="info" :bordered="false">选股条件:</n-text>
|
|
||||||
<n-text type="warning" :bordered="true">{{ traceInfo }}</n-text>
|
|
||||||
<template #tooltip>
|
|
||||||
<div style="text-align: center;max-width: 580px">
|
|
||||||
<n-text type="warning">{{ traceInfo }}</n-text>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</n-ellipsis>
|
|
||||||
|
|
||||||
<!-- <n-button type="primary" size="small">保存策略</n-button>-->
|
|
||||||
</n-flex>
|
|
||||||
<n-data-table
|
|
||||||
:striped="true"
|
|
||||||
:max-height="'calc(100vh - 250px)'"
|
|
||||||
size="medium"
|
|
||||||
:columns="columns"
|
|
||||||
:data="dataList"
|
|
||||||
:pagination="{pageSize: 9}"
|
|
||||||
:scroll-x="1800"
|
|
||||||
:render-cell="(value, rowData, column) => {
|
|
||||||
|
|
||||||
if(column.key=='SECURITY_CODE'||column.key=='SERIAL'){
|
if(column.key=='SECURITY_CODE'||column.key=='SERIAL'){
|
||||||
return h(NText, { type: 'info',border: false }, { default: () => `${value}` })
|
return h(NText, { type: 'info',border: false }, { default: () => `${value}` })
|
||||||
@ -208,24 +112,13 @@ function openCenteredWindow(url, width, height) {
|
|||||||
return h(NText, { type: type }, { default: () => `${value}` })
|
return h(NText, { type: type }, { default: () => `${value}` })
|
||||||
}else{
|
}else{
|
||||||
if(column.key=='SECURITY_SHORT_NAME'){
|
if(column.key=='SECURITY_SHORT_NAME'){
|
||||||
return h(NButton, { type: 'info',bordered: false ,size:'small',onClick:()=>{
|
return h(NTag, { type: 'info',bordered: false }, { default: () => `${value}` })
|
||||||
//https://quote.eastmoney.com/sz300558.html#fullScreenChart
|
|
||||||
openCenteredWindow(`https://quote.eastmoney.com/${rowData.MARKET_SHORT_NAME}${rowData.SECURITY_CODE}.html#fullScreenChart`,1240,700)
|
|
||||||
}}, { default: () => `${value}` })
|
|
||||||
}else{
|
}else{
|
||||||
return h(NText, { type: 'info' }, { default: () => `${value}` })
|
return h(NText, { type: 'info' }, { default: () => `${value}` })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
<n-text>共找到
|
|
||||||
<n-tag type="info" :bordered="false">{{ dataList.length }}</n-tag>
|
|
||||||
只股
|
|
||||||
</n-text>
|
|
||||||
</n-gi>
|
|
||||||
</n-grid>
|
|
||||||
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -3,19 +3,15 @@
|
|||||||
// preview.css相比style.css少了编辑器那部分样式
|
// preview.css相比style.css少了编辑器那部分样式
|
||||||
import 'md-editor-v3/lib/preview.css';
|
import 'md-editor-v3/lib/preview.css';
|
||||||
import {h, onBeforeUnmount, onMounted, ref} from 'vue';
|
import {h, onBeforeUnmount, onMounted, ref} from 'vue';
|
||||||
import {CheckUpdate, GetVersionInfo,GetSponsorInfo,OpenURL} from "../../wailsjs/go/main/App";
|
import {CheckUpdate, GetVersionInfo} from "../../wailsjs/go/main/App";
|
||||||
import {EventsOff, EventsOn,Environment} from "../../wailsjs/runtime";
|
import {EventsOff, EventsOn} from "../../wailsjs/runtime";
|
||||||
import {NAvatar, NButton, useNotification} from "naive-ui";
|
import {NAvatar, NButton, useNotification} from "naive-ui";
|
||||||
const updateLog = ref('');
|
const updateLog = ref('');
|
||||||
const versionInfo = ref('');
|
const versionInfo = ref('');
|
||||||
const icon = ref('https://raw.githubusercontent.com/ArvinLovegood/go-stock/master/build/appicon.png');
|
const icon = ref('https://raw.githubusercontent.com/ArvinLovegood/go-stock/master/build/appicon.png');
|
||||||
const alipay =ref('https://github.com/ArvinLovegood/go-stock/raw/master/build/screenshot/alipay.jpg')
|
const alipay =ref('https://github.com/ArvinLovegood/go-stock/raw/master/build/screenshot/alipay.jpg')
|
||||||
const wxpay =ref('https://github.com/ArvinLovegood/go-stock/raw/master/build/screenshot/wxpay.jpg')
|
const wxpay =ref('https://github.com/ArvinLovegood/go-stock/raw/master/build/screenshot/wxpay.jpg')
|
||||||
const wxgzh =ref('https://github.com/ArvinLovegood/go-stock/raw/dev/build/screenshot/%E6%89%AB%E7%A0%81_%E6%90%9C%E7%B4%A2%E8%81%94%E5%90%88%E4%BC%A0%E6%92%AD%E6%A0%B7%E5%BC%8F-%E7%99%BD%E8%89%B2%E7%89%88.png')
|
|
||||||
const notify = useNotification()
|
const notify = useNotification()
|
||||||
const vipLevel=ref("");
|
|
||||||
const vipStartTime=ref("");
|
|
||||||
const vipEndTime=ref("");
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
document.title = '关于软件';
|
document.title = '关于软件';
|
||||||
@ -25,18 +21,7 @@ onMounted(() => {
|
|||||||
icon.value = res.icon;
|
icon.value = res.icon;
|
||||||
alipay.value=res.alipay;
|
alipay.value=res.alipay;
|
||||||
wxpay.value=res.wxpay;
|
wxpay.value=res.wxpay;
|
||||||
wxgzh.value=res.wxgzh;
|
|
||||||
|
|
||||||
GetSponsorInfo().then((res) => {
|
|
||||||
vipLevel.value = res.vipLevel;
|
|
||||||
vipStartTime.value = res.vipStartTime;
|
|
||||||
vipEndTime.value = res.vipEndTime;
|
|
||||||
})
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
notify.destroyAll()
|
notify.destroyAll()
|
||||||
@ -85,16 +70,7 @@ EventsOn("updateVersion",async (msg) => {
|
|||||||
type: 'primary',
|
type: 'primary',
|
||||||
size: 'small',
|
size: 'small',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
Environment().then(env => {
|
window.open(msg.html_url)
|
||||||
switch (env.platform) {
|
|
||||||
case 'windows':
|
|
||||||
window.open(msg.html_url)
|
|
||||||
break
|
|
||||||
default :
|
|
||||||
OpenURL(msg.html_url)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}, { default: () => '查看' })
|
}, { default: () => '查看' })
|
||||||
}
|
}
|
||||||
@ -104,22 +80,21 @@ EventsOn("updateVersion",async (msg) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<n-space vertical size="large" style="--wails-draggable:drag">
|
<n-space vertical size="large">
|
||||||
<!-- 软件描述 -->
|
<!-- 软件描述 -->
|
||||||
<n-card size="large">
|
<n-card size="large">
|
||||||
<n-divider title-placement="center">关于软件</n-divider>
|
<n-divider title-placement="center">关于软件</n-divider>
|
||||||
<n-space vertical >
|
<n-space vertical >
|
||||||
<n-image width="100" :src="icon" />
|
<n-image width="100" :src="icon" />
|
||||||
<h1>
|
<h1>
|
||||||
<n-badge v-if="!vipLevel" :value="versionInfo" :offset="[50,10]" type="success">
|
<n-badge :value="versionInfo" :offset="[50,10]" type="success">
|
||||||
<n-gradient-text type="info" :size="50" >go-stock</n-gradient-text>
|
<n-gradient-text type="info" :size="50" >go-stock</n-gradient-text>
|
||||||
</n-badge>
|
</n-badge>
|
||||||
<n-badge v-if="vipLevel" :value="versionInfo" :offset="[50,10]" type="success">
|
|
||||||
<n-gradient-text type="warning" :size="50" >go-stock</n-gradient-text><n-tag :bordered="false" size="small" type="warning">VIP{{vipLevel}}</n-tag>
|
|
||||||
</n-badge>
|
|
||||||
</h1>
|
</h1>
|
||||||
<n-gradient-text type="warning" v-if="vipLevel" >vip到期时间:{{vipEndTime}}</n-gradient-text>
|
|
||||||
<n-button size="tiny" @click="CheckUpdate" type="info" tertiary >检查更新</n-button>
|
<n-button size="tiny" @click="CheckUpdate" type="info" tertiary >检查更新</n-button>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div style="justify-self: center;text-align: left" >
|
<div style="justify-self: center;text-align: left" >
|
||||||
<p>自选股行情实时监控,基于Wails和NaiveUI构建的AI赋能股票分析工具</p>
|
<p>自选股行情实时监控,基于Wails和NaiveUI构建的AI赋能股票分析工具</p>
|
||||||
<p>目前已支持A股,港股,美股,未来计划加入基金,ETF等支持</p>
|
<p>目前已支持A股,港股,美股,未来计划加入基金,ETF等支持</p>
|
||||||
@ -138,39 +113,14 @@ EventsOn("updateVersion",async (msg) => {
|
|||||||
<p>QQ交流群:<a href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=0YQ8qD3exahsD4YLNhzQTWe5ssstWC89&authKey=usOMMRFtIQDC%2FYcatHYapcxQbJ7PwXPHK9OypTXWzNjAq%2FRVvQu9bj2lRgb%2BSZ3p&noverify=0&group_code=491605333" target="_blank">491605333</a></p>
|
<p>QQ交流群:<a href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=0YQ8qD3exahsD4YLNhzQTWe5ssstWC89&authKey=usOMMRFtIQDC%2FYcatHYapcxQbJ7PwXPHK9OypTXWzNjAq%2FRVvQu9bj2lRgb%2BSZ3p&noverify=0&group_code=491605333" target="_blank">491605333</a></p>
|
||||||
</div>
|
</div>
|
||||||
</n-space>
|
</n-space>
|
||||||
<n-divider title-placement="center">支持💕开源</n-divider>
|
|
||||||
<n-flex justify="center">
|
|
||||||
<n-table size="small" style="width: 820px">
|
|
||||||
<n-thead>
|
|
||||||
<n-tr>
|
|
||||||
<n-th>赞助计划</n-th>
|
|
||||||
<n-th>赞助等级</n-th>
|
|
||||||
<n-th>权益说明</n-th>
|
|
||||||
</n-tr>
|
|
||||||
</n-thead>
|
|
||||||
<n-tbody>
|
|
||||||
<n-tr>
|
|
||||||
<n-td>每月 0 RMB</n-td><n-td>vip0</n-td><n-td>🌟 全部功能,软件自动更新(从GitHub下载),自行解决github平台网络问题。</n-td>
|
|
||||||
</n-tr>
|
|
||||||
<n-tr>
|
|
||||||
<n-td>赞助 18.8 RMB/月<br>赞助 120 RMB/年</n-td><n-td>vip1</n-td><n-td>💕 全部功能,软件自动更新(从CDN下载),更新快速便捷。AI配置指导,提示词参考等</n-td>
|
|
||||||
</n-tr>
|
|
||||||
<n-tr>
|
|
||||||
<n-td>赞助 28.8 RMB/月<br>赞助 240 RMB/年</n-td><n-td>vip2</n-td><n-td>💕 vip1全部功能,赠送硅基流动AI分析服务💕</n-td>
|
|
||||||
</n-tr>
|
|
||||||
<n-tr>
|
|
||||||
<n-td>每月赞助 X RMB</n-td><n-td>vipX</n-td><n-td>🧩 更多计划,视go-stock开源项目发展情况而定...(承接GitHub项目README广告推广💖)</n-td>
|
|
||||||
</n-tr>
|
|
||||||
</n-tbody>
|
|
||||||
</n-table>
|
|
||||||
</n-flex>
|
|
||||||
<n-divider title-placement="center">关于作者</n-divider>
|
<n-divider title-placement="center">关于作者</n-divider>
|
||||||
<n-space vertical>
|
<n-space vertical>
|
||||||
<!-- <h1>关于作者</h1>-->
|
<!-- <h1>关于作者</h1>-->
|
||||||
<n-avatar width="100" src="https://avatars.githubusercontent.com/u/7401917?v=4" />
|
<n-avatar width="100" src="https://avatars.githubusercontent.com/u/7401917?v=4" />
|
||||||
<h2><a href="https://github.com/ArvinLovegood" target="_blank">@ArvinLovegood</a></h2>
|
<h2><a href="https://github.com/ArvinLovegood" target="_blank">@ArvinLovegood</a></h2>
|
||||||
<p>一个热爱编程的小白,欢迎关注我的Github/微信公众号</p>
|
<p>一个热爱编程的小白,欢迎关注我的Github</p>
|
||||||
<n-image width="300" :src="wxgzh" />
|
<n-image width="300" src="https://go-stock.sparkmemory.top/assets/%E6%89%AB%E7%A0%81_%E6%90%9C%E7%B4%A2%E8%81%94%E5%90%88%E4%BC%A0%E6%92%AD%E6%A0%B7%E5%BC%8F-%E7%99%BD%E8%89%B2%E7%89%88-DEJtWc_y.png" />
|
||||||
|
|
||||||
<p>开源不易,如果觉得好用,可以请作者喝杯咖啡。</p>
|
<p>开源不易,如果觉得好用,可以请作者喝杯咖啡。</p>
|
||||||
<n-flex justify="center">
|
<n-flex justify="center">
|
||||||
<n-image width="200" :src="alipay" />
|
<n-image width="200" :src="alipay" />
|
||||||
@ -185,7 +135,6 @@ EventsOn("updateVersion",async (msg) => {
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
感谢以下开发者:
|
感谢以下开发者:
|
||||||
<a href="https://github.com/GiCo001" target="_blank">@Gico</a><n-divider vertical />
|
|
||||||
<a href="https://github.com/CodeNoobLH" target="_blank">浓睡不消残酒</a><n-divider vertical />
|
<a href="https://github.com/CodeNoobLH" target="_blank">浓睡不消残酒</a><n-divider vertical />
|
||||||
<a href="https://github.com/gnim2600" target="_blank">@gnim2600</a><n-divider vertical />
|
<a href="https://github.com/gnim2600" target="_blank">@gnim2600</a><n-divider vertical />
|
||||||
<a href="https://github.com/XXXiaohuayanGGG" target="_blank">@XXXiaohuayanGGG</a><n-divider vertical />
|
<a href="https://github.com/XXXiaohuayanGGG" target="_blank">@XXXiaohuayanGGG</a><n-divider vertical />
|
||||||
|
@ -7,7 +7,7 @@ import {
|
|||||||
GetConfig,
|
GetConfig,
|
||||||
GetFollowedFund,
|
GetFollowedFund,
|
||||||
GetfundList,
|
GetfundList,
|
||||||
GetVersionInfo, OpenURL,
|
GetVersionInfo,
|
||||||
UnFollowFund
|
UnFollowFund
|
||||||
} from "../../wailsjs/go/main/App";
|
} from "../../wailsjs/go/main/App";
|
||||||
import vueDanmaku from 'vue3-danmaku'
|
import vueDanmaku from 'vue3-danmaku'
|
||||||
@ -147,19 +147,8 @@ function formatterTitle(title){
|
|||||||
|
|
||||||
function search(code,name){
|
function search(code,name){
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
//window.open("https://fund.eastmoney.com/"+code+".html","_blank","noreferrer,width=1000,top=100,left=100,status=no,toolbar=no,location=no,scrollbars=no")
|
window.open("https://fund.eastmoney.com/"+code+".html","_blank","noreferrer,width=1000,top=100,left=100,status=no,toolbar=no,location=no,scrollbars=no")
|
||||||
//window.open("https://finance.sina.com.cn/fund/quotes/"+code+"/bc.shtml","_blank","width=1000,height=800,top=100,left=100,toolbar=no,location=no")
|
//window.open("https://finance.sina.com.cn/fund/quotes/"+code+"/bc.shtml","_blank","width=1000,height=800,top=100,left=100,toolbar=no,location=no")
|
||||||
|
|
||||||
Environment().then(env => {
|
|
||||||
switch (env.platform) {
|
|
||||||
case 'windows':
|
|
||||||
window.open("https://fund.eastmoney.com/"+code+".html","_blank","noreferrer,width=1000,top=100,left=100,status=no,toolbar=no,location=no,scrollbars=no")
|
|
||||||
break
|
|
||||||
default :
|
|
||||||
OpenURL("https://fund.eastmoney.com/"+code+".html")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
}, 500)
|
}, 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {computed, h, onBeforeMount, onBeforeUnmount, onMounted, ref} from 'vue'
|
import {computed, h, onBeforeMount, onBeforeUnmount, ref} from 'vue'
|
||||||
import {
|
import {
|
||||||
GetAIResponseResult,
|
GetAIResponseResult,
|
||||||
GetConfig,
|
GetConfig,
|
||||||
@ -32,7 +32,6 @@ import HotTopics from "./HotTopics.vue";
|
|||||||
import InvestCalendarTimeLine from "./InvestCalendarTimeLine.vue";
|
import InvestCalendarTimeLine from "./InvestCalendarTimeLine.vue";
|
||||||
import ClsCalendarTimeLine from "./ClsCalendarTimeLine.vue";
|
import ClsCalendarTimeLine from "./ClsCalendarTimeLine.vue";
|
||||||
import SelectStock from "./SelectStock.vue";
|
import SelectStock from "./SelectStock.vue";
|
||||||
import Stockhotmap from "./stockhotmap.vue";
|
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const icon = ref('https://raw.githubusercontent.com/ArvinLovegood/go-stock/master/build/appicon.png');
|
const icon = ref('https://raw.githubusercontent.com/ArvinLovegood/go-stock/master/build/appicon.png');
|
||||||
@ -71,7 +70,6 @@ const nowTab = ref("市场快讯")
|
|||||||
const indexInterval = ref(null)
|
const indexInterval = ref(null)
|
||||||
const indexIndustryRank = ref(null)
|
const indexIndustryRank = ref(null)
|
||||||
const stockCode= ref('')
|
const stockCode= ref('')
|
||||||
const enableTools= ref(true)
|
|
||||||
|
|
||||||
function getIndex() {
|
function getIndex() {
|
||||||
GlobalStockIndexes().then((res) => {
|
GlobalStockIndexes().then((res) => {
|
||||||
@ -84,6 +82,8 @@ function getIndex() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
nowTab.value = route.query.name
|
nowTab.value = route.query.name
|
||||||
stockCode.value = route.query.stockCode
|
stockCode.value = route.query.stockCode
|
||||||
@ -129,20 +129,16 @@ EventsOn("changeMarketTab", async (msg) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
EventsOn("newTelegraph", (data) => {
|
EventsOn("newTelegraph", (data) => {
|
||||||
if (data!=null) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
for (let i = 0; i < data.length; i++) {
|
telegraphList.value.pop()
|
||||||
telegraphList.value.pop()
|
|
||||||
}
|
|
||||||
telegraphList.value.unshift(...data)
|
|
||||||
}
|
}
|
||||||
|
telegraphList.value.unshift(...data)
|
||||||
})
|
})
|
||||||
EventsOn("newSinaNews", (data) => {
|
EventsOn("newSinaNews", (data) => {
|
||||||
if (data!=null) {
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
sinaNewsList.value.pop()
|
sinaNewsList.value.pop()
|
||||||
}
|
}
|
||||||
sinaNewsList.value.unshift(...data)
|
sinaNewsList.value.unshift(...data)
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
//获取页面高度
|
//获取页面高度
|
||||||
@ -190,14 +186,13 @@ function reAiSummary() {
|
|||||||
aiSummary.value = ""
|
aiSummary.value = ""
|
||||||
summaryModal.value = true
|
summaryModal.value = true
|
||||||
loading.value = true
|
loading.value = true
|
||||||
SummaryStockNews(question.value, sysPromptId.value,enableTools.value)
|
SummaryStockNews(question.value, sysPromptId.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAiSummary() {
|
function getAiSummary() {
|
||||||
summaryModal.value = true
|
summaryModal.value = true
|
||||||
loading.value = true
|
loading.value = true
|
||||||
GetAIResponseResult("市场资讯").then(result => {
|
GetAIResponseResult("市场资讯").then(result => {
|
||||||
loading.value = false
|
|
||||||
if (result.content) {
|
if (result.content) {
|
||||||
aiSummary.value = result.content
|
aiSummary.value = result.content
|
||||||
question.value = result.question
|
question.value = result.question
|
||||||
@ -216,7 +211,7 @@ function getAiSummary() {
|
|||||||
aiSummaryTime.value = ""
|
aiSummaryTime.value = ""
|
||||||
aiSummary.value = ""
|
aiSummary.value = ""
|
||||||
modelName.value = ""
|
modelName.value = ""
|
||||||
//SummaryStockNews(question.value, sysPromptId.value,enableTools.value)
|
SummaryStockNews(question.value, sysPromptId.value)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -310,7 +305,7 @@ function ReFlesh(source) {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<n-card>
|
<n-card>
|
||||||
<n-tabs type="line" animated @update-value="updateTab" :value="nowTab" style="--wails-draggable:drag">
|
<n-tabs type="line" animated @update-value="updateTab" :value="nowTab">
|
||||||
<n-tab-pane name="市场快讯" tab="市场快讯">
|
<n-tab-pane name="市场快讯" tab="市场快讯">
|
||||||
<n-grid :cols="2" :y-gap="0">
|
<n-grid :cols="2" :y-gap="0">
|
||||||
<n-gi>
|
<n-gi>
|
||||||
@ -388,32 +383,12 @@ function ReFlesh(source) {
|
|||||||
</n-tab-pane>
|
</n-tab-pane>
|
||||||
</n-tabs>
|
</n-tabs>
|
||||||
</n-tab-pane>
|
</n-tab-pane>
|
||||||
<n-tab-pane name="重大指数" tab="重大指数">
|
<n-tab-pane name="指标行情" tab="指标行情">
|
||||||
<n-tabs type="segment" animated>
|
<n-tabs type="segment" animated>
|
||||||
<n-tab-pane name="科创50" tab="科创50" >
|
<n-tab-pane name="科创50" tab="科创50">
|
||||||
<k-line-chart code="sh000688" :chart-height="panelHeight" name="科创50" :k-days="20"
|
<k-line-chart code="sh000688" :chart-height="panelHeight" name="科创50" :k-days="20"
|
||||||
:dark-theme="true"></k-line-chart>
|
:dark-theme="true"></k-line-chart>
|
||||||
</n-tab-pane>
|
</n-tab-pane>
|
||||||
<n-tab-pane name="科创芯片" tab="科创芯片" >
|
|
||||||
<k-line-chart code="sh000685" :chart-height="panelHeight" name="科创芯片" :k-days="20"
|
|
||||||
:dark-theme="true"></k-line-chart>
|
|
||||||
</n-tab-pane>
|
|
||||||
<n-tab-pane name="证券龙头" tab="证券龙头" >
|
|
||||||
<k-line-chart code="sz399437" :chart-height="panelHeight" name="证券龙头" :k-days="20"
|
|
||||||
:dark-theme="true"></k-line-chart>
|
|
||||||
</n-tab-pane>
|
|
||||||
<n-tab-pane name="高端装备" tab="高端装备" >
|
|
||||||
<k-line-chart code="sz399437" :chart-height="panelHeight" name="高端装备" :k-days="20"
|
|
||||||
:dark-theme="true"></k-line-chart>
|
|
||||||
</n-tab-pane>
|
|
||||||
<n-tab-pane name="中证银行" tab="中证银行">
|
|
||||||
<k-line-chart code="sz399986" :chart-height="panelHeight" name="中证银行" :k-days="20"
|
|
||||||
:dark-theme="true"></k-line-chart>
|
|
||||||
</n-tab-pane>
|
|
||||||
<n-tab-pane name="上证医药" tab="上证医药">
|
|
||||||
<k-line-chart code="sh000037" :chart-height="panelHeight" name="上证医药" :k-days="20"
|
|
||||||
:dark-theme="true"></k-line-chart>
|
|
||||||
</n-tab-pane>
|
|
||||||
<n-tab-pane name="沪深300" tab="沪深300">
|
<n-tab-pane name="沪深300" tab="沪深300">
|
||||||
<k-line-chart code="sh000300" :chart-height="panelHeight" name="沪深300" :k-days="20"
|
<k-line-chart code="sh000300" :chart-height="panelHeight" name="沪深300" :k-days="20"
|
||||||
:dark-theme="true"></k-line-chart>
|
:dark-theme="true"></k-line-chart>
|
||||||
@ -623,9 +598,6 @@ function ReFlesh(source) {
|
|||||||
<n-tab-pane name="指标选股" tab="指标选股">
|
<n-tab-pane name="指标选股" tab="指标选股">
|
||||||
<select-stock />
|
<select-stock />
|
||||||
</n-tab-pane>
|
</n-tab-pane>
|
||||||
<n-tab-pane name="名站优选" tab="名站优选">
|
|
||||||
<Stockhotmap />
|
|
||||||
</n-tab-pane>
|
|
||||||
</n-tabs>
|
</n-tabs>
|
||||||
</n-card>
|
</n-card>
|
||||||
<n-modal transform-origin="center" v-model:show="summaryModal" preset="card" style="width: 800px;"
|
<n-modal transform-origin="center" v-model:show="summaryModal" preset="card" style="width: 800px;"
|
||||||
@ -643,17 +615,6 @@ function ReFlesh(source) {
|
|||||||
</n-flex>
|
</n-flex>
|
||||||
</template>
|
</template>
|
||||||
<template #action>
|
<template #action>
|
||||||
<n-flex justify="left" style="margin-bottom: 10px">
|
|
||||||
<n-switch v-model:value="enableTools" :round="false">
|
|
||||||
<template #checked>
|
|
||||||
启用AI函数工具调用
|
|
||||||
</template>
|
|
||||||
<template #unchecked>
|
|
||||||
不启用AI函数工具调用
|
|
||||||
</template>
|
|
||||||
</n-switch>
|
|
||||||
<n-gradient-text type="error" style="margin-left: 10px">*AI函数工具调用可以增强AI获取数据的能力,但会消耗更多tokens。</n-gradient-text>
|
|
||||||
</n-flex>
|
|
||||||
<n-flex justify="space-between" style="margin-bottom: 10px">
|
<n-flex justify="space-between" style="margin-bottom: 10px">
|
||||||
<n-select style="width: 49%" v-model:value="sysPromptId" label-field="name" value-field="ID"
|
<n-select style="width: 49%" v-model:value="sysPromptId" label-field="name" value-field="ID"
|
||||||
:options="sysPromptOptions" placeholder="请选择系统提示词"/>
|
:options="sysPromptOptions" placeholder="请选择系统提示词"/>
|
||||||
@ -690,4 +651,5 @@ function ReFlesh(source) {
|
|||||||
|
|
||||||
</template>
|
</template>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
||||||
</style>
|
</style>
|
@ -1,15 +1,15 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
import {h, onBeforeUnmount, onMounted, ref} from "vue";
|
import {computed, onBeforeUnmount, onMounted, ref} from "vue";
|
||||||
import {
|
import {
|
||||||
AddPrompt, DelPrompt,
|
AddPrompt, DelPrompt,
|
||||||
ExportConfig,
|
ExportConfig,
|
||||||
GetConfig,
|
GetConfig,
|
||||||
GetPromptTemplates,
|
GetPromptTemplates,
|
||||||
SendDingDingMessageByType,
|
SendDingDingMessageByType,
|
||||||
UpdateConfig,CheckSponsorCode
|
UpdateConfig
|
||||||
} from "../../wailsjs/go/main/App";
|
} from "../../wailsjs/go/main/App";
|
||||||
import {NTag, useMessage} from "naive-ui";
|
import {useMessage} from "naive-ui";
|
||||||
import {data, models} from "../../wailsjs/go/models";
|
import {data, models} from "../../wailsjs/go/models";
|
||||||
import {EventsEmit} from "../../wailsjs/runtime";
|
import {EventsEmit} from "../../wailsjs/runtime";
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
@ -46,7 +46,6 @@ const formValue = ref({
|
|||||||
darkTheme:true,
|
darkTheme:true,
|
||||||
enableFund:false,
|
enableFund:false,
|
||||||
enablePushNews:false,
|
enablePushNews:false,
|
||||||
sponsorCode:"",
|
|
||||||
})
|
})
|
||||||
const promptTemplates=ref([])
|
const promptTemplates=ref([])
|
||||||
onMounted(()=>{
|
onMounted(()=>{
|
||||||
@ -81,8 +80,6 @@ onMounted(()=>{
|
|||||||
formValue.value.darkTheme = res.darkTheme
|
formValue.value.darkTheme = res.darkTheme
|
||||||
formValue.value.enableFund = res.enableFund
|
formValue.value.enableFund = res.enableFund
|
||||||
formValue.value.enablePushNews = res.enablePushNews
|
formValue.value.enablePushNews = res.enablePushNews
|
||||||
formValue.value.sponsorCode = res.sponsorCode
|
|
||||||
|
|
||||||
|
|
||||||
//console.log(res)
|
//console.log(res)
|
||||||
})
|
})
|
||||||
@ -123,28 +120,15 @@ function saveConfig(){
|
|||||||
enableNews:formValue.value.enableNews,
|
enableNews:formValue.value.enableNews,
|
||||||
darkTheme:formValue.value.darkTheme,
|
darkTheme:formValue.value.darkTheme,
|
||||||
enableFund:formValue.value.enableFund,
|
enableFund:formValue.value.enableFund,
|
||||||
enablePushNews:formValue.value.enablePushNews,
|
enablePushNews:formValue.value.enablePushNews
|
||||||
sponsorCode:formValue.value.sponsorCode
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (config.sponsorCode){
|
|
||||||
CheckSponsorCode(config.sponsorCode).then(res=>{
|
|
||||||
if (res.code){
|
|
||||||
UpdateConfig(config).then(res=>{
|
|
||||||
message.success(res)
|
|
||||||
EventsEmit("updateSettings", config);
|
|
||||||
})
|
|
||||||
}else{
|
|
||||||
message.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}else{
|
|
||||||
UpdateConfig(config).then(res=>{
|
|
||||||
message.success(res)
|
|
||||||
EventsEmit("updateSettings", config);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//console.log("Settings",config)
|
||||||
|
UpdateConfig(config).then(res=>{
|
||||||
|
message.success(res)
|
||||||
|
EventsEmit("updateSettings", config);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -215,7 +199,6 @@ function importConfig(){
|
|||||||
formValue.value.darkTheme = config.darkTheme
|
formValue.value.darkTheme = config.darkTheme
|
||||||
formValue.value.enableFund = config.enableFund
|
formValue.value.enableFund = config.enableFund
|
||||||
formValue.value.enablePushNews = config.enablePushNews
|
formValue.value.enablePushNews = config.enablePushNews
|
||||||
formValue.value.sponsorCode = config.sponsorCode
|
|
||||||
// formRef.value.resetFields()
|
// formRef.value.resetFields()
|
||||||
};
|
};
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
@ -284,13 +267,12 @@ function deletePrompt(ID){
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<n-flex justify="left" style="text-align: left;--wails-draggable:drag" >
|
<n-flex justify="left" style="margin-top: 12px;padding-left: 12px;">
|
||||||
<n-form ref="formRef" :label-placement="'left'" :label-align="'left'" >
|
<n-form ref="formRef" :label-placement="'left'" :label-align="'left'" >
|
||||||
<n-card :title="()=> h(NTag, { type: 'primary',bordered:false },()=> '基础设置')" size="small" >
|
<n-grid :cols="24" :x-gap="24" style="text-align: left" :layout-shift-disabled="true">
|
||||||
<n-grid :cols="24" :x-gap="24" style="text-align: left" >
|
<n-gi :span="24">
|
||||||
<!-- <n-gi :span="24">-->
|
<n-text type="success" style="font-size: 25px;font-weight: bold">基础设置</n-text>
|
||||||
<!-- <n-text type="success" style="font-size: 25px;font-weight: bold">基础设置</n-text>-->
|
</n-gi>
|
||||||
<!-- </n-gi>-->
|
|
||||||
<n-form-item-gi :span="10" label="Tushare Token:" path="tushareToken" >
|
<n-form-item-gi :span="10" label="Tushare Token:" path="tushareToken" >
|
||||||
<n-input type="text" placeholder="Tushare api token" v-model:value="formValue.tushareToken" clearable />
|
<n-input type="text" placeholder="Tushare api token" v-model:value="formValue.tushareToken" clearable />
|
||||||
</n-form-item-gi>
|
</n-form-item-gi>
|
||||||
@ -310,24 +292,15 @@ function deletePrompt(ID){
|
|||||||
<n-form-item-gi :span="10" label="浏览器安装路径:" path="browserPath" >
|
<n-form-item-gi :span="10" label="浏览器安装路径:" path="browserPath" >
|
||||||
<n-input type="text" placeholder="浏览器安装路径" v-model:value="formValue.browserPath" clearable />
|
<n-input type="text" placeholder="浏览器安装路径" v-model:value="formValue.browserPath" clearable />
|
||||||
</n-form-item-gi>
|
</n-form-item-gi>
|
||||||
<n-form-item-gi :span="3" label="指数基金:" path="enableFund" >
|
<n-form-item-gi :span="6" label="指数基金:" path="enableFund" >
|
||||||
<n-switch v-model:value="formValue.enableFund" />
|
<n-switch v-model:value="formValue.enableFund" />
|
||||||
</n-form-item-gi>
|
</n-form-item-gi>
|
||||||
<n-form-item-gi :span="11" label="赞助码:" path="sponsorCode" >
|
|
||||||
<n-input-group>
|
|
||||||
<n-input :show-count="true" placeholder="赞助码" v-model:value="formValue.sponsorCode" />
|
|
||||||
<n-button type="success" secondary strong @click="CheckSponsorCode(formValue.sponsorCode).then((res) => {message.warning(res.msg) })">验证</n-button>
|
|
||||||
</n-input-group>
|
|
||||||
</n-form-item-gi>
|
|
||||||
</n-grid>
|
</n-grid>
|
||||||
</n-card>
|
|
||||||
|
|
||||||
|
|
||||||
<n-card :title="()=> h(NTag, { type: 'primary',bordered:false },()=> '通知设置')" size="small" >
|
|
||||||
<n-grid :cols="24" :x-gap="24" style="text-align: left">
|
<n-grid :cols="24" :x-gap="24" style="text-align: left">
|
||||||
<!-- <n-gi :span="24">-->
|
<n-gi :span="24">
|
||||||
<!-- <n-text type="success" style="font-size: 25px;font-weight: bold">通知设置</n-text>-->
|
<n-text type="success" style="font-size: 25px;font-weight: bold">通知设置</n-text>
|
||||||
<!-- </n-gi>-->
|
</n-gi>
|
||||||
<n-form-item-gi :span="4" label="钉钉推送:" path="dingPush.enable" >
|
<n-form-item-gi :span="4" label="钉钉推送:" path="dingPush.enable" >
|
||||||
<n-switch v-model:value="formValue.dingPush.enable" />
|
<n-switch v-model:value="formValue.dingPush.enable" />
|
||||||
</n-form-item-gi>
|
</n-form-item-gi>
|
||||||
@ -348,13 +321,11 @@ function deletePrompt(ID){
|
|||||||
<n-button type="primary" @click="sendTestNotice">发送测试通知</n-button>
|
<n-button type="primary" @click="sendTestNotice">发送测试通知</n-button>
|
||||||
</n-form-item-gi>
|
</n-form-item-gi>
|
||||||
</n-grid>
|
</n-grid>
|
||||||
</n-card>
|
|
||||||
|
|
||||||
<n-card :title="()=> h(NTag, { type: 'primary',bordered:false },()=> 'AI设置')" size="small" >
|
|
||||||
<n-grid :cols="24" :x-gap="24" style="text-align: left;">
|
<n-grid :cols="24" :x-gap="24" style="text-align: left;">
|
||||||
<!-- <n-gi :span="24">-->
|
<n-gi :span="24">
|
||||||
<!-- <n-text type="success" style="font-size: 25px;font-weight: bold">OpenAI设置</n-text>-->
|
<n-text type="success" style="font-size: 25px;font-weight: bold">OpenAI设置</n-text>
|
||||||
<!-- </n-gi>-->
|
</n-gi>
|
||||||
<n-form-item-gi :span="3" label="AI诊股:" path="openAI.enable" >
|
<n-form-item-gi :span="3" label="AI诊股:" path="openAI.enable" >
|
||||||
<n-switch v-model:value="formValue.openAI.enable" />
|
<n-switch v-model:value="formValue.openAI.enable" />
|
||||||
</n-form-item-gi>
|
</n-form-item-gi>
|
||||||
@ -405,38 +376,28 @@ function deletePrompt(ID){
|
|||||||
/>
|
/>
|
||||||
</n-form-item-gi>
|
</n-form-item-gi>
|
||||||
</n-grid>
|
</n-grid>
|
||||||
<n-grid :cols="24">
|
<n-gi :span="24">
|
||||||
<n-gi :span="24">
|
|
||||||
<n-space justify="center">
|
<n-space justify="center">
|
||||||
<n-button type="warning" @click="managePrompts">
|
<n-button type="warning" @click="managePrompts">
|
||||||
添加提示词模板
|
添加提示词模板
|
||||||
</n-button>
|
</n-button>
|
||||||
<n-button type="primary" @click="saveConfig">
|
<n-button type="primary" @click="saveConfig">
|
||||||
保存
|
保存
|
||||||
</n-button>
|
</n-button>
|
||||||
<n-button type="info" @click="exportConfig">
|
<n-button type="info" @click="exportConfig">
|
||||||
导出
|
导出
|
||||||
</n-button>
|
</n-button>
|
||||||
<n-button type="error" @click="importConfig">
|
<n-button type="error" @click="importConfig">
|
||||||
导入
|
导入
|
||||||
</n-button>
|
</n-button>
|
||||||
</n-space>
|
</n-space>
|
||||||
</n-gi>
|
</n-gi>
|
||||||
<n-gi :span="24" v-if="promptTemplates.length>0" type="warning">
|
|
||||||
<n-flex justify="start" style="margin-top: 4px" >
|
|
||||||
<n-text type="warning" >
|
|
||||||
<n-flex justify="left" >
|
|
||||||
<n-tag :bordered="false" type="warning" > 提示词模板:</n-tag>
|
|
||||||
<n-tag size="medium" secondary v-if="promptTemplates.length>0" v-for="prompt in promptTemplates" closable @close="deletePrompt(prompt.ID)" @click="editPrompt(prompt)" :title="prompt.content"
|
|
||||||
:type="prompt.type==='模型系统Prompt'?'success':'info'" :bordered="false"> {{ prompt.name }}
|
|
||||||
</n-tag>
|
|
||||||
</n-flex>
|
|
||||||
</n-text>
|
|
||||||
</n-flex>
|
|
||||||
</n-gi>
|
|
||||||
</n-grid>
|
|
||||||
</n-card>
|
|
||||||
</n-form>
|
</n-form>
|
||||||
|
<n-gi :span="24" v-if="promptTemplates.length>0" v-for="prompt in promptTemplates" >
|
||||||
|
<n-flex justify="start">
|
||||||
|
<n-tag closable @close="deletePrompt(prompt.ID)" @click="editPrompt(prompt)" :title="prompt.content" :type="prompt.type==='模型系统Prompt'?'success':'info'" :bordered="false"> {{prompt.name}} </n-tag>
|
||||||
|
</n-flex>
|
||||||
|
</n-gi>
|
||||||
</n-flex>
|
</n-flex>
|
||||||
<n-modal v-model:show="showManagePromptsModal" closable :mask-closable="false">
|
<n-modal v-model:show="showManagePromptsModal" closable :mask-closable="false">
|
||||||
<n-card
|
<n-card
|
||||||
@ -481,9 +442,5 @@ function deletePrompt(ID){
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.cardHeaderClass{
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: bold;
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
@ -26,10 +26,7 @@ import {
|
|||||||
SetStockAICron,
|
SetStockAICron,
|
||||||
SetStockSort,
|
SetStockSort,
|
||||||
ShareAnalysis,
|
ShareAnalysis,
|
||||||
UnFollow,
|
UnFollow
|
||||||
OpenURL,
|
|
||||||
SaveImage,
|
|
||||||
SaveWordFile
|
|
||||||
} from '../../wailsjs/go/main/App'
|
} from '../../wailsjs/go/main/App'
|
||||||
import {
|
import {
|
||||||
NAvatar,
|
NAvatar,
|
||||||
@ -44,7 +41,6 @@ import {
|
|||||||
useNotification
|
useNotification
|
||||||
} from 'naive-ui'
|
} from 'naive-ui'
|
||||||
import {
|
import {
|
||||||
Environment,
|
|
||||||
EventsEmit,
|
EventsEmit,
|
||||||
EventsOff,
|
EventsOff,
|
||||||
EventsOn,
|
EventsOn,
|
||||||
@ -67,8 +63,6 @@ import vueDanmaku from 'vue3-danmaku'
|
|||||||
import {keys, padStart} from "lodash";
|
import {keys, padStart} from "lodash";
|
||||||
import {useRoute, useRouter} from 'vue-router'
|
import {useRoute, useRouter} from 'vue-router'
|
||||||
import MoneyTrend from "./moneyTrend.vue";
|
import MoneyTrend from "./moneyTrend.vue";
|
||||||
import {TaskTools} from "@vicons/carbon";
|
|
||||||
import StockSparkLine from "./stockSparkLine.vue";
|
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@ -107,7 +101,6 @@ const modalShow3 = ref(false)
|
|||||||
const modalShow4 = ref(false)
|
const modalShow4 = ref(false)
|
||||||
const modalShow5 = ref(false)
|
const modalShow5 = ref(false)
|
||||||
const addBTN = ref(true)
|
const addBTN = ref(true)
|
||||||
const enableTools = ref(false)
|
|
||||||
const formModel = ref({
|
const formModel = ref({
|
||||||
name: "",
|
name: "",
|
||||||
code: "",
|
code: "",
|
||||||
@ -230,11 +223,8 @@ onMounted(() => {
|
|||||||
if (!stocks.value.includes(followedStock.StockCode)) {
|
if (!stocks.value.includes(followedStock.StockCode)) {
|
||||||
stocks.value.push(followedStock.StockCode)
|
stocks.value.push(followedStock.StockCode)
|
||||||
}
|
}
|
||||||
Greet(followedStock.StockCode).then(result => {
|
|
||||||
updateData(result)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
//monitor()
|
monitor()
|
||||||
message.destroyAll()
|
message.destroyAll()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -388,15 +378,7 @@ EventsOn("updateVersion", async (msg) => {
|
|||||||
type: 'primary',
|
type: 'primary',
|
||||||
size: 'small',
|
size: 'small',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
Environment().then(env => {
|
window.open(msg.html_url)
|
||||||
switch (env.platform) {
|
|
||||||
case 'windows':
|
|
||||||
window.open(msg.html_url)
|
|
||||||
break
|
|
||||||
default :
|
|
||||||
OpenURL(msg.html_url)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}, {default: () => '查看'})
|
}, {default: () => '查看'})
|
||||||
}
|
}
|
||||||
@ -453,7 +435,7 @@ function AddStock() {
|
|||||||
Follow(data.code).then(result => {
|
Follow(data.code).then(result => {
|
||||||
if (result === "关注成功") {
|
if (result === "关注成功") {
|
||||||
if (data.code.startsWith("us")) {
|
if (data.code.startsWith("us")) {
|
||||||
data.code = "gb_" + data.code.replace("us", "").toLowerCase()
|
data.code= "gb_" + data.code.replace("us", "").toLowerCase()
|
||||||
}
|
}
|
||||||
stocks.value.push(data.code)
|
stocks.value.push(data.code)
|
||||||
message.success(result)
|
message.success(result)
|
||||||
@ -482,7 +464,6 @@ function removeMonitor(code, name, key) {
|
|||||||
|
|
||||||
UnFollow(code).then(result => {
|
UnFollow(code).then(result => {
|
||||||
message.success(result)
|
message.success(result)
|
||||||
monitor()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -600,6 +581,7 @@ async function monitor() {
|
|||||||
showPopover.value = true
|
showPopover.value = true
|
||||||
}
|
}
|
||||||
for (let code of stocks.value) {
|
for (let code of stocks.value) {
|
||||||
|
|
||||||
Greet(code).then(result => {
|
Greet(code).then(result => {
|
||||||
updateData(result)
|
updateData(result)
|
||||||
})
|
})
|
||||||
@ -608,7 +590,8 @@ async function monitor() {
|
|||||||
|
|
||||||
|
|
||||||
function GetSortKey(sort, code) {
|
function GetSortKey(sort, code) {
|
||||||
return padStart(sort, 8, '0') + "_" + code
|
let sortKey = padStart(sort, 8, '0') + "_" + code
|
||||||
|
return sortKey
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSelect(item) {
|
function onSelect(item) {
|
||||||
@ -626,28 +609,12 @@ function onSelect(item) {
|
|||||||
function openCenteredWindow(url, width, height) {
|
function openCenteredWindow(url, width, height) {
|
||||||
const left = (window.screen.width - width) / 2;
|
const left = (window.screen.width - width) / 2;
|
||||||
const top = (window.screen.height - height) / 2;
|
const top = (window.screen.height - height) / 2;
|
||||||
Environment().then(env => {
|
|
||||||
switch (env.platform) {
|
|
||||||
case 'windows':
|
|
||||||
window.open(
|
|
||||||
url,
|
|
||||||
'centeredWindow',
|
|
||||||
`width=${width},height=${height},left=${left},top=${top},location=no,menubar=no,toolbar=no,display=standalone`
|
|
||||||
)
|
|
||||||
break
|
|
||||||
default :
|
|
||||||
OpenURL(url)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
return window.open(
|
||||||
//
|
url,
|
||||||
// return window.open(
|
'centeredWindow',
|
||||||
// url,
|
`width=${width},height=${height},left=${left},top=${top}`
|
||||||
// 'centeredWindow',
|
);
|
||||||
// `width=${width},height=${height},left=${left},top=${top}`
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function search(code, name) {
|
function search(code, name) {
|
||||||
@ -659,7 +626,7 @@ function search(code, name) {
|
|||||||
//window.open("https://www.iwencai.com/unifiedwap/result?w=" + name)
|
//window.open("https://www.iwencai.com/unifiedwap/result?w=" + name)
|
||||||
//window.open("https://www.iwencai.com/chat/?question="+code)
|
//window.open("https://www.iwencai.com/chat/?question="+code)
|
||||||
|
|
||||||
openCenteredWindow("https://www.iwencai.com/unifiedwap/result?w=" + name, 1000, 800)
|
openCenteredWindow("https://www.iwencai.com/unifiedwap/result?w=" + name,1000,800)
|
||||||
|
|
||||||
}, 500)
|
}, 500)
|
||||||
}
|
}
|
||||||
@ -1387,7 +1354,7 @@ function aiReCheckStock(stock, stockCode) {
|
|||||||
//
|
//
|
||||||
|
|
||||||
//message.info("sysPromptId:"+data.sysPromptId)
|
//message.info("sysPromptId:"+data.sysPromptId)
|
||||||
NewChatStream(stock, stockCode, data.question, data.sysPromptId, enableTools.value)
|
NewChatStream(stock, stockCode, data.question, data.sysPromptId)
|
||||||
}
|
}
|
||||||
|
|
||||||
function aiCheckStock(stock, stockCode) {
|
function aiCheckStock(stock, stockCode) {
|
||||||
@ -1416,12 +1383,12 @@ function aiCheckStock(stock, stockCode) {
|
|||||||
data.time = ""
|
data.time = ""
|
||||||
data.name = stock
|
data.name = stock
|
||||||
data.code = stockCode
|
data.code = stockCode
|
||||||
data.loading = false
|
data.loading = true
|
||||||
modalShow4.value = true
|
modalShow4.value = true
|
||||||
// message.loading("ai检测中...", {
|
message.loading("ai检测中...", {
|
||||||
// duration: 0,
|
duration: 0,
|
||||||
// })
|
})
|
||||||
// NewChatStream(stock, stockCode, "", data.sysPromptId)
|
NewChatStream(stock, stockCode, "", data.sysPromptId)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1465,42 +1432,21 @@ window.onerror = function (msg, source, lineno, colno, error) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function saveAsImage(name, code) {
|
function saveAsImage(name, code) {
|
||||||
Environment().then(env => {
|
const element = document.querySelector('.md-editor-preview');
|
||||||
switch (env.platform) {
|
if (element) {
|
||||||
case 'windows':
|
html2canvas(element, {
|
||||||
const element = document.querySelector('.md-editor-preview');
|
useCORS: true, // 解决跨域图片问题
|
||||||
if (element) {
|
scale: 2, // 提高截图质量
|
||||||
html2canvas(element, {
|
allowTaint: true, // 允许跨域图片
|
||||||
useCORS: true, // 解决跨域图片问题
|
}).then(canvas => {
|
||||||
scale: 2, // 提高截图质量
|
const link = document.createElement('a');
|
||||||
allowTaint: true, // 允许跨域图片
|
link.href = canvas.toDataURL('image/png');
|
||||||
}).then(canvas => {
|
link.download = name + "[" + code + ']-ai-analysis-result.png';
|
||||||
const link = document.createElement('a');
|
link.click();
|
||||||
link.href = canvas.toDataURL('image/png');
|
});
|
||||||
link.download = name + "[" + code + ']-ai-analysis-result.png';
|
} else {
|
||||||
link.click();
|
message.error('无法找到分析结果元素');
|
||||||
});
|
}
|
||||||
} else {
|
|
||||||
message.error('无法找到分析结果元素');
|
|
||||||
}
|
|
||||||
break
|
|
||||||
default :
|
|
||||||
saveCanvasImage(name)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveCanvasImage(name) {
|
|
||||||
const element = document.querySelector('.md-editor-preview'); // 要截图的 DOM 节点
|
|
||||||
const canvas = await html2canvas(element)
|
|
||||||
|
|
||||||
const dataUrl = canvas.toDataURL('image/png') // base64 格式
|
|
||||||
const base64 = dataUrl.replace(/^data:image\/png;base64,/, '')
|
|
||||||
|
|
||||||
// 调用 Go 后端保存文件(Wails 绑定方法)
|
|
||||||
await SaveImage(name,base64).then(result => {
|
|
||||||
message.success(result)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function copyToClipboard() {
|
async function copyToClipboard() {
|
||||||
@ -1560,26 +1506,13 @@ AI赋能股票分析:自选股行情获取,成本盈亏展示,涨跌报警
|
|||||||
`
|
`
|
||||||
// landscape就是横着的,portrait是竖着的,默认是竖屏portrait。
|
// landscape就是横着的,portrait是竖着的,默认是竖屏portrait。
|
||||||
const blob = await asBlob(value, {orientation: 'portrait'})
|
const blob = await asBlob(value, {orientation: 'portrait'})
|
||||||
const { platform } = await Environment()
|
const a = document.createElement('a')
|
||||||
switch (platform) {
|
a.href = URL.createObjectURL(blob)
|
||||||
case 'windows':
|
a.download = `${data.name}[${data.code}]-ai-analysis-result.docx`;
|
||||||
const a = document.createElement('a')
|
a.click()
|
||||||
a.href = URL.createObjectURL(blob)
|
// 下载后将标签移除
|
||||||
a.download = `${data.name}[${data.code}]-ai-analysis-result.docx`;
|
URL.revokeObjectURL(a.href);
|
||||||
a.click()
|
a.remove()
|
||||||
// 下载后将标签移除
|
|
||||||
URL.revokeObjectURL(a.href);
|
|
||||||
a.remove()
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
const arrayBuffer = await blob.arrayBuffer()
|
|
||||||
const uint8Array = new Uint8Array(arrayBuffer)
|
|
||||||
const binary = uint8Array.reduce((data, byte) => data + String.fromCharCode(byte), '')
|
|
||||||
const base64 = btoa(binary)
|
|
||||||
await SaveWordFile(`${data.name}[${data.code}]-ai-analysis-result.docx`, base64).then(result => {
|
|
||||||
message.success(result)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function share(code, name) {
|
function share(code, name) {
|
||||||
@ -1640,20 +1573,18 @@ function AddStockGroupInfo(groupId, code, name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateTab(name) {
|
function updateTab(name) {
|
||||||
stocks.value = []
|
|
||||||
currentGroupId.value = Number(name)
|
currentGroupId.value = Number(name)
|
||||||
GetFollowList(currentGroupId.value).then(result => {
|
GetFollowList(currentGroupId.value).then(result => {
|
||||||
|
stocks.value = []
|
||||||
followList.value = result
|
followList.value = result
|
||||||
for (const followedStock of result) {
|
for (const followedStock of result) {
|
||||||
if (followedStock.StockCode.startsWith("us")) {
|
if (followedStock.StockCode.startsWith("us")) {
|
||||||
followedStock.StockCode = "gb_" + followedStock.StockCode.replace("us", "").toLowerCase()
|
followedStock.StockCode = "gb_" + followedStock.StockCode.replace("us", "").toLowerCase()
|
||||||
}
|
}
|
||||||
|
////console.log("followList",followedStock.StockCode)
|
||||||
stocks.value.push(followedStock.StockCode)
|
stocks.value.push(followedStock.StockCode)
|
||||||
Greet(followedStock.StockCode).then(result => {
|
|
||||||
updateData(result)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
//monitor()
|
monitor()
|
||||||
message.destroyAll()
|
message.destroyAll()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1808,20 +1739,18 @@ function searchStockReport(stockCode) {
|
|||||||
@click="removeMonitor(result['股票代码'],result['股票名称'],result.key)">
|
@click="removeMonitor(result['股票代码'],result['股票名称'],result.key)">
|
||||||
取消关注
|
取消关注
|
||||||
</n-button>
|
</n-button>
|
||||||
|
|
||||||
<n-button size="tiny" v-if="data.openAiEnable" secondary type="warning"
|
<n-button size="tiny" v-if="data.openAiEnable" secondary type="warning"
|
||||||
@click="aiCheckStock(result['股票名称'],result['股票代码'])">
|
@click="aiCheckStock(result['股票名称'],result['股票代码'])">
|
||||||
AI分析
|
AI分析
|
||||||
</n-button>
|
</n-button>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<n-flex justify="center">
|
<n-flex justify="center">
|
||||||
<n-text :type="'info'">{{ result["日期"] + " " + result["时间"] }}</n-text>
|
<n-text :type="'info'">{{ result["日期"] + " " + result["时间"] }}</n-text>
|
||||||
<n-tag size="small" v-if="result.volume>0" :type="result.profitType">{{ result.volume + "股" }}</n-tag>
|
<n-tag size="small" v-if="result.volume>0" :type="result.profitType">{{ result.volume + "股" }}</n-tag>
|
||||||
<n-tag size="small" v-if="result.costPrice>0" :type="result.profitType">
|
<n-tag size="small" v-if="result.costPrice>0" :type="result.profitType">
|
||||||
{{
|
{{ "成本:" + result.costPrice + "*" + result.costVolume + " " + result.profit + "%" + " ( " + result.profitAmount + " ¥ )" }}
|
||||||
"成本:" + result.costPrice + "*" + result.costVolume + " " + result.profit + "%" + " ( " + result.profitAmount + " ¥ )"
|
|
||||||
}}
|
|
||||||
</n-tag>
|
</n-tag>
|
||||||
</n-flex>
|
</n-flex>
|
||||||
</template>
|
</template>
|
||||||
@ -1862,8 +1791,8 @@ function searchStockReport(stockCode) {
|
|||||||
<n-card :data-sort="result.sort" :id="result['股票代码']" :data-code="result['股票代码']" :bordered="true"
|
<n-card :data-sort="result.sort" :id="result['股票代码']" :data-code="result['股票代码']" :bordered="true"
|
||||||
:title="result['股票名称']" :closable="false"
|
:title="result['股票名称']" :closable="false"
|
||||||
@close="removeMonitor(result['股票代码'],result['股票名称'],result.key)">
|
@close="removeMonitor(result['股票代码'],result['股票名称'],result.key)">
|
||||||
<n-grid :cols="12" :y-gap="6">
|
<n-grid :cols="1" :y-gap="6">
|
||||||
<n-gi :span="6">
|
<n-gi>
|
||||||
<n-text :type="result.type">
|
<n-text :type="result.type">
|
||||||
<n-number-animation :duration="1000" :precision="2" :from="result['上次当前价格']"
|
<n-number-animation :duration="1000" :precision="2" :from="result['上次当前价格']"
|
||||||
:to="Number(result['当前价格'])"/>
|
:to="Number(result['当前价格'])"/>
|
||||||
@ -1879,10 +1808,6 @@ function searchStockReport(stockCode) {
|
|||||||
<n-number-animation :duration="1000" :precision="2" :from="0" :to="result.profitAmountToday"/>
|
<n-number-animation :duration="1000" :precision="2" :from="0" :to="result.profitAmountToday"/>
|
||||||
</n-text>
|
</n-text>
|
||||||
</n-gi>
|
</n-gi>
|
||||||
<n-gi :span="6">
|
|
||||||
<stock-spark-line :last-price="Number(result['当前价格'])" :open-price="Number(result['昨日收盘价'])"
|
|
||||||
:stock-code="result['股票代码']" :stock-name="result['股票名称']"></stock-spark-line>
|
|
||||||
</n-gi>
|
|
||||||
</n-grid>
|
</n-grid>
|
||||||
<n-grid :cols="2" :y-gap="4" :x-gap="4">
|
<n-grid :cols="2" :y-gap="4" :x-gap="4">
|
||||||
<n-gi>
|
<n-gi>
|
||||||
@ -1951,11 +1876,10 @@ function searchStockReport(stockCode) {
|
|||||||
@click="removeMonitor(result['股票代码'],result['股票名称'],result.key)">
|
@click="removeMonitor(result['股票代码'],result['股票名称'],result.key)">
|
||||||
取消关注
|
取消关注
|
||||||
</n-button>
|
</n-button>
|
||||||
|
|
||||||
<n-button size="tiny" v-if="data.openAiEnable" secondary type="warning"
|
<n-button size="tiny" v-if="data.openAiEnable" secondary type="warning"
|
||||||
@click="aiCheckStock(result['股票名称'],result['股票代码'])">
|
@click="aiCheckStock(result['股票名称'],result['股票代码'])">
|
||||||
AI分析
|
AI分析
|
||||||
</n-button>
|
</n-button>
|
||||||
<n-button secondary type="error" size="tiny"
|
<n-button secondary type="error" size="tiny"
|
||||||
@click="delStockGroup(result['股票代码'],result['股票名称'],group.ID)">移出分组
|
@click="delStockGroup(result['股票代码'],result['股票名称'],group.ID)">移出分组
|
||||||
</n-button>
|
</n-button>
|
||||||
@ -1965,9 +1889,7 @@ function searchStockReport(stockCode) {
|
|||||||
<n-text :type="'info'">{{ result["日期"] + " " + result["时间"] }}</n-text>
|
<n-text :type="'info'">{{ result["日期"] + " " + result["时间"] }}</n-text>
|
||||||
<n-tag size="small" v-if="result.volume>0" :type="result.profitType">{{ result.volume + "股" }}</n-tag>
|
<n-tag size="small" v-if="result.volume>0" :type="result.profitType">{{ result.volume + "股" }}</n-tag>
|
||||||
<n-tag size="small" v-if="result.costPrice>0" :type="result.profitType">
|
<n-tag size="small" v-if="result.costPrice>0" :type="result.profitType">
|
||||||
{{
|
{{ "成本:" + result.costPrice + "*" + result.costVolume + " " + result.profit + "%" + " ( " + result.profitAmount + " ¥ )" }}
|
||||||
"成本:" + result.costPrice + "*" + result.costVolume + " " + result.profit + "%" + " ( " + result.profitAmount + " ¥ )"
|
|
||||||
}}
|
|
||||||
</n-tag>
|
</n-tag>
|
||||||
</n-flex>
|
</n-flex>
|
||||||
</template>
|
</template>
|
||||||
@ -2123,7 +2045,7 @@ function searchStockReport(stockCode) {
|
|||||||
</n-modal>
|
</n-modal>
|
||||||
|
|
||||||
<n-modal transform-origin="center" v-model:show="modalShow4" preset="card" style="width: 800px;"
|
<n-modal transform-origin="center" v-model:show="modalShow4" preset="card" style="width: 800px;"
|
||||||
:title="'['+data.name+']AI分析'">
|
:title="'['+data.name+']AI分析结果'">
|
||||||
<n-spin size="small" :show="data.loading">
|
<n-spin size="small" :show="data.loading">
|
||||||
<MdEditor v-if="enableEditor" :toolbars="toolbars" ref="mdEditorRef" style="height: 440px;text-align: left"
|
<MdEditor v-if="enableEditor" :toolbars="toolbars" ref="mdEditorRef" style="height: 440px;text-align: left"
|
||||||
:modelValue="data.airesult" :theme="theme">
|
:modelValue="data.airesult" :theme="theme">
|
||||||
@ -2147,19 +2069,7 @@ function searchStockReport(stockCode) {
|
|||||||
</n-flex>
|
</n-flex>
|
||||||
</template>
|
</template>
|
||||||
<template #action>
|
<template #action>
|
||||||
<n-flex justify="left" style="margin-bottom: 10px">
|
|
||||||
<n-switch v-model:value="enableTools" :round="false">
|
|
||||||
<template #checked>
|
|
||||||
启用AI函数工具调用
|
|
||||||
</template>
|
|
||||||
<template #unchecked>
|
|
||||||
不启用AI函数工具调用
|
|
||||||
</template>
|
|
||||||
</n-switch>
|
|
||||||
<n-gradient-text type="error" style="margin-left: 10px">
|
|
||||||
*AI函数工具调用可以增强AI获取数据的能力,但会消耗更多tokens。
|
|
||||||
</n-gradient-text>
|
|
||||||
</n-flex>
|
|
||||||
<n-flex justify="space-between" style="margin-bottom: 10px">
|
<n-flex justify="space-between" style="margin-bottom: 10px">
|
||||||
<n-select style="width: 49%" v-model:value="data.sysPromptId" label-field="name" value-field="ID"
|
<n-select style="width: 49%" v-model:value="data.sysPromptId" label-field="name" value-field="ID"
|
||||||
:options="sysPromptOptions" placeholder="请选择系统提示词"/>
|
:options="sysPromptOptions" placeholder="请选择系统提示词"/>
|
||||||
@ -2177,7 +2087,7 @@ function searchStockReport(stockCode) {
|
|||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
<!-- <n-button size="tiny" type="error" @click="enableEditor=!enableEditor">编辑/预览</n-button>-->
|
<!-- <n-button size="tiny" type="error" @click="enableEditor=!enableEditor">编辑/预览</n-button>-->
|
||||||
<n-button size="tiny" type="warning" @click="aiReCheckStock(data.name,data.code)">开始AI分析</n-button>
|
<n-button size="tiny" type="warning" @click="aiReCheckStock(data.name,data.code)">再次分析</n-button>
|
||||||
<n-button size="tiny" type="info" @click="saveAsImage(data.name,data.code)">保存为图片</n-button>
|
<n-button size="tiny" type="info" @click="saveAsImage(data.name,data.code)">保存为图片</n-button>
|
||||||
<n-button size="tiny" type="success" @click="copyToClipboard">复制到剪切板</n-button>
|
<n-button size="tiny" type="success" @click="copyToClipboard">复制到剪切板</n-button>
|
||||||
<n-button size="tiny" type="primary" @click="saveAsMarkdown">保存为Markdown文件</n-button>
|
<n-button size="tiny" type="primary" @click="saveAsMarkdown">保存为Markdown文件</n-button>
|
||||||
|
@ -1,137 +0,0 @@
|
|||||||
<script setup>
|
|
||||||
import {onMounted, onBeforeMount, ref, watchEffect} from "vue";
|
|
||||||
import * as echarts from 'echarts';
|
|
||||||
import {GetStockMinutePriceLineData} from "../../wailsjs/go/main/App"; // 如果您使用多个组件,请将此样式导入放在您的主文件中
|
|
||||||
const {stockCode,stockName,lastPrice,openPrice,darkTheme} = defineProps({
|
|
||||||
stockCode: {
|
|
||||||
type: String,
|
|
||||||
default: ""
|
|
||||||
},
|
|
||||||
stockName: {
|
|
||||||
type: String,
|
|
||||||
default: ""
|
|
||||||
},
|
|
||||||
lastPrice: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
openPrice: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
darkTheme: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const chartRef=ref();
|
|
||||||
|
|
||||||
function setChartData(chart) {
|
|
||||||
//console.log("setChartData")
|
|
||||||
GetStockMinutePriceLineData(stockCode, stockName).then(result => {
|
|
||||||
//console.log("GetStockMinutePriceLineData",result)
|
|
||||||
const priceData = result.priceData
|
|
||||||
let category = []
|
|
||||||
let price = []
|
|
||||||
let min = 0
|
|
||||||
let max = 0
|
|
||||||
for (let i = 0; i < priceData.length; i++) {
|
|
||||||
category.push(priceData[i].time)
|
|
||||||
price.push(priceData[i].price)
|
|
||||||
if (min === 0 || min > priceData[i].price) {
|
|
||||||
min = priceData[i].price
|
|
||||||
}
|
|
||||||
if (max < priceData[i].price) {
|
|
||||||
max = priceData[i].price
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let option = {
|
|
||||||
padding: [0, 0, 0, 0],
|
|
||||||
grid: {
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
bottom: 0
|
|
||||||
},
|
|
||||||
tooltip: {
|
|
||||||
trigger: 'axis',
|
|
||||||
axisPointer: {
|
|
||||||
type: 'cross',
|
|
||||||
label: {
|
|
||||||
backgroundColor: '#6a7985'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
xAxis: {
|
|
||||||
show: false,
|
|
||||||
type: 'category',
|
|
||||||
data: category
|
|
||||||
},
|
|
||||||
yAxis: {
|
|
||||||
show: false,
|
|
||||||
type: 'value',
|
|
||||||
min: (min).toFixed(2),
|
|
||||||
max: (max).toFixed(2),
|
|
||||||
minInterval: 0.01,
|
|
||||||
},
|
|
||||||
// visualMap: {
|
|
||||||
// show: false,
|
|
||||||
// type: 'piecewise',
|
|
||||||
// pieces: [
|
|
||||||
// {
|
|
||||||
// min: Number(min),
|
|
||||||
// max: Number(openPrice),
|
|
||||||
// color: 'green'
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// min: Number(openPrice),
|
|
||||||
// max: Number(max),
|
|
||||||
// color: 'red'
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
// },
|
|
||||||
series: [
|
|
||||||
{
|
|
||||||
data: price,
|
|
||||||
type: 'line',
|
|
||||||
smooth: false,
|
|
||||||
stack: '总量',
|
|
||||||
showSymbol: false,
|
|
||||||
lineStyle: {
|
|
||||||
color: lastPrice > openPrice ? 'rgba(245, 0, 0, 1)' : 'rgb(6,251,10)'
|
|
||||||
},
|
|
||||||
areaStyle: {
|
|
||||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
|
||||||
offset: 0,
|
|
||||||
color: lastPrice > openPrice ? 'rgba(245, 0, 0, 1)' : 'rgba(6,251,10, 1)'
|
|
||||||
}, {
|
|
||||||
offset: 1,
|
|
||||||
color: lastPrice > openPrice ? 'rgba(245, 0, 0, 0.25)' : 'rgba(6,251,10, 0.25)'
|
|
||||||
}])
|
|
||||||
},
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
chart.setOption(option);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const chart =ref( null)
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
chart.value = echarts.init( document.getElementById('sparkLine'+stockCode));
|
|
||||||
setChartData(chart.value);
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
watchEffect(() => {
|
|
||||||
console.log(stockName,'lastPrice变化为:', lastPrice,lastPrice > openPrice)
|
|
||||||
setChartData(chart.value);
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<div style="height: 20px;width: 100%" :id="'sparkLine'+stockCode">
|
|
||||||
</div>
|
|
||||||
</template>
|
|
@ -1,36 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import {h} from 'vue'
|
|
||||||
import {NTag,NImage} from 'naive-ui'
|
|
||||||
import EmbeddedUrl from "./EmbeddedUrl.vue";
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<n-tabs type="line" animated>
|
|
||||||
<n-tab-pane name="选股通" tab="选股通">
|
|
||||||
<embedded-url url="https://xuangutong.com.cn" :height="'calc(100vh - 252px)'"/>
|
|
||||||
</n-tab-pane>
|
|
||||||
<!-- <n-tab-pane name="百度股市通" tab="百度股市通">-->
|
|
||||||
<!-- <embedded-url url="https://gushitong.baidu.com" :height="'calc(100vh - 252px)'"/>-->
|
|
||||||
<!-- </n-tab-pane>-->
|
|
||||||
<n-tab-pane name="东财大盘星图" tab="东财大盘星图">
|
|
||||||
<embedded-url url="https://quote.eastmoney.com/stockhotmap/" :height="'calc(100vh - 252px)'"/>
|
|
||||||
</n-tab-pane>
|
|
||||||
<n-tab-pane name="TopHub" tab="TopHub(今日热榜)">
|
|
||||||
<embedded-url url="https://tophub.today/c/finance" :height="'calc(100vh - 252px)'"/>
|
|
||||||
</n-tab-pane>
|
|
||||||
<!-- <n-tab-pane name="摸鱼" tab="摸鱼">-->
|
|
||||||
<!-- <embedded-url url="https://996.ninja/" :height="'calc(100vh - 252px)'"/>-->
|
|
||||||
<!-- </n-tab-pane>-->
|
|
||||||
|
|
||||||
|
|
||||||
<n-tab-pane name="欢迎推荐更多有趣的财经网页" tab="欢迎推荐更多有趣的财经网页">
|
|
||||||
</n-tab-pane>
|
|
||||||
<!-- <n-tab-pane name="自在量化" tab="自在量化">-->
|
|
||||||
<!-- <embedded-url url="https://quant.zizizaizai.com/home"/>-->
|
|
||||||
<!-- </n-tab-pane>-->
|
|
||||||
</n-tabs>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
@ -2,22 +2,21 @@ import {createMemoryHistory, createRouter, createWebHashHistory, createWebHistor
|
|||||||
|
|
||||||
import stockView from '../components/stock.vue'
|
import stockView from '../components/stock.vue'
|
||||||
import settingsView from '../components/settings.vue'
|
import settingsView from '../components/settings.vue'
|
||||||
import aboutView from "../components/about.vue";
|
import about from "../components/about.vue";
|
||||||
import fundView from "../components/fund.vue";
|
import fundView from "../components/fund.vue";
|
||||||
import marketView from "../components/market.vue";
|
import market from "../components/market.vue";
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{ path: '/', component: stockView,name: 'stock'},
|
{ path: '/', component: stockView,name: 'stock'},
|
||||||
{ path: '/fund', component: fundView,name: 'fund' },
|
{ path: '/fund', component: fundView,name: 'fund' },
|
||||||
{ path: '/settings', component: settingsView,name: 'settings' },
|
{ path: '/settings', component: settingsView,name: 'settings' },
|
||||||
{ path: '/about', component: aboutView,name: 'about' },
|
{ path: '/about', component: about,name: 'about' },
|
||||||
{ path: '/market', component: marketView,name: 'market' },
|
{ path: '/market', component: market,name: 'market' },
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
//history: createWebHistory(),
|
history: createWebHistory(),
|
||||||
history: createWebHashHistory(),
|
|
||||||
routes,
|
routes,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
16
frontend/wailsjs/go/main/App.d.ts
vendored
Executable file → Normal file
16
frontend/wailsjs/go/main/App.d.ts
vendored
Executable file → Normal file
@ -13,8 +13,6 @@ export function AddStockGroup(arg1:number,arg2:string):Promise<string>;
|
|||||||
|
|
||||||
export function AnalyzeSentiment(arg1:string):Promise<data.SentimentResult>;
|
export function AnalyzeSentiment(arg1:string):Promise<data.SentimentResult>;
|
||||||
|
|
||||||
export function CheckSponsorCode(arg1:string):Promise<Record<string, any>>;
|
|
||||||
|
|
||||||
export function CheckUpdate():Promise<void>;
|
export function CheckUpdate():Promise<void>;
|
||||||
|
|
||||||
export function ClsCalendar():Promise<Array<any>>;
|
export function ClsCalendar():Promise<Array<any>>;
|
||||||
@ -41,8 +39,6 @@ export function GetGroupList():Promise<Array<data.Group>>;
|
|||||||
|
|
||||||
export function GetGroupStockList(arg1:number):Promise<Array<data.GroupStock>>;
|
export function GetGroupStockList(arg1:number):Promise<Array<data.GroupStock>>;
|
||||||
|
|
||||||
export function GetHotStrategy():Promise<Record<string, any>>;
|
|
||||||
|
|
||||||
export function GetIndustryMoneyRankSina(arg1:string,arg2:string):Promise<Array<Record<string, any>>>;
|
export function GetIndustryMoneyRankSina(arg1:string,arg2:string):Promise<Array<Record<string, any>>>;
|
||||||
|
|
||||||
export function GetIndustryRank(arg1:string,arg2:number):Promise<Array<any>>;
|
export function GetIndustryRank(arg1:string,arg2:number):Promise<Array<any>>;
|
||||||
@ -51,8 +47,6 @@ export function GetMoneyRankSina(arg1:string):Promise<Array<Record<string, any>>
|
|||||||
|
|
||||||
export function GetPromptTemplates(arg1:string,arg2:string):Promise<any>;
|
export function GetPromptTemplates(arg1:string,arg2:string):Promise<any>;
|
||||||
|
|
||||||
export function GetSponsorInfo():Promise<Record<string, any>>;
|
|
||||||
|
|
||||||
export function GetStockCommonKLine(arg1:string,arg2:string,arg3:number):Promise<any>;
|
export function GetStockCommonKLine(arg1:string,arg2:string,arg3:number):Promise<any>;
|
||||||
|
|
||||||
export function GetStockKLine(arg1:string,arg2:string,arg3:number):Promise<any>;
|
export function GetStockKLine(arg1:string,arg2:string,arg3:number):Promise<any>;
|
||||||
@ -85,12 +79,10 @@ export function InvestCalendarTimeLine(arg1:string):Promise<Array<any>>;
|
|||||||
|
|
||||||
export function LongTigerRank(arg1:string):Promise<any>;
|
export function LongTigerRank(arg1:string):Promise<any>;
|
||||||
|
|
||||||
export function NewChatStream(arg1:string,arg2:string,arg3:string,arg4:any,arg5:boolean):Promise<void>;
|
export function NewChatStream(arg1:string,arg2:string,arg3:string,arg4:any):Promise<void>;
|
||||||
|
|
||||||
export function NewsPush(arg1:any):Promise<void>;
|
export function NewsPush(arg1:any):Promise<void>;
|
||||||
|
|
||||||
export function OpenURL(arg1:string):Promise<void>;
|
|
||||||
|
|
||||||
export function ReFleshTelegraphList(arg1:string):Promise<any>;
|
export function ReFleshTelegraphList(arg1:string):Promise<any>;
|
||||||
|
|
||||||
export function RemoveGroup(arg1:number):Promise<string>;
|
export function RemoveGroup(arg1:number):Promise<string>;
|
||||||
@ -101,10 +93,6 @@ export function SaveAIResponseResult(arg1:string,arg2:string,arg3:string,arg4:st
|
|||||||
|
|
||||||
export function SaveAsMarkdown(arg1:string,arg2:string):Promise<string>;
|
export function SaveAsMarkdown(arg1:string,arg2:string):Promise<string>;
|
||||||
|
|
||||||
export function SaveImage(arg1:string,arg2:string):Promise<string>;
|
|
||||||
|
|
||||||
export function SaveWordFile(arg1:string,arg2:string):Promise<string>;
|
|
||||||
|
|
||||||
export function SearchStock(arg1:string):Promise<Record<string, any>>;
|
export function SearchStock(arg1:string):Promise<Record<string, any>>;
|
||||||
|
|
||||||
export function SendDingDingMessage(arg1:string,arg2:string):Promise<string>;
|
export function SendDingDingMessage(arg1:string,arg2:string):Promise<string>;
|
||||||
@ -125,7 +113,7 @@ export function StockNotice(arg1:string):Promise<Array<any>>;
|
|||||||
|
|
||||||
export function StockResearchReport(arg1:string):Promise<Array<any>>;
|
export function StockResearchReport(arg1:string):Promise<Array<any>>;
|
||||||
|
|
||||||
export function SummaryStockNews(arg1:string,arg2:any,arg3:boolean):Promise<void>;
|
export function SummaryStockNews(arg1:string,arg2:any):Promise<void>;
|
||||||
|
|
||||||
export function UnFollow(arg1:string):Promise<string>;
|
export function UnFollow(arg1:string):Promise<string>;
|
||||||
|
|
||||||
|
32
frontend/wailsjs/go/main/App.js
Executable file → Normal file
32
frontend/wailsjs/go/main/App.js
Executable file → Normal file
@ -22,10 +22,6 @@ export function AnalyzeSentiment(arg1) {
|
|||||||
return window['go']['main']['App']['AnalyzeSentiment'](arg1);
|
return window['go']['main']['App']['AnalyzeSentiment'](arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CheckSponsorCode(arg1) {
|
|
||||||
return window['go']['main']['App']['CheckSponsorCode'](arg1);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function CheckUpdate() {
|
export function CheckUpdate() {
|
||||||
return window['go']['main']['App']['CheckUpdate']();
|
return window['go']['main']['App']['CheckUpdate']();
|
||||||
}
|
}
|
||||||
@ -78,10 +74,6 @@ export function GetGroupStockList(arg1) {
|
|||||||
return window['go']['main']['App']['GetGroupStockList'](arg1);
|
return window['go']['main']['App']['GetGroupStockList'](arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function GetHotStrategy() {
|
|
||||||
return window['go']['main']['App']['GetHotStrategy']();
|
|
||||||
}
|
|
||||||
|
|
||||||
export function GetIndustryMoneyRankSina(arg1, arg2) {
|
export function GetIndustryMoneyRankSina(arg1, arg2) {
|
||||||
return window['go']['main']['App']['GetIndustryMoneyRankSina'](arg1, arg2);
|
return window['go']['main']['App']['GetIndustryMoneyRankSina'](arg1, arg2);
|
||||||
}
|
}
|
||||||
@ -98,10 +90,6 @@ export function GetPromptTemplates(arg1, arg2) {
|
|||||||
return window['go']['main']['App']['GetPromptTemplates'](arg1, arg2);
|
return window['go']['main']['App']['GetPromptTemplates'](arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function GetSponsorInfo() {
|
|
||||||
return window['go']['main']['App']['GetSponsorInfo']();
|
|
||||||
}
|
|
||||||
|
|
||||||
export function GetStockCommonKLine(arg1, arg2, arg3) {
|
export function GetStockCommonKLine(arg1, arg2, arg3) {
|
||||||
return window['go']['main']['App']['GetStockCommonKLine'](arg1, arg2, arg3);
|
return window['go']['main']['App']['GetStockCommonKLine'](arg1, arg2, arg3);
|
||||||
}
|
}
|
||||||
@ -166,18 +154,14 @@ export function LongTigerRank(arg1) {
|
|||||||
return window['go']['main']['App']['LongTigerRank'](arg1);
|
return window['go']['main']['App']['LongTigerRank'](arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function NewChatStream(arg1, arg2, arg3, arg4, arg5) {
|
export function NewChatStream(arg1, arg2, arg3, arg4) {
|
||||||
return window['go']['main']['App']['NewChatStream'](arg1, arg2, arg3, arg4, arg5);
|
return window['go']['main']['App']['NewChatStream'](arg1, arg2, arg3, arg4);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function NewsPush(arg1) {
|
export function NewsPush(arg1) {
|
||||||
return window['go']['main']['App']['NewsPush'](arg1);
|
return window['go']['main']['App']['NewsPush'](arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function OpenURL(arg1) {
|
|
||||||
return window['go']['main']['App']['OpenURL'](arg1);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function ReFleshTelegraphList(arg1) {
|
export function ReFleshTelegraphList(arg1) {
|
||||||
return window['go']['main']['App']['ReFleshTelegraphList'](arg1);
|
return window['go']['main']['App']['ReFleshTelegraphList'](arg1);
|
||||||
}
|
}
|
||||||
@ -198,14 +182,6 @@ export function SaveAsMarkdown(arg1, arg2) {
|
|||||||
return window['go']['main']['App']['SaveAsMarkdown'](arg1, arg2);
|
return window['go']['main']['App']['SaveAsMarkdown'](arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SaveImage(arg1, arg2) {
|
|
||||||
return window['go']['main']['App']['SaveImage'](arg1, arg2);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function SaveWordFile(arg1, arg2) {
|
|
||||||
return window['go']['main']['App']['SaveWordFile'](arg1, arg2);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function SearchStock(arg1) {
|
export function SearchStock(arg1) {
|
||||||
return window['go']['main']['App']['SearchStock'](arg1);
|
return window['go']['main']['App']['SearchStock'](arg1);
|
||||||
}
|
}
|
||||||
@ -246,8 +222,8 @@ export function StockResearchReport(arg1) {
|
|||||||
return window['go']['main']['App']['StockResearchReport'](arg1);
|
return window['go']['main']['App']['StockResearchReport'](arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SummaryStockNews(arg1, arg2, arg3) {
|
export function SummaryStockNews(arg1, arg2) {
|
||||||
return window['go']['main']['App']['SummaryStockNews'](arg1, arg2, arg3);
|
return window['go']['main']['App']['SummaryStockNews'](arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function UnFollow(arg1) {
|
export function UnFollow(arg1) {
|
||||||
|
6
frontend/wailsjs/go/models.ts
Executable file → Normal file
6
frontend/wailsjs/go/models.ts
Executable file → Normal file
@ -343,7 +343,6 @@ export namespace data {
|
|||||||
browserPoolSize: number;
|
browserPoolSize: number;
|
||||||
enableFund: boolean;
|
enableFund: boolean;
|
||||||
enablePushNews: boolean;
|
enablePushNews: boolean;
|
||||||
sponsorCode: string;
|
|
||||||
|
|
||||||
static createFrom(source: any = {}) {
|
static createFrom(source: any = {}) {
|
||||||
return new Settings(source);
|
return new Settings(source);
|
||||||
@ -380,7 +379,6 @@ export namespace data {
|
|||||||
this.browserPoolSize = source["browserPoolSize"];
|
this.browserPoolSize = source["browserPoolSize"];
|
||||||
this.enableFund = source["enableFund"];
|
this.enableFund = source["enableFund"];
|
||||||
this.enablePushNews = source["enablePushNews"];
|
this.enablePushNews = source["enablePushNews"];
|
||||||
this.sponsorCode = source["sponsorCode"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||||
@ -702,9 +700,7 @@ export namespace models {
|
|||||||
icon: string;
|
icon: string;
|
||||||
alipay: string;
|
alipay: string;
|
||||||
wxpay: string;
|
wxpay: string;
|
||||||
wxgzh: string;
|
|
||||||
buildTimeStamp: number;
|
buildTimeStamp: number;
|
||||||
officialStatement: string;
|
|
||||||
IsDel: number;
|
IsDel: number;
|
||||||
|
|
||||||
static createFrom(source: any = {}) {
|
static createFrom(source: any = {}) {
|
||||||
@ -722,9 +718,7 @@ export namespace models {
|
|||||||
this.icon = source["icon"];
|
this.icon = source["icon"];
|
||||||
this.alipay = source["alipay"];
|
this.alipay = source["alipay"];
|
||||||
this.wxpay = source["wxpay"];
|
this.wxpay = source["wxpay"];
|
||||||
this.wxgzh = source["wxgzh"];
|
|
||||||
this.buildTimeStamp = source["buildTimeStamp"];
|
this.buildTimeStamp = source["buildTimeStamp"];
|
||||||
this.officialStatement = source["officialStatement"];
|
|
||||||
this.IsDel = source["IsDel"];
|
this.IsDel = source["IsDel"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
go.mod
9
go.mod
@ -8,12 +8,10 @@ require (
|
|||||||
github.com/coocood/freecache v1.2.4
|
github.com/coocood/freecache v1.2.4
|
||||||
github.com/duke-git/lancet/v2 v2.3.4
|
github.com/duke-git/lancet/v2 v2.3.4
|
||||||
github.com/energye/systray v1.0.2
|
github.com/energye/systray v1.0.2
|
||||||
github.com/gen2brain/beeep v0.11.1
|
|
||||||
github.com/glebarez/sqlite v1.11.0
|
github.com/glebarez/sqlite v1.11.0
|
||||||
github.com/go-ego/gse v0.80.3
|
github.com/go-ego/gse v0.80.3
|
||||||
github.com/go-resty/resty/v2 v2.16.2
|
github.com/go-resty/resty/v2 v2.16.2
|
||||||
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4
|
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4
|
||||||
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf
|
|
||||||
github.com/robertkrimen/otto v0.5.1
|
github.com/robertkrimen/otto v0.5.1
|
||||||
github.com/robfig/cron/v3 v3.0.1
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
github.com/samber/lo v1.49.1
|
github.com/samber/lo v1.49.1
|
||||||
@ -30,7 +28,6 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.sr.ht/~jackmordaunt/go-toast v1.1.2 // indirect
|
|
||||||
github.com/andybalholm/cascadia v1.3.3 // indirect
|
github.com/andybalholm/cascadia v1.3.3 // indirect
|
||||||
github.com/bep/debounce v1.2.1 // indirect
|
github.com/bep/debounce v1.2.1 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||||
@ -38,7 +35,6 @@ require (
|
|||||||
github.com/chromedp/sysutil v1.1.0 // indirect
|
github.com/chromedp/sysutil v1.1.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/esiqveland/notify v0.13.3 // indirect
|
|
||||||
github.com/glebarez/go-sqlite v1.21.2 // indirect
|
github.com/glebarez/go-sqlite v1.21.2 // indirect
|
||||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||||
github.com/gobwas/httphead v0.1.0 // indirect
|
github.com/gobwas/httphead v0.1.0 // indirect
|
||||||
@ -46,7 +42,6 @@ require (
|
|||||||
github.com/gobwas/ws v1.4.0 // indirect
|
github.com/gobwas/ws v1.4.0 // indirect
|
||||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/jackmordaunt/icns/v3 v3.0.1 // indirect
|
|
||||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
|
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/jinzhu/now v1.1.5 // indirect
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
@ -60,16 +55,12 @@ require (
|
|||||||
github.com/mailru/easyjson v0.7.7 // indirect
|
github.com/mailru/easyjson v0.7.7 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
|
|
||||||
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
|
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
|
||||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||||
github.com/rivo/uniseg v0.4.7 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/sergeymakinen/go-bmp v1.0.0 // indirect
|
|
||||||
github.com/sergeymakinen/go-ico v1.0.0-beta.0 // indirect
|
|
||||||
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
|
|
||||||
github.com/tevino/abool v0.0.0-20220530134649-2bfc934cb23c // indirect
|
github.com/tevino/abool v0.0.0-20220530134649-2bfc934cb23c // indirect
|
||||||
github.com/tidwall/match v1.1.1 // indirect
|
github.com/tidwall/match v1.1.1 // indirect
|
||||||
github.com/tidwall/pretty v1.2.0 // indirect
|
github.com/tidwall/pretty v1.2.0 // indirect
|
||||||
|
26
go.sum
26
go.sum
@ -1,5 +1,3 @@
|
|||||||
git.sr.ht/~jackmordaunt/go-toast v1.1.2 h1:/yrfI55LRt1M7H1vkaw+NaH1+L1CDxrqDltwm5euVuE=
|
|
||||||
git.sr.ht/~jackmordaunt/go-toast v1.1.2/go.mod h1:jA4OqHKTQ4AFBdwrSnwnskUIIS3HYzlJSgdzCKqfavo=
|
|
||||||
github.com/PuerkitoBio/goquery v1.10.1 h1:Y8JGYUkXWTGRB6Ars3+j3kN0xg1YqqlwvdTV8WTFQcU=
|
github.com/PuerkitoBio/goquery v1.10.1 h1:Y8JGYUkXWTGRB6Ars3+j3kN0xg1YqqlwvdTV8WTFQcU=
|
||||||
github.com/PuerkitoBio/goquery v1.10.1/go.mod h1:IYiHrOMps66ag56LEH7QYDDupKXyo5A8qrjIx3ZtujY=
|
github.com/PuerkitoBio/goquery v1.10.1/go.mod h1:IYiHrOMps66ag56LEH7QYDDupKXyo5A8qrjIx3ZtujY=
|
||||||
github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
|
github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
|
||||||
@ -16,7 +14,6 @@ github.com/chromedp/sysutil v1.1.0 h1:PUFNv5EcprjqXZD9nJb9b/c9ibAbxiYo4exNWZyipw
|
|||||||
github.com/chromedp/sysutil v1.1.0/go.mod h1:WiThHUdltqCNKGc4gaU50XgYjwjYIhKWoHGPTUfWTJ8=
|
github.com/chromedp/sysutil v1.1.0/go.mod h1:WiThHUdltqCNKGc4gaU50XgYjwjYIhKWoHGPTUfWTJ8=
|
||||||
github.com/coocood/freecache v1.2.4 h1:UdR6Yz/X1HW4fZOuH0Z94KwG851GWOSknua5VUbb/5M=
|
github.com/coocood/freecache v1.2.4 h1:UdR6Yz/X1HW4fZOuH0Z94KwG851GWOSknua5VUbb/5M=
|
||||||
github.com/coocood/freecache v1.2.4/go.mod h1:RBUWa/Cy+OHdfTGFEhEuE1pMCMX51Ncizj7rthiQ3vk=
|
github.com/coocood/freecache v1.2.4/go.mod h1:RBUWa/Cy+OHdfTGFEhEuE1pMCMX51Ncizj7rthiQ3vk=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/duke-git/lancet/v2 v2.3.4 h1:8XGI7P9w+/GqmEBEXYaH/XuNiM0f4/90Ioti0IvYJls=
|
github.com/duke-git/lancet/v2 v2.3.4 h1:8XGI7P9w+/GqmEBEXYaH/XuNiM0f4/90Ioti0IvYJls=
|
||||||
@ -25,10 +22,6 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
|
|||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/energye/systray v1.0.2 h1:63R4prQkANtpM2CIA4UrDCuwZFt+FiygG77JYCsNmXc=
|
github.com/energye/systray v1.0.2 h1:63R4prQkANtpM2CIA4UrDCuwZFt+FiygG77JYCsNmXc=
|
||||||
github.com/energye/systray v1.0.2/go.mod h1:sp7Q/q/I4/w5ebvpSuJVep71s9Bg7L9ZVp69gBASehM=
|
github.com/energye/systray v1.0.2/go.mod h1:sp7Q/q/I4/w5ebvpSuJVep71s9Bg7L9ZVp69gBASehM=
|
||||||
github.com/esiqveland/notify v0.13.3 h1:QCMw6o1n+6rl+oLUfg8P1IIDSFsDEb2WlXvVvIJbI/o=
|
|
||||||
github.com/esiqveland/notify v0.13.3/go.mod h1:hesw/IRYTO0x99u1JPweAl4+5mwXJibQVUcP0Iu5ORE=
|
|
||||||
github.com/gen2brain/beeep v0.11.1 h1:EbSIhrQZFDj1K2fzlMpAYlFOzV8YuNe721A58XcCTYI=
|
|
||||||
github.com/gen2brain/beeep v0.11.1/go.mod h1:jQVvuwnLuwOcdctHn/uyh8horSBNJ8uGb9Cn2W4tvoc=
|
|
||||||
github.com/glebarez/go-sqlite v1.21.2 h1:3a6LFC4sKahUunAmynQKLZceZCOzUthkRkEAl9gAXWo=
|
github.com/glebarez/go-sqlite v1.21.2 h1:3a6LFC4sKahUunAmynQKLZceZCOzUthkRkEAl9gAXWo=
|
||||||
github.com/glebarez/go-sqlite v1.21.2/go.mod h1:sfxdZyhQjTM2Wry3gVYWaW072Ri1WMdWJi0k6+3382k=
|
github.com/glebarez/go-sqlite v1.21.2/go.mod h1:sfxdZyhQjTM2Wry3gVYWaW072Ri1WMdWJi0k6+3382k=
|
||||||
github.com/glebarez/sqlite v1.11.0 h1:wSG0irqzP6VurnMEpFGer5Li19RpIRi2qvQz++w0GMw=
|
github.com/glebarez/sqlite v1.11.0 h1:wSG0irqzP6VurnMEpFGer5Li19RpIRi2qvQz++w0GMw=
|
||||||
@ -57,10 +50,6 @@ github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbu
|
|||||||
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo=
|
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf h1:WfD7VjIE6z8dIvMsI4/s+1qr5EL+zoIGev1BQj1eoJ8=
|
|
||||||
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf/go.mod h1:hyb9oH7vZsitZCiBt0ZvifOrB+qc8PS5IiilCIb87rg=
|
|
||||||
github.com/jackmordaunt/icns/v3 v3.0.1 h1:xxot6aNuGrU+lNgxz5I5H0qSeCjNKp8uTXB1j8D4S3o=
|
|
||||||
github.com/jackmordaunt/icns/v3 v3.0.1/go.mod h1:5sHL59nqTd2ynTnowxB/MDQFhKNqkK8X687uKNygaSQ=
|
|
||||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
|
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
|
||||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
|
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
|
||||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||||
@ -102,8 +91,6 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
|
|||||||
github.com/mattn/go-sqlite3 v1.14.3/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI=
|
github.com/mattn/go-sqlite3 v1.14.3/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI=
|
||||||
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
|
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
|
||||||
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
|
||||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||||
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
|
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
|
||||||
@ -128,20 +115,8 @@ github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
|||||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||||
github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew=
|
github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew=
|
||||||
github.com/samber/lo v1.49.1/go.mod h1:dO6KHFzUKXgP8LDhU0oI8d2hekjXnGOu0DB8Jecxd6o=
|
github.com/samber/lo v1.49.1/go.mod h1:dO6KHFzUKXgP8LDhU0oI8d2hekjXnGOu0DB8Jecxd6o=
|
||||||
github.com/sergeymakinen/go-bmp v1.0.0 h1:SdGTzp9WvCV0A1V0mBeaS7kQAwNLdVJbmHlqNWq0R+M=
|
|
||||||
github.com/sergeymakinen/go-bmp v1.0.0/go.mod h1:/mxlAQZRLxSvJFNIEGGLBE/m40f3ZnUifpgVDlcUIEY=
|
|
||||||
github.com/sergeymakinen/go-ico v1.0.0-beta.0 h1:m5qKH7uPKLdrygMWxbamVn+tl2HfiA3K6MFJw4GfZvQ=
|
|
||||||
github.com/sergeymakinen/go-ico v1.0.0-beta.0/go.mod h1:wQ47mTczswBO5F0NoDt7O0IXgnV4Xy3ojrroMQzyhUk=
|
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG04SN9W+iWHCRyHqlVYILiSXziwk=
|
|
||||||
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o=
|
|
||||||
github.com/tevino/abool v0.0.0-20220530134649-2bfc934cb23c h1:coVla7zpsycc+kA9NXpcvv2E4I7+ii6L5hZO2S6C3kw=
|
github.com/tevino/abool v0.0.0-20220530134649-2bfc934cb23c h1:coVla7zpsycc+kA9NXpcvv2E4I7+ii6L5hZO2S6C3kw=
|
||||||
github.com/tevino/abool v0.0.0-20220530134649-2bfc934cb23c/go.mod h1:qc66Pna1RiIsPa7O4Egxxs9OqkuxDX55zznh9K07Tzg=
|
github.com/tevino/abool v0.0.0-20220530134649-2bfc934cb23c/go.mod h1:qc66Pna1RiIsPa7O4Egxxs9OqkuxDX55zznh9K07Tzg=
|
||||||
github.com/tidwall/gjson v1.14.2 h1:6BBkirS0rAHjumnjHF6qgy5d2YAJ1TLIaFE2lzfOLqo=
|
github.com/tidwall/gjson v1.14.2 h1:6BBkirS0rAHjumnjHF6qgy5d2YAJ1TLIaFE2lzfOLqo=
|
||||||
@ -263,7 +238,6 @@ gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST
|
|||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
||||||
gopkg.in/sourcemap.v1 v1.0.5 h1:inv58fC9f9J3TK2Y2R1NPntXEn3/wjWHkonhIUODNTI=
|
gopkg.in/sourcemap.v1 v1.0.5 h1:inv58fC9f9J3TK2Y2R1NPntXEn3/wjWHkonhIUODNTI=
|
||||||
gopkg.in/sourcemap.v1 v1.0.5/go.mod h1:2RlvNNSMglmRrcvhfuzp4hQHwOtjxlbjX7UPY/GXb78=
|
gopkg.in/sourcemap.v1 v1.0.5/go.mod h1:2RlvNNSMglmRrcvhfuzp4hQHwOtjxlbjX7UPY/GXb78=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
|
gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
|
||||||
|
62
main.go
62
main.go
@ -19,8 +19,10 @@ import (
|
|||||||
log "go-stock/backend/logger"
|
log "go-stock/backend/logger"
|
||||||
"go-stock/backend/models"
|
"go-stock/backend/models"
|
||||||
"os"
|
"os"
|
||||||
|
goruntime "runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed frontend/dist
|
//go:embed frontend/dist
|
||||||
@ -38,9 +40,6 @@ var alipay []byte
|
|||||||
//go:embed build/screenshot/wxpay.jpg
|
//go:embed build/screenshot/wxpay.jpg
|
||||||
var wxpay []byte
|
var wxpay []byte
|
||||||
|
|
||||||
//go:embed build/screenshot/扫码_搜索联合传播样式-白色版.png
|
|
||||||
var wxgzh []byte
|
|
||||||
|
|
||||||
//go:embed build/stock_basic.json
|
//go:embed build/stock_basic.json
|
||||||
var stocksBin []byte
|
var stocksBin []byte
|
||||||
|
|
||||||
@ -54,8 +53,6 @@ var stocksBinUS []byte
|
|||||||
|
|
||||||
var Version string
|
var Version string
|
||||||
var VersionCommit string
|
var VersionCommit string
|
||||||
var OFFICIAL_STATEMENT string
|
|
||||||
var BuildKey string
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
checkDir("data")
|
checkDir("data")
|
||||||
@ -70,31 +67,34 @@ func main() {
|
|||||||
// Create an instance of the app structure
|
// Create an instance of the app structure
|
||||||
app := NewApp()
|
app := NewApp()
|
||||||
AppMenu := menu.NewMenu()
|
AppMenu := menu.NewMenu()
|
||||||
AppMenu.Append(menu.EditMenu())
|
|
||||||
FileMenu := AppMenu.AddSubmenu("设置")
|
FileMenu := AppMenu.AddSubmenu("设置")
|
||||||
|
FileMenu.AddText("显示搜索框", keys.CmdOrCtrl("s"), func(callbackData *menu.CallbackData) {
|
||||||
|
runtime.EventsEmit(app.ctx, "showSearch", 1)
|
||||||
|
})
|
||||||
|
FileMenu.AddText("隐藏搜索框", keys.CmdOrCtrl("d"), func(callbackData *menu.CallbackData) {
|
||||||
|
runtime.EventsEmit(app.ctx, "showSearch", 0)
|
||||||
|
})
|
||||||
|
FileMenu.AddText("刷新数据", keys.CmdOrCtrl("r"), func(callbackData *menu.CallbackData) {
|
||||||
|
//runtime.EventsEmit(app.ctx, "refresh", "setting-"+time.Now().Format("2006-01-02 15:04:05"))
|
||||||
|
runtime.EventsEmit(app.ctx, "refreshFollowList", "refresh-"+time.Now().Format("2006-01-02 15:04:05"))
|
||||||
|
})
|
||||||
|
FileMenu.AddSeparator()
|
||||||
FileMenu.AddText("窗口全屏", keys.CmdOrCtrl("f"), func(callback *menu.CallbackData) {
|
FileMenu.AddText("窗口全屏", keys.CmdOrCtrl("f"), func(callback *menu.CallbackData) {
|
||||||
runtime.WindowFullscreen(app.ctx)
|
runtime.WindowFullscreen(app.ctx)
|
||||||
})
|
})
|
||||||
FileMenu.AddText("窗口还原", keys.Key("Esc"), func(callback *menu.CallbackData) {
|
FileMenu.AddText("窗口还原", keys.Key("Esc"), func(callback *menu.CallbackData) {
|
||||||
runtime.WindowUnfullscreen(app.ctx)
|
runtime.WindowUnfullscreen(app.ctx)
|
||||||
})
|
})
|
||||||
//FileMenu.AddText("显示搜索框", keys.CmdOrCtrl("s"), func(callbackData *menu.CallbackData) {
|
|
||||||
// runtime.EventsEmit(app.ctx, "showSearch", 1)
|
|
||||||
//})
|
|
||||||
//FileMenu.AddText("隐藏搜索框", keys.CmdOrCtrl("d"), func(callbackData *menu.CallbackData) {
|
|
||||||
// runtime.EventsEmit(app.ctx, "showSearch", 0)
|
|
||||||
//})
|
|
||||||
//FileMenu.AddText("刷新数据", keys.CmdOrCtrl("r"), func(callbackData *menu.CallbackData) {
|
|
||||||
// //runtime.EventsEmit(app.ctx, "refresh", "setting-"+time.Now().Format("2006-01-02 15:04:05"))
|
|
||||||
// runtime.EventsEmit(app.ctx, "refreshFollowList", "refresh-"+time.Now().Format("2006-01-02 15:04:05"))
|
|
||||||
//})
|
|
||||||
//FileMenu.AddSeparator()
|
|
||||||
|
|
||||||
//if goruntime.GOOS == "windows" {
|
if goruntime.GOOS == "windows" {
|
||||||
// FileMenu.AddText("隐藏到托盘区", keys.CmdOrCtrl("z"), func(_ *menu.CallbackData) {
|
FileMenu.AddText("隐藏到托盘区", keys.CmdOrCtrl("h"), func(_ *menu.CallbackData) {
|
||||||
// runtime.WindowHide(app.ctx)
|
runtime.WindowHide(app.ctx)
|
||||||
// })
|
})
|
||||||
//}
|
|
||||||
|
FileMenu.AddText("显示", keys.CmdOrCtrl("v"), func(_ *menu.CallbackData) {
|
||||||
|
runtime.WindowShow(app.ctx)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
//FileMenu.AddText("退出", keys.CmdOrCtrl("q"), func(_ *menu.CallbackData) {
|
//FileMenu.AddText("退出", keys.CmdOrCtrl("q"), func(_ *menu.CallbackData) {
|
||||||
// runtime.Quit(app.ctx)
|
// runtime.Quit(app.ctx)
|
||||||
@ -105,7 +105,7 @@ func main() {
|
|||||||
//var width, height int
|
//var width, height int
|
||||||
//var err error
|
//var err error
|
||||||
//
|
//
|
||||||
width, _, minWidth, minHeight, err := getScreenResolution()
|
width, _, err := getScreenResolution()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.SugaredLogger.Error("get screen resolution error")
|
log.SugaredLogger.Error("get screen resolution error")
|
||||||
width = 1456
|
width = 1456
|
||||||
@ -118,20 +118,18 @@ func main() {
|
|||||||
backgroundColour = &options.RGBA{R: 27, G: 38, B: 54, A: 1}
|
backgroundColour = &options.RGBA{R: 27, G: 38, B: 54, A: 1}
|
||||||
}
|
}
|
||||||
|
|
||||||
frameless := getFrameless()
|
|
||||||
|
|
||||||
// Create application with options
|
// Create application with options
|
||||||
err = wails.Run(&options.App{
|
err = wails.Run(&options.App{
|
||||||
Title: "go-stock",
|
Title: "go-stock",
|
||||||
Width: width * 4 / 5,
|
Width: width * 4 / 5,
|
||||||
Height: 900,
|
Height: 900,
|
||||||
MinWidth: minWidth,
|
MinWidth: 1456,
|
||||||
MinHeight: minHeight,
|
MinHeight: 768,
|
||||||
//MaxWidth: width,
|
//MaxWidth: width,
|
||||||
//MaxHeight: height,
|
//MaxHeight: height,
|
||||||
DisableResize: false,
|
DisableResize: false,
|
||||||
Fullscreen: false,
|
Fullscreen: false,
|
||||||
Frameless: frameless,
|
Frameless: true,
|
||||||
StartHidden: false,
|
StartHidden: false,
|
||||||
HideWindowOnClose: false,
|
HideWindowOnClose: false,
|
||||||
EnableDefaultContextMenu: true,
|
EnableDefaultContextMenu: true,
|
||||||
@ -164,11 +162,12 @@ func main() {
|
|||||||
// Mac platform specific options
|
// Mac platform specific options
|
||||||
Mac: &mac.Options{
|
Mac: &mac.Options{
|
||||||
TitleBar: &mac.TitleBar{
|
TitleBar: &mac.TitleBar{
|
||||||
TitlebarAppearsTransparent: false,
|
TitlebarAppearsTransparent: true,
|
||||||
HideTitle: false,
|
HideTitle: false,
|
||||||
HideTitleBar: false,
|
HideTitleBar: false,
|
||||||
FullSizeContent: false,
|
FullSizeContent: false,
|
||||||
UseToolbar: true,
|
UseToolbar: false,
|
||||||
|
HideToolbarSeparator: true,
|
||||||
},
|
},
|
||||||
Appearance: mac.NSAppearanceNameDarkAqua,
|
Appearance: mac.NSAppearanceNameDarkAqua,
|
||||||
WebviewIsTransparent: true,
|
WebviewIsTransparent: true,
|
||||||
@ -346,9 +345,6 @@ func checkDir(dir string) {
|
|||||||
os.Mkdir(dir, os.ModePerm)
|
os.Mkdir(dir, os.ModePerm)
|
||||||
log.SugaredLogger.Info("create dir: " + dir)
|
log.SugaredLogger.Info("create dir: " + dir)
|
||||||
}
|
}
|
||||||
if BuildKey == "" {
|
|
||||||
BuildKey = "cc1e0d684e32f176c56ff1fcf384dcd9"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PanicHandler 捕获 panic 的包装函数
|
// PanicHandler 捕获 panic 的包装函数
|
||||||
|
23
utils.go
23
utils.go
@ -1,23 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
// @Author spark
|
|
||||||
// @Date 2025/7/8 18:51
|
|
||||||
// @Desc
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
import "runtime"
|
|
||||||
|
|
||||||
// IsWindows 判断是否为 Windows 系统
|
|
||||||
func IsWindows() bool {
|
|
||||||
return runtime.GOOS == "windows"
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsMacOS 判断是否为 macOS 系统
|
|
||||||
func IsMacOS() bool {
|
|
||||||
return runtime.GOOS == "darwin"
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsLinux 判断是否为 Linux 系统
|
|
||||||
func IsLinux() bool {
|
|
||||||
return runtime.GOOS == "linux"
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user