From 158bc91833b28d91594cce4bc23adea69f1bb197 Mon Sep 17 00:00:00 2001 From: qianmoQ Date: Fri, 22 Mar 2024 22:39:40 +0800 Subject: [PATCH 1/5] [Page] [Layout] Add content --- src/data/Navigation.ts | 21 ++++++++++++++ src/data/index.ts | 4 +++ src/main.ts | 3 ++ src/router/default.ts | 11 ++++++- src/services/Navigation.ts | 10 +++++-- src/views/layouts/base/LayoutContainer.vue | 29 +++++++++++++++++++ .../layouts/base/components/LayoutSidebar.vue | 1 + src/views/pages/home/HomeIndex.vue | 14 +++++++++ 8 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 src/data/Navigation.ts create mode 100644 src/data/index.ts create mode 100644 src/views/layouts/base/LayoutContainer.vue create mode 100644 src/views/pages/home/HomeIndex.vue diff --git a/src/data/Navigation.ts b/src/data/Navigation.ts new file mode 100644 index 00000000..565316fd --- /dev/null +++ b/src/data/Navigation.ts @@ -0,0 +1,21 @@ +import { NavigationModel } from '@/model/Navigation' +import NavigationService from '@/services/Navigation' +import { Home } from 'lucide-vue-next' + +const createNavigation = (): void => { + NavigationService.addNavigation(createNavigationItem('Home', undefined, '/home', Home)) +} + +const createNavigationItem = (title?: string, label?: string, href?: string, icon?: any, children?: NavigationModel[]): NavigationModel => { + return { + title: title, + label: label, + href: href, + icon: icon, + children: children + } +} + +export { + createNavigation +} diff --git a/src/data/index.ts b/src/data/index.ts new file mode 100644 index 00000000..56245cb2 --- /dev/null +++ b/src/data/index.ts @@ -0,0 +1,4 @@ +import { createNavigation } from '@/data/Navigation' + +// Import navigation data +createNavigation() diff --git a/src/main.ts b/src/main.ts index ad34f420..2ca1a7c5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,6 +4,9 @@ import router from '@/router' import './style.css' import './assets/index.css' +// Import mock data +import '@/data/index' + const app = createApp(App) app.use(router) app.mount('#app') diff --git a/src/router/default.ts b/src/router/default.ts index 5bbdf76b..44c374e8 100644 --- a/src/router/default.ts +++ b/src/router/default.ts @@ -1,10 +1,19 @@ import { Router } from 'vue-router' +import LayoutContainer from '@/views/layouts/base/LayoutContainer.vue' const createDefaultRouter = (router: Router): void => { router.addRoute({ path: '/', name: 'home', - redirect: '/auth/signup' + redirect: '/home', + component: LayoutContainer, + children: [ + { + name: 'home', + path: 'home', + component: () => import('@/views/pages/home/HomeIndex.vue') + } + ] }) createHttpRouter(router) createUserRouter(router) diff --git a/src/services/Navigation.ts b/src/services/Navigation.ts index 546e7ece..c103b8df 100644 --- a/src/services/Navigation.ts +++ b/src/services/Navigation.ts @@ -2,11 +2,17 @@ import { NavigationModel } from '@/model/Navigation' class NavigationService { - getNavigation(): NavigationModel[] + private navigations: NavigationModel[] = [] + + addNavigation(navigation: NavigationModel): void { - return [] + this.navigations.push(navigation) } + getNavigation(): NavigationModel[] + { + return this.navigations + } } export default new NavigationService() diff --git a/src/views/layouts/base/LayoutContainer.vue b/src/views/layouts/base/LayoutContainer.vue new file mode 100644 index 00000000..b362f890 --- /dev/null +++ b/src/views/layouts/base/LayoutContainer.vue @@ -0,0 +1,29 @@ + + + diff --git a/src/views/layouts/base/components/LayoutSidebar.vue b/src/views/layouts/base/components/LayoutSidebar.vue index de353781..54f23d0a 100644 --- a/src/views/layouts/base/components/LayoutSidebar.vue +++ b/src/views/layouts/base/components/LayoutSidebar.vue @@ -62,6 +62,7 @@ export default defineComponent({ setIsCollapsed(opened: boolean) { this.isCollapsed = opened + this.$emit('changeCollapsed', opened) } } }) diff --git a/src/views/pages/home/HomeIndex.vue b/src/views/pages/home/HomeIndex.vue new file mode 100644 index 00000000..1ed67e6a --- /dev/null +++ b/src/views/pages/home/HomeIndex.vue @@ -0,0 +1,14 @@ + + + From 2b8517afab75debfbfa71b65b7fc8b1c3402b763 Mon Sep 17 00:00:00 2001 From: qianmoQ Date: Fri, 22 Mar 2024 22:48:30 +0800 Subject: [PATCH 2/5] [Page] [Layout] Add header --- src/views/layouts/base/LayoutContainer.vue | 10 +++++++--- .../layouts/base/components/LayoutHeader.vue | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 src/views/layouts/base/components/LayoutHeader.vue diff --git a/src/views/layouts/base/LayoutContainer.vue b/src/views/layouts/base/LayoutContainer.vue index b362f890..a52e0e2e 100644 --- a/src/views/layouts/base/LayoutContainer.vue +++ b/src/views/layouts/base/LayoutContainer.vue @@ -1,7 +1,10 @@ @@ -9,10 +12,11 @@ import { defineComponent } from 'vue' import LayoutSidebar from '@/views/layouts/base/components/LayoutSidebar.vue' import { cn } from '@/lib/utils' +import LayoutHeader from '@/views/layouts/base/components/LayoutHeader.vue' export default defineComponent({ name: 'LayoutContainer', - components: {LayoutSidebar}, + components: {LayoutHeader, LayoutSidebar}, setup() { return { diff --git a/src/views/layouts/base/components/LayoutHeader.vue b/src/views/layouts/base/components/LayoutHeader.vue new file mode 100644 index 00000000..4bccc975 --- /dev/null +++ b/src/views/layouts/base/components/LayoutHeader.vue @@ -0,0 +1,16 @@ + + + + \ No newline at end of file From cb36b4c31279fdc6946e457bd62ad875094edd7f Mon Sep 17 00:00:00 2001 From: qianmoQ Date: Fri, 22 Mar 2024 22:56:43 +0800 Subject: [PATCH 3/5] [Page] [Layout] Fixed router link --- .../components/NavigationClosed.vue | 14 ++++++---- .../components/NavigationOpened.vue | 28 ++++++++++--------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/views/layouts/base/components/components/NavigationClosed.vue b/src/views/layouts/base/components/components/NavigationClosed.vue index ab97b0f6..3bb89f24 100644 --- a/src/views/layouts/base/components/components/NavigationClosed.vue +++ b/src/views/layouts/base/components/components/NavigationClosed.vue @@ -1,10 +1,12 @@