ROUTER.ts.ftl 9.5 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
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: ';' }));
                }
KK's avatar
KK committed
20
                const url: string = 'appdata';
ibizdev's avatar
ibizdev committed
21 22 23 24 25 26 27 28
                const auth: Promise<any> = AuthGuard.getInstance().authGuard(url, params, store);
                auth.then(() => {
                    next();
                }).catch(() => {
                    next();
                });
            },
            meta: {  
KK's avatar
KK committed
29
                keepAlive:true,
ibizdev's avatar
ibizdev committed
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
                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: ';' }));
                }
KK's avatar
KK committed
51
                const url: string = 'appdata';
ibizdev's avatar
ibizdev committed
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 80
                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:循环路径下所有关系  -->
                {
81
                    path: '${path}${srfpluralize(appDataEntity.codeName)?lower_case}/:${appDataEntity.getCodeName()?lower_case}?/${subView.getPSDEViewCodeName()?lower_case}',
ibizdev's avatar
ibizdev committed
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
                    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:有多重路径  -->
                {
105
                    path: '${srfpluralize(appDataEntity.codeName)?lower_case}/:${appDataEntity.getCodeName()?lower_case}?/${subView.getPSDEViewCodeName()?lower_case}',
ibizdev's avatar
ibizdev committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
                    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>
                {
123
                    path: '${subView.getCodeName()?lower_case}',
ibizdev's avatar
ibizdev committed
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 173
                    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;