| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import Vue from 'vue';
- import VueRouter from 'vue-router';
- import HomeView from '@/views/HomeView.vue';
- import { getToken } from '@/utils/token-util';
- Vue.use(VueRouter);
- let routerInstance = null;
- export function getRouter() { return routerInstance; }
- const dev = process.env.NODE_ENV === 'development';
- const routes = [
- { path: '/login', name: 'login', component: () => import('@/views/login/index.vue'), meta: { title: '登录', public: true, fullPage: true } },
- { path: '/', name: 'home', component: HomeView, meta: { title: '首页', public: dev } },
- { path: '/organization', name: 'organization', component: () => import('@/views/organization/index.vue'), meta: { title: '组织架构', public: dev } },
- { path: '/position-management', name: 'positionManagement', component: () => import('@/views/positionManagement/index.vue'), meta: { title: '岗位设定', public: dev } },
- { path: '/position-sequence', name: 'positionSequence', component: () => import('@/views/positionSequence/index.vue'), meta: { title: '岗位序列', public: dev } },
- { path: '/position-application', name: 'positionApplication', component: () => import('@/views/positionApplication/index.vue'), meta: { title: '岗位申请', public: dev } },
- { path: '/employee-archive', name: 'employeeArchive', component: () => import('@/views/employeeArchive/index.vue'), meta: { title: '员工档案', public: dev } },
- { path: '/performance-scoring', name: 'performanceScoring', component: () => import('@/views/performanceScoring/index.vue'), meta: { title: '绩效评分', public: dev } },
- { path: '/performance-scheme', name: 'performanceScheme', component: () => import('@/views/performanceScheme/index.vue'), meta: { title: '绩效方案', public: dev } },
- { path: '/personnel-structure-dashboard', name: 'personnelStructureDashboard', component: () => import('@/views/personnelStructureDashboard/index.vue'), meta: { title: '人员结构看板', public: dev } },
- { path: '/personnel-structure-analysis-board', name: 'personnelStructureAnalysisBoard', component: () => import('@/views/personnelStructureAnalysisBoard/index.vue'), meta: { title: '人员结构分析看板', public: dev } },
- { path: '/recruitment-plan', name: 'recruitmentPlan', component: () => import('@/views/recruitmentPlan/index.vue'), meta: { title: '招聘需求计划', public: dev } },
- { path: '/talent-pool', name: 'talentPool', component: () => import('@/views/talentPool/index.vue'), meta: { title: '人才库', public: dev } },
- { path: '/onboarding-contract-template', name: 'onboardingContractTemplate', component: () => import('@/views/onboardingContractTemplate/index.vue'), meta: { title: '入职合同模板', public: dev } },
- { path: '/regularization-handling', name: 'regularizationHandling', component: () => import('@/views/regularizationHandling/index.vue'), meta: { title: '转正办理', public: dev } },
- { path: '/regularization-template', name: 'regularizationTemplate', component: () => import('@/views/regularizationTemplate/index.vue'), meta: { title: '转正申请模板', public: dev } },
- { path: '/onboarding-handling', name: 'onboardingHandling', component: () => import('@/views/onboardingHandling/index.vue'), meta: { title: '办理入职', public: dev } },
- { path: '/resignation-letter', name: 'resignationLetter', component: () => import('@/views/resignationLetter/index.vue'), meta: { title: '辞职申请书', public: dev } },
- { path: '/resignation-application', name: 'resignationApplication', component: () => import('@/views/resignationApplication/index.vue'), meta: { title: '离职申请', public: dev } },
- { path: '/resignation-handover-order', name: 'resignationHandoverOrder', component: () => import('@/views/resignationHandoverOrder/index.vue'), meta: { title: '离职交接单', public: dev } },
- { path: '/resignation-handover-table', name: 'resignationHandoverTable', component: () => import('@/views/resignationHandoverTable/index.vue'), meta: { title: '离职交接表', public: dev } },
- { path: '/resignation-certificate', name: 'resignationCertificate', component: () => import('@/views/resignationCertificate/index.vue'), meta: { title: '离职证明', public: dev } }
- ];
- export default function createRouter(routerBase) {
- const router = new VueRouter({ mode: 'history', base: window.__POWERED_BY_QIANKUN__ ? routerBase || process.env.VUE_APP_QIANKUN_ACTIVE_RULE : process.env.VUE_APP_PUBLIC_PATH, routes, scrollBehavior: () => ({ x: 0, y: 0 }) });
- routerInstance = router;
- router.beforeEach((to, from, next) => {
- if (to.meta && to.meta.title) document.title = `${to.meta.title} - ${process.env.VUE_APP_NAME}`;
- if (!window.__POWERED_BY_QIANKUN__ && !to.meta?.public && !getToken()) { next({ path: '/login', query: to.fullPath === '/' ? {} : { from: to.fullPath } }); return; }
- if (to.path === '/login' && getToken()) { next('/'); return; }
- next();
- });
- return router;
- }
|