接入Salon对外内容审核与发布门禁
This commit is contained in:
@@ -40,6 +40,15 @@
|
||||
<a-form-item label="内容">
|
||||
<a-textarea v-model:value="form.content" :rows="4" :maxlength="1000" placeholder="支持 HTML / Markdown,也可以直接输入纯文本" />
|
||||
</a-form-item>
|
||||
<a-form-item label="图片">
|
||||
<a-upload :show-upload-list="false" accept="image/*" :before-upload="uploadAnnouncementImage">
|
||||
<a-button :loading="imageUploading">添加图片</a-button>
|
||||
</a-upload>
|
||||
<a-space v-if="form.imageFileIds.length" wrap class="announcement-images">
|
||||
<a-tag v-for="fileId in form.imageFileIds" :key="String(fileId)">图片 {{ fileId }}</a-tag>
|
||||
</a-space>
|
||||
<div class="upload-tip">图片会和标题、正文一起进入内容审核,审核通过后才会对外展示。</div>
|
||||
</a-form-item>
|
||||
<a-form-item label="接收范围">
|
||||
<a-select v-model:value="form.targetType" :options="targetOptions" />
|
||||
</a-form-item>
|
||||
@@ -68,7 +77,7 @@ import { message, Modal } from 'ant-design-vue'
|
||||
* Purpose: AnnouncementVO supports AnnouncementsView.vue by holding or executing the announcement vo page or API role.
|
||||
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
import { adminAnnouncementApi, type AnnouncementVO, type MessageTargetOptionsVO } from '@/api/admin'
|
||||
import { adminAnnouncementApi, adminFileApi, type AnnouncementVO, type MessageTargetOptionsVO } from '@/api/admin'
|
||||
import { extractRichText, renderRichContent } from '@/utils/rich-content'
|
||||
|
||||
/** loading is a reactive state variable used by the template and event handlers. */
|
||||
@@ -91,7 +100,8 @@ const options = ref<MessageTargetOptionsVO>({ shops: [], users: [] })
|
||||
* Purpose: form supports AnnouncementsView.vue by holding or executing the form 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 form = reactive<any>({ title: '', content: '', targetType: 'PLATFORM_ALL', shopIds: [], userIds: [], sortOrder: 0 })
|
||||
const form = reactive<any>({ title: '', content: '', imageFileIds: [], targetType: 'PLATFORM_ALL', shopIds: [], userIds: [], sortOrder: 0 })
|
||||
const imageUploading = ref(false)
|
||||
|
||||
/**
|
||||
* Purpose: columns supports AnnouncementsView.vue by holding or executing the columns page or API role.
|
||||
@@ -143,10 +153,24 @@ const load = async () => {
|
||||
|
||||
/** openCreate is a local helper used by this page script. */
|
||||
const openCreate = () => {
|
||||
Object.assign(form, { title: '', content: '', targetType: 'PLATFORM_ALL', shopIds: [], userIds: [], sortOrder: 0 })
|
||||
Object.assign(form, { title: '', content: '', imageFileIds: [], targetType: 'PLATFORM_ALL', shopIds: [], userIds: [], sortOrder: 0 })
|
||||
formOpen.value = true
|
||||
}
|
||||
|
||||
const uploadAnnouncementImage = async (file: File) => {
|
||||
imageUploading.value = true
|
||||
try {
|
||||
const uploaded = await adminFileApi.uploadFile(file)
|
||||
if (uploaded?.id) form.imageFileIds.push(uploaded.id)
|
||||
message.success('图片已上传,提交后会进入审核')
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '图片上传失败')
|
||||
} finally {
|
||||
imageUploading.value = false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/** submit is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const submit = async () => {
|
||||
if (!form.title || !form.content) {
|
||||
@@ -155,7 +179,7 @@ const submit = async () => {
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
await adminAnnouncementApi.createAnnouncement(form)
|
||||
await adminAnnouncementApi.createAnnouncement({ ...form, imageFileIds: form.imageFileIds.join(',') })
|
||||
message.success('公告已发布')
|
||||
formOpen.value = false
|
||||
await load()
|
||||
@@ -188,6 +212,8 @@ onMounted(load)
|
||||
|
||||
<style scoped>
|
||||
.admin-page { display: grid; gap: 18px; }
|
||||
.announcement-images { margin-top: 8px; }
|
||||
.upload-tip { color: var(--ant-color-text-secondary); font-size: 12px; margin-top: 6px; }
|
||||
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
|
||||
.page-head h2 { margin: 0 0 4px; }
|
||||
.page-head p { margin: 0; color: var(--text-secondary); }
|
||||
|
||||
@@ -29,7 +29,22 @@
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'type'">{{ moderationType(record.contentType) }}</template>
|
||||
<template v-else-if="column.key === 'content'">
|
||||
<pre class="payload-preview">{{ formatPayload(record.payloadJson) }}</pre>
|
||||
<div class="moderation-content">
|
||||
<div class="moderation-author">{{ record.authorName || '未知发布者' }}</div>
|
||||
<pre class="payload-preview">{{ record.textPreview || '无文字内容' }}</pre>
|
||||
<a-space v-if="record.images?.length" wrap>
|
||||
<a-image
|
||||
v-for="image in record.images"
|
||||
:key="String(image.fileId)"
|
||||
:src="image.url"
|
||||
:width="56"
|
||||
:height="56"
|
||||
fit="cover"
|
||||
:preview="Boolean(image.url)"
|
||||
/>
|
||||
<span v-if="record.images.some((image: NonNullable<ContentModerationRecordVO['images']>[number]) => !image.url)" class="image-pending">图片预览不可用</span>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'status'">{{ record.status === 'RETRY' ? '待复核(模拟服务故障)' : '待复核' }}</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
@@ -255,12 +270,7 @@ function runBackfill() {
|
||||
}
|
||||
|
||||
function moderationType(type: string) {
|
||||
return ({ USER_PROFILE: '个人资料', USER_AVATAR: '头像', PRODUCT: '作品', COMMENT: '评论' } as Record<string, string>)[type] || type
|
||||
}
|
||||
|
||||
function formatPayload(value?: string) {
|
||||
if (!value) return '无待复核载荷'
|
||||
try { return JSON.stringify(JSON.parse(value), null, 2) } catch { return value }
|
||||
return ({ USER_PROFILE: '个人资料', USER_AVATAR: '头像', PRODUCT: '作品', EFFECT_DIAGRAM: '效果图', COMMENT: '评论', ORDER_ARTIST_REVIEW: '订单评价', SHOP: '门店资料', ANNOUNCEMENT: '公告', SYSTEM_MESSAGE: '系统消息' } as Record<string, string>)[type] || type
|
||||
}
|
||||
|
||||
onMounted(loadActiveTab)
|
||||
@@ -270,6 +280,9 @@ onMounted(loadActiveTab)
|
||||
.privacy-page { display: grid; gap: 16px; }
|
||||
.page-notice { border-radius: 8px; }
|
||||
.payload-preview { max-width: 420px; max-height: 180px; margin: 0; overflow: auto; white-space: pre-wrap; word-break: break-word; font-size: 12px; }
|
||||
.moderation-content { display: grid; gap: 6px; }
|
||||
.moderation-author { color: var(--ant-color-text-secondary); font-size: 12px; }
|
||||
.image-pending { color: var(--ant-color-text-secondary); font-size: 12px; }
|
||||
.backfill-panel { width: 100%; padding: 8px 0; }
|
||||
.closure-shops { display: grid; gap: 12px; margin-bottom: 16px; }
|
||||
.closure-shops p { margin: 0; }
|
||||
|
||||
Reference in New Issue
Block a user