杂务:整理文档并收口 YumiNail 修复

This commit is contained in:
xiaowang
2026-05-21 18:43:59 +08:00
parent 3797938616
commit 9227ec6175
362 changed files with 8358 additions and 19928 deletions
@@ -1,74 +1,111 @@
<template>
<div class="system-messages admin-page">
<a-page-header title="消息发布" sub-title="发布站内消息,支持文本和单张图片" />
<section class="message-page-head">
<a-page-header title="消息发布" sub-title="发布站内消息,支持文本和单张图片" />
</section>
<a-card :bordered="false" class="admin-section-card">
<template #title>发布消息</template>
<a-form layout="vertical" :model="form">
<a-form-item label="标题" required>
<a-input v-model:value="form.title" :maxlength="100" placeholder="请输入消息标题" />
</a-form-item>
<a-form-item label="内容">
<a-textarea v-model:value="form.content" :rows="5" :maxlength="2000" placeholder="请输入消息内容,可配合图片展示" />
</a-form-item>
<a-form-item label="消息图片">
<div class="image-upload-row">
<a-upload
accept="image/*"
list-type="picture-card"
:show-upload-list="false"
:custom-request="handleImageUpload"
>
<div v-if="!imagePreviewUrl" class="upload-placeholder">
<span class="upload-plus">+</span>
<span>上传图片</span>
</div>
<img v-else class="message-image-preview" :src="imagePreviewUrl" alt="消息图片预览" />
</a-upload>
<div class="image-upload-copy">
<div>每条消息最多上传一张图片。</div>
<small>建议使用 JPG/PNG/WebP,图片会在弹窗和通知详情中展示。</small>
<a-button v-if="form.imageFileId" type="link" danger size="small" @click="removeImage">移除图片</a-button>
<section class="message-composer-shell">
<div class="message-composer-grid">
<article class="message-editor-panel">
<div class="panel-heading">
<div class="panel-heading__icon">
<SendOutlined />
</div>
<div>
<p class="panel-eyebrow">站内消息</p>
<h2>发布消息</h2>
</div>
</div>
</a-form-item>
<a-row :gutter="16">
<a-col :xs="24" :md="10">
<a-form-item label="接收范围" required>
<a-select v-model:value="form.targetType" @change="handleTargetTypeChange">
<a-select-option v-for="item in targetTypes" :key="item.value" :value="item.value">
{{ item.label }}
</a-select-option>
</a-select>
<a-form layout="vertical" :model="form" class="message-form">
<a-form-item label="标题" required>
<a-input v-model:value="form.title" :maxlength="100" placeholder="请输入消息标题" />
</a-form-item>
</a-col>
<a-col v-if="needsShopSelection" :xs="24" :md="14">
<a-form-item label="接收店铺" required>
<a-select v-model:value="form.shopIds" mode="multiple" :options="shopOptions" placeholder="请选择店铺" />
<a-form-item label="内容">
<a-textarea v-model:value="form.content" :rows="6" :maxlength="2000" placeholder="请输入消息内容,可配合图片展示" />
</a-form-item>
</a-col>
<a-col v-if="form.targetType === 'SELECTED_USERS'" :xs="24" :md="14">
<a-form-item label="接收用户" required>
<a-select
v-model:value="form.userIds"
mode="multiple"
show-search
option-filter-prop="label"
:options="userOptions"
placeholder="请选择用户"
/>
<a-form-item label="消息图片">
<div class="image-upload-row">
<a-upload accept="image/*" list-type="picture-card" :show-upload-list="false" :custom-request="handleImageUpload">
<div v-if="!imagePreviewUrl" class="upload-placeholder">
<PictureOutlined />
<span>上传图片</span>
</div>
<img v-else class="message-image-preview" :src="imagePreviewUrl" alt="消息图片预览" />
</a-upload>
<div class="image-upload-copy">
<div>每条消息最多上传一张图片。</div>
<small>建议使用 JPG/PNG/WebP,图片会在弹窗和通知详情中展示。</small>
<a-button v-if="form.imageFileId" type="link" danger size="small" @click="removeImage">移除图片</a-button>
</div>
</div>
</a-form-item>
</a-col>
</a-row>
<a-form-item>
<a-checkbox v-model:checked="popupEnabled">弹窗显示一次</a-checkbox>
</a-form-item>
<a-space>
<a-button type="primary" :loading="saving" @click="handlePublish">发布</a-button>
<a-button @click="resetForm">清空</a-button>
</a-space>
</a-form>
</a-card>
<div class="scope-panel">
<a-row :gutter="16">
<a-col :xs="24" :md="10">
<a-form-item label="接收范围" required>
<a-select v-model:value="form.targetType" @change="handleTargetTypeChange">
<a-select-option v-for="item in targetTypes" :key="item.value" :value="item.value">
{{ item.label }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col v-if="needsShopSelection" :xs="24" :md="14">
<a-form-item label="接收店铺" required>
<a-select v-model:value="form.shopIds" mode="multiple" :options="shopOptions" placeholder="请选择店铺" />
</a-form-item>
</a-col>
<a-col v-if="form.targetType === 'SELECTED_USERS'" :xs="24" :md="14">
<a-form-item label="接收用户" required>
<a-select
v-model:value="form.userIds"
mode="multiple"
show-search
option-filter-prop="label"
:options="userOptions"
placeholder="请选择用户"
/>
</a-form-item>
</a-col>
</a-row>
</div>
<div class="publish-footer">
<a-checkbox v-model:checked="popupEnabled" class="popup-checkbox">弹窗显示一次</a-checkbox>
<a-space>
<a-button @click="resetForm">清空</a-button>
<a-button type="primary" :loading="saving" @click="handlePublish">
<template #icon>
<SendOutlined />
</template>
发布
</a-button>
</a-space>
</div>
</a-form>
</article>
<aside class="message-preview-panel">
<SystemMessageCard
:title="previewTitle"
:content="previewContent"
:image-url="imagePreviewUrl"
:meta="previewMeta"
surface="preview"
footer-align="end"
>
<template #footer>
<button class="preview-read-button" type="button" tabindex="-1">
<CheckOutlined />
我知道了
</button>
</template>
</SystemMessageCard>
</aside>
</div>
</section>
<a-card :bordered="false" class="admin-section-card">
<template #title>发布记录</template>
@@ -96,40 +133,48 @@
</a-table>
</a-card>
<a-modal v-model:open="previewVisible" title="消息详情" :footer="null" width="620px">
<h3>{{ currentMessage?.title }}</h3>
<p class="message-meta">{{ currentMessage?.publisherName }} · {{ currentMessage?.targetTypeName }} · {{ currentMessage?.publishTime }}</p>
<div v-if="currentMessage?.content" class="message-content">{{ currentMessage?.content }}</div>
<img v-if="currentMessage?.imageUrl" class="detail-image" :src="currentMessage.imageUrl" alt="消息图片" />
<a-modal v-model:open="previewVisible" :footer="null" width="560px" wrap-class-name="message-detail-modal-wrap">
<SystemMessageCard
:title="currentMessage?.title || '消息详情'"
:content="currentMessage?.content || ''"
:image-url="currentMessage?.imageUrl || ''"
:meta="currentMessageMeta"
surface="modal"
footer-align="end"
>
<template #footer>
<a-button type="primary" class="message-detail-close-button" @click="previewVisible = false">
<template #icon>
<CheckOutlined />
</template>
我知道了
</a-button>
</template>
</SystemMessageCard>
</a-modal>
</div>
</template>
<script setup lang="ts">
/**
* SystemMessagesView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { computed, onMounted, reactive, ref } from 'vue'
import { message } from 'ant-design-vue'
import { adminFileApi, adminSystemMessageApi, type SystemMessageVO, type SystemMessageCreateRequest } from '@/api/admin'
import {
CheckOutlined,
PictureOutlined,
SendOutlined
} from '@ant-design/icons-vue'
import SystemMessageCard from '@/components/SystemMessageCard.vue'
import { adminFileApi, adminSystemMessageApi, type SystemMessageCreateRequest, type SystemMessageVO } from '@/api/admin'
import type { IdType } from '@/utils/id'
/** loading is a reactive state variable used by the template and event handlers. */
const loading = ref(false)
/** saving is a reactive state variable used by the template and event handlers. */
const saving = ref(false)
/** imageUploading is a reactive state variable used by the template and event handlers. */
const imageUploading = ref(false)
const messages = ref<SystemMessageVO[]>([])
/** targetOptions is a reactive state variable used by the template and event handlers. */
const targetOptions = ref({ shops: [] as any[], users: [] as any[] })
/** popupEnabled is a reactive state variable used by the template and event handlers. */
const popupEnabled = ref(true)
/** previewVisible is a reactive state variable used by the template and event handlers. */
const previewVisible = ref(false)
const currentMessage = ref<SystemMessageVO | null>(null)
/** imagePreviewUrl is a reactive state variable used by the template and event handlers. */
const imagePreviewUrl = ref('')
const form = reactive<SystemMessageCreateRequest>({
@@ -142,26 +187,36 @@ const form = reactive<SystemMessageCreateRequest>({
popupEnabled: 1
})
/** targetTypes is a reactive state variable used by the template and event handlers. */
const targetTypes = computed(() => {
const shopCount = targetOptions.value.shops.length
const hasPlatformScope = shopCount > 1
return [
...(hasPlatformScope ? [{ label: '全平台', value: 'PLATFORM_ALL' }] : []),
{ label: hasPlatformScope ? '指定店铺全员' : '本店全员', value: hasPlatformScope ? 'SELECTED_SHOPS' : 'CURRENT_SHOP_ALL' },
{ label: '指定用户', value: 'SELECTED_USERS' }
]
const currentAdminUser = computed(() => {
try {
const cache = localStorage.getItem('adminUserInfo') || sessionStorage.getItem('adminUserInfo')
return cache ? JSON.parse(cache) : null
} catch {
return null
}
})
/** needsShopSelection is a reactive state variable used by the template and event handlers. */
const isPlatformAdmin = computed(() => Number(currentAdminUser.value?.type) === 4)
const targetTypes = computed(() => [
...(isPlatformAdmin.value ? [{ label: '全平台', value: 'PLATFORM_ALL' }] : []),
{ label: isPlatformAdmin.value ? '指定店铺全员' : '本店全员', value: isPlatformAdmin.value ? 'SELECTED_SHOPS' : 'CURRENT_SHOP_ALL' },
{ label: '指定用户', value: 'SELECTED_USERS' }
])
const needsShopSelection = computed(() => form.targetType === 'SELECTED_SHOPS' || form.targetType === 'SHOP_ALL')
/** shopOptions is a reactive state variable used by the template and event handlers. */
const shopOptions = computed(() => targetOptions.value.shops.map(shop => ({ label: shop.shopName, value: shop.id })))
/** userOptions is a reactive state variable used by the template and event handlers. */
const userOptions = computed(() => targetOptions.value.users.map(user => ({
label: `${user.nickname || user.account} ${user.shopName ? `(${user.shopName})` : ''}`,
value: user.id
})))
const previewTitle = computed(() => form.title.trim() || '消息标题预览')
const previewContent = computed(() => form.content.trim() || (imagePreviewUrl.value ? '' : '这里会显示消息正文。支持纯文本,也可以配合一张图片展示给用户。'))
const previewMeta = computed(() => `系统消息 · ${popupEnabled.value ? '弹窗预览' : '列表预览'}`)
const currentMessageMeta = computed(() => {
if (!currentMessage.value) return ''
return [
currentMessage.value.publisherName || '系统消息',
currentMessage.value.publishTime || currentMessage.value.createTime
].filter(Boolean).join(' · ')
})
const columns = [
{ title: '标题', dataIndex: 'title', key: 'title' },
@@ -174,7 +229,15 @@ const columns = [
{ title: '操作', key: 'action', width: 120 }
]
/** loadData is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const syncDefaultTargetType = () => {
if (isPlatformAdmin.value && form.targetType === 'CURRENT_SHOP_ALL') {
form.targetType = 'PLATFORM_ALL'
}
if (!isPlatformAdmin.value && form.targetType === 'PLATFORM_ALL') {
form.targetType = 'CURRENT_SHOP_ALL'
}
}
const loadData = async () => {
loading.value = true
try {
@@ -184,9 +247,7 @@ const loadData = async () => {
])
messages.value = messageList || []
targetOptions.value = options || { shops: [], users: [] }
if (targetOptions.value.shops.length > 1 && form.targetType === 'CURRENT_SHOP_ALL') {
form.targetType = 'PLATFORM_ALL'
}
syncDefaultTargetType()
} catch (error: any) {
message.error(error?.message || '消息数据加载失败')
} finally {
@@ -194,31 +255,27 @@ const loadData = async () => {
}
}
/** handleTargetTypeChange is a local helper used by this page script. */
const handleTargetTypeChange = () => {
form.shopIds = []
form.userIds = []
}
/** removeImage is a local helper used by this page script. */
const removeImage = () => {
form.imageFileId = undefined
imagePreviewUrl.value = ''
}
/** resetForm is a local helper used by this page script. */
const resetForm = () => {
form.title = ''
form.content = ''
form.imageFileId = undefined
form.targetType = targetOptions.value.shops.length > 1 ? 'PLATFORM_ALL' : 'CURRENT_SHOP_ALL'
form.targetType = isPlatformAdmin.value ? 'PLATFORM_ALL' : 'CURRENT_SHOP_ALL'
form.shopIds = []
form.userIds = []
popupEnabled.value = true
imagePreviewUrl.value = ''
}
/** handleImageUpload is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleImageUpload = async (options: any) => {
const file = options.file as File
if (!file?.type?.startsWith('image/')) {
@@ -245,7 +302,6 @@ const handleImageUpload = async (options: any) => {
}
}
/** handlePublish is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handlePublish = async () => {
if (!form.title.trim()) return message.warning('请填写消息标题')
if (!form.content.trim() && !form.imageFileId) return message.warning('请填写消息内容或上传消息图片')
@@ -265,14 +321,12 @@ const handlePublish = async () => {
}
}
/** handleRevoke is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleRevoke = async (id: IdType) => {
await adminSystemMessageApi.revokeMessage(id)
message.success('消息已撤回')
await loadData()
}
/** previewMessage is a local helper used by this page script. */
const previewMessage = (record: SystemMessageVO) => {
currentMessage.value = record
previewVisible.value = true
@@ -283,11 +337,177 @@ onMounted(loadData)
<style scoped>
.system-messages {
padding: 16px;
padding: 18px;
max-width: 1180px;
margin: 0 auto;
}
.message-page-head {
max-width: 1120px;
margin: 0 auto 12px;
}
.message-page-head :deep(.ant-page-header) {
padding: 0 0 12px;
}
.message-page-head :deep(.ant-page-header-heading-title) {
color: #33232d;
font-weight: 700;
}
.message-composer-shell {
max-width: 1120px;
margin: 0 auto 24px;
}
.message-composer-grid {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(330px, 420px);
gap: 22px;
align-items: stretch;
}
.message-editor-panel,
.message-preview-panel {
min-width: 0;
}
.message-editor-panel {
padding: 24px;
border: 1px solid rgba(245, 203, 218, 0.9);
border-radius: 22px;
background: rgba(255, 255, 255, 0.96);
box-shadow: 0 18px 48px rgba(198, 89, 125, 0.12);
}
.panel-heading {
display: flex;
gap: 14px;
align-items: center;
margin-bottom: 22px;
}
.panel-heading__icon {
display: grid;
width: 46px;
height: 46px;
flex: 0 0 auto;
place-items: center;
border-radius: 14px;
color: #ffffff;
font-size: 20px;
background: linear-gradient(135deg, #c6597d 0%, #e9b7c7 100%);
box-shadow: 0 12px 24px rgba(198, 89, 125, 0.24);
}
.panel-eyebrow {
margin: 0 0 4px;
color: #a45771;
font-size: 13px;
font-weight: 600;
}
.panel-heading h2 {
margin: 0;
color: #312330;
font-size: 22px;
font-weight: 750;
}
.message-form :deep(.ant-form-item-label > label) {
color: #4a3a44;
font-weight: 600;
}
.message-form :deep(.ant-input),
.message-form :deep(.ant-input-number),
.message-form :deep(.ant-select-selector),
.message-form :deep(.ant-input-affix-wrapper) {
border-color: #f1d6df;
border-radius: 10px;
}
.message-form :deep(.ant-input:focus),
.message-form :deep(.ant-input-focused),
.message-form :deep(.ant-select-focused .ant-select-selector),
.message-form :deep(.ant-input-affix-wrapper-focused) {
border-color: #c6597d;
box-shadow: 0 0 0 3px rgba(198, 89, 125, 0.12);
}
.scope-panel {
padding: 16px 16px 0;
margin-bottom: 18px;
border: 1px solid rgba(246, 205, 219, 0.9);
border-radius: 16px;
background: #fff8fa;
}
.publish-footer {
display: flex;
gap: 16px;
align-items: center;
justify-content: space-between;
padding-top: 18px;
border-top: 1px solid #f5dbe4;
}
.popup-checkbox {
color: #5c4b55;
}
.message-preview-panel {
display: flex;
align-items: center;
justify-content: center;
--theme-primary: #c6597d;
--theme-secondary: #e9b7c7;
--theme-accent: #9f4967;
--theme-primary-soft: #f8edf1;
--theme-card-bg: #ffffff;
--theme-border: #efd4dd;
--theme-gradient: linear-gradient(135deg, #c6597d 0%, #e9b7c7 100%);
--theme-gradient-soft: linear-gradient(145deg, #ffffff 0%, #fff7f9 58%, #f8edf1 100%);
--theme-button-shadow: 0 12px 28px rgba(198, 89, 125, 0.22);
--text-primary: #2d2430;
--text-secondary: #7a6871;
}
.message-preview-panel :deep(.system-message-card) {
max-width: 420px;
}
.preview-read-button {
display: inline-flex;
min-height: 40px;
align-items: center;
justify-content: center;
gap: 8px;
padding: 0 18px;
border: 0;
border-radius: 12px;
color: #ffffff;
font-weight: 700;
background: var(--theme-gradient);
box-shadow: var(--theme-button-shadow);
cursor: default;
}
.admin-section-card {
max-width: 1120px;
margin-bottom: 16px;
margin-left: auto;
margin-right: auto;
border: 1px solid rgba(246, 205, 219, 0.75);
border-radius: 18px;
box-shadow: 0 18px 42px rgba(198, 89, 125, 0.1);
overflow: hidden;
}
.admin-section-card :deep(.ant-card-head) {
color: #7a4058;
background: linear-gradient(135deg, #fff7f9 0%, #ffe8ef 100%);
}
.image-upload-row {
@@ -299,15 +519,11 @@ onMounted(loadData)
.upload-placeholder {
display: grid;
gap: 4px;
place-items: center;
color: #8a7b83;
text-align: center;
}
.upload-plus {
font-size: 24px;
line-height: 1;
}
.message-image-preview {
width: 100%;
height: 100%;
@@ -321,30 +537,92 @@ onMounted(loadData)
}
.image-upload-copy small,
.message-meta,
.muted {
color: #7f7781;
font-size: 13px;
}
.message-content {
white-space: pre-wrap;
line-height: 1.8;
}
.detail-image {
display: block;
width: 100%;
max-height: 420px;
margin-top: 14px;
object-fit: contain;
border-radius: 8px;
background: #f7f2f4;
}
.table-image {
overflow: hidden;
border-radius: 6px;
object-fit: cover;
border-radius: 6px;
}
:global(.message-detail-modal-wrap .ant-modal-content) {
padding: 0;
overflow: hidden;
border-radius: 8px;
background: transparent;
}
:global(.message-detail-modal-wrap .ant-modal-body) {
padding: 0;
}
:global(.message-detail-modal-wrap .system-message-card) {
--theme-primary: #c6597d;
--theme-secondary: #e9b7c7;
--theme-accent: #9f4967;
--theme-primary-soft: #f8edf1;
--theme-card-bg: #ffffff;
--theme-border: #efd4dd;
--theme-gradient: linear-gradient(135deg, #c6597d 0%, #e9b7c7 100%);
--theme-gradient-soft: linear-gradient(145deg, #ffffff 0%, #fff7f9 58%, #f8edf1 100%);
--theme-button-shadow: 0 12px 28px rgba(198, 89, 125, 0.22);
--text-primary: #2d2430;
--text-secondary: #7a6871;
}
:global(.message-detail-modal-wrap .ant-modal-close) {
color: var(--text-secondary);
}
:global(.message-detail-modal-wrap .message-detail-close-button) {
border: 0;
border-radius: 12px;
color: #ffffff;
font-weight: 700;
background: var(--theme-gradient);
box-shadow: var(--theme-button-shadow);
}
:global(.message-detail-modal-wrap .message-detail-close-button:hover),
:global(.message-detail-modal-wrap .message-detail-close-button:focus) {
color: #ffffff;
background: var(--theme-gradient);
filter: brightness(0.98);
}
@media (max-width: 960px) {
.message-composer-grid {
grid-template-columns: 1fr;
}
.message-preview-panel :deep(.system-message-card) {
max-width: 640px;
}
}
@media (max-width: 640px) {
.system-messages {
padding: 12px;
}
.message-editor-panel {
border-radius: 18px;
}
.image-upload-row,
.publish-footer {
align-items: stretch;
flex-direction: column;
}
.publish-footer :deep(.ant-space) {
justify-content: flex-end;
}
.preview-read-button {
width: 100%;
}
}
</style>