import{ar as e,b as a,a as i,f as s,af as n,o as r,h as t,j as l,i as d,X as o,l as m,k as c,A as u,n as f,B as p,_ as v}from"./index-a5345aa4.js";import{S as _}from"./SwitchRoles-9ecc1430.js";const k=a=>{if(Array.isArray(a)&&a.length>0){const{roles:i}=e();return i.some((e=>a.includes(e)))}return console.error("need roles! Like checkPermission(['admin','editor'])"),!1},g={class:"app-container"},y={class:"margin-top-15"},b=v(a({__name:"directive",setup(e){const a=i(1),v=()=>{a.value++};return(e,i)=>{const b=s("el-tag"),h=s("el-tab-pane"),P=s("el-tabs"),z=n("permission");return r(),t("div",g,[l(_,{onChange:v}),(r(),t("div",{key:a.value,class:"margin-top-30"},[d("div",null,[o((r(),m(b,{type:"success",size:"large",effect:"plain"},{default:c((()=>[u(" 这里采用了 v-permission=\"['admin']\" 所以只有 admin 可以看见这句话 ")])),_:1})),[[z,["admin"]]])]),d("div",null,[o((r(),m(b,{type:"success",size:"large",effect:"plain"},{default:c((()=>[u(" 这里采用了 v-permission=\"['editor']\" 所以只有 editor 可以看见这句话 ")])),_:1})),[[z,["editor"]]])]),d("div",y,[o((r(),m(b,{type:"success",size:"large",effect:"plain"},{default:c((()=>[u(" 这里采用了 v-permission=\"['admin', 'editor']\" 所以 admin 和 editor 都可以看见这句话 ")])),_:1})),[[z,["admin","editor"]]])])])),(r(),t("div",{key:`checkPermission${a.value}`,class:"margin-top-30"},[l(b,{type:"warning",size:"large"},{default:c((()=>[u(" 例如 Element Plus 的 el-tab-pane 或 el-table-column 以及其它动态渲染 Dom 的场景不适合使用 v-permission，这种情况下你可以通过 v-if 和 checkPermission 来实现： ")])),_:1}),l(P,{type:"border-card",class:"margin-top-15"},{default:c((()=>[f(k)(["admin"])?(r(),m(h,{key:0,label:"admin"},{default:c((()=>[u(" 这里采用了 "),l(b,null,{default:c((()=>[u("v-if=\"checkPermission(['admin'])\"")])),_:1}),u(" 所以只有 admin 可以看见这句话 ")])),_:1})):p("",!0),f(k)(["editor"])?(r(),m(h,{key:1,label:"editor"},{default:c((()=>[u(" 这里采用了 "),l(b,null,{default:c((()=>[u("v-if=\"checkPermission(['editor'])\"")])),_:1}),u(" 所以只有 editor 可以看见这句话 ")])),_:1})):p("",!0),f(k)(["admin","editor"])?(r(),m(h,{key:2,label:"admin 和 editor"},{default:c((()=>[u(" 这里采用了 "),l(b,null,{default:c((()=>[u("v-if=\"checkPermission(['admin', 'editor'])\"")])),_:1}),u(" 所以 admin 和 editor 都可以看见这句话 ")])),_:1})):p("",!0)])),_:1})]))])}}}),[["__scopeId","data-v-6d704b73"]]);export{b as default};
