完善权限的管理和校验

This commit is contained in:
xiaowang
2026-02-26 18:44:47 +08:00
parent 2e0f615775
commit 65388cb7f9
4 changed files with 37 additions and 23 deletions
+6 -5
View File
@@ -11,7 +11,7 @@
style="width: 250px"
@search="handleSearch"
/>
<a-button v-if="hasPermission('product:create')" type="primary" @click="showAddModal">
<a-button v-if="isAdmin || hasPermission('product:create')" type="primary" @click="showAddModal">
<template #icon>
<PlusOutlined />
</template>
@@ -58,11 +58,11 @@
<template v-else-if="column.key === 'actions'">
<a-space>
<a-button v-if="hasPermission('product:edit')" type="link" size="small" @click="showEditModal(record)">
<a-button v-if="isAdmin || hasPermission('product:edit')" type="link" size="small" @click="showEditModal(record)">
编辑
</a-button>
<a-popconfirm
v-if="hasPermission('product:delete')"
v-if="isAdmin || hasPermission('product:delete')"
title="确定要删除这个商品吗?"
@confirm="handleDelete(record)"
>
@@ -249,6 +249,7 @@ import { DEFAULT_PRODUCT_IMAGE } from '@/constants'
import { adminProductApi, type Product, adminShopApi, type Shop, adminFileApi, type ObjectStorageFileVO, adminTagApi, adminArtistApi, adminCouponApi } from '@/api/admin'
import { usePermission } from '@/utils/permission'
const { hasPermission, loadUserPermissions } = usePermission()
const loading = ref(false)
const searchText = ref('')
const productList = ref<Product[]>([])
@@ -272,7 +273,6 @@ const imageUrls = ref<Record<number, string[]>>({})
const imageIdCache = ref<Record<string, string>>({})
const isAdmin = ref(false)
const formRef = ref<any>(null)
const { hasPermission } = usePermission()
const pagination = reactive({
current: 1,
@@ -672,7 +672,8 @@ const handleDelete = async (record: Product) => {
}
}
onMounted(() => {
onMounted(async () => {
await loadUserPermissions()
fetchShops()
fetchTags()
fetchCoupons()