mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
refactor(app):重构应用加载和数据初始化逻辑(小白福音)
- 在 domReady 函数中添加股票数据初始化逻辑 - 更新前端 App.vue以显示加载信息 - 修改后端 initStockData 函数,添加上下文和加载消息 - 优化市场数据定时刷新逻辑 - 修复 AI 响应结果获取方式
This commit is contained in:
parent
ad92c41d08
commit
d7b17b2561
16
app.go
16
app.go
@ -139,6 +139,22 @@ func (a *App) CheckUpdate() {
|
|||||||
func (a *App) domReady(ctx context.Context) {
|
func (a *App) domReady(ctx context.Context) {
|
||||||
defer PanicHandler()
|
defer PanicHandler()
|
||||||
|
|
||||||
|
if stocksBin != nil && len(stocksBin) > 0 {
|
||||||
|
go runtime.EventsEmit(a.ctx, "loadingMsg", "检查A股基础信息...")
|
||||||
|
go initStockData(a.ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
if stocksBinHK != nil && len(stocksBinHK) > 0 {
|
||||||
|
go runtime.EventsEmit(a.ctx, "loadingMsg", "检查港股基础信息...")
|
||||||
|
go initStockDataHK(a.ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
if stocksBinUS != nil && len(stocksBinUS) > 0 {
|
||||||
|
go runtime.EventsEmit(a.ctx, "loadingMsg", "检查美股基础信息...")
|
||||||
|
go initStockDataUS(a.ctx)
|
||||||
|
}
|
||||||
|
updateBasicInfo()
|
||||||
|
|
||||||
// Add your action here
|
// Add your action here
|
||||||
//定时更新数据
|
//定时更新数据
|
||||||
config := data.NewSettingsApi(&data.Settings{}).GetConfig()
|
config := data.NewSettingsApi(&data.Settings{}).GetConfig()
|
||||||
|
@ -849,6 +849,6 @@ func (o OpenAi) SaveAIResponseResult(stockCode, stockName, result, chatId, quest
|
|||||||
|
|
||||||
func (o OpenAi) GetAIResponseResult(stock string) *models.AIResponseResult {
|
func (o OpenAi) GetAIResponseResult(stock string) *models.AIResponseResult {
|
||||||
var result models.AIResponseResult
|
var result models.AIResponseResult
|
||||||
db.Dao.Where("stock_code = ?", stock).Order("id desc").Limit(1).First(&result)
|
db.Dao.Where("stock_code = ?", stock).Order("id desc").Limit(1).Find(&result)
|
||||||
return &result
|
return &result
|
||||||
}
|
}
|
||||||
|
@ -1,45 +1,48 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
EventsEmit,
|
EventsEmit,
|
||||||
|
EventsOff,
|
||||||
EventsOn,
|
EventsOn,
|
||||||
Quit,
|
Quit,
|
||||||
WindowFullscreen, WindowGetPosition,
|
WindowFullscreen,
|
||||||
WindowHide,
|
WindowHide,
|
||||||
WindowSetPosition,
|
|
||||||
WindowUnfullscreen
|
WindowUnfullscreen
|
||||||
} from '../wailsjs/runtime'
|
} from '../wailsjs/runtime'
|
||||||
import {h, onBeforeMount, onMounted, ref} from "vue";
|
import {h, onBeforeMount, onBeforeUnmount, onMounted, ref} from "vue";
|
||||||
import { RouterLink } from 'vue-router'
|
import {RouterLink, useRouter} from 'vue-router'
|
||||||
import {darkTheme, NButton, NGradientText, NIcon, NText,} from 'naive-ui'
|
import {darkTheme, NIcon, NText,} from 'naive-ui'
|
||||||
import {
|
import {
|
||||||
SettingsOutline,
|
|
||||||
ReorderTwoOutline,
|
|
||||||
ExpandOutline,
|
|
||||||
PowerOutline,
|
|
||||||
LogoGithub,
|
|
||||||
MoveOutline,
|
|
||||||
WalletOutline,
|
|
||||||
StarOutline,
|
|
||||||
AlarmOutline,
|
AlarmOutline,
|
||||||
SparklesOutline,
|
AnalyticsOutline,
|
||||||
|
BarChartSharp,
|
||||||
|
ExpandOutline,
|
||||||
|
Flame,
|
||||||
|
LogoGithub,
|
||||||
NewspaperOutline,
|
NewspaperOutline,
|
||||||
AnalyticsOutline, BarChartSharp, NewspaperSharp, Flame, BarChartOutline, Wallet,
|
NewspaperSharp,
|
||||||
|
PowerOutline,
|
||||||
|
ReorderTwoOutline,
|
||||||
|
SettingsOutline,
|
||||||
|
SparklesOutline,
|
||||||
|
StarOutline,
|
||||||
|
Wallet,
|
||||||
} from '@vicons/ionicons5'
|
} from '@vicons/ionicons5'
|
||||||
import {GetConfig, GetGroupList} from "../wailsjs/go/main/App";
|
import {GetConfig, GetGroupList} from "../wailsjs/go/main/App";
|
||||||
import { useRouter } from 'vue-router'
|
|
||||||
const router = useRouter()
|
|
||||||
|
|
||||||
const enableNews= ref(false)
|
const router = useRouter()
|
||||||
const contentStyle = ref("")
|
const loading = ref(true)
|
||||||
|
const loadingMsg = ref("加载数据中...")
|
||||||
|
const enableNews = ref(false)
|
||||||
|
const contentStyle = ref("")
|
||||||
const enableFund = ref(false)
|
const enableFund = ref(false)
|
||||||
const enableDarkTheme = ref(null)
|
const enableDarkTheme = ref(null)
|
||||||
const content = ref('数据来源于网络,仅供参考;投资有风险,入市需谨慎')
|
const content = ref('数据来源于网络,仅供参考;投资有风险,入市需谨慎')
|
||||||
const isFullscreen = ref(false)
|
const isFullscreen = ref(false)
|
||||||
const activeKey = ref('')
|
const activeKey = ref('')
|
||||||
const containerRef= ref({})
|
const containerRef = ref({})
|
||||||
const realtimeProfit= ref(0)
|
const realtimeProfit = ref(0)
|
||||||
const telegraph= ref([])
|
const telegraph = ref([])
|
||||||
const groupList=ref([])
|
const groupList = ref([])
|
||||||
const menuOptions = ref([
|
const menuOptions = ref([
|
||||||
{
|
{
|
||||||
label: () =>
|
label: () =>
|
||||||
@ -52,15 +55,14 @@ const menuOptions = ref([
|
|||||||
groupName: '全部',
|
groupName: '全部',
|
||||||
groupId: 0,
|
groupId: 0,
|
||||||
},
|
},
|
||||||
params: {
|
params: {},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ default: () => '股票自选',}
|
{default: () => '股票自选',}
|
||||||
),
|
),
|
||||||
key: 'stock',
|
key: 'stock',
|
||||||
icon: renderIcon(StarOutline),
|
icon: renderIcon(StarOutline),
|
||||||
children:[
|
children: [
|
||||||
{
|
{
|
||||||
label: () =>
|
label: () =>
|
||||||
h(
|
h(
|
||||||
@ -68,7 +70,7 @@ const menuOptions = ref([
|
|||||||
{
|
{
|
||||||
href: '#',
|
href: '#',
|
||||||
type: 'info',
|
type: 'info',
|
||||||
onClick: ()=>{
|
onClick: () => {
|
||||||
//console.log("push",item)
|
//console.log("push",item)
|
||||||
router.push({
|
router.push({
|
||||||
name: 'stock',
|
name: 'stock',
|
||||||
@ -77,7 +79,7 @@ const menuOptions = ref([
|
|||||||
groupId: 0,
|
groupId: 0,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
EventsEmit("changeTab", {ID:0,name:'全部'})
|
EventsEmit("changeTab", {ID: 0, name: '全部'})
|
||||||
},
|
},
|
||||||
to: {
|
to: {
|
||||||
name: 'stock',
|
name: 'stock',
|
||||||
@ -87,7 +89,7 @@ const menuOptions = ref([
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ default: () => '全部',}
|
{default: () => '全部',}
|
||||||
),
|
),
|
||||||
key: 0,
|
key: 0,
|
||||||
}
|
}
|
||||||
@ -101,18 +103,17 @@ const menuOptions = ref([
|
|||||||
href: '#',
|
href: '#',
|
||||||
to: {
|
to: {
|
||||||
name: 'market',
|
name: 'market',
|
||||||
params: {
|
params: {}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onClick: ()=>{
|
onClick: () => {
|
||||||
EventsEmit("changeMarketTab", {ID:0,name:'市场快讯'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '市场快讯'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ default: () => '市场行情' }
|
{default: () => '市场行情'}
|
||||||
),
|
),
|
||||||
key: 'market',
|
key: 'market',
|
||||||
icon: renderIcon(NewspaperOutline),
|
icon: renderIcon(NewspaperOutline),
|
||||||
children:[
|
children: [
|
||||||
{
|
{
|
||||||
label: () =>
|
label: () =>
|
||||||
h(
|
h(
|
||||||
@ -122,14 +123,14 @@ const menuOptions = ref([
|
|||||||
to: {
|
to: {
|
||||||
name: 'market',
|
name: 'market',
|
||||||
query: {
|
query: {
|
||||||
name:"市场快讯",
|
name: "市场快讯",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick: ()=>{
|
onClick: () => {
|
||||||
EventsEmit("changeMarketTab", {ID:0,name:'市场快讯'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '市场快讯'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ default: () => '市场快讯',}
|
{default: () => '市场快讯',}
|
||||||
),
|
),
|
||||||
key: 'market1',
|
key: 'market1',
|
||||||
icon: renderIcon(NewspaperSharp),
|
icon: renderIcon(NewspaperSharp),
|
||||||
@ -143,14 +144,14 @@ const menuOptions = ref([
|
|||||||
to: {
|
to: {
|
||||||
name: 'market',
|
name: 'market',
|
||||||
query: {
|
query: {
|
||||||
name:"全球股指",
|
name: "全球股指",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
onClick: ()=>{
|
onClick: () => {
|
||||||
EventsEmit("changeMarketTab", {ID:0,name:'全球股指'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '全球股指'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ default: () => '全球股指',}
|
{default: () => '全球股指',}
|
||||||
),
|
),
|
||||||
key: 'market2',
|
key: 'market2',
|
||||||
icon: renderIcon(BarChartSharp),
|
icon: renderIcon(BarChartSharp),
|
||||||
@ -164,14 +165,14 @@ const menuOptions = ref([
|
|||||||
to: {
|
to: {
|
||||||
name: 'market',
|
name: 'market',
|
||||||
query: {
|
query: {
|
||||||
name:"指标行情",
|
name: "指标行情",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick: ()=>{
|
onClick: () => {
|
||||||
EventsEmit("changeMarketTab", {ID:0,name:'指标行情'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '指标行情'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ default: () => '指标行情',}
|
{default: () => '指标行情',}
|
||||||
),
|
),
|
||||||
key: 'market3',
|
key: 'market3',
|
||||||
icon: renderIcon(AnalyticsOutline),
|
icon: renderIcon(AnalyticsOutline),
|
||||||
@ -185,14 +186,14 @@ const menuOptions = ref([
|
|||||||
to: {
|
to: {
|
||||||
name: 'market',
|
name: 'market',
|
||||||
query: {
|
query: {
|
||||||
name:"行业排名",
|
name: "行业排名",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick: ()=>{
|
onClick: () => {
|
||||||
EventsEmit("changeMarketTab", {ID:0,name:'行业排名'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '行业排名'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ default: () => '行业排名',}
|
{default: () => '行业排名',}
|
||||||
),
|
),
|
||||||
key: 'market4',
|
key: 'market4',
|
||||||
icon: renderIcon(Flame),
|
icon: renderIcon(Flame),
|
||||||
@ -206,14 +207,14 @@ const menuOptions = ref([
|
|||||||
to: {
|
to: {
|
||||||
name: 'market',
|
name: 'market',
|
||||||
query: {
|
query: {
|
||||||
name:"个股资金流向",
|
name: "个股资金流向",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick: ()=>{
|
onClick: () => {
|
||||||
EventsEmit("changeMarketTab", {ID:0,name:'个股资金流向'})
|
EventsEmit("changeMarketTab", {ID: 0, name: '个股资金流向'})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ default: () => '个股资金流向',}
|
{default: () => '个股资金流向',}
|
||||||
),
|
),
|
||||||
key: 'market5',
|
key: 'market5',
|
||||||
icon: renderIcon(Wallet),
|
icon: renderIcon(Wallet),
|
||||||
@ -227,18 +228,17 @@ const menuOptions = ref([
|
|||||||
{
|
{
|
||||||
to: {
|
to: {
|
||||||
name: 'fund',
|
name: 'fund',
|
||||||
params: {
|
params: {},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ default: () => '基金自选',}
|
{default: () => '基金自选',}
|
||||||
),
|
),
|
||||||
show: enableFund.value,
|
show: enableFund.value,
|
||||||
key: 'fund',
|
key: 'fund',
|
||||||
icon: renderIcon(SparklesOutline),
|
icon: renderIcon(SparklesOutline),
|
||||||
children:[
|
children: [
|
||||||
{
|
{
|
||||||
label: ()=> h(NText, {type:realtimeProfit.value>0?'error':'success'},{ default: () => '功能完善中!'}),
|
label: () => h(NText, {type: realtimeProfit.value > 0 ? 'error' : 'success'}, {default: () => '功能完善中!'}),
|
||||||
key: 'realtimeProfit',
|
key: 'realtimeProfit',
|
||||||
show: realtimeProfit.value,
|
show: realtimeProfit.value,
|
||||||
icon: renderIcon(AlarmOutline),
|
icon: renderIcon(AlarmOutline),
|
||||||
@ -252,11 +252,10 @@ const menuOptions = ref([
|
|||||||
{
|
{
|
||||||
to: {
|
to: {
|
||||||
name: 'settings',
|
name: 'settings',
|
||||||
params: {
|
params: {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ default: () => '设置' }
|
{default: () => '设置'}
|
||||||
),
|
),
|
||||||
key: 'settings',
|
key: 'settings',
|
||||||
icon: renderIcon(SettingsOutline),
|
icon: renderIcon(SettingsOutline),
|
||||||
@ -268,30 +267,29 @@ const menuOptions = ref([
|
|||||||
{
|
{
|
||||||
to: {
|
to: {
|
||||||
name: 'about',
|
name: 'about',
|
||||||
params: {
|
params: {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ default: () => '关于' }
|
{default: () => '关于'}
|
||||||
),
|
),
|
||||||
key: 'about',
|
key: 'about',
|
||||||
icon: renderIcon(LogoGithub),
|
icon: renderIcon(LogoGithub),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: ()=> h("a", {
|
label: () => h("a", {
|
||||||
href: '#',
|
href: '#',
|
||||||
onClick: toggleFullscreen,
|
onClick: toggleFullscreen,
|
||||||
title: '全屏 Ctrl+F 退出全屏 Esc',
|
title: '全屏 Ctrl+F 退出全屏 Esc',
|
||||||
}, { default: () => isFullscreen.value?'取消全屏':'全屏' }),
|
}, {default: () => isFullscreen.value ? '取消全屏' : '全屏'}),
|
||||||
key: 'full',
|
key: 'full',
|
||||||
icon: renderIcon(ExpandOutline),
|
icon: renderIcon(ExpandOutline),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: ()=> h("a", {
|
label: () => h("a", {
|
||||||
href: '#',
|
href: '#',
|
||||||
onClick: WindowHide,
|
onClick: WindowHide,
|
||||||
title: '隐藏到托盘区 Ctrl+H',
|
title: '隐藏到托盘区 Ctrl+H',
|
||||||
}, { default: () => '隐藏到托盘区' }),
|
}, {default: () => '隐藏到托盘区'}),
|
||||||
key: 'hide',
|
key: 'hide',
|
||||||
icon: renderIcon(ReorderTwoOutline),
|
icon: renderIcon(ReorderTwoOutline),
|
||||||
},
|
},
|
||||||
@ -305,28 +303,31 @@ const menuOptions = ref([
|
|||||||
// icon: renderIcon(MoveOutline),
|
// icon: renderIcon(MoveOutline),
|
||||||
// },
|
// },
|
||||||
{
|
{
|
||||||
label: ()=> h("a", {
|
label: () => h("a", {
|
||||||
href: '#',
|
href: '#',
|
||||||
onClick: Quit,
|
onClick: Quit,
|
||||||
}, { default: () => '退出程序' }),
|
}, {default: () => '退出程序'}),
|
||||||
key: 'exit',
|
key: 'exit',
|
||||||
icon: renderIcon(PowerOutline),
|
icon: renderIcon(PowerOutline),
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
function renderIcon(icon) {
|
function renderIcon(icon) {
|
||||||
return () => h(NIcon, null, { default: () => h(icon) })
|
return () => h(NIcon, null, {default: () => h(icon)})
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleFullscreen(e) {
|
function toggleFullscreen(e) {
|
||||||
//console.log(e)
|
//console.log(e)
|
||||||
if (isFullscreen.value) {
|
if (isFullscreen.value) {
|
||||||
WindowUnfullscreen()
|
WindowUnfullscreen()
|
||||||
//e.target.innerHTML = '全屏'
|
//e.target.innerHTML = '全屏'
|
||||||
} else {
|
} else {
|
||||||
WindowFullscreen()
|
WindowFullscreen()
|
||||||
// e.target.innerHTML = '取消全屏'
|
// e.target.innerHTML = '取消全屏'
|
||||||
}
|
}
|
||||||
isFullscreen.value=!isFullscreen.value
|
isFullscreen.value = !isFullscreen.value
|
||||||
}
|
}
|
||||||
|
|
||||||
// const drag = ref(false)
|
// const drag = ref(false)
|
||||||
// const lastPos= ref({x:0,y:0})
|
// const lastPos= ref({x:0,y:0})
|
||||||
// function toggleStartMoveWindow(e) {
|
// function toggleStartMoveWindow(e) {
|
||||||
@ -344,11 +345,28 @@ function toggleFullscreen(e) {
|
|||||||
// }
|
// }
|
||||||
// window.addEventListener('mousemove', dragstart)
|
// window.addEventListener('mousemove', dragstart)
|
||||||
|
|
||||||
EventsOn("realtime_profit",(data)=>{
|
EventsOn("realtime_profit", (data) => {
|
||||||
realtimeProfit.value=data
|
realtimeProfit.value = data
|
||||||
})
|
})
|
||||||
EventsOn("telegraph",(data)=>{
|
EventsOn("telegraph", (data) => {
|
||||||
telegraph.value=data
|
telegraph.value = data
|
||||||
|
})
|
||||||
|
|
||||||
|
EventsOn("loadingMsg", (data) => {
|
||||||
|
if(data==="done"){
|
||||||
|
loadingMsg.value = "加载完成..."
|
||||||
|
EventsEmit("loadingDone", "app")
|
||||||
|
loading.value = false
|
||||||
|
}else{
|
||||||
|
loading.value = true
|
||||||
|
loadingMsg.value = data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
EventsOff("realtime_profit")
|
||||||
|
EventsOff("loadingMsg")
|
||||||
|
EventsOff("telegraph")
|
||||||
})
|
})
|
||||||
|
|
||||||
window.onerror = function (msg, source, lineno, colno, error) {
|
window.onerror = function (msg, source, lineno, colno, error) {
|
||||||
@ -364,13 +382,13 @@ window.onerror = function (msg, source, lineno, colno, error) {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
onBeforeMount(()=>{
|
onBeforeMount(() => {
|
||||||
GetGroupList().then(result => {
|
GetGroupList().then(result => {
|
||||||
groupList.value=result
|
groupList.value = result
|
||||||
menuOptions.value.map((item)=>{
|
menuOptions.value.map((item) => {
|
||||||
//console.log(item)
|
//console.log(item)
|
||||||
if(item.key==='stock'){
|
if (item.key === 'stock') {
|
||||||
item.children.push(...groupList.value.map(item=>{
|
item.children.push(...groupList.value.map(item => {
|
||||||
return {
|
return {
|
||||||
label: () =>
|
label: () =>
|
||||||
h(
|
h(
|
||||||
@ -378,7 +396,7 @@ onBeforeMount(()=>{
|
|||||||
{
|
{
|
||||||
href: '#',
|
href: '#',
|
||||||
type: 'info',
|
type: 'info',
|
||||||
onClick: ()=>{
|
onClick: () => {
|
||||||
//console.log("push",item)
|
//console.log("push",item)
|
||||||
router.push({
|
router.push({
|
||||||
name: 'stock',
|
name: 'stock',
|
||||||
@ -387,9 +405,9 @@ onBeforeMount(()=>{
|
|||||||
groupId: item.ID,
|
groupId: item.ID,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
setTimeout(()=>{
|
setTimeout(() => {
|
||||||
EventsEmit("changeTab", item)
|
EventsEmit("changeTab", item)
|
||||||
},100)
|
}, 100)
|
||||||
},
|
},
|
||||||
to: {
|
to: {
|
||||||
name: 'stock',
|
name: 'stock',
|
||||||
@ -399,7 +417,7 @@ onBeforeMount(()=>{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ default: () => item.name,}
|
{default: () => item.name,}
|
||||||
),
|
),
|
||||||
key: item.ID,
|
key: item.ID,
|
||||||
}
|
}
|
||||||
@ -409,91 +427,86 @@ onBeforeMount(()=>{
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
GetConfig().then((res) => {
|
||||||
GetConfig().then((res)=>{
|
|
||||||
//console.log(res)
|
//console.log(res)
|
||||||
enableFund.value=res.enableFund
|
enableFund.value = res.enableFund
|
||||||
|
|
||||||
menuOptions.value.filter((item)=>{
|
menuOptions.value.filter((item) => {
|
||||||
if(item.key==='fund'){
|
if (item.key === 'fund') {
|
||||||
item.show=res.enableFund
|
item.show = res.enableFund
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if(res.darkTheme){
|
if (res.darkTheme) {
|
||||||
enableDarkTheme.value=darkTheme
|
enableDarkTheme.value = darkTheme
|
||||||
}else{
|
} else {
|
||||||
enableDarkTheme.value=null
|
enableDarkTheme.value = null
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(()=>{
|
onMounted(() => {
|
||||||
contentStyle.value="max-height: calc(90vh);overflow: hidden"
|
contentStyle.value = "max-height: calc(90vh);overflow: hidden"
|
||||||
GetConfig().then((res)=>{
|
GetConfig().then((res) => {
|
||||||
if(res.enableNews){
|
if (res.enableNews) {
|
||||||
enableNews.value=true
|
enableNews.value = true
|
||||||
}
|
}
|
||||||
enableFund.value=res.enableFund
|
enableFund.value = res.enableFund
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<n-config-provider ref="containerRef" :theme="enableDarkTheme" >
|
<n-config-provider ref="containerRef" :theme="enableDarkTheme">
|
||||||
<n-message-provider >
|
<n-message-provider>
|
||||||
<n-notification-provider>
|
<n-notification-provider>
|
||||||
<n-modal-provider>
|
<n-modal-provider>
|
||||||
<n-dialog-provider>
|
<n-dialog-provider>
|
||||||
|
<n-watermark
|
||||||
<n-watermark
|
:content="content"
|
||||||
:content="content"
|
cross
|
||||||
cross
|
selectable
|
||||||
selectable
|
:font-size="16"
|
||||||
:font-size="16"
|
:line-height="16"
|
||||||
:line-height="16"
|
:width="500"
|
||||||
:width="500"
|
:height="400"
|
||||||
:height="400"
|
:x-offset="50"
|
||||||
:x-offset="50"
|
:y-offset="150"
|
||||||
:y-offset="150"
|
:rotate="-15"
|
||||||
:rotate="-15"
|
>
|
||||||
>
|
<n-flex>
|
||||||
<n-flex>
|
<n-grid x-gap="12" :cols="1">
|
||||||
<n-grid x-gap="12" :cols="1">
|
<n-gi>
|
||||||
<!--
|
<n-spin :show="loading">
|
||||||
<n-gi style="position: relative;top:1px;z-index: 19;width: 100%" v-if="telegraph.length>0">
|
<template #description>
|
||||||
|
{{ loadingMsg }}
|
||||||
</n-gi>
|
</template>
|
||||||
-->
|
<n-marquee :speed="100" style="position: relative;top:0;z-index: 19;width: 100%"
|
||||||
|
v-if="(telegraph.length>0)&&(enableNews)">
|
||||||
<n-gi>
|
<n-tag type="warning" v-for="item in telegraph" style="margin-right: 10px">
|
||||||
<n-marquee :speed="100" style="position: relative;top:0;z-index: 19;width: 100%" v-if="(telegraph.length>0)&&(enableNews)">
|
{{ item }}
|
||||||
<n-tag type="warning" v-for="item in telegraph" style="margin-right: 10px">
|
</n-tag>
|
||||||
{{item}}
|
</n-marquee>
|
||||||
</n-tag>
|
<n-scrollbar :style="contentStyle">
|
||||||
<!-- <n-text type="warning"> {{telegraph[0]}}</n-text>-->
|
<RouterView/>
|
||||||
</n-marquee>
|
</n-scrollbar>
|
||||||
<n-scrollbar :style="contentStyle">
|
</n-spin>
|
||||||
<RouterView />
|
</n-gi>
|
||||||
</n-scrollbar>
|
<n-gi style="position: fixed;bottom:0;z-index: 9;width: 100%;">
|
||||||
</n-gi>
|
<n-card size="small" style="--wails-draggable:drag">
|
||||||
|
<n-menu style="font-size: 18px;"
|
||||||
|
v-model:value="activeKey"
|
||||||
<n-gi style="position: fixed;bottom:0;z-index: 9;width: 100%;">
|
mode="horizontal"
|
||||||
<n-card size="small" style="--wails-draggable:drag">
|
:options="menuOptions"
|
||||||
<n-menu style="font-size: 18px;"
|
responsive
|
||||||
v-model:value="activeKey"
|
/>
|
||||||
mode="horizontal"
|
</n-card>
|
||||||
:options="menuOptions"
|
</n-gi>
|
||||||
responsive
|
</n-grid>
|
||||||
/>
|
</n-flex>
|
||||||
</n-card>
|
</n-watermark>
|
||||||
</n-gi>
|
</n-dialog-provider>
|
||||||
</n-grid>
|
</n-modal-provider>
|
||||||
</n-flex>
|
|
||||||
</n-watermark>
|
|
||||||
</n-dialog-provider>
|
|
||||||
</n-modal-provider>
|
|
||||||
</n-notification-provider>
|
</n-notification-provider>
|
||||||
</n-message-provider>
|
</n-message-provider>
|
||||||
</n-config-provider>
|
</n-config-provider>
|
||||||
|
@ -53,6 +53,9 @@ const industryRanks=ref([])
|
|||||||
const sort = ref("")
|
const sort = ref("")
|
||||||
const sortIcon= ref(h(CaretDown))
|
const sortIcon= ref(h(CaretDown))
|
||||||
const nowTab=ref("市场快讯")
|
const nowTab=ref("市场快讯")
|
||||||
|
const indexInterval= ref(null)
|
||||||
|
const indexIndustryRank= ref(null)
|
||||||
|
|
||||||
function getIndex() {
|
function getIndex() {
|
||||||
GlobalStockIndexes().then((res) => {
|
GlobalStockIndexes().then((res) => {
|
||||||
globalStockIndexes.value = res
|
globalStockIndexes.value = res
|
||||||
@ -84,11 +87,11 @@ onBeforeMount(() => {
|
|||||||
})
|
})
|
||||||
getIndex();
|
getIndex();
|
||||||
industryRank();
|
industryRank();
|
||||||
setInterval(() => {
|
indexInterval.value=setInterval(() => {
|
||||||
getIndex()
|
getIndex()
|
||||||
}, 3000)
|
}, 3000)
|
||||||
|
|
||||||
setInterval(() => {
|
indexIndustryRank.value=setInterval(() => {
|
||||||
industryRank()
|
industryRank()
|
||||||
},1000*10)
|
},1000*10)
|
||||||
})
|
})
|
||||||
@ -98,6 +101,8 @@ onBeforeUnmount(() => {
|
|||||||
EventsOff("newTelegraph")
|
EventsOff("newTelegraph")
|
||||||
EventsOff("newSinaNews")
|
EventsOff("newSinaNews")
|
||||||
EventsOff("summaryStockNews")
|
EventsOff("summaryStockNews")
|
||||||
|
clearInterval(indexInterval.value)
|
||||||
|
clearInterval(indexIndustryRank.value)
|
||||||
})
|
})
|
||||||
|
|
||||||
EventsOn("changeMarketTab" ,async (msg) => {
|
EventsOn("changeMarketTab" ,async (msg) => {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
import {CaretDown, CaretUp} from "@vicons/ionicons5";
|
import {CaretDown, CaretUp, RefreshCircleOutline} from "@vicons/ionicons5";
|
||||||
import {NText} from "naive-ui";
|
import {NText,useMessage} from "naive-ui";
|
||||||
import {onMounted, ref} from "vue";
|
import {onBeforeUnmount, onMounted, onUnmounted, ref} from "vue";
|
||||||
import {GetMoneyRankSina} from "../../wailsjs/go/main/App";
|
import {GetMoneyRankSina} from "../../wailsjs/go/main/App";
|
||||||
import KLineChart from "./KLineChart.vue";
|
import KLineChart from "./KLineChart.vue";
|
||||||
|
|
||||||
@ -16,16 +16,22 @@ const props = defineProps({
|
|||||||
default: 'netamount'
|
default: 'netamount'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
const message = useMessage()
|
||||||
const dataList= ref([])
|
const dataList= ref([])
|
||||||
const sort = ref(props.sort)
|
const sort = ref(props.sort)
|
||||||
|
const interval = ref(null)
|
||||||
onMounted(()=>{
|
onMounted(()=>{
|
||||||
sort.value=props.sort
|
sort.value=props.sort
|
||||||
GetMoneyRankSinaData()
|
GetMoneyRankSinaData()
|
||||||
setInterval(()=>{
|
interval.value=setInterval(()=>{
|
||||||
GetMoneyRankSinaData()
|
GetMoneyRankSinaData()
|
||||||
},1000*60)
|
},1000*60)
|
||||||
})
|
})
|
||||||
|
onBeforeUnmount(()=>{
|
||||||
|
clearInterval(interval.value)
|
||||||
|
})
|
||||||
function GetMoneyRankSinaData(){
|
function GetMoneyRankSinaData(){
|
||||||
|
message.loading("正在刷新数据...")
|
||||||
GetMoneyRankSina(sort.value).then(result => {
|
GetMoneyRankSina(sort.value).then(result => {
|
||||||
if(result.length>0){
|
if(result.length>0){
|
||||||
dataList.value = result
|
dataList.value = result
|
||||||
|
@ -62,10 +62,9 @@ import {asBlob} from 'html-docx-js-typescript';
|
|||||||
|
|
||||||
import vueDanmaku from 'vue3-danmaku'
|
import vueDanmaku from 'vue3-danmaku'
|
||||||
import {keys, pad, padStart} from "lodash";
|
import {keys, pad, padStart} from "lodash";
|
||||||
import {models} from "../../wailsjs/go/models";
|
import {useRoute, useRouter} from 'vue-router'
|
||||||
import {RouterLink} from "vue-router";
|
|
||||||
import { useRoute } from 'vue-router'
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
const danmus = ref([])
|
const danmus = ref([])
|
||||||
const ws = ref(null)
|
const ws = ref(null)
|
||||||
@ -169,6 +168,7 @@ const groupResults=computed(() => {
|
|||||||
}
|
}
|
||||||
return group
|
return group
|
||||||
})
|
})
|
||||||
|
const showPopover=ref(false)
|
||||||
|
|
||||||
onBeforeMount(()=>{
|
onBeforeMount(()=>{
|
||||||
GetGroupList().then(result => {
|
GetGroupList().then(result => {
|
||||||
@ -188,20 +188,6 @@ onBeforeMount(()=>{
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
GetFollowList(currentGroupId.value).then(result => {
|
|
||||||
followList.value = result
|
|
||||||
for (const followedStock of result) {
|
|
||||||
if(followedStock.StockCode.startsWith("us")){
|
|
||||||
followedStock.StockCode="gb_"+ followedStock.StockCode.replace("us", "").toLowerCase()
|
|
||||||
}
|
|
||||||
if (!stocks.value.includes(followedStock.StockCode)) {
|
|
||||||
////console.log("followList",followedStock.StockCode)
|
|
||||||
stocks.value.push(followedStock.StockCode)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
monitor()
|
|
||||||
message.destroyAll()
|
|
||||||
})
|
|
||||||
GetConfig().then(result => {
|
GetConfig().then(result => {
|
||||||
if (result.openAiEnable) {
|
if (result.openAiEnable) {
|
||||||
data.openAiEnable = true
|
data.openAiEnable = true
|
||||||
@ -236,6 +222,23 @@ onMounted(() => {
|
|||||||
// }
|
// }
|
||||||
// }, 3500)
|
// }, 3500)
|
||||||
|
|
||||||
|
GetFollowList(currentGroupId.value).then(result => {
|
||||||
|
|
||||||
|
followList.value = result
|
||||||
|
for (const followedStock of result) {
|
||||||
|
if(followedStock.StockCode.startsWith("us")){
|
||||||
|
followedStock.StockCode="gb_"+ followedStock.StockCode.replace("us", "").toLowerCase()
|
||||||
|
}
|
||||||
|
if (!stocks.value.includes(followedStock.StockCode)) {
|
||||||
|
////console.log("followList",followedStock.StockCode)
|
||||||
|
stocks.value.push(followedStock.StockCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
monitor()
|
||||||
|
message.destroyAll()
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
GetVersionInfo().then((res) => {
|
GetVersionInfo().then((res) => {
|
||||||
icon.value = res.icon;
|
icon.value = res.icon;
|
||||||
});
|
});
|
||||||
@ -280,6 +283,19 @@ onBeforeUnmount(() => {
|
|||||||
EventsOff("warnMsg")
|
EventsOff("warnMsg")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
EventsOn("loadingDone",(data)=>{
|
||||||
|
message.loading("刷新股票基础数据...")
|
||||||
|
GetStockList("").then(result => {
|
||||||
|
stockList.value = result
|
||||||
|
options.value=result.map(item => {
|
||||||
|
return {
|
||||||
|
label: item.name+" - "+item.ts_code,
|
||||||
|
value: item.ts_code
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
EventsOn("refresh",(data)=>{
|
EventsOn("refresh",(data)=>{
|
||||||
message.success(data)
|
message.success(data)
|
||||||
})
|
})
|
||||||
@ -576,6 +592,9 @@ async function updateData(result) {
|
|||||||
|
|
||||||
|
|
||||||
async function monitor() {
|
async function monitor() {
|
||||||
|
if(stocks.value&&stocks.value.length===0){
|
||||||
|
showPopover.value=true
|
||||||
|
}
|
||||||
for (let code of stocks.value) {
|
for (let code of stocks.value) {
|
||||||
// //console.log(code)
|
// //console.log(code)
|
||||||
Greet(code).then(result => {
|
Greet(code).then(result => {
|
||||||
@ -1825,9 +1844,16 @@ function delStockGroup(code,name,groupId){
|
|||||||
:options="options"
|
:options="options"
|
||||||
placeholder="股票指数名称/代码/弹幕"
|
placeholder="股票指数名称/代码/弹幕"
|
||||||
clearable @update-value="getStockList" :on-select="onSelect"/>
|
clearable @update-value="getStockList" :on-select="onSelect"/>
|
||||||
<n-button type="primary" @click="AddStock" v-if="addBTN">
|
|
||||||
<n-icon :component="Add"/> 关注
|
<n-popover trigger="manual" :show="showPopover">
|
||||||
</n-button>
|
<template #trigger>
|
||||||
|
<n-button type="primary" @click="AddStock" v-if="addBTN">
|
||||||
|
<n-icon :component="Add"/> 关注
|
||||||
|
</n-button>
|
||||||
|
</template>
|
||||||
|
<span>输入股票名称/代码关键词开始吧~~~</span>
|
||||||
|
</n-popover>
|
||||||
|
|
||||||
<n-button type="info" @click="SendDanmu" v-if="data.enableDanmu">
|
<n-button type="info" @click="SendDanmu" v-if="data.enableDanmu">
|
||||||
<n-icon :component="ChatboxOutline"/> 发送弹幕
|
<n-icon :component="ChatboxOutline"/> 发送弹幕
|
||||||
</n-button>
|
</n-button>
|
||||||
|
32
main.go
32
main.go
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"embed"
|
"embed"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -62,21 +63,6 @@ func main() {
|
|||||||
// Sort: 0,
|
// Sort: 0,
|
||||||
//})
|
//})
|
||||||
|
|
||||||
if stocksBin != nil && len(stocksBin) > 0 {
|
|
||||||
go initStockData()
|
|
||||||
}
|
|
||||||
log.SugaredLogger.Infof("init stocksBinHK %d", len(stocksBinHK))
|
|
||||||
|
|
||||||
if stocksBinHK != nil && len(stocksBinHK) > 0 {
|
|
||||||
go initStockDataHK()
|
|
||||||
}
|
|
||||||
log.SugaredLogger.Infof("init stocksBinUS %d", len(stocksBinUS))
|
|
||||||
|
|
||||||
if stocksBinUS != nil && len(stocksBinUS) > 0 {
|
|
||||||
go initStockDataUS()
|
|
||||||
}
|
|
||||||
updateBasicInfo()
|
|
||||||
|
|
||||||
// Create an instance of the app structure
|
// Create an instance of the app structure
|
||||||
app := NewApp()
|
app := NewApp()
|
||||||
AppMenu := menu.NewMenu()
|
AppMenu := menu.NewMenu()
|
||||||
@ -218,7 +204,10 @@ func AutoMigrate() {
|
|||||||
db.Dao.AutoMigrate(&models.TelegraphTags{})
|
db.Dao.AutoMigrate(&models.TelegraphTags{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func initStockDataUS() {
|
func initStockDataUS(ctx context.Context) {
|
||||||
|
defer func() {
|
||||||
|
go runtime.EventsEmit(ctx, "loadingMsg", "done")
|
||||||
|
}()
|
||||||
var v []models.StockInfoUS
|
var v []models.StockInfoUS
|
||||||
err := json.Unmarshal(stocksBinUS, &v)
|
err := json.Unmarshal(stocksBinUS, &v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -241,7 +230,10 @@ func initStockDataUS() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func initStockDataHK() {
|
func initStockDataHK(ctx context.Context) {
|
||||||
|
defer func() {
|
||||||
|
go runtime.EventsEmit(ctx, "loadingMsg", "done")
|
||||||
|
}()
|
||||||
var v []models.StockInfoHK
|
var v []models.StockInfoHK
|
||||||
err := json.Unmarshal(stocksBinHK, &v)
|
err := json.Unmarshal(stocksBinHK, &v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -274,7 +266,11 @@ func updateBasicInfo() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func initStockData() {
|
func initStockData(ctx context.Context) {
|
||||||
|
defer func() {
|
||||||
|
go runtime.EventsEmit(ctx, "loadingMsg", "done")
|
||||||
|
}()
|
||||||
|
|
||||||
log.SugaredLogger.Info("init stock data")
|
log.SugaredLogger.Info("init stock data")
|
||||||
res := &data.TushareStockBasicResponse{}
|
res := &data.TushareStockBasicResponse{}
|
||||||
err := json.Unmarshal(stocksBin, res)
|
err := json.Unmarshal(stocksBin, res)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user