From e8d60aa63a9b41862c6277c2d602113bc130d136 Mon Sep 17 00:00:00 2001 From: dongzp <975303544@qq.com> Date: Fri, 24 Jul 2026 10:50:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E5=8D=95=E6=8F=90=E9=86=92=E7=9A=84?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=EF=BC=8C=E9=80=9A=E7=9F=A5=E9=87=8D=E5=8F=A0?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/styles/global.css | 9 +++++++++ src/utils/largeOrderAlert.ts | 21 ++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/styles/global.css b/src/styles/global.css index 9755c69..e1e29b3 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -47,3 +47,12 @@ a:hover { font-size: 16px; font-weight: 600; } + +/* 大单提醒:买入 Top / 卖出 Bottom(无 type,避免覆盖自定义 icon) */ +.large-order-alert--buy .el-notification__icon { + color: var(--up); +} + +.large-order-alert--sell .el-notification__icon { + color: var(--down); +} diff --git a/src/utils/largeOrderAlert.ts b/src/utils/largeOrderAlert.ts index 4887e9a..14ed18e 100644 --- a/src/utils/largeOrderAlert.ts +++ b/src/utils/largeOrderAlert.ts @@ -1,4 +1,6 @@ +import { markRaw, nextTick } from 'vue' import { ElNotification } from 'element-plus' +import { Bottom, Top } from '@element-plus/icons-vue' import type { ContractItem, TradeTick } from '../types' /** @@ -9,15 +11,28 @@ export function notifyLargeOrders(trades: TradeTick[], contract: ContractItem): const threshold = contract.largeOrderAlertLots if (!threshold || threshold <= 0 || trades.length === 0) return + let shown = 0 for (const t of trades) { if (t.volume <= threshold) continue - const sideLabel = t.side === 'B' ? '买' : '卖' + const isBuy = t.side === 'B' + const sideLabel = isBuy ? '买' : '卖' ElNotification({ title: `大单提醒 · ${contract.name || contract.code}`, message: `${t.time} ${sideLabel} ${t.volume}手 @ ${t.price.toFixed(2)}`, - type: t.side === 'B' ? 'error' : 'success', - duration: 4500, + // 勿设 type:type 会覆盖自定义 icon,买入会变成 error 图标 + icon: markRaw(isBuy ? Top : Bottom), + duration: 10000, position: 'top-right', + customClass: isBuy ? 'large-order-alert--buy' : 'large-order-alert--sell', + }) + shown++ + } + + // 同步连弹时前一个通知尚未 mount(visible=false → offsetHeight=0),会叠在一起; + // 等 DOM 就绪后按真实高度重算 offset。 + if (shown > 1) { + void nextTick(() => { + ElNotification.updateOffsets('top-right') }) } }