281 lines
7.1 KiB
Vue
281 lines
7.1 KiB
Vue
<script setup lang="ts">
|
|
import { computed } from 'vue'
|
|
import { BellOutlined, ClockCircleOutlined } from '@ant-design/icons-vue'
|
|
import { renderRichContent } from '@/utils/rich-content'
|
|
|
|
/**
|
|
* Purpose: props supports SystemMessageCard.vue by holding or executing the props page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
const props = withDefaults(defineProps<{
|
|
title?: string
|
|
content?: string
|
|
imageUrl?: string
|
|
imageAlt?: string
|
|
meta?: string
|
|
badge?: string
|
|
auxiliaryBadge?: string
|
|
surface?: 'modal' | 'preview'
|
|
footerAlign?: 'between' | 'end'
|
|
}>(), {
|
|
title: '系统消息',
|
|
content: '',
|
|
imageUrl: '',
|
|
imageAlt: '消息图片',
|
|
meta: '',
|
|
badge: '',
|
|
auxiliaryBadge: '',
|
|
surface: 'preview',
|
|
footerAlign: 'between'
|
|
})
|
|
|
|
/**
|
|
* Purpose: hasImage supports SystemMessageCard.vue by holding or executing the has image page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
const hasImage = computed(() => Boolean(props.imageUrl))
|
|
/**
|
|
* Purpose: displayTitle supports SystemMessageCard.vue by holding or executing the display title page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
const displayTitle = computed(() => props.title?.trim() || '系统消息')
|
|
/**
|
|
* Purpose: displayContent supports SystemMessageCard.vue by holding or executing the display content page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
const displayContent = computed(() => props.content?.trim() || (hasImage.value ? '' : '你收到了一条新的系统消息。'))
|
|
const displayContentHtml = computed(() => renderRichContent(displayContent.value))
|
|
</script>
|
|
|
|
<template>
|
|
<article
|
|
class="system-message-card"
|
|
:class="[
|
|
`system-message-card--${surface}`,
|
|
`system-message-card--footer-${footerAlign}`,
|
|
{ 'system-message-card--with-image': hasImage }
|
|
]"
|
|
>
|
|
<div v-if="hasImage" class="system-message-card__media">
|
|
<img :src="imageUrl" :alt="imageAlt" />
|
|
</div>
|
|
|
|
<div v-else class="system-message-card__icon">
|
|
<BellOutlined />
|
|
</div>
|
|
|
|
<section class="system-message-card__main">
|
|
<div v-if="badge || auxiliaryBadge" class="system-message-card__badges">
|
|
<span v-if="auxiliaryBadge" class="system-message-card__badge system-message-card__badge--soft">{{ auxiliaryBadge }}</span>
|
|
<span v-if="badge" class="system-message-card__badge">{{ badge }}</span>
|
|
</div>
|
|
|
|
<h2 class="system-message-card__title">{{ displayTitle }}</h2>
|
|
|
|
<div v-if="meta" class="system-message-card__meta">
|
|
<ClockCircleOutlined />
|
|
<span>{{ meta }}</span>
|
|
</div>
|
|
|
|
<div v-if="displayContentHtml" class="system-message-card__content" v-html="displayContentHtml"></div>
|
|
</section>
|
|
|
|
<footer v-if="$slots.footer" class="system-message-card__footer">
|
|
<slot name="footer" />
|
|
</footer>
|
|
</article>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.system-message-card {
|
|
width: 100%;
|
|
overflow: hidden;
|
|
border: 1px solid var(--theme-border);
|
|
border-radius: 8px;
|
|
background: var(--theme-card-bg);
|
|
}
|
|
|
|
.system-message-card--preview {
|
|
box-shadow: 0 20px 54px rgba(77, 50, 62, 0.16);
|
|
}
|
|
|
|
.system-message-card--modal {
|
|
border: 0;
|
|
box-shadow: none;
|
|
}
|
|
|
|
.system-message-card__media {
|
|
width: 100%;
|
|
aspect-ratio: 16 / 9;
|
|
padding: 12px 12px 0;
|
|
background: var(--theme-gradient-soft);
|
|
}
|
|
|
|
.system-message-card__media img {
|
|
display: block;
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
border-radius: 8px;
|
|
}
|
|
|
|
.system-message-card__icon {
|
|
display: grid;
|
|
width: 48px;
|
|
height: 48px;
|
|
margin: 28px auto 0;
|
|
place-items: center;
|
|
border-radius: 8px;
|
|
color: #ffffff;
|
|
font-size: 20px;
|
|
background: var(--theme-gradient);
|
|
box-shadow: var(--theme-button-shadow);
|
|
}
|
|
|
|
.system-message-card__main {
|
|
padding: 20px 30px 28px;
|
|
text-align: center;
|
|
}
|
|
|
|
.system-message-card--with-image .system-message-card__main {
|
|
padding-top: 20px;
|
|
}
|
|
|
|
.system-message-card__badges {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 8px;
|
|
justify-content: center;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.system-message-card__badge {
|
|
display: inline-flex;
|
|
min-height: 24px;
|
|
align-items: center;
|
|
padding: 0 10px;
|
|
border-radius: 8px;
|
|
color: #ffffff;
|
|
font-size: 12px;
|
|
font-weight: 700;
|
|
background: var(--theme-gradient);
|
|
}
|
|
|
|
.system-message-card__badge--soft {
|
|
color: var(--theme-primary);
|
|
background: var(--theme-primary-soft);
|
|
}
|
|
|
|
.system-message-card__title {
|
|
margin: 0;
|
|
color: var(--text-primary);
|
|
font-size: 19px;
|
|
font-weight: 800;
|
|
line-height: 1.35;
|
|
overflow-wrap: break-word;
|
|
}
|
|
|
|
.system-message-card__meta {
|
|
display: inline-flex;
|
|
max-width: 100%;
|
|
gap: 6px;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin-top: 10px;
|
|
color: var(--text-secondary);
|
|
font-size: 13px;
|
|
line-height: 1.5;
|
|
overflow-wrap: break-word;
|
|
}
|
|
|
|
.system-message-card__content {
|
|
margin: 20px 0 0;
|
|
color: var(--text-primary);
|
|
font-size: 15px;
|
|
line-height: 1.75;
|
|
text-align: left;
|
|
overflow-wrap: break-word;
|
|
}
|
|
|
|
.system-message-card__content :deep(*) {
|
|
max-width: 100%;
|
|
}
|
|
|
|
.system-message-card__content :deep(p),
|
|
.system-message-card__content :deep(ul),
|
|
.system-message-card__content :deep(ol),
|
|
.system-message-card__content :deep(blockquote),
|
|
.system-message-card__content :deep(pre),
|
|
.system-message-card__content :deep(table) {
|
|
margin: 0 0 12px;
|
|
}
|
|
|
|
.system-message-card__content :deep(p:last-child),
|
|
.system-message-card__content :deep(ul:last-child),
|
|
.system-message-card__content :deep(ol:last-child),
|
|
.system-message-card__content :deep(blockquote:last-child),
|
|
.system-message-card__content :deep(pre:last-child),
|
|
.system-message-card__content :deep(table:last-child) {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.system-message-card__content :deep(ul),
|
|
.system-message-card__content :deep(ol) {
|
|
padding-left: 1.25em;
|
|
}
|
|
|
|
.system-message-card__content :deep(a) {
|
|
color: var(--theme-primary);
|
|
}
|
|
|
|
.system-message-card__content :deep(img) {
|
|
display: block;
|
|
max-width: 100%;
|
|
border-radius: 8px;
|
|
}
|
|
|
|
.system-message-card__content :deep(pre) {
|
|
overflow-x: auto;
|
|
padding: 10px 12px;
|
|
border-radius: 8px;
|
|
background: var(--theme-primary-soft);
|
|
}
|
|
|
|
.system-message-card__footer {
|
|
display: flex;
|
|
gap: 12px;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 18px 30px;
|
|
border-top: 1px solid var(--theme-border);
|
|
color: var(--text-secondary);
|
|
font-size: 13px;
|
|
background: var(--theme-card-bg);
|
|
}
|
|
|
|
.system-message-card--footer-end .system-message-card__footer {
|
|
justify-content: flex-end;
|
|
}
|
|
|
|
@media (max-width: 640px) {
|
|
.system-message-card {
|
|
border-radius: 8px;
|
|
}
|
|
|
|
.system-message-card__main,
|
|
.system-message-card__footer {
|
|
padding-left: 22px;
|
|
padding-right: 22px;
|
|
}
|
|
|
|
.system-message-card__title {
|
|
font-size: 18px;
|
|
}
|
|
|
|
.system-message-card__footer {
|
|
align-items: stretch;
|
|
flex-direction: column;
|
|
}
|
|
}
|
|
</style>
|