From c776f49d8c343a35533f53a579b5f7553748138b Mon Sep 17 00:00:00 2001 From: CharleeWa <18888351756@163.com> Date: Tue, 27 Feb 2024 01:03:41 +0800 Subject: [PATCH] feat: New layout system (#62) --- README.md | 6 +++ README.zh-CN.md | 6 +++ build/vite/index.ts | 32 +++++++++++---- package.json | 1 + pnpm-lock.yaml | 19 +++++++++ src/components.d.ts | 1 + src/components/container/index.vue | 4 +- src/layouts/404.vue | 21 ++++++++++ src/layouts/README.md | 14 +++++++ src/layouts/default.vue | 9 +++++ src/layouts/home.vue | 9 +++++ src/{views => pages}/README.md | 0 src/pages/[...all].vue | 10 +++++ src/{views => pages}/charts/index.vue | 0 src/{views => pages}/counter/index.vue | 4 +- src/pages/index.vue | 56 ++++++++++++++++++++++++++ src/{views => pages}/mock/index.vue | 2 +- src/{views => pages}/unocss/index.vue | 6 +-- src/router/README.md | 4 +- src/router/index.ts | 2 + src/typed-router.d.ts | 1 + src/views/index.vue | 52 ------------------------ tsconfig.json | 6 ++- uno.config.ts | 16 ++------ 24 files changed, 198 insertions(+), 83 deletions(-) create mode 100644 src/layouts/404.vue create mode 100644 src/layouts/README.md create mode 100644 src/layouts/default.vue create mode 100644 src/layouts/home.vue rename src/{views => pages}/README.md (100%) create mode 100644 src/pages/[...all].vue rename src/{views => pages}/charts/index.vue (100%) rename src/{views => pages}/counter/index.vue (91%) create mode 100644 src/pages/index.vue rename src/{views => pages}/mock/index.vue (97%) rename src/{views => pages}/unocss/index.vue (80%) delete mode 100644 src/views/index.vue diff --git a/README.md b/README.md index e7c64a9..bc8a3f5 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ - 🍍 [State Management via Pinia](https://pinia.vuejs.org) +- 📑 [Layout system](./src/layouts) + - 🎨 [UnoCSS](https://github.com/antfu/unocss) - the instant on-demand atomic CSS engine - 🔥 Use the [new ` + + + + diff --git a/src/layouts/README.md b/src/layouts/README.md new file mode 100644 index 0000000..fb3135f --- /dev/null +++ b/src/layouts/README.md @@ -0,0 +1,14 @@ +# Layouts + +Vue components in this dir are used as layouts. + +By default, `default.vue` will be used unless an alternative is specified in the route meta. + +With [`unplugin-vue-router`](https://github.com/posva/unplugin-vue-router) and [`vite-plugin-vue-layouts`](https://github.com/JohnCampionJr/vite-plugin-vue-layouts), you can specify the layout in the page's SFCs like this: + +```vue + +meta: + layout: home + +``` diff --git a/src/layouts/default.vue b/src/layouts/default.vue new file mode 100644 index 0000000..55c4bff --- /dev/null +++ b/src/layouts/default.vue @@ -0,0 +1,9 @@ + diff --git a/src/layouts/home.vue b/src/layouts/home.vue new file mode 100644 index 0000000..93b152b --- /dev/null +++ b/src/layouts/home.vue @@ -0,0 +1,9 @@ + diff --git a/src/views/README.md b/src/pages/README.md similarity index 100% rename from src/views/README.md rename to src/pages/README.md diff --git a/src/pages/[...all].vue b/src/pages/[...all].vue new file mode 100644 index 0000000..369e3a9 --- /dev/null +++ b/src/pages/[...all].vue @@ -0,0 +1,10 @@ + + + +meta: + layout: 404 + diff --git a/src/views/charts/index.vue b/src/pages/charts/index.vue similarity index 100% rename from src/views/charts/index.vue rename to src/pages/charts/index.vue diff --git a/src/views/counter/index.vue b/src/pages/counter/index.vue similarity index 91% rename from src/views/counter/index.vue rename to src/pages/counter/index.vue index 677112f..04e58d4 100644 --- a/src/views/counter/index.vue +++ b/src/pages/counter/index.vue @@ -21,7 +21,7 @@ const onClickLeft = () => history.back()