topfans/frontend/pages/mailbox/components/PostcardTarget.vue

88 lines
2.7 KiB
Vue

<template>
<PostcardBase
:notification="notification"
:displayTitle="displayTitle"
@mark-read="emit('mark-read', $event)"
@delete="emit('delete', $event)"
>
<template #body>
<view class="target-body">
<view class="badge-row">
<text class="badge" :class="actionColor">{{ actionText }}</text>
</view>
<view v-if="reasonSummary" class="reason-summary">
<text class="reason-label">原因:</text>
<text class="reason-text">{{ reasonSummary }}</text>
</view>
<view v-if="targetType" class="chip-row">
<text class="chip-label">涉及对象:</text>
<text class="chip-value">{{ targetType }}#{{ targetId }}</text>
</view>
<view class="target-content">
<text>{{ notification.content }}</text>
</view>
</view>
</template>
</PostcardBase>
</template>
<script setup>
import { computed } from 'vue'
import PostcardBase from './PostcardBase.vue'
import { parseData, actionLabel, actionColorClass } from './postcardHelpers.js'
const props = defineProps({
notification: { type: Object, required: true },
displayTitle: { type: String, default: '' },
})
const emit = defineEmits(['mark-read', 'delete'])
const data = computed(() => parseData(props.notification.data))
const rawAction = computed(() => data.value.action || '')
const actionText = computed(() => actionLabel(rawAction.value))
const actionColor = computed(() => actionColorClass(rawAction.value))
const reasonSummary = computed(() => data.value.reason_summary || '')
const targetType = computed(() => data.value.target_type || '')
const targetId = computed(() => data.value.target_id || '')
</script>
<style lang="scss" scoped>
.target-body {
.badge-row { margin-bottom: 12rpx; }
.badge {
display: inline-block;
padding: 4rpx 16rpx;
border-radius: 8rpx;
font-size: 22rpx;
color: #fff;
&.badge-red { background: #f5222d; }
&.badge-orange { background: #fa8c16; }
&.badge-green { background: #52c41a; }
&.badge-gray { background: #999; }
}
.reason-summary {
margin-bottom: 16rpx;
padding: 12rpx 16rpx;
background: #fff7e6;
border-left: 4rpx solid #fa8c16;
border-radius: 4rpx;
font-size: 24rpx;
.reason-label { color: #fa8c16; margin-right: 8rpx; font-weight: 500; }
.reason-text { color: #333; }
}
.chip-row {
display: flex;
font-size: 24rpx;
padding: 6rpx 0;
.chip-label { color: #999; margin-right: 16rpx; min-width: 140rpx; }
.chip-value { color: #333; }
}
.target-content {
margin-top: 16rpx;
font-size: 28rpx;
line-height: 1.7;
color: #333;
white-space: pre-wrap;
}
}
</style>