mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
feat(frontend):添加股票分钟线迷你图表并优化界面
- 新增 StockSparkLine 组件,用于显示股票分钟迷你线图表 - 在股票页面中集成 StockSparkLine 组件 - 为 about、market 和 settings 页面的主体元素添加可拖拽样式 - 优化股票页面布局,调整网格列数和对齐方式
This commit is contained in:
parent
b5843bcdb8
commit
2dd4f072b2
@ -80,7 +80,7 @@ EventsOn("updateVersion",async (msg) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<n-space vertical size="large">
|
<n-space vertical size="large" style="--wails-draggable:drag">
|
||||||
<!-- 软件描述 -->
|
<!-- 软件描述 -->
|
||||||
<n-card size="large">
|
<n-card size="large">
|
||||||
<n-divider title-placement="center">关于软件</n-divider>
|
<n-divider title-placement="center">关于软件</n-divider>
|
||||||
|
@ -199,6 +199,7 @@ 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
|
||||||
@ -310,7 +311,7 @@ function ReFlesh(source) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<n-card>
|
<n-card style="--wails-draggable:drag">
|
||||||
<n-tabs type="line" animated @update-value="updateTab" :value="nowTab">
|
<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">
|
||||||
|
@ -267,7 +267,7 @@ function deletePrompt(ID){
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<n-flex justify="left" style="text-align: left">
|
<n-flex justify="left" style="text-align: left;--wails-draggable:drag" >
|
||||||
<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-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" >
|
||||||
|
@ -64,6 +64,7 @@ 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 {TaskTools} from "@vicons/carbon";
|
||||||
|
import StockSparkLine from "./stockSparkLine.vue";
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@ -1796,8 +1797,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="1" :y-gap="6">
|
<n-grid :cols="12" :y-gap="6">
|
||||||
<n-gi>
|
<n-gi :span="6">
|
||||||
<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['当前价格'])"/>
|
||||||
@ -1813,6 +1814,9 @@ 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 :open-price="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>
|
||||||
|
128
frontend/src/components/stockSparkLine.vue
Normal file
128
frontend/src/components/stockSparkLine.vue
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
<script setup>
|
||||||
|
import {onMounted,onBeforeMount, ref} from "vue";
|
||||||
|
import * as echarts from 'echarts';
|
||||||
|
import {GetStockMinutePriceLineData} from "../../wailsjs/go/main/App"; // 如果您使用多个组件,请将此样式导入放在您的主文件中
|
||||||
|
const {stockCode,stockName,openPrice,darkTheme} = defineProps({
|
||||||
|
stockCode: {
|
||||||
|
type: String,
|
||||||
|
default: ""
|
||||||
|
},
|
||||||
|
stockName: {
|
||||||
|
type: String,
|
||||||
|
default: ""
|
||||||
|
},
|
||||||
|
openPrice: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
darkTheme: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const chartRef=ref();
|
||||||
|
|
||||||
|
function setChartData(chart) {
|
||||||
|
GetStockMinutePriceLineData(stockCode, stockName).then(result => {
|
||||||
|
//console.log("GetStockMinutePriceLineData",result)
|
||||||
|
const priceData = result.priceData
|
||||||
|
let category = []
|
||||||
|
let price = []
|
||||||
|
let min = 0
|
||||||
|
let max = 0
|
||||||
|
let lastPrice = priceData[priceData.length - 1].price
|
||||||
|
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);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
const chart = echarts.init(chartRef.value);
|
||||||
|
setChartData(chart);
|
||||||
|
|
||||||
|
// setInterval(() => {
|
||||||
|
// setChartData(chart);
|
||||||
|
// }, 1000 * 5 );
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<div style="height: 20px;width: 100%" ref="chartRef">
|
||||||
|
</div>
|
||||||
|
</template>
|
Loading…
x
Reference in New Issue
Block a user