ROUTER.ts.ftl 9.4 KB
Newer Older
ibizdev's avatar
ibizdev committed
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
import Vue from 'vue';
import Router from 'vue-router';
import { AuthGuard } from '@/utils';
import qs from 'qs';
import store from '@/store';

Vue.use(Router);

const router = new Router({
    routes: [
        <#--  路由内容  -->
        {
            path: '/${view.getCodeName()?lower_case}/:${view.getCodeName()?lower_case}?',
            beforeEnter: (to: any, from: any, next: any) => {
                const routerParamsName = '${view.getCodeName()?lower_case}';
                const params: any = {};
                if (to.params && to.params[routerParamsName]) {
                    Object.assign(params, qs.parse(to.params[routerParamsName], { delimiter: ';' }));
                }
                const url: string = 'v7/appdata';
                const auth: Promise<any> = AuthGuard.getInstance().authGuard(url, params, store);
                auth.then(() => {
                    next();
                }).catch(() => {
                    next();
                });
            },
            meta: {  
                caption: '${view.getCaption()}',
                viewType: 'APPINDEX',
                <#if view.getPSSysImage()??>
                imgPath: '${view.getPSSysImage().getImagePath()}',
                iconCls: '${view.getPSSysImage().getCssClass()}',
                </#if>
                parameters: [
                    { pathName: '${view.getCodeName()?lower_case}', parameterName: '${view.getCodeName()?lower_case}' },
                ],
                requireAuth: <#if view.getAccUserMode?? && view.getAccUserMode()?? && (view.getAccUserMode() == 1 || view.getAccUserMode() == 3)>false<#else>true</#if>,
            },
            component: () => import('@pages/${srffilepath2(view.getPSAppModule().getCodeName())}/${srffilepath2(view.getCodeName())}/${srffilepath2(view.getCodeName())}.vue'),
        },
        {
            path: '/viewshell/:viewshell?',
            beforeEnter: (to: any, from: any, next: any) => {
                const routerParamsName = '${view.getCodeName()?lower_case}';
                const params: any = {};
                if (to.params && to.params[routerParamsName]) {
                    Object.assign(params, qs.parse(to.params[routerParamsName], { delimiter: ';' }));
                }
                const url: string = 'v7/appdata';
                const auth: Promise<any> = AuthGuard.getInstance().authGuard(url, params, store);
                auth.then(() => {
                    next();
                }).catch(() => {
                    next();
                });
            },
            meta: {
                parameters: [
                    { pathName: 'viewshell', parameterName: 'viewshell' },
                ],
            },
            component: () => import('@/components/view-shell/view-shell.vue'),
            children: [
            <#list view.getAllRelatedPSAppViewsEx() as subView>
            <#if !subView.isRedirectView()>
            <#if subView.isPSDEView() && subView.getPSAppDataEntity()??>
                <#assign appDataEntity = subView.getPSAppDataEntity()/>
                <#--  BEGIN:有多重路径  -->
                <#if subView.getPSAppDERSPathCount() gt 0>
                <#list 1..subView.getPSAppDERSPathCount() as count>
                <#assign path = ''/>
                <#--  BEGIN:循环路径下所有关系  -->
                <#list subView.getPSAppDERSPath(count_index) as deRSPath>
                <#assign majorPSAppDataEntity = deRSPath.getMajorPSAppDataEntity()/>
                <#assign path>${path}${srfpluralize(majorPSAppDataEntity.codeName)?lower_case}/:${majorPSAppDataEntity.getCodeName()?lower_case}?/</#assign>
                </#list>
                <#--  END:循环路径下所有关系  -->
                {
80
                    path: '${path}${srfpluralize(appDataEntity.codeName)?lower_case}/:${appDataEntity.getCodeName()?lower_case}?/${subView.getPSDEViewCodeName()?lower_case}',
ibizdev's avatar
ibizdev committed
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
                    meta: {
                        caption: '<#if subView.isPSDEView()>${subView.getPSDataEntity().getCodeName()?lower_case}.views.${subView.getPSDEViewCodeName()?lower_case}.caption<#else>app.views.${subView.getCodeName()?lower_case}.caption</#if>',
                        <#if subView.getPSSysImage()??>
                        imgPath: '${subView.getPSSysImage().getImagePath()}',
                        iconCls: '${subView.getPSSysImage().getCssClass()}',
                        </#if>
                        parameters: [
                            { pathName: 'viewshell', parameterName: 'viewshell' },
                            <#list subView.getPSAppDERSPath(count_index) as deRSPath>
                            <#assign majorPSAppDataEntity = deRSPath.getMajorPSAppDataEntity()/>
                            { pathName: '${srfpluralize(majorPSAppDataEntity.codeName)?lower_case}', parameterName: '${majorPSAppDataEntity.getCodeName()?lower_case}' },
                            </#list>
                            { pathName: '${srfpluralize(appDataEntity.codeName)?lower_case}', parameterName: '${appDataEntity.getCodeName()?lower_case}' },
                            { pathName: '${subView.getPSDEViewCodeName()?lower_case}', parameterName: '${subView.getPSDEViewCodeName()?lower_case}' },
                        ],
                        requireAuth: <#if subView.getAccUserMode?? && subView.getAccUserMode()?? && (subView.getAccUserMode() == 1 || subView.getAccUserMode() == 3)>false<#else>true</#if>,
                    },
                    component: () => import('@pages/${srffilepath2(subView.getPSAppModule().getCodeName())}/${srffilepath2(subView.getCodeName())}/${srffilepath2(subView.getCodeName())}.vue'),
                },
                </#list>
                </#if>
                <#--  END:有多重路径  -->
                {
104
                    path: '${srfpluralize(appDataEntity.codeName)?lower_case}/:${appDataEntity.getCodeName()?lower_case}?/${subView.getPSDEViewCodeName()?lower_case}',
ibizdev's avatar
ibizdev committed
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
                    meta: {
                        caption: '<#if subView.isPSDEView()>${subView.getPSDataEntity().getCodeName()?lower_case}.views.${subView.getPSDEViewCodeName()?lower_case}.caption<#else>app.views.${subView.getCodeName()?lower_case}.caption</#if>',
                        <#if subView.getPSSysImage()??>
                        imgPath: '${subView.getPSSysImage().getImagePath()}',
                        iconCls: '${subView.getPSSysImage().getCssClass()}',
                        </#if>
                        parameters: [
                            { pathName: 'viewshell', parameterName: 'viewshell' },
                            { pathName: '${srfpluralize(appDataEntity.codeName)?lower_case}', parameterName: '${appDataEntity.getCodeName()?lower_case}' },
                            { pathName: '${subView.getPSDEViewCodeName()?lower_case}', parameterName: '${subView.getPSDEViewCodeName()?lower_case}' },
                        ],
                        requireAuth: <#if subView.getAccUserMode?? && subView.getAccUserMode()?? && (subView.getAccUserMode() == 1 || subView.getAccUserMode() == 3)>false<#else>true</#if>,
                    },
                    component: () => import('@pages/${srffilepath2(subView.getPSAppModule().getCodeName())}/${srffilepath2(subView.getCodeName())}/${srffilepath2(subView.getCodeName())}.vue'),
                },
            <#else>
                {
122
                    path: '${subView.getCodeName()?lower_case}',
ibizdev's avatar
ibizdev committed
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
                    meta: {
                        caption: '<#if subView.isPSDEView()>${subView.getPSDataEntity().getCodeName()?lower_case}.views.${subView.getPSDEViewCodeName()?lower_case}.caption<#else>app.views.${subView.getCodeName()?lower_case}.caption</#if>',
                        <#if subView.getPSSysImage()??>
                        imgPath: '${subView.getPSSysImage().getImagePath()}',
                        iconCls: '${subView.getPSSysImage().getCssClass()}',
                        </#if>
                        parameters: [
                            { pathName: 'viewshell', parameterName: 'viewshell' },
                            { pathName: '${subView.getCodeName()?lower_case}', parameterName: '${subView.getCodeName()?lower_case}' },
                        ],
                        requireAuth: <#if subView.getAccUserMode?? && subView.getAccUserMode()?? && (subView.getAccUserMode() == 1 || subView.getAccUserMode() == 3)>false<#else>true</#if>,
                    },
                    component: () => import('@pages/${srffilepath2(subView.getPSAppModule().getCodeName())}/${srffilepath2(subView.getCodeName())}/${srffilepath2(subView.getCodeName())}.vue'),
                },
            </#if>
            </#if>
            </#list>
            ]
        },
        {
            path: '/login/:login?',
            name: 'login',
            meta: {  
                caption: '登录',
                viewType: 'login',
                requireAuth: false,
                ignoreAddPage: true,
            },
            beforeEnter: (to: any, from: any, next: any) => {
                router.app.$store.commit('resetRootStateData');
                next();
            },
            component: () => import('@components/login/login.vue'),
        },
        {
            path: '/404',
            component: () => import('@components/404/404.vue')
        },
        {
            path: '/500',
            component: () => import('@components/500/500.vue')
        },
        {
            path: '*',
            redirect: '${view.getCodeName()?lower_case}'
        },
    ],
});

export default router;