update
This commit is contained in:
parent
da1389bf66
commit
ce3f305077
@ -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'
|
||||
|
||||
@ -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<HistoryItem[]>([])
|
||||
|
||||
// 根据环境选择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 = '<div class="error-message">请输入正确的6位股票代码</div>'
|
||||
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"
|
||||
/>
|
||||
<button
|
||||
@ -258,7 +212,7 @@ const copyAnalysis = async () => {
|
||||
</div>
|
||||
<button
|
||||
class="analyze-button"
|
||||
@click="handleAnalysis"
|
||||
@click="() => handleAnalysis()"
|
||||
:disabled="!stockCode || isAnalyzing"
|
||||
>
|
||||
{{ isAnalyzing ? '分析中...' : '开始分析' }}
|
||||
@ -267,37 +221,6 @@ const copyAnalysis = async () => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 搜索历史 -->
|
||||
<div class="search-history-section">
|
||||
<div v-if="searchHistory.length > 0 && !isAnalyzing" class="search-history-container">
|
||||
<div class="history-header">
|
||||
<span class="history-title">搜索历史</span>
|
||||
<button class="clear-history" @click="clearHistory">清空</button>
|
||||
</div>
|
||||
<div class="history-list">
|
||||
<div v-for="item in searchHistory" :key="item.code" class="history-item">
|
||||
<button class="history-code" @click="selectFromHistory(item)">
|
||||
<span class="code">{{ item.code }}</span>
|
||||
</button>
|
||||
<button class="remove-history" @click.stop="removeFromHistory(item)">
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
class="remove-icon"
|
||||
>
|
||||
<line x1="18" y1="6" x2="6" y2="18"></line>
|
||||
<line x1="6" y1="6" x2="18" y2="18"></line>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 分析视图 -->
|
||||
@ -345,7 +268,6 @@ const copyAnalysis = async () => {
|
||||
</div>
|
||||
<div class="status-text">
|
||||
<div class="status-label">AI 正在分析</div>
|
||||
<!-- <div v-if="currentThought" class="thought-text">{{ currentThought }}</div> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/* 滚动条样式 */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user