chore: update access demo
parent
7801a90dcb
commit
ba780a7d3f
|
@ -118,6 +118,17 @@ export class MenuController {
|
||||||
title: 'page.demos.access.buttonControl',
|
title: 'page.demos.access.buttonControl',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'AccessMenuVisible403',
|
||||||
|
path: 'menu-visible-403',
|
||||||
|
component: '/demos/access/menu-visible-403',
|
||||||
|
meta: {
|
||||||
|
authority: ['no-body'],
|
||||||
|
icon: 'mdi:button-cursor',
|
||||||
|
menuVisibleWithForbidden: true,
|
||||||
|
title: 'page.demos.access.menuVisible403',
|
||||||
|
},
|
||||||
|
},
|
||||||
roleWithMenus[role],
|
roleWithMenus[role],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Fallback } from '@vben/universal-ui';
|
import { Fallback } from '@vben/universal-ui';
|
||||||
|
|
||||||
defineOptions({ name: 'AccessFrontendAccessTest2' });
|
defineOptions({ name: 'AccessAdminVisible' });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { Button } from 'ant-design-vue';
|
||||||
|
|
||||||
import { useAccessStore, useAppStore } from '#/store';
|
import { useAccessStore, useAppStore } from '#/store';
|
||||||
|
|
||||||
defineOptions({ name: 'AccessBackend' });
|
defineOptions({ name: 'AccessButtonControl' });
|
||||||
|
|
||||||
const accounts: Record<string, LoginAndRegisterParams> = {
|
const accounts: Record<string, LoginAndRegisterParams> = {
|
||||||
admin: {
|
admin: {
|
||||||
|
@ -41,7 +41,7 @@ async function changeAccount(role: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const account = accounts[role];
|
const account = accounts[role];
|
||||||
await appStore.resetAppState();
|
appStore.resetAppState();
|
||||||
await accessStore.authLogin(account, async () => {
|
await accessStore.authLogin(account, async () => {
|
||||||
router.go(0);
|
router.go(0);
|
||||||
});
|
});
|
||||||
|
@ -51,68 +51,68 @@ async function changeAccount(role: string) {
|
||||||
<template>
|
<template>
|
||||||
<div class="p-5">
|
<div class="p-5">
|
||||||
<div class="card-box p-5">
|
<div class="card-box p-5">
|
||||||
<h1 class="text-xl font-semibold">后端页面访问权限演示</h1>
|
<h1 class="text-xl font-semibold">
|
||||||
|
{{ accessMode === 'frontend' ? '前端' : '后端' }}页面访问权限演示
|
||||||
|
</h1>
|
||||||
<div class="text-foreground/80 mt-2">切换不同的账号,观察按钮变化。</div>
|
<div class="text-foreground/80 mt-2">切换不同的账号,观察按钮变化。</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template v-if="accessMode === 'backend'">
|
<div class="card-box mt-5 p-5 font-semibold">
|
||||||
<div class="card-box mt-5 p-5 font-semibold">
|
<div class="mb-3">
|
||||||
<div class="mb-3">
|
<span class="text-lg">当前账号:</span>
|
||||||
<span class="text-lg">当前账号:</span>
|
<span class="text-primary mx-4">
|
||||||
<span class="text-primary mx-4">
|
{{ accessStore.userRoles }}
|
||||||
{{ accessStore.userRoles }}
|
</span>
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Button :type="roleButtonType('super')" @click="changeAccount('super')">
|
|
||||||
切换为 Super 账号
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
:type="roleButtonType('admin')"
|
|
||||||
class="mx-4"
|
|
||||||
@click="changeAccount('admin')"
|
|
||||||
>
|
|
||||||
切换为 Admin 账号
|
|
||||||
</Button>
|
|
||||||
<Button :type="roleButtonType('user')" @click="changeAccount('user')">
|
|
||||||
切换为 User 账号
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-box mt-5 p-5 font-semibold">
|
<Button :type="roleButtonType('super')" @click="changeAccount('super')">
|
||||||
<div class="mb-3 text-lg">组件形式控制</div>
|
切换为 Super 账号
|
||||||
<CodeAccess :value="['AC_100100']">
|
</Button>
|
||||||
<Button class="mr-4"> Super 账号可见 ["AC_1000001"] </Button>
|
|
||||||
</CodeAccess>
|
|
||||||
<CodeAccess :value="['AC_100030']">
|
|
||||||
<Button class="mr-4"> Admin 账号可见 ["AC_100010"] </Button>
|
|
||||||
</CodeAccess>
|
|
||||||
<CodeAccess :value="['AC_1000001']">
|
|
||||||
<Button class="mr-4"> User 账号可见 ["AC_1000001"] </Button>
|
|
||||||
</CodeAccess>
|
|
||||||
<CodeAccess :value="['AC_100100', 'AC_100010']">
|
|
||||||
<Button class="mr-4">
|
|
||||||
Super & Admin 账号可见 ["AC_100100","AC_1000001"]
|
|
||||||
</Button>
|
|
||||||
</CodeAccess>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card-box mt-5 p-5 font-semibold">
|
<Button
|
||||||
<div class="mb-3 text-lg">函数形式控制</div>
|
:type="roleButtonType('admin')"
|
||||||
<Button v-if="hasAuthByCodes(['AC_100100'])" class="mr-4">
|
class="mx-4"
|
||||||
Super 账号可见 ["AC_1000001"]
|
@click="changeAccount('admin')"
|
||||||
</Button>
|
>
|
||||||
<Button v-if="hasAuthByCodes(['AC_100030'])" class="mr-4">
|
切换为 Admin 账号
|
||||||
Admin 账号可见 ["AC_100010"]
|
</Button>
|
||||||
</Button>
|
<Button :type="roleButtonType('user')" @click="changeAccount('user')">
|
||||||
<Button v-if="hasAuthByCodes(['AC_1000001'])" class="mr-4">
|
切换为 User 账号
|
||||||
User 账号可见 ["AC_1000001"]
|
</Button>
|
||||||
</Button>
|
</div>
|
||||||
<Button v-if="hasAuthByCodes(['AC_100100', 'AC_1000001'])" class="mr-4">
|
|
||||||
|
<div class="card-box mt-5 p-5 font-semibold">
|
||||||
|
<div class="mb-3 text-lg">组件形式控制</div>
|
||||||
|
<CodeAccess :value="['AC_100100']">
|
||||||
|
<Button class="mr-4"> Super 账号可见 ["AC_1000001"] </Button>
|
||||||
|
</CodeAccess>
|
||||||
|
<CodeAccess :value="['AC_100030']">
|
||||||
|
<Button class="mr-4"> Admin 账号可见 ["AC_100010"] </Button>
|
||||||
|
</CodeAccess>
|
||||||
|
<CodeAccess :value="['AC_1000001']">
|
||||||
|
<Button class="mr-4"> User 账号可见 ["AC_1000001"] </Button>
|
||||||
|
</CodeAccess>
|
||||||
|
<CodeAccess :value="['AC_100100', 'AC_100010']">
|
||||||
|
<Button class="mr-4">
|
||||||
Super & Admin 账号可见 ["AC_100100","AC_1000001"]
|
Super & Admin 账号可见 ["AC_100100","AC_1000001"]
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</CodeAccess>
|
||||||
</template>
|
</div>
|
||||||
|
|
||||||
|
<div class="card-box mt-5 p-5 font-semibold">
|
||||||
|
<div class="mb-3 text-lg">函数形式控制</div>
|
||||||
|
<Button v-if="hasAuthByCodes(['AC_100100'])" class="mr-4">
|
||||||
|
Super 账号可见 ["AC_1000001"]
|
||||||
|
</Button>
|
||||||
|
<Button v-if="hasAuthByCodes(['AC_100030'])" class="mr-4">
|
||||||
|
Admin 账号可见 ["AC_100010"]
|
||||||
|
</Button>
|
||||||
|
<Button v-if="hasAuthByCodes(['AC_1000001'])" class="mr-4">
|
||||||
|
User 账号可见 ["AC_1000001"]
|
||||||
|
</Button>
|
||||||
|
<Button v-if="hasAuthByCodes(['AC_100100', 'AC_1000001'])" class="mr-4">
|
||||||
|
Super & Admin 账号可见 ["AC_100100","AC_1000001"]
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Fallback } from '@vben/universal-ui';
|
import { Fallback } from '@vben/universal-ui';
|
||||||
|
|
||||||
defineOptions({ name: 'AccessFrontendAccessTest2' });
|
defineOptions({ name: 'AccessMenuVisible403' });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Fallback } from '@vben/universal-ui';
|
import { Fallback } from '@vben/universal-ui';
|
||||||
|
|
||||||
defineOptions({ name: 'AccessFrontendAccessTest1' });
|
defineOptions({ name: 'AccessSuperVisible' });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Fallback } from '@vben/universal-ui';
|
import { Fallback } from '@vben/universal-ui';
|
||||||
|
|
||||||
defineOptions({ name: 'AccessFrontendAccessTest1' });
|
defineOptions({ name: 'AccessUserVisible' });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
Loading…
Reference in New Issue