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
| import { createRouter, createWebHistory } from 'vue-router'
| import Layout from '@/layout/Layout.vue'
| import { isAuthenticated } from '@/utils/auth'
|
| const router = createRouter({
| history: createWebHistory(),
| routes: [
| {
| path: '/login',
| name: 'Login',
| component: () => import('@/views/Login.vue'),
| meta: { title: '登录', public: true },
| },
| {
| path: '/',
| component: Layout,
| redirect: '/dashboard',
| children: [
| {
| path: 'dashboard',
| name: 'Dashboard',
| component: () => import('@/views/Dashboard.vue'),
| meta: { title: '工作台', icon: 'HomeFilled' },
| },
| {
| path: 'test-list',
| name: 'test-list',
| component: () => import('@/views/TestList.vue'),
| meta: { title: '测试列表' },
| },
| {
| path: 'test-list/new',
| name: 'test-create',
| component: () => import('@/views/TestCreate.vue'),
| meta: { title: '新建测试' },
| },
| {
| path: 'test-list/:id/console',
| name: 'test-console',
| component: () => import('@/views/TestConsole.vue'),
| meta: { title: '测试控制台' },
| },
| {
| path: 'test-list/:id/console/data/:recordId/edit',
| name: 'test-console-data-edit',
| component: () => import('@/views/ConsoleDataEdit.vue'),
| meta: { title: '修改测试数据' },
| },
| {
| path: 'test-list/:id/console/data/import',
| name: 'test-console-data-import',
| component: () => import('@/views/ConsoleDataImport.vue'),
| meta: { title: '导入测试数据' },
| },
| {
| path: 'battery-group',
| name: 'battery-group',
| component: () => import('@/views/BatteryGroup.vue'),
| meta: { title: '电池组管理' },
| },
| {
| path: 'battery-group/fields',
| name: 'battery-group-fields',
| component: () => import('@/views/BatteryGroupField.vue'),
| meta: { title: '电池组字段管理' },
| },
| {
| path: 'battery-group/new',
| name: 'battery-group-create',
| component: () => import('@/views/BatteryGroupForm.vue'),
| meta: { title: '新建电池组' },
| },
| {
| path: 'battery-group/:id/edit',
| name: 'battery-group-edit',
| component: () => import('@/views/BatteryGroupForm.vue'),
| meta: { title: '编辑电池组' },
| },
| {
| path: 'test-type',
| name: 'test-type',
| component: () => import('@/views/TestType.vue'),
| meta: { title: '测试类型管理' },
| },
| {
| path: 'test-type/new',
| name: 'test-type-create',
| component: () => import('@/views/TestTypeForm.vue'),
| meta: { title: '新建测试类型' },
| },
| {
| path: 'test-type/:id/edit',
| name: 'test-type-edit',
| component: () => import('@/views/TestTypeForm.vue'),
| meta: { title: '编辑测试类型' },
| },
| {
| path: 'data-revision',
| name: 'data-revision',
| component: () => import('@/views/DataRevision.vue'),
| meta: { title: '数据修订记录' },
| },
| {
| path: 'data-revision/:id',
| name: 'data-revision-detail',
| component: () => import('@/views/DataRevisionDetail.vue'),
| meta: { title: '数据修订详情' },
| },
| {
| path: 'exception',
| name: 'exception',
| component: () => import('@/views/Exception.vue'),
| meta: { title: '异常管理' },
| },
| {
| path: 'device-cabinet',
| name: 'device-cabinet',
| component: () => import('@/views/DeviceCabinet.vue'),
| meta: { title: '检测柜' },
| },
| {
| path: 'device-collector',
| name: 'device-collector',
| component: () => import('@/views/DeviceCollector.vue'),
| meta: { title: '采集器' },
| },
| {
| path: 'device-collector/new',
| name: 'device-collector-create',
| component: () => import('@/views/DeviceCollectorForm.vue'),
| meta: { title: '新增采集器' },
| },
| {
| path: 'device-collector/:id/edit',
| name: 'device-collector-edit',
| component: () => import('@/views/DeviceCollectorForm.vue'),
| meta: { title: '编辑采集器' },
| },
| {
| path: 'report-compare',
| name: 'report-compare',
| component: () => import('@/views/ReportCompare.vue'),
| meta: { title: '对比报表' },
| },
| {
| path: 'report-compare/new',
| name: 'report-compare-create',
| component: () => import('@/views/ReportCompareForm.vue'),
| meta: { title: '新增对比报表' },
| },
| {
| path: 'report-compare/:id/edit',
| name: 'report-compare-edit',
| component: () => import('@/views/ReportCompareForm.vue'),
| meta: { title: '编辑对比报表' },
| },
| {
| path: 'report-formation',
| name: 'report-formation',
| component: () => import('@/views/FormationReport.vue'),
| meta: { title: '化成报表' },
| },
| {
| path: 'report-formation/new',
| name: 'report-formation-create',
| component: () => import('@/views/FormationReportForm.vue'),
| meta: { title: '新增化成报表' },
| },
| {
| path: 'report-formation/:id/edit',
| name: 'report-formation-edit',
| component: () => import('@/views/FormationReportForm.vue'),
| meta: { title: '编辑化成报表' },
| },
| {
| path: 'report-splice',
| name: 'report-splice',
| component: () => import('@/views/SpliceReport.vue'),
| meta: { title: '拼接报表' },
| },
| {
| path: 'report-splice/new',
| name: 'report-splice-create',
| component: () => import('@/views/SpliceReportForm.vue'),
| meta: { title: '新增拼接报表' },
| },
| {
| path: 'report-splice/:id/edit',
| name: 'report-splice-edit',
| component: () => import('@/views/SpliceReportForm.vue'),
| meta: { title: '编辑拼接报表' },
| },
| {
| path: 'todo-list',
| name: 'todo-list',
| component: () => import('@/views/TodoList.vue'),
| meta: { title: '待办列表' },
| },
| { path: 'account', name: 'account', component: () => import('@/views/Account.vue'), meta: { title: '账号管理' } },
| { path: 'role', name: 'role', component: () => import('@/views/Role.vue'), meta: { title: '角色管理' } },
| { path: 'role/new', name: 'role-create', component: () => import('@/views/RoleForm.vue'), meta: { title: '新增角色' } },
| { path: 'role/:id', name: 'role-detail', component: () => import('@/views/RoleForm.vue'), meta: { title: '角色详情' } },
| { path: 'role/:id/edit', name: 'role-edit', component: () => import('@/views/RoleForm.vue'), meta: { title: '编辑角色' } },
| { path: 'operation-log', name: 'operation-log', component: () => import('@/views/OperationLog.vue'), meta: { title: '操作日志' } },
| ],
| },
| {
| path: '/:pathMatch(.*)*',
| redirect: '/dashboard',
| },
| ],
| })
|
| router.beforeEach((to) => {
| const authenticated = isAuthenticated()
|
| if (!to.meta.public && !authenticated) {
| return {
| path: '/login',
| query: to.fullPath !== '/' ? { redirect: to.fullPath } : undefined,
| }
| }
|
| if (to.path === '/login' && authenticated) {
| return '/dashboard'
| }
|
| document.title = `${String(to.meta.title || '工作台')} - 检测室数据可视化系统`
| return true
| })
|
| export default router
|
|