import Vue from vue import Router from vue-router import Home from vie

  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
import Vue from "vue";
import Router from 'vue-router'
import Home from "./views/Home.vue";
import Signin from "@/views/Signin";
import Signup from "@/views/Signup";
import Logout from "@/views/Logout";
import Profile from "@/views/Profile";
import PageError from "@/views/PageError";
import OrderPoints from "@/views/OrderPoints";
import OrderStatus from "@/views/OrderStatus";
import Role from "@/views/Role";
import TruckProp from "@/views/TruckProp";
import TruckType from "@/views/TruckType";
import Managers from "@/views/Managers";
import Dispetchers from "@/views/Dispetchers";
import Companies from "@/views/Companies";
import Transports from "@/views/Transports";
import Drivers from "@/views/Drivers";
import Orders from "@/views/Orders";
import OrderPage from "@/views/OrderPage";
import Billing from "@/views/Billing";
import Tickets from "@/views/Tickets";
import Settings from "@/views/Settings";
import Dashboard from "@/views/Dashboard";
import User from "@/views/User";
import Mess from "@/views/Mess";
// import token from './main'
Vue.use(Router);
const router = new Router({
mode: 'history',
// base: process.env.BASE_URL,
routes: [
{
path: "/",
name: "home",
component: Home,
meta: { title: 'home', requireAuth: true }
},
{
path: "/mess",
name: "mess",
component: Mess,
meta: { title: 'mess', requireAuth: true }
},
{
path: "/signin",
name: "signin",
component: Signin,
meta: { title: 'signin', requireAuth: true }
},
{
path: "/signup",
name: "signup",
component: Signup,
meta: { title: 'signup', requireAuth: true }
},
{
path: "/dashboard",
name: "dashboard",
component: Dashboard,
meta: { title: 'dashboard', requireAuth: true }
},
{
path: "/logout",
name: "Выйти",
component: Logout,
meta: { title: 'Выйти', requireAuth: true }
},
{
path: "/profile",
name: "Profile",
component: Profile,
meta: { title: 'Profile', requireAuth: true }
},
{
path: "/user",
name: "User",
component: User,
meta: { title: 'User', requireAuth: true }
},
{
path: '/orders',
name: "orders",
component: Orders,
meta: { title: 'orders', requireAuth: true }
},
{
path: "/orders/:id",
name: "orderpage",
component: OrderPage,
meta: { title: 'orderpage', requireAuth: true }
},
{
path: "/orderPoints",
name: "OrderPoints",
component: OrderPoints,
meta: { title: 'OrderPoints', requireAuth: true }
},
{
path: "/orderStatus",
name: "OrderStatus",
component: OrderStatus,
meta: { title: 'OrderStatus', requireAuth: true }
},
{
path: "/role",
name: "Role",
component: Role,
meta: { title: 'Role', requireAuth: true }
},
{
path: "/truckProp",
name: "TruckProp",
component: TruckProp,
meta: { title: 'TruckProp', requireAuth: true }
},
{
path: "/truckType",
name: "TruckType",
component: TruckType,
meta: { title: 'TruckType', requireAuth: true }
},
{
path: "/dispetchers",
name: "Диспетчеры",
component: Dispetchers,
meta: { title: 'Диспетчеры', requireAuth: true }
},
{
path: "/managers",
name: "Менеджеры",
component: Managers,
meta: { title: 'Менеджеры', requireAuth: true }
},
{
path: "/companies",
name: "Компании",
component: Companies,
meta: { title: 'Компании', requireAuth: true }
},
{
path: "/transports",
name: "Транспорт",
component: Transports,
meta: { title: 'Транспорт', requireAuth: true }
},
{
path: "/drivers",
name: "Водители",
component: Drivers,
meta: { title: 'Водители', requireAuth: true }
},
{
path: "/billing",
name: "Биллинг",
component: Billing,
meta: { title: 'Биллинг', requireAuth: true }
},
{
path: "/tickets",
name: "Обращения",
component: Tickets,
meta: { title: 'Обращения', requireAuth: true }
},
{
path: "/settings",
name: "Настройки",
component: Settings,
meta: { title: 'Настройки', requireAuth: true }
},
{
path: "*",
name: "Страница ошибок 404",
component: PageError,
},
],
});
// REDIRECT на главную страницу если не зарегистрирован
router.beforeEach((to, from, next) => {
console.log(!router.app.$options.store.getters.loggedIn);
if (to.name !== 'home' && to.meta.requireAuth && !router.app.$options.store.getters.loggedIn) {
next({name: 'home'})
}
next();
})
export default router;