import{d as T,e as R,U as n,v,a2 as l,ad as E,af as o,k as t,a4 as F,G as s,a5 as d,V as f,q as C}from"./vue-vendor-CxLCUzY4.js";import{W as g,A as U}from"./antd-vue-vendor-CahNzUUa.js";import k from"./CurrentPermissionMode-COBLuPWN.js";import{U as b,ab as $,bw as D,_ as V}from"./index-Cy4uayzW.js";import{A as w}from"./index-D8uB2zHR.js";import{P as N}from"./index-CRgSyMPH.js";import"./vxe-table-vendor-Cdi8WfTx.js";import"./useContentHeight-XU-h1taH.js";import"./useWindowSizeFn-DDyhhqyw.js";import"./useContentViewHeight-Qm4QNm5l.js";import"./usePageContext-CXQdt-5h.js";import"./injectionKey-DPVn4AgL.js";const W=T({components:{Alert:U,PageWrapper:N,CurrentPermissionMode:k,Divider:g,Authority:w},setup(){const{changeRole:e,hasPermission:u}=b(),a=$();return{userStore:a,RoleEnum:D,isSuper:R(()=>a.getRoleList.includes(D.SUPER)),isTest:R(()=>a.getRoleList.includes(D.TEST)),changeRole:e,hasPermission:u}}}),L={class:"mt-4"};function M(e,u,a,q,G,I){const A=n("CurrentPermissionMode"),S=n("Alert"),r=n("a-button"),B=n("a-button-group"),m=n("Divider"),i=n("Authority"),y=n("PageWrapper"),p=v("auth");return l(),E(y,{title:"前端权限按钮示例",contentBackground:"",contentClass:"p-4",content:"由于刷新的时候会请求用户信息接口，会根据接口重置角色信息，所以刷新后界面会恢复原样，如果不需要，可以注释 src/layout/default/index内的获取用户信息接口"},{default:o(()=>[t(A),F("p",null,[u[2]||(u[2]=s(" 当前角色: ")),F("a",null,d(e.userStore.getRoleList),1)]),t(S,{class:"mt-4",type:"info",message:"点击后请查看按钮变化","show-icon":""}),F("div",L,[u[3]||(u[3]=s(" 权限切换(请先切换权限模式为前端角色权限模式): ")),t(B,null,{default:o(()=>[t(r,{onClick:u[0]||(u[0]=P=>e.changeRole(e.RoleEnum.SUPER)),type:e.isSuper?"primary":"default"},{default:o(()=>[s(d(e.RoleEnum.SUPER),1)]),_:1},8,["type"]),t(r,{onClick:u[1]||(u[1]=P=>e.changeRole(e.RoleEnum.TEST)),type:e.isTest?"primary":"default"},{default:o(()=>[s(d(e.RoleEnum.TEST),1)]),_:1},8,["type"])]),_:1})]),t(m,null,{default:o(()=>u[4]||(u[4]=[s("组件方式判断权限(有需要可以自行全局注册)")])),_:1}),t(i,{value:e.RoleEnum.SUPER},{default:o(()=>[t(r,{type:"primary",class:"mx-4"},{default:o(()=>u[5]||(u[5]=[s(" 拥有super角色权限可见 ")])),_:1})]),_:1},8,["value"]),t(i,{value:e.RoleEnum.TEST},{default:o(()=>[t(r,{color:"success",class:"mx-4"},{default:o(()=>u[6]||(u[6]=[s(" 拥有test角色权限可见 ")])),_:1})]),_:1},8,["value"]),t(i,{value:[e.RoleEnum.TEST,e.RoleEnum.SUPER]},{default:o(()=>[t(r,{color:"error",class:"mx-4"},{default:o(()=>u[7]||(u[7]=[s(" 拥有[test,super]角色权限可见 ")])),_:1})]),_:1},8,["value"]),t(m,null,{default:o(()=>u[8]||(u[8]=[s("函数方式方式判断权限(适用于函数内部过滤)")])),_:1}),e.hasPermission(e.RoleEnum.SUPER)?(l(),E(r,{key:0,type:"primary",class:"mx-4"},{default:o(()=>u[9]||(u[9]=[s(" 拥有super角色权限可见 ")])),_:1})):f("",!0),e.hasPermission(e.RoleEnum.TEST)?(l(),E(r,{key:1,color:"success",class:"mx-4"},{default:o(()=>u[10]||(u[10]=[s(" 拥有test角色权限可见 ")])),_:1})):f("",!0),e.hasPermission([e.RoleEnum.TEST,e.RoleEnum.SUPER])?(l(),E(r,{key:2,color:"error",class:"mx-4"},{default:o(()=>u[11]||(u[11]=[s(" 拥有[test,super]角色权限可见 ")])),_:1})):f("",!0),t(m,null,{default:o(()=>u[12]||(u[12]=[s("指令方式方式判断权限(该方式不能动态修改权限.)")])),_:1}),C((l(),E(r,{type:"primary",class:"mx-4"},{default:o(()=>u[13]||(u[13]=[s(" 拥有super角色权限可见 ")])),_:1})),[[p,e.RoleEnum.SUPER]]),C((l(),E(r,{color:"success",class:"mx-4"},{default:o(()=>u[14]||(u[14]=[s(" 拥有test角色权限可见 ")])),_:1})),[[p,e.RoleEnum.TEST]]),C((l(),E(r,{color:"error",class:"mx-4"},{default:o(()=>u[15]||(u[15]=[s(" 拥有[test,super]角色权限可见 ")])),_:1})),[[p,[e.RoleEnum.TEST,e.RoleEnum.SUPER]]])]),_:1})}const c=V(W,[["render",M],["__scopeId","data-v-2a337dd6"]]);export{c as default};
