功能:完善订单流程和加固
This commit is contained in:
@@ -56,6 +56,22 @@ const currentMessage = ref<SystemMessageVO | null>(null)
|
||||
/** unreadCount is a reactive state variable used by the template and event handlers. */
|
||||
const unreadCount = computed(() => messages.value.filter(item => item.readStatus !== 1).length)
|
||||
|
||||
const resolveSystemMessageActionPath = (item: SystemMessageVO) => {
|
||||
const actionPath = String(item.actionPath || '').trim()
|
||||
if (!actionPath || !actionPath.startsWith('/') || actionPath.startsWith('//')) {
|
||||
return ''
|
||||
}
|
||||
return actionPath
|
||||
}
|
||||
|
||||
const markMessageReadIfNeeded = async (item: SystemMessageVO) => {
|
||||
if (item.readStatus === 1) {
|
||||
return
|
||||
}
|
||||
await userApi.markMessageRead(item.id)
|
||||
item.readStatus = 1
|
||||
}
|
||||
|
||||
/** loadMessages is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const loadMessages = async () => {
|
||||
loading.value = true
|
||||
@@ -70,12 +86,21 @@ const loadMessages = async () => {
|
||||
|
||||
/** openMessage is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const openMessage = async (item: SystemMessageVO) => {
|
||||
try {
|
||||
await markMessageReadIfNeeded(item)
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '标记已读失败')
|
||||
return
|
||||
}
|
||||
|
||||
const actionPath = resolveSystemMessageActionPath(item)
|
||||
if (actionPath) {
|
||||
await router.push(actionPath)
|
||||
return
|
||||
}
|
||||
|
||||
currentMessage.value = item
|
||||
detailVisible.value = true
|
||||
if (item.readStatus !== 1) {
|
||||
await userApi.markMessageRead(item.id)
|
||||
item.readStatus = 1
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadMessages)
|
||||
|
||||
Reference in New Issue
Block a user