Skip to content

Commit

Permalink
feat: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
singuerinc committed Oct 12, 2019
1 parent fc6d9a9 commit 9e8931f
Show file tree
Hide file tree
Showing 4 changed files with 2,956 additions and 1,775 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@
"url-loader": "^0.5.7",
"vue": "^2.4.2",
"vue-loader": "^13.0.2",
"vue-router": "^2.7.0",
"vue-router": "^3.1.3",
"vue-template-compiler": "^2.4.2",
"vuex": "^2.0.0",
"vuex": "^3.1.1",
"webpack": "^3.4.1",
"webpack-dev-server": "^2.6.1"
},
"devDependencies": {
"@types/vue": "^2.0.0",
"@types/vue-router": "^2.0.0",
"tslint": "^5.5.0"
}
}
90 changes: 46 additions & 44 deletions src/router.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,58 @@
import Vue from 'vue';
import VueRouter from 'vue-router';
import Vue from "vue";
import VueRouter, { RouteConfig, Route } from "vue-router";

import Login from './views/Login.vue';
import Photos from './views/Photos.vue';
import Login from "./views/Login.vue";
import Photos from "./views/Photos.vue";

import store from './store';
import store from "./store";

Vue.use(VueRouter);

const routes: VueRouter.RouteConfig[] = [
{
path: '/',
name: 'photos',
component: Photos,
beforeEnter: (to: VueRouter.Route, from: VueRouter.Route, next: (path?: string) => void) => {
if (store.state.accessToken === '') {
next('/login');
} else {
next();
}
},
},
{
path: '/access_token*',
beforeEnter: (to: VueRouter.Route, from: VueRouter.Route, next: (path?: string) => void) => {
try {
const match: RegExpMatchArray | null = to.path.match(/^\/access_token=(.+)$/);
const token = (match as RegExpMatchArray)[1];
const routes: RouteConfig[] = [
{
path: "/",
name: "photos",
component: Photos,
beforeEnter: (to: Route, from: Route, next: (path?: string) => void) => {
if (store.state.accessToken === "") {
next("/login");
} else {
next();
}
}
},
{
path: "/access_token*",
beforeEnter: (to: Route, from: Route, next: (path?: string) => void) => {
try {
const match: RegExpMatchArray | null = to.path.match(
/^\/access_token=(.+)$/
);
const token = (match as RegExpMatchArray)[1];

store.commit('SET_ACCESS_TOKEN', token);
next('/');
} catch (e) {
next('/login');
}
},
},
{
path: '/logout',
beforeEnter: (to: VueRouter.Route, from: VueRouter.Route, next: (path?: string) => void) => {
store.commit('SET_ACCESS_TOKEN', '');
next('/login');
},
},
{
path: '/login',
name: 'login',
component: Login,
},
store.commit("SET_ACCESS_TOKEN", token);
next("/");
} catch (e) {
next("/login");
}
}
},
{
path: "/logout",
beforeEnter: (to: Route, from: Route, next: (path?: string) => void) => {
store.commit("SET_ACCESS_TOKEN", "");
next("/login");
}
},
{
path: "/login",
name: "login",
component: Login
}
];

const router = new VueRouter({
routes,
routes
});

export default router;
12 changes: 6 additions & 6 deletions src/store.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Vue from 'vue';
import Vuex from 'vuex';
import Storage from './api/storage';
import Vue from "vue";
import Vuex from "vuex";
import Storage from "./api/storage";

Vue.use(Vuex);

const storage = new Storage();

const state = {
accessToken: '',
feedZoom: 'x3',
accessToken: "",
feedZoom: "x3",
feed: {
data: [],
pagination: {
Expand Down Expand Up @@ -38,7 +38,7 @@ const actions = {
{ commit }: { commit: (key: string, value: any) => void },
data: any
): any {
commit('ADD_FEED', data);
commit("ADD_FEED", data);
}
};

Expand Down
Loading

0 comments on commit 9e8931f

Please sign in to comment.