Download playground/src/router/access.ts from binhugg3/admin: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/spaces/binhugg3/admin/resolve/main/playground/src/router/access.ts
- Command line
-
hf download hf://spaces/binhugg3/admin/playground/src/router/access.ts
-
curl -L -o access.ts https://huggingface.co/spaces/binhugg3/admin/resolve/main/playground/src/router/access.ts
1.14 kB
| import type { | |
| ComponentRecordType, | |
| GenerateMenuAndRoutesOptions, | |
| } from '@vben/types'; | |
| import { generateAccessible } from '@vben/access'; | |
| import { preferences } from '@vben/preferences'; | |
| import { message } from 'ant-design-vue'; | |
| import { getAllMenusApi } from '#/api'; | |
| import { BasicLayout, IFrameView } from '#/layouts'; | |
| import { $t } from '#/locales'; | |
| const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue'); | |
| async function generateAccess(options: GenerateMenuAndRoutesOptions) { | |
| const pageMap: ComponentRecordType = import.meta.glob('../views/**/*.vue'); | |
| const layoutMap: ComponentRecordType = { | |
| BasicLayout, | |
| IFrameView, | |
| }; | |
| return await generateAccessible(preferences.app.accessMode, { | |
| ...options, | |
| fetchMenuListAsync: async () => { | |
| message.loading({ | |
| content: `${$t('common.loadingMenu')}...`, | |
| duration: 1.5, | |
| }); | |
| return await getAllMenusApi(); | |
| }, | |
| // 可以指定没有权限跳转403页面 | |
| forbiddenComponent, | |
| // 如果 route.meta.menuVisibleWithForbidden = true | |
| layoutMap, | |
| pageMap, | |
| }); | |
| } | |
| export { generateAccess }; | |