-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
executable file
·73 lines (63 loc) · 1.69 KB
/
main.js
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
import Vue from "vue";
import App from "./App.vue";
import { IonicVueRouter } from "@ionic/vue";
import Ionic from "@ionic/vue";
import "@ionic/core/css/core.css";
import "@ionic/core/css/ionic.bundle.css";
import store from "./store";
import Home from "./views/Home.vue";
Vue.use(IonicVueRouter);
Vue.use(Ionic);
Vue.config.productionTip = false;
Vue.config.ignoredElements = [/^ion-/];
console.log(window.Ionic);
const privateRoute = (to, from, next) => {
let userStore = store.state.user;
let isAuthenticated = userStore.user !== null;
console.log("isAuthenticated:" + isAuthenticated);
if (!isAuthenticated) {
next({ name: "login" });
} else {
next();
}
};
const routes = [
{ path: "/", redirect: "/home" },
{
path: "/home",
name: "home",
component: Home,
beforeEnter: privateRoute
},
// Add @babel/plugin-syntax-dynamic-import (https://git.io/vb4Sv) to the
// 'plugins' section of your Babel config to enable parsing.
{
path: "/login",
name: "login",
component: () => import(/* webpackChunkName: "login" */ "@/views/Login.vue")
//beforeEnter: privateRoute
},
{
path: "/about",
name: "about",
component: () => import(/* webpackChunkName: "about" */ "@/views/About.vue")
},
{
path: "/about/help",
name: "about-help",
component: () => import(/* webpackChunkName: "about" */ "@/views/Help.vue")
}
];
// 3. Create the router instance and pass the `routes` option
// You can pass in additional options here, but let's
// keep it simple for now.
const router = new IonicVueRouter({
routes
});
store.dispatch("user/checkAuth").then(() => {
new Vue({
render: h => h(App),
store,
router
}).$mount("#app");
});