wupengfei
2025-04-25 e446ab2cda42d2eaeb4f393bdaa0517c1e49a768
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
import { createRouter, RouteRecordRaw, createWebHistory } from 'vue-router';
 
import Layout from '@/layout/MainLayout/Layout.vue';
import ErrorLayout from '@/layout/ErrorLayout/ErrorLayout.vue';
 
// import { ElIcons } from '@/typings'
 
export type RouteMeta = {
  /**
   * 页面标题
   */
  title?: string;
  /**
   * menus菜单图标
   */
  icon?: string;
  /**
   * 是否固定标签页
   */
  affix?: boolean;
  /**
   * 是否在面包屑中显示
   */
  breadcrumb?: boolean;
  /**
   * 是否缓存页面
   */
  noCache?: boolean;
  /**
   * 菜单排序显示等级
   */
  rank?: number;
 
  moduleId?: string;
 
  /**
   * 是否是根Menu
   */
  rootMenu?: boolean;
};
 
export type Route = RouteRecordRaw & {
  /**
   * 是否在menu显示
   */
  hidden?: boolean;
  alwaysShow?: boolean;
  /**
   * 设置为noRedirect将不会在面包屑中重定向
   */
  redirect?: string;
  meta?: RouteMeta;
  children?: Route[];
};
 
export const constantRoutes: Route[] = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/Redirect/Redirect.vue'),
        meta: {
          noCache: true,
        },
      },
    ],
  },
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    alwaysShow: true,
    children: [
      {
        path: 'home',
        name: 'Home',
        hidden: false,
        component: () => import('@/views/Home/Home.vue'),
        meta: {
          rank: 10001,
          title: '工作台',
          affix: true,
          rootMenu: true,
        },
      },
    ],
    meta: {
      rank: 1001,
      icon: 'home',
      title: '首页',
      rootMenu: true,
    },
  },
  {
    path: '/EnterpriseInfo',
    redirect: 'noRedirect',
    component: Layout,
    hidden: false,
    alwaysShow: true,
    meta: {
      rank: 10010,
      title: '企业信息',
      rootMenu: true,
      icon: 'home',
    },
    children: [
      {
        path: '/EnterpriseInfoList',
        name: 'EnterpriseInfoList',
        hidden: false,
        alwaysShow: true,
        component: () => import('@/views/EnterpriseInfo/EnterpriseInfo.vue'),
        meta: {
          rank: 10011,
          title: '企业信息',
          // rootMenu: true,
          icon: 'home',
        },
      },
      {
        path: '/EnterpriseInfoDetail/:id',
        name: 'EnterpriseInfoDetail',
        hidden: true,
        component: () => import('@/views/EnterpriseInfo/EnterpriseInfoDetail.vue'),
        meta: {
          rank: 10012,
          title: '企业信息详情',
          // rootMenu: true,
          icon: 'home',
        },
      },
    ],
  },
  {
    path: '/MaterialReview',
    redirect: 'noRedirect',
    component: Layout,
    hidden: false,
    alwaysShow: true,
    meta: {
      rank: 10020,
      title: '材料审核',
      rootMenu: true,
      icon: 'home',
    },
    children: [
      {
        path: '/MaterialReviewList',
        name: 'MaterialReviewList',
        hidden: false,
        alwaysShow: true,
        component: () => import('@/views/MaterialReview/MaterialReview.vue'),
        meta: {
          rank: 10021,
          title: '材料审核',
          // rootMenu: true,
          icon: 'home',
        },
      },
      {
        path: '/MaterialReviewDetail/:id',
        name: 'MaterialReviewDetail',
        hidden: true,
        component: () => import('@/views/MaterialReview/MaterialReviewDetail.vue'),
        meta: {
          rank: 10022,
          title: '材料审核详情',
          rootMenu: false,
        },
      },
      {
        path: '/MaterialReviewAudit/:id',
        name: 'MaterialReviewAudit',
        hidden: true,
        component: () => import('@/views/MaterialReview/MaterialReviewAudit.vue'),
        meta: {
          rank: 10023,
          title: '审核',
          rootMenu: false,
        },
      },
    ],
  },
  {
    path: '/Reward',
    redirect: 'noRedirect',
    component: Layout,
    hidden: false,
    alwaysShow: true,
    meta: {
      rank: 10030,
      title: '平台奖励',
      rootMenu: true,
      icon: 'home',
    },
    children: [
      {
        path: '/RewardGrant',
        name: 'RewardGrant',
        hidden: false,
        alwaysShow: true,
        component: () => import('@/views/Reward/RewardGrant.vue'),
        meta: {
          rank: 10031,
          title: '奖励发放',
          // rootMenu: true,
          icon: 'home',
        },
      },
      {
        path: '/RewardDeclareDetail/:id',
        name: 'RewardDeclareDetail',
        hidden: true,
        component: () => import('@/views/Reward/RewardDeclareDetail.vue'),
        meta: {
          rank: 10032,
          title: '申报详情',
          rootMenu: false,
        },
      },
    ],
  },
  // {
  //   path: '/Syatem',
  //   redirect: 'noRedirect',
  //   component: Layout,
  //   hidden: true,
  //   alwaysShow: false,
  //   meta: {
  //     rank: 10030,
  //     title: '系统配置',
  //     rootMenu: true,
  //     icon: 'home',
  //   },
  //   children: [
  //     {
  //       path: '/Account',
  //       name: 'Account',
  //       hidden: true,
  //       alwaysShow: true,
  //       component: () => import('@/views/Account/AccountManageList.vue'),
  //       meta: {
  //         rank: 10031,
  //         title: '账号管理',
  //         // rootMenu: true,
  //         icon: 'home',
  //       },
  //     },
  //   ],
  // },
 
  {
    path: '/Login',
    name: 'Login',
    hidden: true,
    component: () => import('@/views/Login/Login.vue'),
    meta: {
      title: '登录',
      rank: 101,
    },
  },
  {
    path: '/Error',
    component: ErrorLayout,
    redirect: '/Error/401',
    hidden: true,
    meta: {
      title: '错误页',
    },
    children: [
      {
        path: '/401',
        name: '401',
        component: () => import('@/views/Error/401.vue'),
        meta: {
          title: '401',
        },
      },
      {
        path: '/404',
        name: '404',
        component: () => import('@/views/Error/404.vue'),
        meta: {
          title: '404',
        },
      },
    ],
  },
];
 
export const asyncRoutes: Route[] = [
  {
    path: '/System',
    name: 'System',
    redirect: 'noRedirect',
    alwaysShow: true,
    meta: {
      title: '系统配置管理',
      rootMenu: true,
    },
    children: [
      {
        path: '/System/ModuleManage',
        name: 'ModuleManage',
        component: null,
        meta: {
          title: '功能模块管理',
        },
      },
    ],
  },
];
 
const createRouterFactory = () =>
  createRouter({
    history: createWebHistory(), // hash模式:createWebHashHistory,history模式:createWebHistory
    scrollBehavior(to, from, savedPosition) {
      return new Promise((resolve) => {
        if (savedPosition) {
          return savedPosition;
        } else {
          if (from.meta.saveSrollTop) {
            const top: number = document.documentElement.scrollTop || document.body.scrollTop;
            resolve({ left: 0, top });
          }
        }
      });
    },
    routes: constantRoutes,
  });
 
export const router = createRouterFactory();
 
export function resetRouter() {
  const newRouter = createRouterFactory();
  //@ts-ignore
  router.matcher = newRouter.matcher; // reset router
}
 
export function redirect404() {
  router.replace({ path: '/404' });
}