mirror of
https://github.com/zclzone/vue-naive-admin.git
synced 2025-05-01 06:39:01 +08:00
feat: 添加PH函数,根据按钮权限判断当前按钮是否渲染
This commit is contained in:
parent
84fb1198d5
commit
e74856040a
@ -8,7 +8,7 @@
|
||||
|
||||
import { router } from '@/router'
|
||||
|
||||
const permission = {
|
||||
export const permission = {
|
||||
mounted(el, binding) {
|
||||
const currentRoute = unref(router.currentRoute)
|
||||
const btns = currentRoute.meta?.btns?.map(item => item.code) || []
|
||||
|
@ -11,4 +11,5 @@ export * from './common'
|
||||
export * from './http'
|
||||
export * from './is'
|
||||
export * from './naiveTools'
|
||||
export * from './permissionH'
|
||||
export * from './storage'
|
||||
|
14
src/utils/permissionH.js
Normal file
14
src/utils/permissionH.js
Normal file
@ -0,0 +1,14 @@
|
||||
import { permission } from '@/directives'
|
||||
/**
|
||||
* @description: 按钮权限渲染
|
||||
*/
|
||||
import { h, withDirectives } from 'vue'
|
||||
|
||||
export function PH(el, props, slots, butCode) {
|
||||
return withDirectives(
|
||||
h(el, props, slots),
|
||||
[
|
||||
[permission, butCode],
|
||||
],
|
||||
)
|
||||
}
|
@ -112,7 +112,7 @@
|
||||
<script setup>
|
||||
import { MeCrud, MeModal, MeQueryItem } from '@/components'
|
||||
import { useCrud } from '@/composables'
|
||||
import { formatDateTime } from '@/utils'
|
||||
import { formatDateTime, PH } from '@/utils'
|
||||
import { NAvatar, NButton, NSwitch, NTag } from 'naive-ui'
|
||||
import api from './api'
|
||||
|
||||
@ -225,7 +225,7 @@ const columns = [
|
||||
hideInExcel: true,
|
||||
render(row) {
|
||||
return [
|
||||
h(
|
||||
PH(
|
||||
NButton,
|
||||
{
|
||||
size: 'small',
|
||||
@ -237,6 +237,7 @@ const columns = [
|
||||
default: () => '分配角色',
|
||||
icon: () => h('i', { class: 'i-carbon:user-role text-14' }),
|
||||
},
|
||||
'setRole',
|
||||
),
|
||||
h(
|
||||
NButton,
|
||||
|
Loading…
x
Reference in New Issue
Block a user