杂务:新增声明级注释覆盖率
This commit is contained in:
@@ -164,19 +164,63 @@ import {
|
||||
SendOutlined
|
||||
} from '@ant-design/icons-vue'
|
||||
import SystemMessageCard from '@/components/SystemMessageCard.vue'
|
||||
/**
|
||||
* Purpose: SystemMessageCreateRequest supports SystemMessagesView.vue by holding or executing the system message create request 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 { adminFileApi, adminSystemMessageApi, type SystemMessageCreateRequest, type SystemMessageVO } from '@/api/admin'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
/**
|
||||
* Purpose: loading supports SystemMessagesView.vue by holding or executing the loading 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 loading = ref(false)
|
||||
/**
|
||||
* Purpose: saving supports SystemMessagesView.vue by holding or executing the saving 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 saving = ref(false)
|
||||
/**
|
||||
* Purpose: imageUploading supports SystemMessagesView.vue by holding or executing the image uploading 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 imageUploading = ref(false)
|
||||
/**
|
||||
* Purpose: messages supports SystemMessagesView.vue by holding or executing the messages 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 messages = ref<SystemMessageVO[]>([])
|
||||
/**
|
||||
* Purpose: targetOptions supports SystemMessagesView.vue by holding or executing the target options 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 targetOptions = ref({ shops: [] as any[], users: [] as any[] })
|
||||
/**
|
||||
* Purpose: popupEnabled supports SystemMessagesView.vue by holding or executing the popup enabled 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 popupEnabled = ref(true)
|
||||
/**
|
||||
* Purpose: previewVisible supports SystemMessagesView.vue by holding or executing the preview visible 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 previewVisible = ref(false)
|
||||
/**
|
||||
* Purpose: currentMessage supports SystemMessagesView.vue by holding or executing the current message 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 currentMessage = ref<SystemMessageVO | null>(null)
|
||||
/**
|
||||
* Purpose: imagePreviewUrl supports SystemMessagesView.vue by holding or executing the image preview url 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 imagePreviewUrl = ref('')
|
||||
|
||||
/**
|
||||
* Purpose: form supports SystemMessagesView.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<SystemMessageCreateRequest>({
|
||||
title: '',
|
||||
content: '',
|
||||
@@ -187,6 +231,10 @@ const form = reactive<SystemMessageCreateRequest>({
|
||||
popupEnabled: 1
|
||||
})
|
||||
|
||||
/**
|
||||
* Purpose: currentAdminUser supports SystemMessagesView.vue by holding or executing the current admin user 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 currentAdminUser = computed(() => {
|
||||
try {
|
||||
const cache = localStorage.getItem('adminUserInfo') || sessionStorage.getItem('adminUserInfo')
|
||||
@@ -195,21 +243,57 @@ const currentAdminUser = computed(() => {
|
||||
return null
|
||||
}
|
||||
})
|
||||
/**
|
||||
* Purpose: isPlatformAdmin supports SystemMessagesView.vue by holding or executing the is platform admin 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 isPlatformAdmin = computed(() => Number(currentAdminUser.value?.type) === 4)
|
||||
/**
|
||||
* Purpose: targetTypes supports SystemMessagesView.vue by holding or executing the target types 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 targetTypes = computed(() => [
|
||||
...(isPlatformAdmin.value ? [{ label: '全平台', value: 'PLATFORM_ALL' }] : []),
|
||||
{ label: isPlatformAdmin.value ? '指定店铺全员' : '本店全员', value: isPlatformAdmin.value ? 'SELECTED_SHOPS' : 'CURRENT_SHOP_ALL' },
|
||||
{ label: '指定用户', value: 'SELECTED_USERS' }
|
||||
])
|
||||
/**
|
||||
* Purpose: needsShopSelection supports SystemMessagesView.vue by holding or executing the needs shop selection 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 needsShopSelection = computed(() => form.targetType === 'SELECTED_SHOPS' || form.targetType === 'SHOP_ALL')
|
||||
/**
|
||||
* Purpose: shopOptions supports SystemMessagesView.vue by holding or executing the shop options 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 shopOptions = computed(() => targetOptions.value.shops.map(shop => ({ label: shop.shopName, value: shop.id })))
|
||||
/**
|
||||
* Purpose: userOptions supports SystemMessagesView.vue by holding or executing the user options 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 userOptions = computed(() => targetOptions.value.users.map(user => ({
|
||||
label: `${user.nickname || user.account} ${user.shopName ? `(${user.shopName})` : ''}`,
|
||||
value: user.id
|
||||
})))
|
||||
/**
|
||||
* Purpose: previewTitle supports SystemMessagesView.vue by holding or executing the preview 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 previewTitle = computed(() => form.title.trim() || '消息标题预览')
|
||||
/**
|
||||
* Purpose: previewContent supports SystemMessagesView.vue by holding or executing the preview 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 previewContent = computed(() => form.content.trim() || (imagePreviewUrl.value ? '' : '这里会显示消息正文。支持纯文本,也可以配合一张图片展示给用户。'))
|
||||
/**
|
||||
* Purpose: previewMeta supports SystemMessagesView.vue by holding or executing the preview meta 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 previewMeta = computed(() => `系统消息 · ${popupEnabled.value ? '弹窗预览' : '列表预览'}`)
|
||||
/**
|
||||
* Purpose: currentMessageMeta supports SystemMessagesView.vue by holding or executing the current message meta 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 currentMessageMeta = computed(() => {
|
||||
if (!currentMessage.value) return ''
|
||||
return [
|
||||
@@ -218,6 +302,10 @@ const currentMessageMeta = computed(() => {
|
||||
].filter(Boolean).join(' · ')
|
||||
})
|
||||
|
||||
/**
|
||||
* Purpose: columns supports SystemMessagesView.vue by holding or executing the columns 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 columns = [
|
||||
{ title: '标题', dataIndex: 'title', key: 'title' },
|
||||
{ title: '图片', key: 'image', width: 84 },
|
||||
@@ -229,6 +317,10 @@ const columns = [
|
||||
{ title: '操作', key: 'action', width: 120 }
|
||||
]
|
||||
|
||||
/**
|
||||
* Purpose: syncDefaultTargetType supports SystemMessagesView.vue by holding or executing the sync default target type 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 syncDefaultTargetType = () => {
|
||||
if (isPlatformAdmin.value && form.targetType === 'CURRENT_SHOP_ALL') {
|
||||
form.targetType = 'PLATFORM_ALL'
|
||||
@@ -238,6 +330,10 @@ const syncDefaultTargetType = () => {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: loadData supports SystemMessagesView.vue by holding or executing the load data 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 loadData = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
@@ -255,16 +351,28 @@ const loadData = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: handleTargetTypeChange supports SystemMessagesView.vue by holding or executing the handle target type change 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 handleTargetTypeChange = () => {
|
||||
form.shopIds = []
|
||||
form.userIds = []
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: removeImage supports SystemMessagesView.vue by holding or executing the remove 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 removeImage = () => {
|
||||
form.imageFileId = undefined
|
||||
imagePreviewUrl.value = ''
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: resetForm supports SystemMessagesView.vue by holding or executing the reset 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 resetForm = () => {
|
||||
form.title = ''
|
||||
form.content = ''
|
||||
@@ -276,6 +384,10 @@ const resetForm = () => {
|
||||
imagePreviewUrl.value = ''
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: handleImageUpload supports SystemMessagesView.vue by holding or executing the handle image upload 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 handleImageUpload = async (options: any) => {
|
||||
const file = options.file as File
|
||||
if (!file?.type?.startsWith('image/')) {
|
||||
@@ -302,6 +414,10 @@ const handleImageUpload = async (options: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: handlePublish supports SystemMessagesView.vue by holding or executing the handle publish 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 handlePublish = async () => {
|
||||
if (!form.title.trim()) return message.warning('请填写消息标题')
|
||||
if (!form.content.trim() && !form.imageFileId) return message.warning('请填写消息内容或上传消息图片')
|
||||
@@ -321,12 +437,20 @@ const handlePublish = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: handleRevoke supports SystemMessagesView.vue by holding or executing the handle revoke 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 handleRevoke = async (id: IdType) => {
|
||||
await adminSystemMessageApi.revokeMessage(id)
|
||||
message.success('消息已撤回')
|
||||
await loadData()
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: previewMessage supports SystemMessagesView.vue by holding or executing the preview message 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 previewMessage = (record: SystemMessageVO) => {
|
||||
currentMessage.value = record
|
||||
previewVisible.value = true
|
||||
|
||||
Reference in New Issue
Block a user