ai_trade_assistance/src/components/ai/AiAdviceDrawer.vue

134 lines
2.4 KiB
Vue

<template>
<div class="ai-drawer" :class="{ open: expanded }">
<div class="bar">
<div class="summary">
<span class="badge" :class="data.direction">AI</span>
<strong>{{ data.action }}</strong>
<span class="text">{{ data.summary }}</span>
<span class="meta">置信度 {{ data.confidence }}% · {{ data.updatedAt }}</span>
</div>
<div class="btns">
<el-button size="small" :loading="loading" @click="onRefresh">一键获取建议</el-button>
<el-button size="small" text type="primary" @click="expanded = !expanded">
{{ expanded ? '收起' : '展开' }}
</el-button>
</div>
</div>
<div v-show="expanded" class="body">
<div class="hint">基于行情、盘口、新闻与持仓,由 DeepSeek 综合分析</div>
<ul>
<li v-for="(r, i) in data.reasons" :key="i">{{ r }}</li>
</ul>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { AiAdvice } from '../../types'
withDefaults(
defineProps<{
data: AiAdvice
loading?: boolean
}>(),
{ loading: false },
)
const emit = defineEmits<{
refresh: []
}>()
const expanded = ref(false)
function onRefresh() {
emit('refresh')
}
</script>
<style scoped>
.ai-drawer {
max-width: 1440px;
margin: 0 auto;
}
.bar {
min-height: var(--ai-bar-height);
padding: 8px 16px;
display: flex;
align-items: center;
gap: 12px;
}
.summary {
display: flex;
align-items: center;
gap: 10px;
flex: 1;
min-width: 0;
font-size: 13px;
}
.badge {
display: inline-flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
border-radius: 6px;
background: linear-gradient(135deg, #1677ff, #69b1ff);
color: #fff;
font-size: 11px;
font-weight: 700;
flex-shrink: 0;
}
.text {
color: var(--text-primary);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.meta {
color: var(--text-secondary);
flex-shrink: 0;
font-size: 12px;
}
.btns {
display: flex;
gap: 4px;
flex-shrink: 0;
}
.body {
padding: 0 16px 14px 54px;
border-top: 1px dashed var(--border);
}
.hint {
font-size: 12px;
color: var(--text-secondary);
margin: 10px 0 6px;
}
ul {
margin: 0;
padding-left: 18px;
font-size: 13px;
line-height: 1.7;
color: #3d4450;
}
@media (max-width: 768px) {
.bar {
flex-direction: column;
align-items: stretch;
}
.meta {
display: none;
}
}
</style>