Advertisement
Guest User

app.js

a guest
Feb 10th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var $resource = require("vue-resource");
  2. var pathToRegexp = require('path-to-regexp');
  3. import Home from './components/Home.vue';
  4. import Navigator from './components/Navigator.vue';
  5. import Categories from './components/Categories.vue';
  6. import Category from './components/Category.vue';
  7. import Results from './components/Results.vue';
  8. import Users from './components/Users.vue';
  9. import Challengesent from './components/Challengesent.vue';
  10. import Notifications from './components/Notifications.vue';
  11. import Acceptchallenge from './components/Acceptchallenge.vue';
  12. import ChallengeResult from './components/ChallengeResult.vue';
  13. import Profile from './components/Profile.vue';
  14. const routes = [
  15.     { path: '', component: Home,name:"home" },
  16.     { path: '/new_quiz', component: Categories , name:"single_player_categories" },
  17.     { path: '/new_quiz/:category_id', component: Category,name:"single_play"},
  18.     { path: '/single_player_result/:quiz_id', component: Results,name:"single_player_result" },
  19.     { path: '/new_challenge', component: Users,name:"users" },
  20.     { path: '/new_challenge/:opponent_id', component: Categories,name:"challenge_categories" },
  21.     { path: '/new_challenge/:opponent_id/:category_id', component: Category,name:"challenge_play" },
  22.     { path: '/challenge_sent/:challenge_id', component: Challengesent,name:"challenge_sent" },
  23.     { path: '/notifications', component: Notifications,name:"notifications" },
  24.     { path: '/accept_challenge/:challenge_id', component: Acceptchallenge,name:"accept_challenge"},
  25.     { path: '/opponent_challenge_result/:challenge_id', component: ChallengeResult,name:"challenge_result"},
  26.     { path: '/profile', component: Profile,name:"profile"}
  27. ];
  28. const router = new VueRouter({
  29.     mode:'history',
  30.     base:"/game/play/",
  31.     linkActiveClass:"active",
  32.     routes
  33. });
  34. Vue.component("navigator",Navigator);
  35. const app = new Vue({
  36.     router,
  37.     beforeCreate:function(){
  38.         this.$http.get("game/get_user_info").then(function(r){
  39.            if(r.data.size == 0) location.href = "/login";
  40.            this.user = r.data;
  41.         });
  42.     },
  43.     methods:{
  44.         parse_url:function(path){
  45.             return pathToRegexp.parse(path);
  46.         }
  47.     }
  48. }).$mount('#app');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement