ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import type { ComponentRecordType, GenerateMenuAndRoutesOptions } from '@vben/types';
 
import { useGlobSetting } from '@jnpf/hooks';
 
import { generateAccessible } from '@vben/access';
import { preferences } from '@vben/preferences';
import { useAccessStore } from '@vben/stores';
 
import { BasicLayout, IFrameView } from '#/layouts';
import { APP_PREFIX } from '#/utils/constants';
import { getRealJnpfAppEnCode } from '#/utils/jnpf';
 
const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue');
const NotFoundView = () => import('#/views/_core/fallback/not-found.vue');
const OnlineModelView = () => import('#/views/common/dynamicModel/index.vue');
const OnlineDictView = () => import('#/views/common/dynamicDictionary/index.vue');
const OnlineReportView = () => import('#/views/common/dynamicReport/index.vue');
// 旧版报表
const OnlineDataReportView = () => import('#/views/common/dynamicDataReport/index.vue');
const OnlinePortalView = () => import('#/views/common/dynamicPortal/index.vue');
 
async function generateAccess(options: GenerateMenuAndRoutesOptions) {
  const pageMap: ComponentRecordType = import.meta.glob('../views/**/*.vue');
 
  const layoutMap: ComponentRecordType = {
    BasicLayout,
    IFrameView,
    OnlineModelView,
    OnlineDictView,
    OnlineReportView,
    OnlineDataReportView,
    OnlinePortalView,
    NotFoundView,
  };
 
  const globSetting = useGlobSetting();
  const accessStore = useAccessStore();
  const appEnCode = getRealJnpfAppEnCode();
 
  return await generateAccessible(preferences.app.accessMode, {
    ...options,
    // 可以指定没有权限跳转403页面
    forbiddenComponent,
    // 如果 route.meta.menuVisibleWithForbidden = true
    layoutMap,
    pageMap,
    globSetting,
    token: accessStore.accessToken || undefined,
    isAddHomeToMenu: !appEnCode,
    appEnCode,
    appPrefix: APP_PREFIX,
  });
}
 
export { generateAccess };