- changed model IQueryRoute.

- changed name of queryRoutes to queries.
- modified QueryRouter for take router from arguments.
- modified router index.
This commit is contained in:
Eugene Serb 2022-08-29 15:28:18 +03:00
parent 0f720f2201
commit 0ad9753af0
5 changed files with 18 additions and 16 deletions

View File

@ -2,7 +2,7 @@
"name": "wavelovers", "name": "wavelovers",
"description": "Wavelovers. Use your device vibration correctly. Make a massager out of a gamepad.", "description": "Wavelovers. Use your device vibration correctly. Make a massager out of a gamepad.",
"keywords": [ "wavelovers", "gamepad-vibrator", "gamepad-test-tool", "gamepad-vibration-test-tool" ], "keywords": [ "wavelovers", "gamepad-vibrator", "gamepad-test-tool", "gamepad-vibration-test-tool" ],
"version": "1.0.9", "version": "1.0.10",
"license": "GNU GPL v3", "license": "GNU GPL v3",
"homepage": "https://wavelovers.ru/", "homepage": "https://wavelovers.ru/",
"author": { "author": {

View File

@ -1,30 +1,30 @@
import IQueryRoute from '@/router/models/IQueryRoute'; import IQueryRoute from '@/router/models/IQueryRoute';
const queryRoutes: Array<IQueryRoute> = [ const queries: Array<IQueryRoute> = [
{ {
query: '/?custom', query: '/?custom',
to: '/custom', path: '/custom',
}, },
{ {
query: '/?manual', query: '/?manual',
to: '/manual', path: '/manual',
}, },
{ {
query: '/?diagnostic', query: '/?diagnostic',
to: '/diagnostic', path: '/diagnostic',
}, },
{ {
query: '/?faq', query: '/?faq',
to: '/faq', path: '/faq',
}, },
{ {
query: '/?about', query: '/?about',
to: '/about', path: '/about',
}, },
{ {
query: '/?donate', query: '/?donate',
to: '/donate', path: '/donate',
} }
]; ];
export default queryRoutes; export default queries;

View File

@ -5,7 +5,7 @@ import {
import PatternsView from '@/views/PatternsView.vue'; import PatternsView from '@/views/PatternsView.vue';
import QueryRouter from '@/router/modules/QueryRouter'; import QueryRouter from '@/router/modules/QueryRouter';
import MetaTagUpdater from '@/router/modules/MetaTagUpdater'; import MetaTagUpdater from '@/router/modules/MetaTagUpdater';
import queryRoutes from '@/router/assets/queryRoutes'; import queries from '@/router/assets/queries';
const routes: Array<RouteRecordRaw> = [ const routes: Array<RouteRecordRaw> = [
{ {
@ -356,7 +356,7 @@ router.beforeEach((
from: RouteLocationNormalized, from: RouteLocationNormalized,
next: NavigationGuardNext next: NavigationGuardNext
) => { ) => {
QueryRouter.update(to, from, next, queryRoutes); QueryRouter.update(to, from, next, router, queries);
MetaTagUpdater.update(to, from, next) MetaTagUpdater.update(to, from, next)
}); });

View File

@ -1,6 +1,6 @@
interface IQueryRoute { interface IQueryRoute {
query: string; query: string;
to: string; path: string;
} }
export default IQueryRoute; export default IQueryRoute;

View File

@ -1,16 +1,18 @@
import router from '@/router'; import {
import { NavigationGuardNext, RouteLocationNormalized } from "vue-router"; Router, NavigationGuardNext, RouteLocationNormalized
} from "vue-router";
import IQueryRoute from '@/router/models/IQueryRoute'; import IQueryRoute from '@/router/models/IQueryRoute';
function updateRoute( function updateRoute(
to: RouteLocationNormalized, to: RouteLocationNormalized,
from: RouteLocationNormalized, from: RouteLocationNormalized,
next: NavigationGuardNext, next: NavigationGuardNext,
router: Router,
queryRoutes: Array<IQueryRoute> queryRoutes: Array<IQueryRoute>
) { ): void {
queryRoutes.forEach((route) => { queryRoutes.forEach((route) => {
if (route.query === to.fullPath) { if (route.query === to.fullPath) {
router.push(route.to); router.push(route.path);
} }
}); });
return next(); return next();