refactor project

This commit is contained in:
liangping 2023-02-10 10:42:05 +08:00
parent 59a7034e5c
commit caa020f367
23 changed files with 15 additions and 87 deletions

View File

@ -3,12 +3,12 @@ import navItems from '@/plugins/vuetify/navigation/vertical'
import { useThemeConfig } from '@/plugins/vuetify/@core/composable/useThemeConfig'
// Components
import Footer from '@/plugins/vuetify/layouts/components/Footer.vue'
import NavbarThemeSwitcher from '@/plugins/vuetify/layouts/components/NavbarThemeSwitcher.vue'
import UserProfile from '@/plugins/vuetify/layouts/components/UserProfile.vue'
import Footer from '@/layouts/components/Footer.vue'
import NavbarThemeSwitcher from '@/layouts/components/NavbarThemeSwitcher.vue'
import UserProfile from '@/layouts/components/UserProfile.vue'
// @layouts plugin
import { VerticalNavLayout } from '@/plugins/vuetify/@layouts'
import { VerticalNavLayout } from '@layouts'
const { appRouteTransition, isLessThanOverlayNavBreakpoint, isVerticalNavCollapsed } = useThemeConfig()
const { width: windowWidth } = useWindowSize()

View File

@ -8,8 +8,8 @@ import "@/plugins/vuetify/@core/scss/template/index.scss";
import "@/plugins/vuetify/styles/styles.scss";
import { createApp } from "vue";
import { createPinia } from "pinia";
// import router from "./router";
import router from "@/plugins/vuetify/router";
import router from "./router";
// import router from "@/plugins/vuetify/router";
loadFonts();

View File

@ -1,5 +0,0 @@
<template>
<div>
dashboard view
</div>
</template>

View File

@ -1,9 +0,0 @@
import type { RouteRecordRaw } from "vue-router";
export const routes: RouteRecordRaw[] = [
{
path: "/dashboard",
alias: ["dashboard"],
component: () => import("./View.vue"),
},
];

View File

@ -1,14 +0,0 @@
import { setupLayouts } from "virtual:generated-layouts";
import { createRouter, createWebHistory } from "vue-router";
import routes from "~pages";
import { routes as route2 } from "@/router";
import { canNavigate } from "@layouts/plugins/casl";
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [...setupLayouts(routes), ...route2],
});
// Docs: https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards
export default router;

View File

@ -1,6 +0,0 @@
/**
* Return if user is logged in
* This is completely up to you and how you want to store the token in your frontend application
* e.g. If you are using cookies to store the application please update this function
*/
export const isUserLoggedIn = () => !!(localStorage.getItem('userData') && localStorage.getItem('accessToken'))

View File

@ -1,50 +1,12 @@
import {
createRouter,
createWebHistory,
type RouteRecordRaw,
} from "vue-router";
import HomeView from "../views/HomeView.vue";
import DashboardLayout from "@/plugins/vuetify/layouts/default.vue";
import { setupLayouts } from "virtual:generated-layouts";
import { createRouter, createWebHistory } from "vue-router";
import routes from "~pages";
const modules: Record<string, { routes: RouteRecordRaw[] }> = import.meta.glob(
"../modules/*/router.ts",
{ eager: true }
);
let children: RouteRecordRaw[] = [];
for (const path in modules) {
children = children.concat(modules[path].routes);
}
console.log(children);
export const routes = [
{
path: "/about",
name: "about",
component: () => import("../views/AboutView.vue"),
},
// setup all modules here.
{
path: "/:chain",
component: DashboardLayout,
children: [
{
path: "",
component: () => import("../views/AboutView.vue"),
},
...children,
],
},
{
path: "/",
name: "home",
component: HomeView,
},
];
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes,
routes: [...setupLayouts(routes)],
});
export default router;
// Docs: https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards
export default router;

View File

@ -21,10 +21,10 @@ export default defineConfig({
},
}),
Pages({
dirs: ["./src/plugins/vuetify/pages"],
dirs: ["./src/pages", "./src/modules"],
}),
Layouts({
layoutsDirs: "./src/plugins/vuetify/layouts/",
layoutsDirs: "./src/layouts/",
}),
Components({
dirs: ["src/plugins/vuetify/@core/components"],