web-map/src/components/follow-view-notification.vue

179 lines
3.3 KiB
Vue

<template>
<div v-if="followStore.isFollowing" class="follow-view-notification">
<div class="notification-content">
<div class="notification-text">
<div class="notification-title">视角跟随中</div>
<div class="notification-subtitle">正在跟随: {{ followStore.robotName }}</div>
</div>
<div class="notification-actions">
<a-button type="text" size="small" @click="handleStopFollow" class="stop-button">
<template #icon>
<i class="icon exit" />
</template>
停止跟随
</a-button>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { message } from 'ant-design-vue';
import { useFollowViewStore } from '../stores/follow-view.store';
// 使用 Pinia store
const followStore = useFollowViewStore();
// 停止视角跟随
const handleStopFollow = () => {
followStore.stopFollow();
message.success('已停止视角跟随');
};
// 定义组件名称
defineOptions({
name: 'FollowViewNotification',
});
</script>
<style scoped lang="scss">
.follow-view-notification {
position: fixed;
top: 16px;
left: 50%;
transform: translateX(-50%);
z-index: 1000;
pointer-events: all;
animation: slideDown 0.3s ease-out;
}
.notification-content {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 16px;
background: linear-gradient(135deg, #0dbb8a 0%, #2ec796 100%);
border-radius: 8px;
box-shadow: 0 4px 12px rgba(24, 144, 255, 0.3);
color: white;
min-width: 300px;
max-width: 500px;
backdrop-filter: blur(8px);
border: 1px solid rgba(255, 255, 255, 0.2);
}
.notification-icon {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
background: rgba(255, 255, 255, 0.2);
border-radius: 50%;
flex-shrink: 0;
.icon {
font-size: 16px;
color: white;
}
}
.notification-text {
flex: 1;
min-width: 0;
}
.notification-title {
font-size: 14px;
font-weight: 600;
line-height: 1.2;
margin-bottom: 2px;
}
.notification-subtitle {
font-size: 12px;
opacity: 0.9;
line-height: 1.2;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.notification-actions {
flex-shrink: 0;
}
.stop-button {
color: white !important;
border-color: rgba(255, 255, 255, 0.3) !important;
background: rgba(255, 255, 255, 0.1) !important;
font-size: 12px;
height: 28px;
padding: 0 12px;
border-radius: 4px;
transition: all 0.2s ease;
&:hover {
background: rgba(255, 255, 255, 0.2) !important;
border-color: rgba(255, 255, 255, 0.5) !important;
}
.icon {
font-size: 12px;
margin-right: 4px;
}
}
// 动画效果
@keyframes slideDown {
from {
opacity: 0;
transform: translateX(-50%) translateY(-20px);
}
to {
opacity: 1;
transform: translateX(-50%) translateY(0);
}
}
// 响应式设计
@media (max-width: 768px) {
.follow-view-notification {
top: 8px;
left: 8px;
right: 8px;
transform: none;
}
.notification-content {
min-width: auto;
max-width: none;
padding: 10px 12px;
}
.notification-icon {
width: 28px;
height: 28px;
.icon {
font-size: 14px;
}
}
.notification-title {
font-size: 13px;
}
.notification-subtitle {
font-size: 11px;
}
.stop-button {
font-size: 11px;
height: 26px;
padding: 0 8px;
}
}
</style>