import{j as g,_ as b}from"./index-S1sRAIbm.js";import{S as y}from"./SwitchRoles-DNcMP9SC.js";import{p as P,ai as p,aq as x,q as o,t as w,U as r,v as a,P as u,M as n,O as i,S as t,u as f,R as v}from"./vue-C8lPpR34.js";import"./element-DU-WrzgO.js";import"./vxe-CSEOtpXg.js";const _=d=>{if(Array.isArray(d)&&d.length>0){const{roles:c}=g();return c.some(e=>d.includes(e))}else return console.error("need roles! Like checkPermission(['admin','editor'])"),!1},z={class:"app-container"},B={class:"margin-top-30"},C={class:"margin-top-15"},N={class:"margin-top-30"},S=P({__name:"directive",setup(d){return(c,e)=>{const s=p("el-tag"),l=p("el-tab-pane"),k=p("el-tabs"),m=x("permission");return o(),w("div",z,[r(y),a("div",B,[a("div",null,[u((o(),n(s,{type:"success",size:"large",effect:"plain"},{default:i(()=>e[0]||(e[0]=[t(` 这里采用了 v-permission="['admin']" 所以只有 admin 可以看见这句话 `)])),_:1})),[[m,["admin"]]])]),a("div",null,[u((o(),n(s,{type:"success",size:"large",effect:"plain"},{default:i(()=>e[1]||(e[1]=[t(` 这里采用了 v-permission="['editor']" 所以只有 editor 可以看见这句话 `)])),_:1})),[[m,["editor"]]])]),a("div",C,[u((o(),n(s,{type:"success",size:"large",effect:"plain"},{default:i(()=>e[2]||(e[2]=[t(` 这里采用了 v-permission="['admin', 'editor']" 所以 admin 和 editor 都可以看见这句话 `)])),_:1})),[[m,["admin","editor"]]])])]),a("div",N,[r(s,{type:"warning",size:"large"},{default:i(()=>e[3]||(e[3]=[t(" 例如 Element Plus 的 el-tab-pane 或 el-table-column 以及其它动态渲染 Dom 的场景不适合使用 v-permission，这种情况下你可以通过 v-if 和 checkPermission 来实现： ")])),_:1}),r(k,{type:"border-card",class:"margin-top-15"},{default:i(()=>[f(_)(["admin"])?(o(),n(l,{key:0,label:"admin"},{default:i(()=>[e[5]||(e[5]=t(" 这里采用了 ")),r(s,null,{default:i(()=>e[4]||(e[4]=[t(`v-if="checkPermission(['admin'])"`)])),_:1}),e[6]||(e[6]=t(" 所以只有 admin 可以看见这句话 "))]),_:1})):v("",!0),f(_)(["editor"])?(o(),n(l,{key:1,label:"editor"},{default:i(()=>[e[8]||(e[8]=t(" 这里采用了 ")),r(s,null,{default:i(()=>e[7]||(e[7]=[t(`v-if="checkPermission(['editor'])"`)])),_:1}),e[9]||(e[9]=t(" 所以只有 editor 可以看见这句话 "))]),_:1})):v("",!0),f(_)(["admin","editor"])?(o(),n(l,{key:2,label:"admin 和 editor"},{default:i(()=>[e[11]||(e[11]=t(" 这里采用了 ")),r(s,null,{default:i(()=>e[10]||(e[10]=[t(`v-if="checkPermission(['admin', 'editor'])"`)])),_:1}),e[12]||(e[12]=t(" 所以 admin 和 editor 都可以看见这句话 "))]),_:1})):v("",!0)]),_:1})])])}}}),U=b(S,[["__scopeId","data-v-295dc3c3"]]);export{U as default};
