refac: move router to pages

This commit is contained in:
Dmitriy Pleshevskiy 2023-01-31 17:53:02 +03:00
parent 92dce58451
commit 7e723cd0d4
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
10 changed files with 63 additions and 57 deletions

View file

@ -3,8 +3,8 @@ import type {
ContactFormApiCreateProps,
ContactsTableApiFetchManyProps,
} from "@/app/contacts";
import type { EntityId } from "@/domain/common/entity";
import type { Contact } from "@/domain/entities/contact";
import type { EntityId } from "@/shared/lib/entity";
import { delay } from "@/shared/lib/utils/promise";
import { faker } from "@faker-js/faker";

View file

@ -2,7 +2,7 @@ import { createApp } from "vue";
import { createPinia } from "pinia";
import App from "./App.vue";
import router from "./router";
import router from "./pages/router";
import "./assets/main.css";
import {

View file

@ -0,0 +1,32 @@
const audienceRoutes = [
{
path: "/audience",
name: "audience",
redirect: { name: "audience_contacts" },
component: () => import("./AudiencePage.vue"),
children: [
{
path: "contacts/new",
name: "audience_create_contact",
component: () => import("./AudienceCreateContactPage.vue"),
},
{
path: "contacts/:listId?",
name: "audience_contacts",
component: () => import("./AudienceContactsPage.vue"),
},
{
path: "lists/new",
name: "audience_create_list",
component: () => import("./AudienceCreateListPage.vue"),
},
{
path: "lists",
name: "audience_lists",
component: () => import("./AudienceListsPage.vue"),
},
],
},
];
export default audienceRoutes;

29
src/pages/router.ts Normal file
View file

@ -0,0 +1,29 @@
import { createRouter, createWebHistory } from "vue-router";
import audienceRoutes from "./audience/router";
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: "/",
name: "dashboard",
redirect: { name: "audience" },
},
...audienceRoutes,
{
path: "/files",
name: "email_files",
component: () => import("./FilesPage.vue"),
},
{
path: "/:pathMatch(.*)*",
name: "not_found",
// route level code-splitting
// this generates a separate chunk (About.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import("./NotFoundPage.vue"),
},
],
});
export default router;

View file

@ -1,55 +0,0 @@
import { createRouter, createWebHistory } from "vue-router";
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: "/",
name: "dashboard",
redirect: { name: "audience" },
},
{
path: "/audience",
name: "audience",
redirect: { name: "audience_contacts" },
component: () => import("./pages/AudiencePage.vue"),
children: [
{
path: "contacts/new",
name: "audience_create_contact",
component: () => import("./pages/AudienceCreateContactPage.vue"),
},
{
path: "contacts/:listId?",
name: "audience_contacts",
component: () => import("./pages/AudienceContactsPage.vue"),
},
{
path: "lists/new",
name: "audience_create_list",
component: () => import("./pages/AudienceCreateListPage.vue"),
},
{
path: "lists",
name: "audience_lists",
component: () => import("./pages/AudienceListsPage.vue"),
},
],
},
{
path: "/files",
name: "email_files",
component: () => import("./pages/FilesPage.vue"),
},
{
path: "/:pathMatch(.*)*",
name: "not_found",
// route level code-splitting
// this generates a separate chunk (About.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import("./pages/NotFoundPage.vue"),
},
],
});
export default router;