From ce3f3050777a1fe18d5d556f8e6d4c21e8510759 Mon Sep 17 00:00:00 2001 From: aaron <> Date: Thu, 15 May 2025 20:33:03 +0800 Subject: [PATCH] update --- docker-compose.yml | 2 +- src/views/AStockAnalysisView.vue | 233 ++----------------------------- 2 files changed, 9 insertions(+), 226 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d228a08..1d779f5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: build: context: . dockerfile: Dockerfile - image: tradus-web:1.18 + image: tradus-web:1.19 container_name: tradus-web ports: - '6000:80' diff --git a/src/views/AStockAnalysisView.vue b/src/views/AStockAnalysisView.vue index cd453ba..d5e802d 100644 --- a/src/views/AStockAnalysisView.vue +++ b/src/views/AStockAnalysisView.vue @@ -2,11 +2,6 @@ import { ref, nextTick } from 'vue' import { useUserStore } from '../stores/user' -interface HistoryItem { - code: string - timestamp: number -} - const userStore = useUserStore() const stockCode = ref('') const isAnalyzing = ref(false) @@ -16,10 +11,6 @@ const currentThought = ref('') const showInitialView = ref(true) const copySuccess = ref(false) -const HISTORY_KEY = 'astock_search_history' -const MAX_HISTORY = 5 -const searchHistory = ref([]) - // 根据环境选择API基础URL const apiBaseUrl = import.meta.env.MODE === 'development' ? 'http://127.0.0.1:8000' : 'https://api.ibtc.work' @@ -31,60 +22,23 @@ const scrollToBottom = async () => { } } -// 加载搜索历史 -const loadSearchHistory = () => { - const history = localStorage.getItem(HISTORY_KEY) - if (history) { - searchHistory.value = JSON.parse(history) +// 处理回车键 +const handleKeyup = (event: KeyboardEvent) => { + if (event.key === 'Enter') { + handleAnalysis() } } -// 添加搜索历史 -const addToHistory = (code: string) => { - const newItem = { - code: code.toUpperCase(), - timestamp: Date.now(), - } - const history = searchHistory.value.filter((item) => item.code !== newItem.code) - history.unshift(newItem) - searchHistory.value = history.slice(0, MAX_HISTORY) - localStorage.setItem(HISTORY_KEY, JSON.stringify(searchHistory.value)) -} - -// 从历史中选择 -const selectFromHistory = (item: HistoryItem) => { - stockCode.value = item.code - handleAnalysis() -} - -// 删除历史记录 -const removeFromHistory = (item: HistoryItem) => { - searchHistory.value = searchHistory.value.filter((h) => h.code !== item.code) - localStorage.setItem(HISTORY_KEY, JSON.stringify(searchHistory.value)) -} - -// 清空历史记录 -const clearHistory = () => { - searchHistory.value = [] - localStorage.removeItem(HISTORY_KEY) -} - -// 初始化时加载历史记录 -loadSearchHistory() - const handleAnalysis = async () => { - if (!stockCode.value || isAnalyzing.value) return - const code = stockCode.value.trim() + if (!code || isAnalyzing.value) return + // 验证股票代码格式 if (!/^\d{6}$/.test(code)) { analysisContent.value = '
请输入正确的6位股票代码
' return } - // 添加到搜索历史 - addToHistory(code) - showInitialView.value = false isAnalyzing.value = true analysisContent.value = '' @@ -234,7 +188,7 @@ const copyAnalysis = async () => { :class="{ 'is-selected': stockCode }" placeholder="请输入6位股票代码" maxlength="6" - @keyup.enter="handleAnalysis" + @keyup="handleKeyup" :disabled="isAnalyzing" /> - -
-
- - -
-
- - @@ -345,7 +268,6 @@ const copyAnalysis = async () => {
AI 正在分析
-
@@ -505,110 +427,6 @@ const copyAnalysis = async () => { cursor: not-allowed; } -/* 搜索历史样式 */ -.search-history-section { - width: 100%; - max-width: 600px; - margin: 0 auto; - padding: 0 1.5rem; -} - -.search-history-container { - margin-top: 1rem; - padding: 1rem; - border-radius: 0.5rem; - background-color: var(--color-bg-secondary); -} - -.history-header { - display: flex; - justify-content: space-between; - align-items: center; - margin-bottom: 0.75rem; -} - -.history-title { - font-size: 0.9rem; - color: var(--color-text-secondary); -} - -.clear-history { - font-size: 0.8rem; - color: var(--color-text-secondary); - background: none; - border: none; - cursor: pointer; - padding: 0.25rem 0.5rem; - border-radius: 0.25rem; - transition: all 0.2s ease; -} - -.clear-history:hover { - color: var(--color-text-primary); - background-color: var(--color-bg-hover); -} - -.history-list { - display: flex; - flex-wrap: wrap; - gap: 0.5rem; -} - -.history-item { - display: flex; - align-items: center; - gap: 0.25rem; -} - -.history-code { - display: flex; - align-items: center; - gap: 0.5rem; - padding: 0.25rem 0.75rem; - border-radius: 0.25rem; - background-color: var(--color-bg-hover); - border: none; - cursor: pointer; - transition: all 0.2s ease; -} - -.history-code:hover { - background-color: var(--color-bg-active); -} - -.history-code .code { - font-size: 0.9rem; - color: var(--color-text-primary); -} - -.remove-history { - display: flex; - align-items: center; - justify-content: center; - width: 1.5rem; - height: 1.5rem; - padding: 0.25rem; - border: none; - background: none; - cursor: pointer; - border-radius: 50%; - transition: all 0.2s ease; -} - -.remove-history:hover { - background-color: var(--color-bg-active); -} - -.remove-history .remove-icon { - width: 1rem; - height: 1rem; - color: var(--color-text-secondary); -} - -.remove-history:hover .remove-icon { - color: var(--color-text-primary); -} - /* 分析视图样式 */ .analysis-view { display: flex; @@ -848,19 +666,6 @@ const copyAnalysis = async () => { padding: 0.6rem; font-size: 0.85rem; } - - .search-history-section { - padding: 0 1rem; - } - - .search-history-container { - padding: 1rem; - } - - .history-code { - padding: 0.25rem 0.6rem; - font-size: 0.85rem; - } } @media (max-width: 480px) { @@ -908,28 +713,6 @@ const copyAnalysis = async () => { padding: 0.5rem; font-size: 0.8rem; } - - .search-history-section { - padding: 0 0.75rem; - } - - .history-title { - font-size: 0.85rem; - } - - .clear-history { - font-size: 0.8rem; - } - - .history-code { - padding: 0.2rem 0.5rem; - font-size: 0.8rem; - } - - .remove-icon { - width: 12px; - height: 12px; - } } /* 滚动条样式 */