feat: 添加 vite-plugin-vue-layouts 插件并更新 vite 版本至 6.0.5

This commit is contained in:
严浩
2024-12-25 00:06:46 +08:00
parent 400de0f222
commit bfbeb326bc
14 changed files with 122 additions and 64 deletions

9
src/layouts/default.vue Normal file
View File

@ -0,0 +1,9 @@
<template>
<RouterView />
</template>
<script setup lang="ts">
import { RouterView } from 'vue-router';
</script>
<style scoped></style>

View File

@ -8,7 +8,7 @@ async function init() {
// https://github.com/antfu-collective/vitesse/blob/47618e72dfba76c77b9b85b94784d739e35c492b/src/modules/README.md
type UserPluginContext = { app: import('vue').App<Element> };
type UserPlugin = (ctx: UserPluginContext) => void;
Object.values(import.meta.glob<{ install: UserPlugin }>('./plugins/**.ts', { eager: true })).forEach((i) =>
Object.values(import.meta.glob<{ install: UserPlugin }>('./plugins/*.ts', { eager: true })).forEach((i) =>
i.install?.({ app }),
);
}

View File

@ -6,4 +6,4 @@ export function install({ app }: { app: import('vue').App<Element> }) {
app.use(PiniaColada, {});
}
export * from './counter';
export * from '../stores/counter';

View File

@ -1,10 +1,11 @@
import { DataLoaderPlugin } from 'unplugin-vue-router/data-loaders';
import { createRouter, createWebHistory } from 'vue-router';
import { setupLayouts } from 'virtual:generated-layouts';
import { createRouter, createWebHistory } from 'vue-router/auto';
import { handleHotUpdate, routes } from 'vue-router/auto-routes';
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes,
routes: setupLayouts(routes),
strict: true,
scrollBehavior: () => ({ left: 0, top: 0 }),
});

View File

@ -1,5 +0,0 @@
/// <reference types="vite/client" />
/// <reference types="unplugin-vue-router/client" />
/// <reference types="unplugin-vue-macros/macros-global" />
/// <reference types="unplugin-icons/types/vue" />
/// <reference types="@intlify/unplugin-vue-i18n/messages" />