index.vue 1.3 KB
Newer Older
陈文彬 已提交
1
<template>
2 3 4 5 6 7
  <PageWrapper
    title="后台权限示例"
    contentBackgrond
    contentClass="p-4"
    content="目前mock了两组数据, id为1 和 2 具体返回的菜单可以在mock/sys/menu.ts内查看"
  >
陈文彬 已提交
8 9 10 11 12 13 14 15 16 17 18
    <CurrentPermissionMode />

    <Alert class="mt-4" type="info" message="点击后请查看左侧菜单变化" show-icon />

    <div class="mt-4">
      权限切换(请先切换权限模式为后台权限模式):
      <a-button-group>
        <a-button @click="changeMenu('1')"> 获取用户id为1的菜单 </a-button>
        <a-button @click="changeMenu('2')"> 获取用户id为2的菜单 </a-button>
      </a-button-group>
    </div>
19
  </PageWrapper>
陈文彬 已提交
20 21 22 23 24 25
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
  import CurrentPermissionMode from '../CurrentPermissionMode.vue';
  import { RoleEnum } from '/@/enums/roleEnum';
  import { usePermission } from '/@/hooks/web/usePermission';
26 27
  import { PageWrapper } from '/@/components/Page';
  import { Alert } from 'ant-design-vue';
陈文彬 已提交
28
  export default defineComponent({
29
    components: { Alert, CurrentPermissionMode, PageWrapper },
陈文彬 已提交
30 31 32 33 34 35 36 37 38
    setup() {
      const { changeMenu } = usePermission();
      return {
        RoleEnum,
        changeMenu,
      };
    },
  });
</script>
N
nebv 已提交
39 40 41 42 43
<style lang="less" scoped>
  .demo {
    background: #fff;
  }
</style>