杂务:新增声明级注释覆盖率
This commit is contained in:
@@ -43,17 +43,53 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
/**
|
||||
* Purpose: AdminCommentVO supports CommentsView.vue by holding or executing the admin comment 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 { adminCommentApi, type AdminCommentVO } from '@/api/admin'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
/**
|
||||
* Purpose: loading supports CommentsView.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: keyword supports CommentsView.vue by holding or executing the keyword 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 keyword = ref('')
|
||||
/**
|
||||
* Purpose: shopKeyword supports CommentsView.vue by holding or executing the shop keyword 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 shopKeyword = ref('')
|
||||
/**
|
||||
* Purpose: productKeyword supports CommentsView.vue by holding or executing the product keyword 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 productKeyword = ref('')
|
||||
/**
|
||||
* Purpose: userKeyword supports CommentsView.vue by holding or executing the user keyword 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 userKeyword = ref('')
|
||||
/**
|
||||
* Purpose: createdRange supports CommentsView.vue by holding or executing the created range 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 createdRange = ref<[string, string] | undefined>()
|
||||
/**
|
||||
* Purpose: comments supports CommentsView.vue by holding or executing the comments 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 comments = ref<AdminCommentVO[]>([])
|
||||
|
||||
/**
|
||||
* Purpose: columns supports CommentsView.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: 'commentContent', key: 'commentContent' },
|
||||
{ title: '用户', dataIndex: 'userNickname', key: 'userNickname', width: 140 },
|
||||
@@ -63,6 +99,10 @@ const columns = [
|
||||
{ title: '操作', key: 'action', width: 100 }
|
||||
]
|
||||
|
||||
/**
|
||||
* Purpose: filteredComments supports CommentsView.vue by holding or executing the filtered comments 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 filteredComments = computed(() => comments.value.filter(comment => {
|
||||
if (!matchText(shopKeyword.value, [comment.shopName, comment.shopId])) return false
|
||||
if (!matchText(productKeyword.value, [comment.productTitle, comment.productId])) return false
|
||||
@@ -70,12 +110,20 @@ const filteredComments = computed(() => comments.value.filter(comment => {
|
||||
return matchRange(comment.createTime, createdRange.value)
|
||||
}))
|
||||
|
||||
/**
|
||||
* Purpose: matchText supports CommentsView.vue by holding or executing the match text 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 matchText = (needle: string, values: any[]) => {
|
||||
const normalized = needle.trim().toLowerCase()
|
||||
if (!normalized) return true
|
||||
return values.some(value => String(value ?? '').toLowerCase().includes(normalized))
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: matchRange supports CommentsView.vue by holding or executing the match range 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 matchRange = (value?: string, range?: [string, string]) => {
|
||||
if (!range?.length) return true
|
||||
if (!value) return false
|
||||
@@ -83,6 +131,10 @@ const matchRange = (value?: string, range?: [string, string]) => {
|
||||
return time >= new Date(range[0]).getTime() && time <= new Date(range[1]).getTime()
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: loadComments supports CommentsView.vue by holding or executing the load comments 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 loadComments = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
@@ -94,12 +146,20 @@ const loadComments = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: deleteComment supports CommentsView.vue by holding or executing the delete comment 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 deleteComment = async (id: IdType) => {
|
||||
await adminCommentApi.deleteComment(id)
|
||||
message.success('评论已删除')
|
||||
await loadComments()
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: resetFilters supports CommentsView.vue by holding or executing the reset filters 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 resetFilters = () => {
|
||||
keyword.value = ''
|
||||
shopKeyword.value = ''
|
||||
|
||||
Reference in New Issue
Block a user