304 lines
5.8 KiB
Vue
304 lines
5.8 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
|
|
v-if="aiScore"
|
|
class="score"
|
|
:class="scoreClass"
|
|
title="同花顺 AI 品种评分"
|
|
>
|
|
评分 {{ formatSigned(aiScore.score) }}
|
|
<span v-if="aiScore.isBest" class="best-tag">最佳</span>
|
|
</span>
|
|
<span class="text">{{ data.summary }}</span>
|
|
<span class="meta">
|
|
置信度 {{ data.confidence }}%
|
|
<template v-if="data.updatedAt">
|
|
· 执行 {{ data.updatedAt }}</template
|
|
>
|
|
</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">基于行情、盘口、新闻、持仓与同花顺 AI 评分,由 DeepSeek 综合分析</div>
|
|
<div v-if="aiScore" class="score-detail">
|
|
<div class="score-head">
|
|
<span
|
|
>{{ aiScore.varietyName }} AI 评分
|
|
<strong :class="scoreClass">{{
|
|
formatSigned(aiScore.score)
|
|
}}</strong></span
|
|
>
|
|
<el-tag v-if="aiScore.isBest" size="small" type="danger" effect="dark"
|
|
>最佳</el-tag
|
|
>
|
|
<span class="score-pct"
|
|
>涨跌幅 {{ formatSigned(aiScore.percent) }}%</span
|
|
>
|
|
</div>
|
|
<ul v-if="aiScore.factors.length" class="factors">
|
|
<li v-for="(f, i) in aiScore.factors" :key="i">
|
|
<span class="judge" :class="judgeClass(f.judge)">{{
|
|
f.judge
|
|
}}</span>
|
|
{{ f.factor }}
|
|
<span class="factor-score">{{ formatSigned(f.score) }}</span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<ul>
|
|
<li v-for="(r, i) in data.reasons" :key="i">{{ r }}</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed, ref } from "vue";
|
|
import type { AiAdvice, AiVarietyScoreView } from "../../types";
|
|
|
|
const props = withDefaults(
|
|
defineProps<{
|
|
data: AiAdvice;
|
|
loading?: boolean;
|
|
aiScore?: AiVarietyScoreView | null;
|
|
}>(),
|
|
{ loading: false, aiScore: null },
|
|
);
|
|
|
|
const emit = defineEmits<{
|
|
refresh: [];
|
|
}>();
|
|
const expanded = ref(false);
|
|
|
|
const scoreClass = computed(() => {
|
|
const s = props.aiScore?.score ?? 0;
|
|
if (s > 0) return "bull";
|
|
if (s < 0) return "bear";
|
|
return "flat";
|
|
});
|
|
|
|
function formatSigned(n: number): string {
|
|
if (!Number.isFinite(n)) return "—";
|
|
return `${n > 0 ? "+" : ""}${n}`;
|
|
}
|
|
|
|
function judgeClass(judge: string): string {
|
|
if (judge.includes("多")) return "bull";
|
|
if (judge.includes("空")) return "bear";
|
|
return "flat";
|
|
}
|
|
|
|
function onRefresh() {
|
|
emit("refresh");
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.ai-drawer {
|
|
max-width: 1440px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.ai-drawer.open {
|
|
min-height: 300px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
.score {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 4px;
|
|
flex-shrink: 0;
|
|
font-weight: 600;
|
|
font-variant-numeric: tabular-nums;
|
|
padding: 2px 8px;
|
|
border-radius: 4px;
|
|
background: var(--bg-elevated, #f5f7fa);
|
|
font-size: 12px;
|
|
}
|
|
|
|
.score.bull {
|
|
color: #cf1322;
|
|
background: #fff1f0;
|
|
}
|
|
|
|
.score.bear {
|
|
color: #389e0d;
|
|
background: #f6ffed;
|
|
}
|
|
|
|
.score.flat {
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.best-tag {
|
|
display: inline-block;
|
|
margin-left: 2px;
|
|
padding: 0 4px;
|
|
border-radius: 3px;
|
|
background: #cf1322;
|
|
color: #fff;
|
|
font-size: 10px;
|
|
font-weight: 700;
|
|
line-height: 16px;
|
|
}
|
|
|
|
.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 {
|
|
flex: 1;
|
|
padding: 0 16px 14px 54px;
|
|
border-top: 1px dashed var(--border);
|
|
overflow: auto;
|
|
}
|
|
|
|
.hint {
|
|
font-size: 12px;
|
|
color: var(--text-secondary);
|
|
margin: 10px 0 6px;
|
|
}
|
|
|
|
.score-detail {
|
|
margin: 8px 0 12px;
|
|
padding: 10px 12px;
|
|
border-radius: 6px;
|
|
background: var(--bg-elevated, #f8f9fb);
|
|
border: 1px solid var(--border);
|
|
}
|
|
|
|
.score-head {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
font-size: 13px;
|
|
margin-bottom: 6px;
|
|
}
|
|
|
|
.score-head .bull {
|
|
color: #cf1322;
|
|
}
|
|
|
|
.score-head .bear {
|
|
color: #389e0d;
|
|
}
|
|
|
|
.score-pct {
|
|
color: var(--text-secondary);
|
|
font-size: 12px;
|
|
margin-left: auto;
|
|
}
|
|
|
|
.factors {
|
|
margin: 0;
|
|
padding-left: 18px;
|
|
font-size: 12px;
|
|
line-height: 1.7;
|
|
color: #3d4450;
|
|
}
|
|
|
|
.judge {
|
|
display: inline-block;
|
|
min-width: 2em;
|
|
margin-right: 4px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.judge.bull {
|
|
color: #cf1322;
|
|
}
|
|
|
|
.judge.bear {
|
|
color: #389e0d;
|
|
}
|
|
|
|
.factor-score {
|
|
color: var(--text-secondary);
|
|
margin-left: 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>
|