mirror of
https://github.com/zclzone/vue-naive-admin.git
synced 2025-04-30 22:29:01 +08:00
fix: withPermission完善
This commit is contained in:
parent
70c2098d2e
commit
cf0ba0a2bf
@ -7,6 +7,7 @@
|
|||||||
**********************************/
|
**********************************/
|
||||||
|
|
||||||
import { router } from '@/router'
|
import { router } from '@/router'
|
||||||
|
import { withDirectives } from 'vue'
|
||||||
|
|
||||||
const permission = {
|
const permission = {
|
||||||
mounted(el, binding) {
|
mounted(el, binding) {
|
||||||
@ -21,3 +22,17 @@ const permission = {
|
|||||||
export function setupDirectives(app) {
|
export function setupDirectives(app) {
|
||||||
app.directive('permission', permission)
|
app.directive('permission', permission)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于h函数使用自定义权限指令
|
||||||
|
*
|
||||||
|
* @param {*} vnode 虚拟节点
|
||||||
|
* @param {*} code 权限码
|
||||||
|
* @returns 返回一个包含权限指令的vnode
|
||||||
|
*
|
||||||
|
* 使用示例:withPermission(h('button', {class: 'text-red-500'}, '删除'), 'user:delete')
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export function withPermission(vnode, code) {
|
||||||
|
return withDirectives(vnode, [[permission, code]])
|
||||||
|
}
|
||||||
|
@ -112,6 +112,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { MeCrud, MeModal, MeQueryItem } from '@/components'
|
import { MeCrud, MeModal, MeQueryItem } from '@/components'
|
||||||
import { useCrud } from '@/composables'
|
import { useCrud } from '@/composables'
|
||||||
|
import { withPermission } from '@/directives'
|
||||||
import { formatDateTime } from '@/utils'
|
import { formatDateTime } from '@/utils'
|
||||||
import { NAvatar, NButton, NSwitch, NTag } from 'naive-ui'
|
import { NAvatar, NButton, NSwitch, NTag } from 'naive-ui'
|
||||||
import api from './api'
|
import api from './api'
|
||||||
@ -225,11 +226,24 @@ const columns = [
|
|||||||
hideInExcel: true,
|
hideInExcel: true,
|
||||||
render(row) {
|
render(row) {
|
||||||
return [
|
return [
|
||||||
|
withPermission(
|
||||||
|
h(NButton, {
|
||||||
|
size: 'small',
|
||||||
|
type: 'primary',
|
||||||
|
secondary: true,
|
||||||
|
onClick: () => handleOpenRolesSet(row),
|
||||||
|
}, {
|
||||||
|
default: () => '超管专属',
|
||||||
|
icon: () => h('i', { class: 'i-carbon:user-role text-14' }),
|
||||||
|
}),
|
||||||
|
'SuperAdmin',
|
||||||
|
),
|
||||||
h(
|
h(
|
||||||
NButton,
|
NButton,
|
||||||
{
|
{
|
||||||
size: 'small',
|
size: 'small',
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
|
class: 'ml-12px',
|
||||||
secondary: true,
|
secondary: true,
|
||||||
onClick: () => handleOpenRolesSet(row),
|
onClick: () => handleOpenRolesSet(row),
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user