From 8d4bcb42920a6546e5d2fdc29d53348c18fc7269 Mon Sep 17 00:00:00 2001 From: fish Date: Sun, 3 May 2026 15:35:26 +0800 Subject: [PATCH] =?UTF-8?q?Web=20=E5=89=8D=E7=AB=AF=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=9A=97=E5=A4=9C=E6=A8=A1=E5=BC=8F=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- web/frontend/src/App.vue | 26 ++++++++++++++++-- web/frontend/src/components/KLineChart.vue | 27 ++++++++++++++---- web/frontend/src/main.ts | 1 + web/frontend/src/stores/theme.ts | 32 ++++++++++++++++++++++ web/frontend/src/views/AdminUsersView.vue | 2 +- web/frontend/src/views/LoginView.vue | 5 ++-- web/frontend/src/views/ScoresView.vue | 2 +- 7 files changed, 83 insertions(+), 12 deletions(-) create mode 100644 web/frontend/src/stores/theme.ts diff --git a/web/frontend/src/App.vue b/web/frontend/src/App.vue index 852ab45..491e341 100644 --- a/web/frontend/src/App.vue +++ b/web/frontend/src/App.vue @@ -2,8 +2,10 @@ import { computed } from 'vue' import { useRouter, useRoute } from 'vue-router' import { useAuthStore } from '@/stores/auth' +import { useThemeStore } from '@/stores/theme' const auth = useAuthStore() +const theme = useThemeStore() const router = useRouter() const route = useRoute() @@ -39,7 +41,16 @@ function logout() { {{ auth.isAdmin ? '管理员' : '普通用户' }} - 退出登录 +
+ + 退出登录 +
@@ -57,6 +68,10 @@ body, margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif; } +body { + background-color: var(--el-bg-color-page); + color: var(--el-text-color-primary); +} .app { height: 100%; } @@ -77,14 +92,19 @@ body, display: flex; justify-content: space-between; align-items: center; - background: #fff; - border-bottom: 1px solid #ebeef5; + background: var(--el-bg-color); + border-bottom: 1px solid var(--el-border-color-light); } .user { display: flex; align-items: center; gap: 10px; } +.right { + display: flex; + align-items: center; + gap: 16px; +} .el-menu { border-right: none !important; } diff --git a/web/frontend/src/components/KLineChart.vue b/web/frontend/src/components/KLineChart.vue index 2613fec..72cfe9a 100644 --- a/web/frontend/src/components/KLineChart.vue +++ b/web/frontend/src/components/KLineChart.vue @@ -2,12 +2,23 @@ import { onBeforeUnmount, onMounted, ref, watch } from 'vue' import * as echarts from 'echarts' import type { Candle } from '@/api/candles' +import { useThemeStore } from '@/stores/theme' const props = defineProps<{ data: Candle[] }>() +const theme = useThemeStore() const containerRef = ref(null) let chart: echarts.ECharts | null = null +function ensureChart() { + if (!containerRef.value) return + if (chart) { + chart.dispose() + chart = null + } + chart = echarts.init(containerRef.value, theme.isDark ? 'dark' : undefined) +} + function render() { if (!chart) return const dates = props.data.map((c) => c.trade_date) @@ -17,6 +28,7 @@ function render() { chart.setOption( { + backgroundColor: 'transparent', tooltip: { trigger: 'axis', axisPointer: { type: 'cross' } }, legend: { data: ['K 线', '持仓量'], top: 0 }, grid: [ @@ -69,11 +81,9 @@ function resize() { } onMounted(() => { - if (containerRef.value) { - chart = echarts.init(containerRef.value) - render() - window.addEventListener('resize', resize) - } + ensureChart() + render() + window.addEventListener('resize', resize) }) onBeforeUnmount(() => { @@ -83,6 +93,13 @@ onBeforeUnmount(() => { }) watch(() => props.data, render, { deep: true }) +watch( + () => theme.isDark, + () => { + ensureChart() + render() + }, +)